- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I observed a strange behavior of the code below:
//allocate and transfer
#pragma offload_transfer target(mic:deviceIdx)\
in(arraySize)\
in(input:length(arraySize) ALLOC RETAIN)
//reuse. this works fine
#pragma offload target(mic:deviceIdx)
nocopy(input:length(arraySize) REUSE RETAIN)
{
#pragma omp parallel shared(arraySize, input)
{
......
}
}
However, if the above "reuse" block is wrapped into a function, say void ReuseDevice(double* data, int dataSize, int deviceIdx);
an error message pops up:
-->offload error: process on the device 0 was terminated by signal 11
What's the catch? Thanks for help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you wrap the 'reuse' block within your function, you are in effect creating a new pointer variable 'data' on the stack which will point to the same location as 'input'. However, during an offload the compiler creates a new pointer variable 'data' for the coprocessor but since you used the modifier 'nocopy' its value is not set and hence the error. If you use in(data:length(0) reuse ) inside the function, the compiler will create the new pointer varianle and set the pointer value to point to the coprocessor side array but will not transfer any data as the length was set as 0.
I hope this helps.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try using "in (input: length(0) ..." instead of "nocopy (input: length(arraySize) ...". It was previously discussed here: http://software.intel.com/en-us/forums/topic/359447 (see the post by Kevin Davis from Fri, 01/25/2013).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you wrap the 'reuse' block within your function, you are in effect creating a new pointer variable 'data' on the stack which will point to the same location as 'input'. However, during an offload the compiler creates a new pointer variable 'data' for the coprocessor but since you used the modifier 'nocopy' its value is not set and hence the error. If you use in(data:length(0) reuse ) inside the function, the compiler will create the new pointer varianle and set the pointer value to point to the coprocessor side array but will not transfer any data as the length was set as 0.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sumedh Naik (Intel) wrote:
When you wrap the 'reuse' block within your function, you are in effect creating a new pointer variable 'data' on the stack which will point to the same location as 'input'. However, during an offload the compiler creates a new pointer variable 'data' for the coprocessor but since you used the modifier 'nocopy' its value is not set and hence the error. If you use in(data:length(0) reuse ) inside the function, the compiler will create the new pointer varianle and set the pointer value to point to the coprocessor side array but will not transfer any data as the length was set as 0.
I hope this helps.
Thanks Sumedh, that is definitely an elegant solution.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page