Interface to a cublas subroutine zgeam

I want to add two matrices. Thus I want to call zgeam, which is one of the extentions of cublas in cuda 5.0. Of course, if I want to call this subroutine in CUDA Fortran, I will have to write an interface to it. However, with following code, I get an error “Segmentation fault”. Could anyone see why, please?


module cublas_device

interface

subroutine cublas_device_zgeam( transa, transb, m, n, alpha, A, lda, beta, B, ldb, C,  ldc) bind(C,name='cublasZgeam')
use iso_c_binding
character(1,c_char),value::transa,transb
integer(c_int),value::m,n,lda,ldb,ldc
complex(c_double_complex),value::alpha,beta
complex(c_double_complex),device::A(lda,*),B(ldb,*),C(ldc,*)
end subroutine  cublas_device_zgeam

end interface

end module

PROGRAM main      
use cudafor
use cublas_device                  

IMPLICIT NONE
        
INTEGER, PARAMETER :: M = 8
INTEGER, PARAMETER :: N = 8
INTEGER :: i,j,incx,incy

complex*16, device,allocatable::A_d(:,:),B_d(:,:),C_d(:,:)

complex*16 alpha,beta

ALLOCATE(A_d(M,N),B_d(M,N),C_d(M,N))

A_d = 1.0
B_d = 2.0
        
alpha = 1.0
beta = 1.0

beta = 1.0
call  cublas_device_zgeam( 'N', 'N', m, n, alpha, A_d, m, beta, B_d, m, C_d,  m)
    
END

For me, other cublas subroutines work fine. But this one does not.

Hi Happyfish,

The segv is being caused because the new CUBLAS has changed all their interfaces to return an error code. Hence, cublas_device_zgeam needs to be updated to be a function which returns an integer. Though, once you get past that, there will be other issues as well since it looks like these are now in the “V2” format. (for example you now need to pass in a handle and transa and transb need to be passed as integers)

We are in the process of adding these routines to our CUBLAS interface modules as well as CUDA 5.0 support. Hence, you may wish to wait until PGI 13.0 is released before using these new routines.

  • Mat

Many thanks. What are the differences between V1 and V2, please? Are there any examples for telling these differences when they are called?

Please see: http://docs.nvidia.com/cuda/cublas/index.html for documentation about CUBLAS. In particular, the differences between the old and new (V2) API can be found under the section “New and Legacy CUBLAS API”.

  • Mat