Dear Nvidia developers:
I just tried the following code from the official guide to learn how to generate random numbers on device.
I compile it use nvfortran -Mcuda=nollvm test_rand.cuf
then it appears
nvlink error : Undefined reference to ‘__pgicudalib_curandInitXORWOW’ in ‘/tmp/nvfortranuyJd8HZIXaog.o’
pgacclnk: child process exit status 2: /opt/nvidia/hpc_sdk_2020_2011/Linux_x86_64/20.11/compilers/bin/tools/nvdd
My compiler is hpc sdk 20.11 cuda 11.2 nvidia-smi 460.32.03 driver version 460.32.03
Thanks much in advance!
module mrand
use curand_device
integer, parameter :: n = 500
contains
attributes(global) subroutine randsub(a)
real, device :: a(n,n,4)
type(curandStateXORWOW) :: h
integer(8) :: seed, seq, offset
j = blockIdx%x; i = threadIdx%x
seed = 12345_8 + j*n*n + i*2
seq = 0_8
offset = 0_8
call curand_init(seed, seq, offset, h)
do k = 1, 4
a(i,j,k) = curand_uniform(h)
end do
end subroutine
end module
program t ! pgfortran -Mcuda=nollvm t.cuf
use mrand
use cudafor ! recognize maxval, minval, sum w/managed
real, managed :: a(n,n,4)
a = 0.0
call randsub<<<n,n>>>(a)
print *,maxval(a),minval(a),sum(a)/(n*n*4)
end program