Hello everyone,
I am trying to use the cufftSetStream(plan,stream) command on a hybrid MPI Cuda fortran code. On the host I am defining the variables as
integer :: plan
integer :: stream
and my interface is
interface cufftSetStream integer function cufftSetStream(plan,stream) bind(C,name='cufftSetStream') use iso_c_binding integer(c_int), value:: plan integer(c_int) :: stream end function cufftSetStream end interface cufftSetStream
My logic here ( I donât know if itâs right) is each cpu to create a cuda stream, copy its data to the device, create the plan, connect the plan with the stream and run the fft. Here is the block that is executed from each cpu:
istat=cudastreamcreate(stream)
!send data to device for each cpu
istat=cudamemcpyasync(val_d,val,proc%nxyz(1)*proc%nxyz(2)*nz,cudaMemcpyHostToDevice,stream)
! allocate arrays where fft and ifft will be performed 1-d
allocate(a_d(proc%nxyz(1)*proc%nxyz(2)*nz),b_d(proc%nxyz(1)*proc%nxyz(2)*nz))
!specify threads on each dimension of the block
block=dim3(32,32,1)
!specify numbers of blocks on each dimension of thegrid
grid=dim3(ceiling(real(proc%nxyz(1))/block%x),ceiling(real(proc%nxyz(2))/block%y),ceiling(real(nz)/block%z))
!map on 1-d array for the fft
call threedim_2_onedim<<<grid,block,0,stream>>>(val_d,a_d,proc%nxyz(1),proc%nxyz(2),nz)
!initialize plan
istat=cufftPlan1D(plan,nz,CUFFT_D2Z,proc%nxyz(1)*proc%nxyz(2))
istat=cufftSetStream(plan,stream)
istat=cufftPlan1D(plan2,nz,CUFFT_Z2D,proc%nxyz(1)*proc%nxyz(2))
istat=cufftSetStream(plan2,stream)
! Execute FFTs
istat=cufftExecD2Z(plan,a_d,b_d,CUFFT_FORWARD)
if(istat.ne.0) write(*,*) 'problem with forward fft'
istat=cufftExecZ2D(plan2,b_d,a_d,CUFFT_INVERSE)
if(istat.ne.0) write(*,*) 'problem with inverse fft'
istat=cufftDestroy(plan)
istat=cufftDestroy(plan2)
!bring processed data back to 3-d form
call onedim_2_threedim <<<grid,block,0,stream>>>(val_d,a_d,proc%nxyz(1),proc%nxyz(2),nz)
!get data back to host
istat=cudamemcpyasync(val,val_d,proc%nxyz(1)*proc%nxyz(2)*nz,cudaMemcpyDeviceToHost,stream)
The problem is that I am getting the following errors and I canât understand why as I am new to Cuda.
[r5u25n1:56095] *** Process received signal ***
[r5u25n1:56095] Signal: Segmentation fault (11)
[r5u25n1:56095] Signal code: (128)
[r5u25n1:56095] Failing at address: (nil)
[r5u25n1:56095] [ 0] /lib64/libpthread.so.0(+0xf630)[0x7f103579c630]
[r5u25n1:56095] [ 1] /usr/lib64/libcuda.so.1(+0x1cb9cd)[0x7f1029ca79cd]
[r5u25n1:56095] [ 2] /usr/lib64/libcuda.so.1(+0x17c0a1)[0x7f1029c580a1]
[r5u25n1:56095] [ 3] /usr/lib64/libcuda.so.1(cuLaunchKernel+0x83)[0x7f1029cfeb93]
[r5u25n1:56095] [ 4] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x24853b)[0x7f1050f4753b]
[r5u25n1:56095] [ 5] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x28a306)[0x7f1050f89306]
[r5u25n1:56095] [ 6] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x22797f)[0x7f1050f2697f]
[r5u25n1:56095] [ 7] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0xd9a2d)[0x7f1050dd8a2d]
[r5u25n1:56095] [ 8] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0xedef7)[0x7f1050decef7]
[r5u25n1:56095] [ 9] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0xee24d)[0x7f1050ded24d]
[r5u25n1:56095] [10] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x54a1f)[0x7f1050d53a1f]
[r5u25n1:56095] [11] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x54aba)[0x7f1050d53aba]
[r5u25n1:56095] [12] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x5400c)[0x7f1050d5300c]
[r5u25n1:56095] [13] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x40a4a)[0x7f1050d3fa4a]
[r5u25n1:56095] [14] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(+0x40bf0)[0x7f1050d3fbf0]
[r5u25n1:56095] [15] /opt/ohpc/pub/apps/cuda/11.0/Linux_x86_64/20.7/math_libs/11.0/lib64/libcufft.so.10(cufftExecD2Z+0x72)[0x7f1050d4ed52]
[r5u25n1:56095] [16] ./test[0x403cc3]
[r5u25n1:56095] [17] ./test[0x402613]
[r5u25n1:56095] *** End of error message ***
Could you please assist me on that issue?
Thank you in advance
VT