Hello,
I want to solve the linear system of equations which is a dense matrix. I note that some library functions can be used, such as “cusparseDcsrsv2_solve” listed in
CUDA Fortran Programming Guide Version 24.7 for ARM, OpenPower, x86 (nvidia.com). However, for the other manual listed in cuSPARSE Library (nvidia.com), I don not find this function “cusparseDcsrsv2_solve”. I think that both of manuals are publeshed from NVIDIA, but I don not know how to use them. Because there are some details of functions, but the CUDA Fortran manual has some simplified descriptions.
Now, I still try to use “Dcsrsv2_solve” correctly. Unfortunately, I get some errors, such as “NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure cusparsedcsrsv2_solve”.
There are partial codes that I used:
!Copyright (c) 2022 by LEEE under guide of Huaifeng Sun(sunhuaifeng@gmail.com)
!written by Shangbin Liu(lsbin87@126.com)
! --------------------------------Subroutine part---------------------------------------------!
subroutine ITERATION_CDM_CUSPARSE_LU
USE CONSTANTPARAMETERS
USE ELECTROMAGNETIC_VARIABLES
USE RES_MODEL_PARAMETER
USE TIME_PARAMETERS
use openacc
use cudafor
USE CUSPARSE
IMPLICIT NONE
TYPE(cusparseHandle) :: handle5
TYPE(cusparseCsrsv2Info) :: info
integer(4) :: transA, m, nnz,policy
TYPE(cusparseMatDescr):: descrA
REAL(KIND=8)::csrValA(14)
INTEGER(KIND=4) :: csrRowPtrA(5), csrColIndA(14)
INTEGER(KIND=4):: istat
INTEGER(KIND=4) :: pBuffer
INTEGER(1), pointer :: buffer(:)
real(8) :: x(4),y(4), alpha
INTEGER(4)::i
istat = cusparseCreate(handle5)
istat = cusparseCreateMatDescr(descrA)
istat = cusparseSetMatType(descrA,CUSPARSE_MATRIX_TYPE_GENERAL)
istat = cusparseSetMatIndexBase(descrA,CUSPARSE_INDEX_BASE_ONE)
istat = cusparseSetStream(handle5,acc_get_cuda_stream(33))
m=4
nnz=14
alpha=1.0D0
transA=0
policy=0
!$acc data create(handle5, transA, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, info,policy, pBuffer)
istat = cusparseCreateCsrsv2Info(info)
istat = cusparseDcsrsv2_bufferSize(handle5, transA, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, info, pBuffer)
istat = cusparseDcsrsv2_analysis(handle5, transA, m, nnz, descrA, csrValA, csrRowPtrA, csrColIndA, info, policy, pBuffer)
ALLOCATE(buffer(pBuffer ) )
!$acc end data
!=========================The test Region1=========================!
!$acc data copyin(handle5, transA, m, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, info, x, y, policy, pBuffer)
write(*,*)"++++"
data csrValA / 1, 8, 13, 5, 2, 9, 14, 11, 6, 3, 10, 12, 7, 4/
data csrRowPtrA / 1, 4, 8, 12, 15/
data csrColIndA / 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 2, 3, 4/
data y /1,2,3,4/
istat = cusparseDcsrsv2_solve(handle5, transA, m, nnz, alpha, descrA, csrValA, csrRowPtrA, csrColIndA, info, x, y, policy, pBuffer)
!$acc update host(x)
do i=1, 4
write(*,*)x(i)
enddo
pause
!=========================The test Region1=========================!
!$acc end data
end subroutine ITERATION_CDM_CUSPARSE_LU