Quantcast
Channel: Intel® Many Integrated Core Architecture
Viewing all articles
Browse latest Browse all 1347

Reuse on-device data within a function call

$
0
0

Hi,

is it possible to reuse data that is already on the device eventhough there is a function call inbetween.
Here is an example:

void foo(){
   float* A;
   ... initialize A ...

   #pragma offload_transfer target(mic:0) in(A:length(sizeA) alloc_if(1) free_if(0)) signal(1)
   ...some CPU function... //overlap this function with data transfer

   bar(A, sizeA);
}

void bar(float* A, int sizeA){
   #pragma offload_transfer target(mic:0) wait(1)

   #pragma offload target(mic) nocopy(A:length(sizeA) alloc_if(0) free_if(0))
   deviceFunction(A,sizeA);
}

A similar program like this segfaults, because A is not known to the device within bar(). The solution that I've found so far would be to make *A a global variable, but this isn't really practical. I also tried to use pointers to pointers but that didn't work somehow.

Does someone know a solution to this problem?

Thanks


Viewing all articles
Browse latest Browse all 1347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>