PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

cuda fortran sample code
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
odyssey



Joined: 07 May 2010
Posts: 7

PostPosted: Tue Jun 15, 2010 4:18 pm    Post subject: cuda fortran sample code Reply with quote

Currently I'm evaluating a trial version of CUDA Fortran compiler. I have just tested a sample source code "cufinfo.cuf" that can be found in C:\Program Files\PGI\win32\10.5\samples after installation.
Code:

program cufinfo
use cudafor

integer istat, num, numdevices

type(cudadeviceprop) :: prop

istat = cudaGetDeviceCount(numdevices)

do num = 0, numdevices-1
  istat = cudaGetDeviceProperties(prop, num)
  call printDeviceProperties(prop, num)
end do

end
!
subroutine printDeviceProperties(prop, num)
use cudafor
type(cudadeviceprop) :: prop
integer num
ilen = verify(prop%name, ' ', .true.)
write (*,900) "Device Number: "      ,num
write (*,901) "Device Name: "        ,prop%name(1:ilen)
write (*,903) "Total Global Memory: ",real(prop%totalGlobalMem)/1e9," Gbytes"
write (*,902) "sharedMemPerBlock: "  ,prop%sharedMemPerBlock," bytes"
write (*,900) "regsPerBlock: "       ,prop%regsPerBlock
write (*,900) "warpSize: "           ,prop%warpSize
write (*,900) "maxThreadsPerBlock: " ,prop%maxThreadsPerBlock
write (*,904) "maxThreadsDim: "      ,prop%maxThreadsDim
write (*,904) "maxGridSize: "        ,prop%maxGridSize
write (*,903) "ClockRate: "          ,real(prop%clockRate)/1e6," GHz"
write (*,902) "Total Const Memory: " ,prop%totalConstMem," bytes"
write (*,905) "Compute Capability Revision: ",prop%major,prop%minor
write (*,902) "TextureAlignment: "   ,prop%textureAlignment," bytes"
write (*,906) "deviceOverlap: "      ,prop%deviceOverlap
write (*,900) "multiProcessorCount: ",prop%multiProcessorCount
write (*,906) "integrated: "         ,prop%integrated
write (*,906) "canMapHostMemory: "   ,prop%canMapHostMemory
900 format (a,i0)
901 format (a,a)
902 format (a,i0,a)
903 format (a,f5.3,a)
904 format (a,2(i0,1x,'x',1x),i0)
905 format (a,i0,'.',i0)
906 format (a,l0)
return
end

After I compile this code by "pgfortran -ta=nvidia cufinfo.cuf", two output files (object file library, exports library file) are not generated. It seems there is a problem with compiling or linking cuda fortran code, because when I tried a standard fortran code (f3.f90 in C:\Program Files\PGI\win32\10.5\samples), it worked fine.
Please give me an advice on what's wrong and what I'm missing.
I'd greatly appreciate for your answer.

odyssey
Back to top
View user's profile
mkcolg



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

PostPosted: Wed Jun 16, 2010 8:27 am    Post subject: Reply with quote

Hi Odyssey,

Since this is CUDA Fortran, replace "-ta=nvidia" with the "-Mcuda" flag. On Linux, we added beta support for mixing CUDA Fortran (-Mcuda) and the PGI Accelerator model (-ta=nvidia), but on Windows you still need to keep them separate.

Hope this helps,
Mat
Back to top
View user's profile
odyssey



Joined: 07 May 2010
Posts: 7

PostPosted: Wed Jun 16, 2010 9:58 am    Post subject: Reply with quote

Hi Mat,

Thanks for reply. The compiling command and option are indicated on the top of the sample source code so we can use it for test. Is the option -Mcuda required? The extension of filename is .cuf. Anyway I tried to compile with the command lines such as "pgfortran -ta=nvidia -Mcuda cufinfo.cuf", and "pgfortran -Mcuda cufinfo.cuf", but it doesn't work.

Please help.

Odyssey
Back to top
View user's profile
mkcolg



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

PostPosted: Wed Jun 16, 2010 11:17 am    Post subject: Reply with quote

Hi Odyssey,

Quote:
Is the option -Mcuda required?
No, not if the file suffix is ".cuf". I was using "-Mcuda" to be explicit about the language being used.

Quote:
"pgfortran -Mcuda cufinfo.cuf", but it doesn't work.
I'll need more details such as the specific error you're seeing.

- Mat
Back to top
View user's profile
odyssey



Joined: 07 May 2010
Posts: 7

PostPosted: Wed Jun 16, 2010 3:39 pm    Post subject: Reply with quote

It seems that the process of compilation or execution doesn't recognize the GPU processors in my computer. I have two GPU's (GeForce GTX 285 and Tesla C1060) in my machine. I simplified the original source code as below so that it counts the number of devices.
Code:

program cufinfo

use cudafor

integer :: istat, numdevices

type(cudadeviceprop) :: prop

istat = cudaGetDeviceCount(numdevices)

print *, numdevices

end


The compilation process created the execution file, and when I ran the exe file, it ouput "0", which is actually supposed to be "2".
Please help.

FYI, My computer is AMD phenom (tm) 2 x4 940 based machine with windows xp professional (32bit).

Odyssey
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
Goto page 1, 2  Next
Page 1 of 2

 
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