Cusparse for solving the sparse linear equation Ax=b

I’d like to solve the sparse linear equation Ax=b (A is stored in ‘CSR’) by using the cuSparse library.
The official document is not detailed.I’d like to know how to achieve this (STEP BY STEP) in detail.For example,the functions and the use-order of functions.
And I see the official document …, it can only get the solution of a sparse triangular linear system ? How about the SPD(Symmetric positive definite) matrixs(not triangular matrixs)
Here I post my test code…The answer is not as expected ,I’m looking forward for some help…,thanks!

      istat=cusparseXcoo2csr(h,cooRowPtr_d,nnz,m,csrRowPtr_d,             &
      istat=cusparseCcsrsv_analysis(h,cusparse_operation_non_transpose, &
!      istat=cusparseCcsrilu0(h,cusparse_operation_non_transpose,m,descr,&
!      csrVal_d,csrRowPtr_d,csrColInd_d,info)
      istat=cusparseCcsrsv_solve(h,cusparse_operation_non_transpose,m,  &

Hi M_yeah,

Have you looked at using the cuSolver library instead?


emmmm, I use '‘fortran’ , does it have cuSolver library? I can’t find
the cuSolver library API in this website…

Yes, you can call cuSolver routines from CUDA Fortran.

We do provide a interface module for most of the DN routines (cusolverdn.mod). For the SP and RF routines, you may need to write an interface, but it’s fairly straight forward to do.

Do you have a particular routine in mind?

Maybe i need a simple example to show me exactly how to do …
Be grateful with your help~~

I’ve not used suSolver myself so wont be much help on using it. But there’s this post over on NVIDIA’s devtalk forum:
and this from Stackoverflow:

I can help with the interfaces if needed. Here’s an example from one of the interfaces in our cuSolverDN module:

module cusolverDn

use cusolver_common

TYPE cusolverDnHandle
  TYPE(C_PTR) :: handle

! cusolverDnDpotrs
  integer(4) function cusolverDnDpotrs(handle, uplo, n, nrhs, A, lda, B, ldb, devinfo) bind(C, name='cusolverDnDpotrs')
    import cusolverDnHandle
    type(cusolverDnHandle), value :: handle
    integer(4), value :: uplo
    integer(4), value :: n, nrhs, lda, ldb
    real(8), device, dimension(lda,*) :: A
    real(8), device, dimension(ldb,*) :: B
    integer(4), device, intent(out) :: devinfo
  end function
end interface


Is there a performance gain from using sparse cuSolver versus cuSparse’s solvers?

  • Ron

It’s my understanding that cuSolver uses cuSparse underneat for its cusolverSP API, so I would think that the performance difference between them shouldn’t be too great. If you later need support for dense matrices, you won’t need to include an additional library if you use cuSolver.