Hello!
In Cuda Fortran: Cuda 11.4 pgfortran
we try to set int value=9 to a 3D arrary “idev” by cudaMemset3D.
However, after
error = cudaMalloc3D(devPtr, extent)
error =cudaMemset3D(devPtr, 9, extent)
devPtr%ptr is a pointer
THEN, we try to use
call c_f_pointer(devPtr%ptr, idev, ishap)
the value of the returned “idev” !=9
**
use cudafor
use iso_c_binding
INTEGER,PARAMETER::m = 600
INTEGER,PARAMETER::n = 300
INTEGER,PARAMETER::p = 3
integer,pointer,device :: idev(:,:,:)
integer ishap(3)
type(cudaPitchedPtr) :: devPtr
type(cudaExtent) :: extent
INTEGER::i,wz(m,n,p),error
extent%width = m
extent%height = n
extent%depth = p
error = cudaMalloc3D(devPtr, extent)
ishap(1) = devPtr%pitch / 4
ishap(2) = n
ishap(3) = p
call c_f_pointer(devPtr%ptr, idev, ishap)
error = cudaMemset3D(devPtr, 9, extent)
call c_f_pointer(devPtr%ptr, idev, ishap)
wz=idev(1:m,1:n,1:p)
write(*,*),'wz =',wz(1,1,:)
end program cublasTest
**
the code is compiled and executed without errors.
** pgfortran -acc -Mcuda -o a.out a.f90**
the results is:
wz = 151587081 151587081 151587081
Question ?:
How can i set idev=9 through cudaMemset3D IN FORTRAN.
Thank you for your help,
hwei