Are derived types containing allocatable arrays supported in any existing OpenACC compilers?
Asked Answered
Z

2

6

Are there any OpenAcc compilers that support the copying of derived types containing allocatable arrays to/from the GPU and their use in accelerated code?

The OpenACC spec (v2.0) states this is possible, but I'm unable to find it implemented in a compiler anywhere. The PGI compiler supports derived types, but seemingly not those containing allocatable arrays (see this page on the PGI forum). While this may have changed since them, it doesn't seem to be publicised (well) anywhere.

Zennas answered 4/2, 2014 at 12:25 Comment(2)
AFAIK, PGI, Cray, & CAPS are the Fortran compliers that allow OpenACC directives. The latter of these 3 claim to be OpenACC 2.0 compliant, unsure of the other two (though the first is what you have already researched)Woolgathering
Slide 12 of this presentation seems to suggest that the Cray compiler might work. I'll see if I can get my hands on it and will report back.Zennas
Z
3

For now I'm unable to access the Cray or CAPS compilers, and the PGI compiler does not support this functionality. A suitable workaround seems to be to create a pointer to the allocatable array within the derived type and copy that to the GPU using the copy clause. If future versions of the PGI compiler support this kind of deep copy then I'll update the answer.

Zennas answered 6/2, 2014 at 9:13 Comment(0)
M
0

Where do you think OpenACC 2.0 states this?

The relative references I find in Version 2.0 June, 2013 are:

Page 13 "Full support for Fortran derived types and derived type members, including allocatable and pointer members."

Page 26-27 "In Fortran, if a variable or array with derived type is specified, all the members of that derived type are allocated and copied, as appropriate. If any member has the OpenACC Programming Interface 27 allocatable or pointer attribute, the data accessed through that member are not copied."

The second reference explicitly states that copying the memory for allocatable and pointer objects inside of a derived type is not supported at this time.

The technical committee is working on "fixing this issue", however, the solution has not been released.

Cray provides a command line option to turn on support for "deep copy". This is a Cray extension and as such is not a portable solution.

Mule answered 7/7, 2014 at 17:45 Comment(1)
If that's what the specification says then I guess I'll be waiting longer. The workaround I posted still seems to be a decent solution for now.Zennas

© 2022 - 2024 — McMap. All rights reserved.