Type Mismatch


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


use cudafor

subroutine setup(A,B)
integer :: N
real, dimension(:) :: A, B
real, device, allocatable, dimension(:) :: Adev, Bdev
type(dim3) :: dimBlock, dimGrid

N = size(A,1)


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
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)
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


Hi gv1579,

Which version of the compiler are you using? Given the error, my best guess is that you’re using a very early version (10.1). In this case, you need to add the “device” attribute to “myKernel” declaration of “A” and “B”.

Later versions of the compiler, 10.3 and later, have worked through these issues and the code will compile as is.

Hope this helps,

Hi Mat,

Yes, I am using version 10.1. I’ll plan on updating our version to fix this problem. Thanks for the help!