Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ashwin_D_1
Beginner
60 Views

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

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!

0 Kudos
1 Reply
Ravi_N_Intel
Employee
60 Views

Difficult to say what is problem without the complete code.
Is the pointer foo also declared with target attribute in the second file

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

Reply