-
-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Currently, the default algorithm choice is not really able to handle sparse cuda matrices. In short:
CuSparseMatrixCSC-> defaults always toGenericLUwhich is not GPU compatible (scalar indexing)CuSparseMatrixCSRCUDSSnot available -> defaults to Krylov which not GPU compatibe (scalar indexing). It gives a warning howeverCUDSSavailable + asym matrix -> worksCUDSSavailable + symmetric matrix -> Cholesky which is not GPU compatible (scalar indexing)
I am not sure what the right thing here is. Maybe just give a clearer error message? Or maybe convert to dense?
Code to play around with:
using LinearSolve
using SparseArrays
using CUDA
using CUDSS
b = Float64[1, 2, 3, 4]
b_gpu = adapt(CuArray, b)
A = Float64[1 1 0 0
0 1 1 0
0 0 3 1
0 0 0 4]
A_sym = Float64[1 1 0 0
1 0 0 2
0 0 3 0
0 2 0 0]
# asymetric matrix on GPU (dense)
A_gpu = adapt(CuArray, A)
prob_gpu = LinearProblem(A_gpu, b_gpu)
solve(prob_gpu) # works
# asymetric sparse matrix
A_gpu_sparse1 = CUDA.CUSPARSE.CuSparseMatrixCSR(sparse(A))
prob_gpu_sparse1 = LinearProblem(A_gpu_sparse1, b_gpu)
solve(prob_gpu_sparse1) # works
A_gpu_sparse2 = CUDA.CUSPARSE.CuSparseMatrixCSC(sparse(A))
prob_gpu_sparse2 = LinearProblem(A_gpu_sparse2, b_gpu)
solve(prob_gpu_sparse2) # fails because of generic LU
# symmetric matrix on GPU (dense)
A_gpu_sym = adapt(CuArray, A_sym)
prob_gpu_sym = LinearProblem(A_gpu_sym, b_gpu)
solve(prob_gpu_sym) # works
# symetric sparse on GPU
A_gpu_sym_sparse1 = CUDA.CUSPARSE.CuSparseMatrixCSR(sparse(A_sym))
prob_gpu_sym_sparse1 = LinearProblem(A_gpu_sym_sparse1, b_gpu)
solve(prob_gpu_sym_sparse1) # errors in colesky
A_gpu_sym_sparse2 = CUDA.CUSPARSE.CuSparseMatrixCSC(sparse(A_sym))
prob_gpu_sym_sparse2 = LinearProblem(A_gpu_sym_sparse2, b_gpu)
solve(prob_gpu_sym_sparse2) # errors in generic LUMetadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working