- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Change
#pragma offload target(mic) nocopy(A:length(sizeA) alloc_if(0) free_if(0))
to
#pragma offload target(mic) in(A:length(0) alloc_if(0) free_if(0))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ravi just beat me to it. The keys are IN and length(0) in the scope of bar(). IN creates a new instance of the local pointer A within the new scope of bar() and the length(0) ensures no data transfer. NOCOPY causes the segV because it assumes an instance of the pointer exists when it does not within the new scope.
Your offload in bar() also does not specify the target-id were as in foo() you created/transferred A to target-id 0 (i.e. target(mic:0) ) so be sure bar() also uses the same target-id.
The offload_transfer in bar() appears to only wait on the signal. You could perhaps use offload_wait if there is no associated transfer expected in waiting on that signal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
perfect! Thanks, that helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your welcome. Glad to hear that.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page