PGI compiler extension function in Fortran


I have found that there is some PGI compiler extension function to get the id of a gang/vector, like ‘omp_get_thread_num’ in openmp. This is __pgi_gangidx. I could find a example from:

But what is the corresponding syntex in Fortran?
The reason I want to use it is that I need to make a allocatable array private to gang. I need to append a additional dimension to the array and create on device. It 's pretty similar to

Instead of making the addition dimension to the the number of trip count, I just want it to be number of gangs. Could some one help?

Hi wenscarl2017,

It’s the same syntax in Fortran. Just use the OpenACC module (i.e. “use openacc”) to get the interfaces.

Though instead of using a PGI extension, you may consider blocking the loop so that it’s two loops, a blocked outer loop corresponding to the gang size, and an inner loop to compute the elements within a block. It will make your code more portable.

Hope this helps,