Skip to content

Commit

Permalink
Use cusparseSpSM_updateMatrix in CUSOLVERRF.jl (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison authored Apr 15, 2024
1 parent e30d7ea commit 428b3d0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
julia-version: ['1.9']
cuda-version: ['11.8', '12.3']
cuda-version: ['11.8', '12.4']
julia-arch: [x64]
os: [ubuntu-22.04]

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ uuid = "a8cc9031-bad2-4722-94f5-40deabb4245c"
version = "0.2.4"

[compat]
CUDA = "4, 5.1.1"
CUDA = "4, 5.3.0"
KLU = "0.3, 0.4"
julia = "1.6"

Expand Down
8 changes: 5 additions & 3 deletions src/backsolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function CuSparseSM(
) where T
chktrans(transa)

# CUDA 12.3 is required for the routine cusparseSpSV_updateMatrix
@assert CUDA.runtime_version() v"12.3"
# CUDA 12.4 is required for the routine cusparseSpSM_updateMatrix
@assert CUDA.runtime_version() v"12.4"

m, n = size(A)
@assert m == n
Expand Down Expand Up @@ -173,8 +173,10 @@ function backsolve!(s::CuSparseSM, A::CUSPARSE.CuSparseMatrixCSR{T}, X::CuMatrix
alpha = one(T)

descX = CUSPARSE.CuDenseMatrixDescriptor(X)
transx = 'N'
CUSPARSE.cusparseSpSM_updateMatrix(CUSPARSE.handle(), s.infoL, A.nzVal, CUSPARSE.CUSPARSE_SPSM_UPDATE_GENERAL)
CUSPARSE.cusparseSpSM_updateMatrix(CUSPARSE.handle(), s.infoU, A.nzVal, CUSPARSE.CUSPARSE_SPSM_UPDATE_GENERAL)

transx = 'N'
if s.transa == 'N'
CUSPARSE.cusparseSpSM_solve(
CUSPARSE.handle(), s.transa, transx, Ref{T}(alpha), s.descL, descX, descX, T, s.algo, s.infoL,
Expand Down
25 changes: 1 addition & 24 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function RFLU(
r = CuVector{Tv}(undef, n) ; fill!(r, zero(Tv))
T = CuMatrix{Tv}(undef, n, nrhs) ; fill!(T, zero(Tv))

if CUDA.runtime_version() v"12.3"
if CUDA.runtime_version() v"12.4"
tsv = CuSparseSV(M, 'T')
dsm = CuSparseSM(M, 'N', T)
tsm = CuSparseSM(M, 'T', T)
Expand All @@ -85,29 +85,6 @@ end
# Refactoring
function LinearAlgebra.lu!(rf::RFLU, J::CuSparseMatrixCSR)
rf_refactor!(rf.rf, J)
# Perform the analysis again of SpSM
if CUDA.runtime_version() v"12.3"
T = eltype(J)
alpha = one(T)
# Update rf.dsm
dsm = rf.dsm
descX = CUSPARSE.CuDenseMatrixDescriptor(T, dsm.n, dsm.nrhs)
CUSPARSE.cusparseSpSM_analysis(
CUSPARSE.handle(), dsm.transa, 'N', Ref{T}(alpha), dsm.descL, descX, descX, T, dsm.algo, dsm.infoL, dsm.bufferL,
)
CUSPARSE.cusparseSpSM_analysis(
CUSPARSE.handle(), dsm.transa, 'N', Ref{T}(alpha), dsm.descU, descX, descX, T, dsm.algo, dsm.infoU, dsm.bufferU,
)
# Update rf.tsm
tsm = rf.tsm
descX = CUSPARSE.CuDenseMatrixDescriptor(T, tsm.n, tsm.nrhs)
CUSPARSE.cusparseSpSM_analysis(
CUSPARSE.handle(), tsm.transa, 'N', Ref{T}(alpha), tsm.descL, descX, descX, T, tsm.algo, tsm.infoL, tsm.bufferL,
)
CUSPARSE.cusparseSpSM_analysis(
CUSPARSE.handle(), tsm.transa, 'N', Ref{T}(alpha), tsm.descU, descX, descX, T, tsm.algo, tsm.infoU, tsm.bufferU,
)
end
end

# Direct solve
Expand Down

0 comments on commit 428b3d0

Please sign in to comment.