strange behavior of the code using pragma offload

strange behavior of the code using pragma offload

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!

 

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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).

Best Reply

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. 

Quote:

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.

Leave a Comment

Please sign in to add a comment. Not a member? Join today