Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Using global pointers to allocate memory on the MIC and reusing it

$
0
0

Hi all,

I am using the offload programming model for my project. What I have is a global pointer that I use to allocate memory on the MIC. After doing some more computation on the host I then try to copy the results from host memory to the memory in the MIC using in() for host structure and nocopy() for the global pointer. The documentation and a few of the forum posts say that it should work however in my case it results in a segfault.

What I read:

https://software.intel.com/en-us/articles/effective-use-of-the-intel-com...

The code is something like this:

//This is global

__attribute__((target(mic:0))) wildstruct* foo;

#pragma offload target(mic:0) nocopy(foo) {

foo = malloc(sizeof(foo));   //foo is then initialized later on in this offload region.

}

In another file:

#pragma offload target(mic:0) in(anotherFoo[0:LENGTH]) nocopy(foo) {

memset(foo,anotherFoo,sizeof(foo));    //segfaults here. foo is NULL which I believe should not be the case according to the documentation.

}

Thanks!


Viewing all articles
Browse latest Browse all 1616

Trending Articles



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