Skip to content

Commit 0f7c438

Browse files
only use LU for CUDA when v1.8+
SciML/PreallocationTools.jl#30 (comment)
1 parent 2b99da3 commit 0f7c438

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/default.jl

+19-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ function defaultalg(A, b)
4747
# This catches the case where A is a CuMatrix
4848
# Which does not have LU fully defined
4949
elseif A isa GPUArraysCore.AbstractGPUArray || b isa GPUArraysCore.AbstractGPUArray
50-
alg = LUFactorization()
50+
if VERSION >= v"1.8-"
51+
alg = LUFactorization()
52+
else
53+
alg = QRFactorization()
54+
end
5155

5256
# Not factorizable operator, default to only using A*x
5357
else
@@ -118,9 +122,13 @@ function SciMLBase.solve(cache::LinearCache, alg::Nothing,
118122
# This catches the case where A is a CuMatrix
119123
# Which does not have LU fully defined
120124
elseif A isa GPUArraysCore.AbstractGPUArray
121-
alg = LUFactorization()
122-
SciMLBase.solve(cache, alg, args...; kwargs...)
123-
125+
if VERSION >= v"1.8-"
126+
alg = LUFactorization()
127+
SciMLBase.solve(cache, alg, args...; kwargs...)
128+
else
129+
alg = QRFactorization()
130+
SciMLBase.solve(cache, alg, args...; kwargs...)
131+
end
124132
# Not factorizable operator, default to only using A*x
125133
# IterativeSolvers is faster on CPU but not GPU-compatible
126134
else
@@ -185,9 +193,13 @@ function init_cacheval(alg::Nothing, A, b, u, Pl, Pr, maxiters, abstol, reltol,
185193
# This catches the case where A is a CuMatrix
186194
# Which does not have LU fully defined
187195
elseif A isa GPUArraysCore.AbstractGPUArray
188-
alg = LUFactorization()
189-
init_cacheval(alg, A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
190-
196+
if VERSION >= v"1.8-"
197+
alg = LUFactorization()
198+
init_cacheval(alg, A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
199+
else
200+
alg = QRFactorization()
201+
init_cacheval(alg, A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
202+
end
191203
# Not factorizable operator, default to only using A*x
192204
# IterativeSolvers is faster on CPU but not GPU-compatible
193205
else

0 commit comments

Comments
 (0)