Module Cusolver_m Interface CusolverSpDcsrsv Subroutine CusolverSpDcsrsv(Handle, N, NNZA, DescrA, CsrValA, CsrRowPtrA, CsrColIndA, B, TOL, & Reorder, X, Singularity) Bind(C, Name='CusolverSpDcsrlsvlu') Use Iso_C_Binding Type(CusolverSpHandle_t) :: Handle Integer(C_Int) :: N, NNZA, Reorder, Singularity Type(CusparseMatDescr_t) :: DescrA Real(C_Double), Device :: CsrValA(NNZA), B(N), X(N) Integer(C_Int), Device :: CsrRowPtrA(N+1), CsrColIndA(NNZA) Real(C_Double) :: TOL End Subroutine End Interface Interface CusolverSpCreate Subroutine CusolverSpCreate(Handle) Bind(C, Name='CusolverSpCreate') Use Iso_C_Binding Type(CusolverSpHandle_t) :: Handle End Subroutine End Interface Interface CusolverSpDestroy Subroutine CusolverSpDestroy(Handle) Bind(C, Name='CusolverSpDestroy') Use Iso_C_Binding Type(CusolverSpHandle_t) :: Handle End Subroutine End Interface End Module Program Sparse_Solver_GPU Use Cudafor Use Cusparse Use Cusolver_m Implicit None Type(CusolverSpHandle) :: Handle Type(CusparseMatDescr) :: DescrA Integer :: Istat,Reorder,Singularity Double Precision :: TOL Integer, Device :: CSR_Row_Index_GPU(5) Integer, Device :: CSR_Matrix_Column_GPU(9) Double Precision, Device :: CSR_Matrix_Value_GPU(9) Double Precision, Device :: Right_Vector_GPU(4) Double Precision, Device :: Computed_Value_GPU(4) Integer :: CSR_Row_Index(5) Integer :: CSR_Matrix_Column(9) Double Precision :: CSR_Matrix_Value(9) Double Precision :: Right_Vector(4) Double Precision :: Computed_Value(4) Print *,'Start LU Decomposing With Cusolver In GPU Platform' Alpha=1.0D0 CSR_Row_Index =(/1,4,5,8,10/) CSR_Matrix_Column=(/1,3,4,2,1,3,4,2,4/) CSR_Matrix_Value =(/1.0D0,2.0D0,3.0D0,4.0D0,5.0D0,6.0D0,7.0D0,8.0D0,9.0D0/) Right_Vector =(/19.0D0,8.0D0,51.0D0,52.0D0/) Computed_Value =0.0D0 CSR_Row_Index_GPU =CSR_Row_Index CSR_Matrix_Column_GPU=CSR_Matrix_Column CSR_Matrix_Value_GPU =CSR_Matrix_Value Right_Vector_GPU =Right_Vector Computed_Value_GPU =Computed_Value Istat=CusolverSpCreate(Handle) If (Istat /= CUSOLVER_STATUS_SUCCESS) Print *, 'CusolverSpCreate Error: ', Istat Istat=CusparseCreateMatDescr(DescrA) Istat=CusparseSetMatType(DescrA,CUSPARSE_MATRIX_TYPE_GENERAL) Istat=CusparseSetMatIndexBase(DescrA,CUSPARSE_INDEX_BASE_ONE) !.... ================================================================================================================================== Istat=CusolverSpDcsrsv(Handle, 4, 9, DescrA, CSR_Matrix_Value_GPU, CSR_Row_Index_GPU, CSR_Matrix_Column_GPU, & Right_Vector_GPU, TOL, Reorder, Computed_Value_GPU, Singularity) !.... ================================================================================================================================== Computed_Value=Computed_Value_GPU ! UÓÉGPU´«ÖÁCPU Print *,Computed_Value !.... Destroy and Deallocate Istat=CusolverSpDestroy(Handle) Stop End Program