PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

Oddity in declaring constant memory in host subprograms

 
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: 340
Location: Greenbelt, MD

PostPosted: Tue Jun 19, 2012 8:23 am    Post subject: Oddity in declaring constant memory in host subprograms Reply with quote

I seem to have found an oddity with constant memory declaration that is...puzzling me. Can someone tell me what I'm doing wrong?

To wit, if I try and compile this:
Code:
program test

use cudafor

implicit none

real, constant :: const(40)

write (*,*) 'Test'

end program test
I get:
Code:
(1224) > pgfortran -Mcuda test.F90
PGF90-S-0134-Illegal attribute constant not allowed in host subprograms (test.F90: 7)
  0 inform,   0 warnings,   1 severes, 0 fatal for test
(1225) >

But if I do this:
Code:
program test

use cudafor

implicit none

real :: const(40)
attributes(constant) :: const

write (*,*) 'Test'

end program test
it compiles just fine:
Code:
(1233) > pgfortran -Mcuda test.att.F90
(1234) >

So, I'm wondering is the first correct in saying that it's illegal (though the CUDA Fortran Guide seems to say it's okay), or is the second one wrong in allowing compilation to occur? I don't know which behavior to trust...if either.

FYI: I'm using PGI 12.5, but it seems to occur just the same with V 11.10.

Thanks,
Matt
Back to top
View user's profile
brentl



Joined: 20 Jul 2004
Posts: 141

PostPosted: Tue Jun 19, 2012 12:56 pm    Post subject: Reply with quote

Looks like you've found a problem mainly with our docs. Looking through our bug history, it appears we tightened the usage of the constant qualifier in version 10.8. One note says:

Compiler should produce an error for CONSTANT data in a host subroutine or function. There is no way for a kernel to use this data, so it's useless. It can't even be passed as an argument.

We are limited to the CUDA use of constant data, which I think in CUDA C is just file global, then accessible by symbol name if needed.

The recommended way to use constant data in CUDA Fortran is to put it into a module that can be "used" in both the host and device, or actually contains the global and device subprograms.

I'll enter a bug into our system to update the docs and to also generate a message for the attributes(constant) statement in host code.
Back to top
View user's profile
MuellerM



Joined: 04 Apr 2013
Posts: 63

PostPosted: Mon Dec 21, 2015 8:29 pm    Post subject: Reply with quote

Sorry for burrowing this out, but I'd be super glad for a clarification here: Is *importing* such memory declared as constant allowed (from other modules)? If yes, supercool, if not - do you have a feature wishlist somewhere? ;-)
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Dec 28, 2015 10:08 am    Post subject: Reply with quote

Hi Michel,

Yes, you can access device variables, constant or global, declared in external modules.

- 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