PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

types, allocatable members, and OpenACC in Fortran

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
AndrewWilson41729



Joined: 19 Dec 2013
Posts: 14

PostPosted: Tue Feb 04, 2014 5:38 pm    Post subject: types, allocatable members, and OpenACC in Fortran Reply with quote

I'm trying to encapsulate my data in a structure, like so:
Code:
type MeshContainer
   real, dimension(:,:,:,:), allocatable :: data1, data2, data3
end type


Without this type of encapsulation, the number of explicitly mentioned arrays and/or indices in my code is becoming unwieldy.

I try to make that available on the device, but it seems the "%" notation is almost entirely incompatible with OpenACC at this time? Do I have that right?

Can anyone recommend an alternate method both encapsulating multiple dynamically allocatable arrays, and making them available on an accelerator?
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Wed Feb 05, 2014 11:47 am    Post subject: Reply with quote

Hi Andrew,

Quote:
I try to make that available on the device, but it seems the "%" notation is almost entirely incompatible with OpenACC at this time? Do I have that right?
Currently only fixed size user defined data types (as well as structs) are allowed (i.e. no dynamically allocated members).

The OpenACC standards committee is in the process of defining how such structures can be described. It's a very difficult issue since these structures would require a deep copy and the standards committee wants to ensure all OpenACC implementations and targets act the same way. Making things more difficult is that not all accelerators can dynamically allocate memory on the device (another requirement).

Quote:
Can anyone recommend an alternate method both encapsulating multiple dynamically allocatable arrays, and making them available on an accelerator?


When used on the device, is each variable a single MeshContainer or is there an array of MeshContainers? For a single MeshContainier, you can use F90 pointers to point to each of the member arrays and then reference the pointers in the accelerator regions.

For an array of MeshContainer, then you'd need to modify the data structure, make the data arrays fixed size, or move to using CUDA Fortran where you write your own deep copy routine.

- Mat
Back to top
View user's profile
AndrewWilson41729



Joined: 19 Dec 2013
Posts: 14

PostPosted: Thu Feb 06, 2014 12:24 pm    Post subject: Reply with quote

Thanks, Mat,

I've managed to get something working with pointers in the way you suggest. Deciding on how best to organize the code is going to take a bit, but at least I see some ways to use objects without excessive host/device copies.

And a general thank you for responding to my questions and others on the forums. It helps a lot having you lurking in here.

-- Andrew
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Thu Feb 06, 2014 3:04 pm    Post subject: Reply with quote

You're welcome Andrew. I'm assuming you mean stackoverflow? I try to lurk around there but don't do it often enough. I need to make it part of my daily regiment since it looks like more and more OpenACC questions are getting posted.

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group