I am still in the learning process of how this CUDA fortran works and I keep receiving this weird message for the following simple code, and I don’t know how to find out the problem. Can anyone help?
module parameters
implicit none
REAL, PARAMETER :: beta = 0.99
REAL, PARAMETER :: alpha = 0.36
real, parameter :: na = 256
REAL, DIMENSION(na) :: agrid
REAL, DIMENSION(na) :: value, kprime
REAL :: amax, amin
end module
module growth_mod
use cudafor
integer :: na_dev
REAL :: beta_dev, alpha_dev
REAL, allocatable, DIMENSION(:) :: agrid_dev,value_dev,valf,kprf
contains
attributes(global) subroutine growth_kernel()
implicit none
integer :: ai,ap,amax
real :: c_tmp
real :: vmax,val,ax
ai=threadidx%x+(blockidx%x-1)*256
val=-1e15
amax=1
ax=agrid_dev(ai)
do ap=1,na_dev
c_tmp = ax**alpha_dev-agrid_dev(ap)
val=log(c_tmp)+beta_dev*value_dev(ap)
if (val>vmax) then
vmax=val
amax=ap
end if
end do
kprf(ai)=agrid_dev(amax)
valf(ai)=vmax
end subroutine
end module
PROGRAM main
use parameters
use cudafor
use growth_mod
implicit none
real :: begin,finish
integer idevice, istat
type(dim3) :: dimGrid, dimBlock
real :: kstar,inc
REAL :: tolv, diffv
INTEGER :: iterv, ai
call cpu_time(begin)
idevice=0
istat = cudaSetDevice(idevice)
dimGrid=dim3(1,1,1)
dimBlock=dim3(256,1,1)
kstar=(1/(alphabeta))**(1/(alpha-1))
amin=0.01kstar
amax=2*kstar
inc=(amax-amin)/real(na-1)
do ai=1,na
agrid(ai)=amin+inc*(ai-1)
end do
value = log(agrid**alpha-agrid)/(1-beta)
tolv = 1.0e-3
allocate(value_dev(na),valf(na),agrid_dev(na),kprf(na))
value_dev=value
agrid_dev=agrid
beta_dev=beta
alpha_dev=alpha
na_dev=na
valf=value
kprf=agrid
diffv = 1
iterv = 0
DO WHILE ( diffv > tolv )
call growth_kernel<<<dimGrid,dimBlock>>>()
istat = cudathreadsynchronize()
diffv=sum(abs(valf-value)/abs(1+value))/real(na)
iterv = iterv + 1
print*, ‘iter number=’, iterv, ‘error=’, diffv
value_dev=valf
value=valf
end do ! for while loop
call cpu_time(finish)
print*, ‘cpu time=’, finish-begin, ‘seconds’
END PROGRAM
Here is the command line to compile the code:
-g -Bstatic -Mbackslash -Mcuda=cuda3.0 -I"c:\program files (x86)\pgi\win32\10.8\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\include" -I"C:\Program Files\PGI\Microsoft Open Tools 10\PlatformSDK\include" -ta=nvidia,wait,cuda3.0 -Minform=warn