Hello everyone,
I am trying to use cusolver with Cuda Fortran in order to perform a LU decomposition and finally solve a system of equations. The relevant part of the code is the following.
subroutine gpu_LU_solver_with_pivot(AA,BB,XX)
implicit none
double precision, pinned, intent(in):: AA(proc%nijk(1),proc%nijk(2)),BB(proc%nijk(2))
double precision, pinned,intent(out):: XX(proc%nijk(2))
double precision, device:: AA_d(proc%nijk(1),proc%nijk(2)),BB_d(proc%nijk(2))
double precision, device:: XX_d(proc%nijk(2))
double precision, allocatable, device:: workspace_d(:)
integer:: istat,work,i,j,idx
integer, device:: info_d,ny_d
integer, device:: pivot_d(proc%nijk(2))
istat=cudamemcpyasync(AA_d,AA,proc%nijk(1)*proc%nijk(2),cudaMemcpyHostToDevice,stream)
istat=cudamemcpyasync(BB_d,BB,proc%nijk(2),cudaMemcpyHostToDevice,stream)
if(istat.ne.0) write(*,*) 'problem with copying B'
istat=cusolverDnDgetrf_bufferSize(cusolverhndl,proc%nijk(1),proc%nijk(2),AA_d,proc%nijk(1),work)
if(istat.ne.0) write(*,*) 'proble with getting buffer size'
allocate(workspace_d(work))
istat=cusolverDnDgetrf(cusolverhndl,proc%nijk(1),proc%nijk(2),AA_d,proc%nijk(1),workspace_d,pivot_d,info_d)
!if(istat.ne.0) write(*,*) 'problem with dndgetrf--LU factorization'
end subroutine gpu_LU_solver_with_pivot
Also the interface for the cusolver functions:
interface cusolverDnDgetrf_bufferSize
integer function cusolverDnDgetrf_bufferSize(cusolverhndl,rows,columns,A,lda,work) bind(C,name='cusolverDnDgetrf_bufferSize')
use iso_c_binding
type(c_ptr), value:: cusolverhndl
integer(c_int), value:: rows,columns,lda
integer(c_int):: work
double precision, device:: A(*)
end function cusolverDnDgetrf_bufferSize
end interface cusolverDnDgetrf_bufferSize
!
interface cusolverDnDgetrf
integer function cusolverDnDgetrf(cusolverhndl,rows,columns,A,lda,workspace,pivot,info) bind(C,name='cusolverDnDgetrf')
use iso_c_binding
type(c_ptr), value:: cusolverhndl
integer(c_int), value:: rows, columns, lda
double precision, device:: A(*),workspace(*)
integer, device:: pivot(*), info
end function cusolverDnDgetrf
end interface cusolverDnDgetrf
Everything works fine except the call for cusolverDnDgetrf which gives a segmentation fault error. I suspect there is an issue with the arguments of that call but I am not entirely sure how to locate that as the code compiles without any issues. I would appreciate your help.
Thank you in advance
vtsakag