PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Interface to a cublas subroutine zgeam

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
happyfish



Joined: 25 Jan 2011
Posts: 7

PostPosted: Sun Dec 09, 2012 5:56 am    Post subject: Interface to a cublas subroutine zgeam Reply with quote

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?


Code:
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.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Mon Dec 10, 2012 12:24 pm    Post subject: Reply with quote

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


Last edited by mkcolg on Tue Dec 11, 2012 8:52 am; edited 1 time in total
Back to top
View user's profile
happyfish



Joined: 25 Jan 2011
Posts: 7

PostPosted: Mon Dec 10, 2012 7:41 pm    Post subject: Reply with quote

Many thanks. What are the differences between V1 and V2, please? Are there any examples for telling these differences when they are called?
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Tue Dec 11, 2012 8:51 am    Post subject: Reply with quote

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
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group