PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Syntax errors?

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling
View previous topic :: View next topic  
Author Message
jmckennon



Joined: 24 Aug 2010
Posts: 34

PostPosted: Mon Aug 30, 2010 3:29 pm    Post subject: Syntax errors? Reply with quote

Hi, I'm trying to debug some of my cudafortran code and keep getting this error:

PGF90-S-0034 Syntax error at or near device (and then the file/line number)

and it occurs for each of the following lines:

real, device, allocatable, DIMENSION(:):: val1
real, device, allocatable, DIMENSION(:):: val2

(and again for like 10 more variable all declared in this way but with different names)

Is this not the correct way to declare allocatable variables for use on the GPU?
Back to top
View user's profile
brentl



Joined: 20 Jul 2004
Posts: 132

PostPosted: Tue Aug 31, 2010 8:34 am    Post subject: Reply with quote

It looks right. What compiler options are you using? Does your source file have the .cuf suffix?
Back to top
View user's profile
jmckennon



Joined: 24 Aug 2010
Posts: 34

PostPosted: Wed Sep 01, 2010 9:17 am    Post subject: Reply with quote

Ah, in the Makefile I hadn't set up the suffixes so there was no rule to build the .cuf file.

I do however have another question. When using CUDA in C, the command cudaMalloc would look like

cudaMalloc((void**)&rd, sizex); //for example

how would I call this in cudaFortran? I keep getting syntax errors when I try doing it in this fashion. I'm not particularly well versed in FORTRAN so I'm not sure how I would use this command. Thanks for the help!!
Back to top
View user's profile
brentl



Joined: 20 Jul 2004
Posts: 132

PostPosted: Wed Sep 01, 2010 11:37 am    Post subject: Reply with quote

You have two choices, either the Fortran way or the cuda way.

If you want a real array, for instance, you can declare it like this:

real, device, allocatable, dimension(:) :: rd
integer sizex

and allocate it like this

sizex = 1000
allocate(rd(sizex))

Or, you can use the CUDA way:

istat = cudaMalloc(rd, sizex)

There are some subtle differences that have to do with Fortran allocatable semantics. Check out the section on allocating device and pinned arrays in the CUDA Fortran Programming Guide and Reference
Back to top
View user's profile
jmckennon



Joined: 24 Aug 2010
Posts: 34

PostPosted: Wed Sep 01, 2010 12:21 pm    Post subject: Reply with quote

Thanks! That helps a ton! I've been getting confused between the two languages. Which method would be preferable for allocating just variables (not arrays)?
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling 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