Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CUSPARSE] Update the interface for triangular solves #2164

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/cusparse/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,17 @@ function sm!(transa::SparseChar, transb::SparseChar, uplo::SparseChar, diag::Spa
transa = T <: Real && transa == 'C' ? 'T' : transa
transb = T <: Real && transb == 'C' ? 'T' : transb

# Check if we solve a triangular system in-place with transb != 'N'.
# In that case we need to update the descriptor of C such that it represents Bᵀ.
is_C_transposed = (B === C) && (transb != 'N')

if isa(A, CuSparseMatrixCSC) && transa == 'C' && T <: Complex
throw(ArgumentError("Backward and forward sweeps with the adjoint of a complex CSC matrix is not supported. Use a CSR or COO matrix instead."))
end

mA,nA = size(A)
mB,nB = size(B)
mC,nC = size(C)
mC,nC = !is_C_transposed ? size(C) : reverse(size(C))

(mA != nA) && throw(DimensionMismatch("A must be square, but has dimensions ($mA,$nA)!"))
(mC != mA) && throw(DimensionMismatch("C must have $mA rows, but has $mC rows"))
Expand All @@ -566,7 +570,7 @@ function sm!(transa::SparseChar, transb::SparseChar, uplo::SparseChar, diag::Spa
cusparseSpMatSetAttribute(descA, 'D', cusparse_diag, Csize_t(sizeof(cusparse_diag)))

descB = CuDenseMatrixDescriptor(B)
descC = CuDenseMatrixDescriptor(C)
descC = CuDenseMatrixDescriptor(C, transposed=is_C_transposed)

spsm_desc = CuSparseSpSMDescriptor()
function bufferSize()
Expand Down
Loading