Problems with linking

Hello,
I am trying to complile a simple CUDA code with pgfortran.

attributes(global) subroutine S
end subroutine S

program P
call S<<1, 1>>
end program P

As a result, I have this:

# pgfortran test.cuf
In function 'p`: /..././test.cuf: undefined reference to 's_`

I am using PGI workstation 10.3
CentOS 5.2

# pgaccelinfo
CUDA Driver Version 3020
Device name: Tesla C2050

pgfortran -c test.cuf compiled without any errors
Is there incompatibility between libraries? I have no idea.

Hi Tez,

CUDA Fortran device kernels require interfaces in order to be called from host code. Hence, you either write an explicit interface for S in your main program or put S in a module where an implicit interface is generated.

module foo
contains
attributes(global) subroutine S
end subroutine S
end module foo

program P
use foo
call S<<<1, 1>>>()
end program P

Hope this helps,
Mat

Yes, it helped, thanks.
Until then, I only programmed in CUDA C and didn’t know about this feature in fortran.