@@ -3,7 +3,7 @@ module LinearSolveSparseArraysExt
33using LinearSolve, LinearAlgebra
44using SparseArrays
55using SparseArrays: AbstractSparseMatrixCSC, nonzeros, rowvals, getcolptr
6- using LinearSolve: BLASELTYPES, pattern_changed
6+ using LinearSolve: BLASELTYPES, pattern_changed, ArrayInterface
77
88# Can't `using KLU` because cannot have a dependency in there without
99# requiring the user does `using KLU`
@@ -100,15 +100,31 @@ function LinearSolve.init_cacheval(
100100 Pl, Pr,
101101 maxiters:: Int , abstol, reltol,
102102 verbose:: Bool , assumptions:: OperatorAssumptions ) where {T<: BLASELTYPES }
103- SparseArrays. UMFPACK. UmfpackLU (SparseMatrixCSC {T, Int64} (zero (Int64), zero (Int64), [Int64 (1 )], Int64[], T[]))
103+ if is_cusparse (A)
104+ ArrayInterface. lu_instance (A)
105+ else
106+ SparseArrays. UMFPACK. UmfpackLU (SparseMatrixCSC {T, Int64} (zero (Int64), zero (Int64), [Int64 (1 )], Int64[], T[]))
107+ end
104108end
105109
106110function LinearSolve. init_cacheval (
107111 alg:: LUFactorization , A:: AbstractSparseArray{T, Int32} , b, u,
108112 Pl, Pr,
109113 maxiters:: Int , abstol, reltol,
110114 verbose:: Bool , assumptions:: OperatorAssumptions ) where {T<: BLASELTYPES }
111- SparseArrays. UMFPACK. UmfpackLU (SparseMatrixCSC {T, Int32} (zero (Int32), zero (Int32), [Int32 (1 )], Int32[], T[]))
115+ if LinearSolve. is_cusparse (A)
116+ ArrayInterface. lu_instance (A)
117+ else
118+ SparseArrays. UMFPACK. UmfpackLU (SparseMatrixCSC {T, Int32} (zero (Int32), zero (Int32), [Int32 (1 )], Int32[], T[]))
119+ end
120+ end
121+
122+ function LinearSolve. init_cacheval (
123+ alg:: LUFactorization , A:: LinearSolve.GPUArraysCore.AnyGPUArray , b, u,
124+ Pl, Pr,
125+ maxiters:: Int , abstol, reltol,
126+ verbose:: Bool , assumptions:: OperatorAssumptions )
127+ ArrayInterface. lu_instance (A)
112128end
113129
114130function LinearSolve. init_cacheval (
@@ -120,6 +136,14 @@ function LinearSolve.init_cacheval(
120136 PREALLOCATED_UMFPACK
121137end
122138
139+ function LinearSolve. init_cacheval (
140+ alg:: UMFPACKFactorization , A:: LinearSolve.GPUArraysCore.AnyGPUArray , b, u,
141+ Pl, Pr,
142+ maxiters:: Int , abstol, reltol,
143+ verbose:: Bool , assumptions:: OperatorAssumptions )
144+ nothing
145+ end
146+
123147function LinearSolve. init_cacheval (
124148 alg:: UMFPACKFactorization , A:: AbstractSparseArray{T, Int64} , b, u,
125149 Pl, Pr,
@@ -191,6 +215,14 @@ function LinearSolve.init_cacheval(
191215 PREALLOCATED_KLU
192216end
193217
218+ function LinearSolve. init_cacheval (
219+ alg:: KLUFactorization , A:: LinearSolve.GPUArraysCore.AnyGPUArray , b, u,
220+ Pl, Pr,
221+ maxiters:: Int , abstol, reltol,
222+ verbose:: Bool , assumptions:: OperatorAssumptions )
223+ nothing
224+ end
225+
194226function LinearSolve. init_cacheval (
195227 alg:: KLUFactorization , A:: AbstractSparseArray{Float64, Int32} , b, u, Pl, Pr,
196228 maxiters:: Int , abstol,
0 commit comments