Hello.
Long time no see.
Recently I have gone into a very strange problem and I would like to ask you the cause.
I’m using PVF 17.7.
Following is a simple code that reproduces my problem.
PROGRAM MULTIGPU
USE OMP_LIB
USE CUDAFOR
USE OPENACC
USE CUBLAS
USE CUSPARSE
IMPLICIT NONE
TYPE(cublasHandle) :: myblasHandle
TYPE(cusparseHandle) :: mysparseHandle
INTEGER :: tid, gid, ierr
INTEGER :: nDevice
nDevice = acc_get_num_devices(acc_device_nvidia)
PRINT *, 'OpenACC Available Devices : ', nDevice
!$OMP PARALLEL PRIVATE(tid, gid, ierr) NUM_THREADS(nDevice)
tid = omp_get_thread_num()
CALL acc_set_device_num(tid, acc_device_nvidia)
gid = acc_get_device_num(acc_device_nvidia)
PRINT *, 'Thread ', tid, ' OpenACC Device : ', gid
ierr = cublasCreate(myblasHandle)
ierr = cusparseCreate(mysparseHandle)
gid = acc_get_device_num(acc_device_nvidia)
PRINT *, 'Thread ', tid, ' OpenACC Device : ', gid
!$OMP END PARALLEL
END PROGRAM
It is just a beginning phase of multi-device control setting.
The output is
OpenACC Available Devices : 2
Thread 0 OpenACC Device : 0
Thread 1 OpenACC Device : 1
Thread 0 OpenACC Device : 1
Thread 1 OpenACC Device : 1
Strange thing is that cublasCreate and cusparseCreate changes the OpenACC device arbitrarily.
What would be the problem?