0

I am using PGI 15.7 compiler. I am wondering to know how I can copy a defined structure from CPU to GPU by OpenACC.

typedef struct str_
{
  int n;       
  int m;      
  int* col;    // size [n*m]
  double* val; // size [n*m]
}str;

Thank you very much.

behzad baghapour
  • 127
  • 2
  • 11

1 Answers1

1

"Deep Copy" is a feature that we're trying to solve in the 3.0 spec. Today the following should work for you though.

#pragma acc enter data copyin(str)
#pragma acc enter data copyin(str.col[:n*m],str.val[:n*m])

...

#pragma acc exit data copyout(str.col[:n*m],str.val[:n*m])
#pragma acc exit data delete(str)

What this is doing is copying the structure itself to the device, then copying over the arrays contained within it. I then do the reverse on the way back out. If you don't need to move the data, you can replace copyin/copyout with create/delete.

jefflarkin
  • 1,279
  • 6
  • 14