| View previous topic :: View next topic |
| Author |
Message |
jmckennon
Joined: 24 Aug 2010 Posts: 34
|
Posted: Mon Aug 30, 2010 3:29 pm Post subject: Syntax errors? |
|
|
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 |
|
 |
brentl
Joined: 20 Jul 2004 Posts: 107
|
Posted: Tue Aug 31, 2010 8:34 am Post subject: |
|
|
| It looks right. What compiler options are you using? Does your source file have the .cuf suffix? |
|
| Back to top |
|
 |
jmckennon
Joined: 24 Aug 2010 Posts: 34
|
Posted: Wed Sep 01, 2010 9:17 am Post subject: |
|
|
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 |
|
 |
brentl
Joined: 20 Jul 2004 Posts: 107
|
Posted: Wed Sep 01, 2010 11:37 am Post subject: |
|
|
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 |
|
 |
jmckennon
Joined: 24 Aug 2010 Posts: 34
|
Posted: Wed Sep 01, 2010 12:21 pm Post subject: |
|
|
| 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 |
|
 |
|