Hi,
I’m porting an older Fortran program (~20000 lines of code) to CUDA Fortran. I’ve been writing a few small test programs before I start the larger port (there’s a significant level of subrountine/function calls, so I’m going to need to make then device routines). I’ve been through the CUDA Fortran documentation, but I still can’t find out why this code keeps giving me an error (Argument 3 and 4 in Seemult : type mismatch). Any help would be appreciated.
I’m compiling with: pgf90 -c test_module.cuf
Code:
MODULE test
use cudafor
contains
subroutine setup(A,B)
integer :: N
real, dimension(:) :: A, B
real, device, allocatable, dimension(:) :: Adev, Bdev
type(dim3) :: dimBlock, dimGrid
N = size(A,1)
allocate(Adev(N),Bdev(N))
Adev = A(1:N)
Bdev = B(1:N)
dimGrid = dim3( N/16, 1, 1)
dimBlock = dim3( 16, 1, 1)
call myKernel<<<dimGrid,dimBlock>>>(Adev,Bdev,N)
B(1:N) = Bdev
deallocate(Adev,Bdev)
end subroutine setup
attributes(device) subroutine seemult(i, n, v1, v2)
implicit none
integer, value :: n
real :: v1(n), v2(n)
integer, value :: i
if(i .le. n) then
v2(i) = v2(i)*v1(i)
endif
end subroutine seemult
attributes(global) subroutine myKernel(A,B,N)
real :: A(N), B(N)
integer, value :: N
integer :: i
i = (blockidx%x-1) * 16 + threadidx%x
call seemult(i,N,A,B)
end subroutine myKernel
END MODULE test