Too many arguments specified for cublasddot

Hello.

I have a problem using cuBLAS library.

Following is the code section where error occurs.

SUBROUTINE cuCMFDEigUpdt(cuCMFD, cuDevice, myBlasHandle, eigv)
USE PARAM
USE CUDATypeDef,		ONLY : cuCMFD_Type,		cuDevice_Type
USE PE_MOD,				ONLY : PE
USE MPIComm_Mod,		ONLY : MPI_SYNC,		REDUCE
USE CUBLAS
USE OPENACC
USE OMP_LIB

TYPE(cuCMFD_Type) :: cuCMFD
TYPE(cuDevice_Type) :: cuDevice
TYPE(cublasHandle) :: myBlasHandle
REAL :: eigv

INTEGER :: ierr, n
REAL, POINTER, DEVICE :: psi(:), psid(:)
REAL :: numerator, denominator
REAL :: psipsi, psipsid
REAL, SAVE :: sum_psipsi, sum_psipsid

psi => cuCMFD%Cell_psi
psid => cuCMFD%Cell_psid

!$OMP MASTER
sum_psipsi = 0; sum_psipsid = 0
!$OMP END MASTER

!--- Error Here
ierr = cublasDdot(myBlasHandle, n, psi, 1, psi, 1, psipsi)
ierr = cublasDdot(myBlasHandle, n, psi, 1, psid, 1, psipsid)

!$OMP CRITICAL
sum_psipsi = numerator + psipsi
sum_psipsid = denominator + psipsid
!$OMP END CRITICAL

!$OMP MASTER
CALL MPI_SYNC(PE%MPI_CMFD_COMM)
CALL REDUCE(sum_psipsi, numerator, PE%MPI_CMFD_COMM, TRUE)
CALL REDUCE(sum_psipsid, denominator, PE%MPI_CMFD_COMM, TRUE)
eigv = numerator / denominator
!$OMP END MASTER

END SUBROUTINE

The compiler says that too many arguments are specified for cublasddot, but I’m following the manual.

Please tell me if I’m doing something wrong.

  • FYI, I’m using -r8 option, which means that REAL is actually REAL(8).

Okay, I saw cublas.h file and found that cuBLAS functions do not receive cublasHandle as an input argument.

And also the function return value is not an integer error code; it is the result itself.

So,

psipsi = cublasDdot(n, psi, 1, psi, 1)
psipsid = cublasDdot(n, psi, 1, psid, 1)

seems to be a valid syntax, and it compiles without error.

Other routines like cublasDscal, cublasDaxpy and cublasDnrm2 also have the same issue.

But why?

It’s different with the interface definitions written in

http://www.pgroup.com/doc/pgicudaint.pdf

Most of the complications with the cublas interfaces are due to legacy reasons. We started by supporting traditional BLAS-style interfaces. CUDA changed to the “v2” interfaces soon after, while still supporting the traditional entry points. Now, CUDA no longer supports some of the new stream-related features when using the traditional entry points, so we’ve recently rewritten the PGI interfaces to always use the “v2” interfaces under the hood.

You should just use the pgicudaint.pdf document as your guide, when using PGI compilers and Fortran.

You can call ddot in the following ways:

use cublas
z = ddot(n,x,incx,y,incy) ! Traditional blas interface
z = cublasddot(n,x,incx,y,incy) ! Tradional (no handle), but now with cublas name
ierr = cublasddot_v2(h,n,x,incx,y,incy,z) ! v2 interface, takes a handle
! Also, z can be on host or device

use cublas_v2
z = ddot(n,x,incx,y,incy) ! Traditional blas interface
ierr = cublasddot(h,n,x,incx,y,incy,z) ! v2 interface, takes a handle
! Also, z can be on host or device
ierr = cublasddot_v2(h,n,x,incx,y,incy,z) ! v2 interface, takes a handle
! z explicitly controlled via cublasSetPointerMode()

Then, which document should I refer to for correctly using cuBLAS and cuSPARSE in Fortran?

The source code is not provided so there’s no way to know how the interface is implemented.