Hi,
We have a MPI code which is mixing part in Fortran and part in Cuda. Before the MPI init we need to set the device by calling cudaSetDevice.
We then also call acc_set_device_num to set the device for the directives (it seems to be necessary to call both).
This used to work fine with pgi12.10, however with 13.3 I am getting an error at runtime.
I was able to reproduce the problem in a simple code (wihtout mpi):
!test setdevice
program main
use openacc
implicit none
integer :: ndev, mydev,ierr
enum, bind(C) !:: cudaError
enumerator :: cudaSuccess=0
end enum ! cudaError
interface ! [['cudaError_t', None], 'cudaSetDevice', [['int', None, 'device']]]
function cudaSetDevice(device) result( res ) bind(C, name="cudaSetDevice")
use, intrinsic :: ISO_C_BINDING
import cudaSuccess
implicit none
integer(c_int), value :: device
integer (KIND(cudaSuccess)) :: res
end function cudaSetDevice
end interface
mydev=0
ierr = cudaSetDevice(mydev)
if (ierr>0) print*, 'Error with cudaSetDevice'
ndev=acc_get_num_devices(acc_device_nvidia)
print*, 'ndev=',ndev
call acc_set_device_num(mydev,acc_device_nvidia)
print*, 'devid=', mydev
end program main
It is compiled as follow:
pgf90 -ta=nvidia -acc -o test_setdevice test_setdevice.f90 -L$CUDALIB -lcudart -lcuda
With 12.10 I get:
mpiexec -n 1 ./test_setdevice
ndev= 2
devid= 0
With 13.3:
mpiexec -n 1 ./test_setdevice
call to cuMemAlloc returned error 709: Context is destroyed or not yet created
Any idea why this could work with 12.10 and not anymore with 13.3 ?
Thanks,
Xavier