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.