Hi there, as I wrote elsewhere,
the device-mapper of openacc had problems in my case (which is a C++ struct with several constructors and three arrays, one for the extents and the other for the strides and member variables for the lengths of these arrays, and whether the data is rowmayor and so on).
I think I can map all these in situ with #acc pragmas, but one then, everytime one uploads a loop, one has to write dozens of mapping commands.
I was, unfortunately, not able to map these with the acc functions and put them into pointers. Only the macros worked. At some point, the nvc++ compiler even generated an exception when i tried it with pointers and to associate the device member variables to the malloced pointers at the device…
I asked chatgp which came up with nice macros, similar to this one:
define STRINGIFY(x) #x
define CREATE_IN_STRUCT(dA)
enter data copyin(dA)
copyin(dA.pdata[0:dA.pdatalength])
copyin(dA.pextents[0:dA.prank])
copyin(dA.pstrides[0:dA.prank])define CREATE_OUT_STRUCT(dL)
enter data copyin(dL)
create(dL.pdata[0:dL.pdatalength])
copyin(dL.pextents[0:dL.prank])
copyin(dL.pstrides[0:dL.prank])define EXIT_STRUCT(dL)
exit data delete(dL.pdata[0:dL.pdatalength])
delete(dL.pextents[0:dL.prank])
delete(dL.pstrides[0:dL.prank])
delete(dL)define UPDATE_HOST(dL) update self(dL.pdata[0:dL.pdatalength])
define UPDATE_DEVICE(dA) update device(dL.pdata[0:dL.pdatalength])
they can be used like this:
mycomplex_data_structure s;
#pragma acc CREATE_IN_STRUCT(s)
And the preprocessor will then replace these with the mapping commands.
But I still do not know why it yields me device sigsevs when i try to use the acc functions like acc_memcpy_to_device. That would be still a cleaner way.
(It maybe that it has something to do that the struct needs its member variables to point to the arrays and simply copying up is not enough, but the member variables of the struct have to be linked to the uploaded array when it is up?).
I hope my routines work at least on the device.
The function acc_ondevice(acc_device_nvidia) seems to say so. And if i empty the array for the results beforehand, and if i do not copy it back from the device to the host, i get zeros, and if i copy it back, i see the results.
So it seems that the copy in and copy back operation with the macros work. They save some writing time one has less code repetition.