Problem with accelerator model data transfer

Hi, I am having a question concerning the data management of the pg fortran accelerator model. I have two subroutines. In the first subroutine I copy an array a to the device (using data region copyin(a)). Later on I use another subroutine that needs this array a on the device, what I now want is to use the array already on the device and not copy the array to the device a second time within the second subroutine. I hope someone has an idea how to deal with this problem, I think it is not possible to have a data region that starts in one subroutine and ends in another, right?
Thank you for your help.

Hi Thomi,

While not implemented yet, the “reflected” and “mirror” clauses (See section 2.6.5 and 2.6.6 in will allow to have data regions that span across multiple subroutine calls.

In the meantime, you can use CUDA Fortran device allocatable arrays. As of release 10.4, the PGI Accelerator model allows the use of CUDA device data. Hence, you can allocate and copy your device data in one section of code, pass these device arrays as arguments, and use them within your ACC REGION.

The caveats are that mixing the two models is only supported on Linux and should be considered ‘beta’. Also, using CUDA Fortran will break portability. But again, this could be a place holder until “reflected” and “mirror” are ready.

Hope this helps,