“Segmentation fault” when calling a device interface to cula

General discussion for CULA. Use this forum for questions, examples, feedback, and feature requests.

“Segmentation fault” when calling a device interface to cula

Postby xhsh » Wed Dec 05, 2012 3:50 am

This code is modified from the fortran example.

PROGRAM CULA_TEST

use CULA

EXTERNAL CULA_INITIALIZE
EXTERNAL CULA_SGEQRF
EXTERNAL CULA_DEVICE_SGEQRF
EXTERNAL CULA_SHUTDOWN

INTEGER CULA_INITIALIZE
INTEGER CULA_SGEQRF
INTEGER CULA_DEVICE_SGEQRF


INTEGER M, N, K, STATUS
INTEGER,device:: M_d, N_d, K_d
PARAMETER ( M = 8192, N = 8192, K = 8192 )

REAL A(M, N)
REAL,device:: A_d(M, N)
REAL TAU(K)
REAL,device:: TAU_d(K)

A_d = A
M_d =M; N_d= N; K_d=K

STATUS = CULA_INITIALIZE()
STATUS = CULA_SGEQRF(M, N, A, M, TAU)
STATUS = CULA_DEVICE_SGEQRF(M_d, N_d, A_d, M_d, TAU_d)

CALL CULA_SHUTDOWN()
END

I want to test CULA_DEVICE_SGEQRF, thus I added the line

STATUS = CULA_DEVICE_SGEQRF(M_d, N_d, A_d, M_d, TAU_d)

However, I got "Segmentation fault". The line "STATUS = CULA_SGEQRF(M, N, A, M, TAU) " runs very well, but the line "STATUS = CULA_DEVICE_SGEQRF(M_d, N_d, A_d, M_d, TAU_d) " produces a segmentation fault. Could you tell me why, please? Thank you very much!
xhsh
 
Posts: 8
Joined: Wed Feb 23, 2011 5:42 pm

Re: “Segmentation fault” when calling a device interface to

Postby john » Wed Dec 05, 2012 9:36 am

Please check the examples directory in R16a. There is a specific PGI CUDA Fortran example that will show the correct usage.
john
Administrator
 
Posts: 587
Joined: Thu Jul 23, 2009 2:31 pm

Re: “Segmentation fault” when calling a device interface to

Postby xhsh » Thu Dec 06, 2012 1:32 am

Thank you very much, john! That works fine.

However, I still want to report another problem. With the arrays defined in this way, if we want to use these arrays in cublas, we have to define interfaces to cublas in the same way.

However, for cublas, if I define the interfaces in the following way, it will also work very fine:

module cublas
interface cuda_gemm

subroutine cuda_zgemm(cta, ctb, m, n, k,&
alpha, A, lda, B, ldb, beta, c, ldc) bind(C,name='cublasZgemm')
use iso_c_binding
character(1,c_char),value :: cta, ctb
integer(c_int),value :: m,n,k,lda,ldb,ldc
complex(c_double_complex),value :: alpha,beta
complex(c_double_complex), device, dimension(lda,*) :: A
complex(c_double_complex), device, dimension(ldb,*) :: B
complex(c_double_complex), device, dimension(ldc,*) :: C
end subroutine cuda_zgemm

end interface

contains
subroutine cublas_zgemm(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
implicit none
integer m,n,k,lda, ldb,ldc
character*1::TRANSA,TRANSB
complex*16 :: a(m,k),b(k,n),c(m,n),alpha,beta
complex*16, device, allocatable :: a_d(:,:),b_d(:,:),c_d(:,:)

allocate(a_d(m,k), b_d(k,n), c_d(m,n))
a_d = a
b_d = b
c_d = c
call cuda_zgemm(TRANSA,TRANSB,m,n,k,alpha,a_d,m,b_d,k,beta,c_d,m)
c=c_d
deallocate (a_d,b_d,c_d)
end subroutine
end module cublas

Obviously, this is much more simple. So, for cublas, it works well, why for cula, it fails?

Comparatively, I prefer to use this way since the syntax is much more simple and we do not have to define a lot of new modules. However, it seems that for cula, we can not define the interfaces in this way. It is really a pity and why?
xhsh
 
Posts: 8
Joined: Wed Feb 23, 2011 5:42 pm

Re: “Segmentation fault” when calling a device interface to

Postby john » Thu Dec 06, 2012 7:21 am

I'm sorry, I don't see how this is different from the interfaces in the cula_lapack_device_pgfortran module?
john
Administrator
 
Posts: 587
Joined: Thu Jul 23, 2009 2:31 pm

Re: “Segmentation fault” when calling a device interface to

Postby xhsh » Thu Dec 06, 2012 8:52 am

Oh, my god! I did not check cula_lapack_device_pgfortran, but only cula_lapack_device. It is my fault!! :-) This module is just what I want.

Thank you very much, john!! It is such a nice work.
xhsh
 
Posts: 8
Joined: Wed Feb 23, 2011 5:42 pm


Return to General CULA Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron