PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

CUDA Fortran and PUBLIC/PRIVATE

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



Joined: 06 Jul 2009
Posts: 322
Location: Greenbelt, MD

PostPosted: Wed Oct 19, 2011 7:53 am    Post subject: CUDA Fortran and PUBLIC/PRIVATE Reply with quote

An odd question, but one I thought I'd ask about. Namely, how compatible is CUDA Fortran with PUBLIC and PRIVATE (and, I suppose, PROTECTED)?

I ask because I was recently trying to clean up some CUDA Fortran modules with some data hiding (as we all should do using modules) and ran into issues.

As a test example to show these, I hacked some matmul code that looked like:
Code:
module mmul_mod

use cudafor
implicit none

real, allocatable, dimension(:,:), device :: A_dev, B_dev, C_dev
 
contains

   attributes(global) subroutine mmul_kernel(N,M,L)

This worked just fine, obviously. I then tried:
Code:
module mmul_mod

use cudafor
implicit none

PRIVATE
PUBLIC :: A_dev, B_dev, C_dev

real, allocatable, dimension(:,:), device :: A_dev, B_dev, C_dev
 
contains

   attributes(global) subroutine mmul_kernel(N,M,L)

Also worked. But, when I try:
Code:
module mmul_mod

use cudafor
implicit none

PRIVATE

real, allocatable, dimension(:,:), device, PUBLIC :: A_dev, B_dev, C_dev
 
contains

   attributes(global) subroutine mmul_kernel(N,M,L)

the compiler bombs out with:
Code:
pgfortran -Minfo -Mcuda -c mmul_mod.F90
PGF90-S-0134-Illegal attribute - conflict with access (mmul_mod.F90: 8)
  0 inform,   0 warnings,   1 severes, 0 fatal for mmul_mod
make: *** [mmul_mod.o] Error 2

As the real code I'm working often has 20-30 device variables (or more) and many constants, I'm not too keen on adding 20-30 extra lines PUBLIC'ing the device variables in addition to all the REAL, ALLOCATABLE, DEVICE declarations. Is there a way I can PUBLIC these on the same line as they are declared?

Also, I guess I should ask: are attributes(global) subroutines and functions inherently PUBLIC? Notice above I never declared mmul_kernel as PUBLIC, and yet it worked just fine. (And, the corollary: are attributes(device) subroutines and functions inherently PRIVATE?)

Thanks,
Matt

PS: I did try the above module with just PRIVATE and no PUBLIC and it bombs out in the way you'd expect. A_dev et al aren't declared in the USEing routine, etc.
Back to top
View user's profile
brentl



Joined: 20 Jul 2004
Posts: 132

PostPosted: Wed Oct 19, 2011 11:54 am    Post subject: Reply with quote

Quite frankly, we haven't paid much attention to attributes like public and private in combination with device to this point. I know originally, we added some limiting checks to keep things simple, and that's likely what you are running into. I'll add a feature request to allow public and private in combination with both device and constant (I think those two make sense) for PGI 12.0.
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