Skip to content

Commit 31784ff

Browse files
Merge pull request #468 from SciML/krylov
Avoid constructing any Krylov cache with default dense
2 parents fa5278e + 91fe4d4 commit 31784ff

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LinearSolve"
22
uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
33
authors = ["SciML"]
4-
version = "2.23.0"
4+
version = "2.23.1"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/default.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function defaultalg(A::Nothing, b::GPUArraysCore.AnyGPUArray, assump::OperatorAs
121121
end
122122

123123
# Ambiguity handling
124-
function defaultalg(A::GPUArraysCore.AnyGPUArray, b::GPUArraysCore.AbstractGPUArray,
124+
function defaultalg(A::GPUArraysCore.AnyGPUArray, b::GPUArraysCore.AnyGPUArray,
125125
assump::OperatorAssumptions{Bool})
126126
if assump.condition === OperatorCondition.IllConditioned || !assump.issq
127127
DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
@@ -152,7 +152,7 @@ function defaultalg(A, b, assump::OperatorAssumptions{Bool})
152152
# Special case on Arrays: avoid BLAS for RecursiveFactorization.jl when
153153
# it makes sense according to the benchmarks, which is dependent on
154154
# whether MKL or OpenBLAS is being used
155-
if (A === nothing && !(b isa GPUArraysCore.AbstractGPUArray)) || A isa Matrix
155+
if (A === nothing && !(b isa GPUArraysCore.AnyGPUArray)) || A isa Matrix
156156
if (A === nothing ||
157157
eltype(A) <: BLASELTYPES) &&
158158
ArrayInterface.can_setindex(b) &&
@@ -296,7 +296,7 @@ cache.cacheval = NamedTuple(LUFactorization = cache of LUFactorization, ...)
296296
abstol, reltol,
297297
verbose::Bool, assump::OperatorAssumptions)
298298
caches = map(first.(EnumX.symbol_map(DefaultAlgorithmChoice.T))) do alg
299-
if alg === :KrylovJL_GMRES
299+
if alg === :KrylovJL_GMRES || alg === :KrylovJL_CRAIGMR || alg === :KrylovJL_LSMR
300300
quote
301301
if A isa Matrix || A isa SparseMatrixCSC
302302
nothing

test/default_algs.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ b = rand(m)
7777
x = rand(n)
7878
f = (du, u, p, t) -> mul!(du, A, u)
7979
fadj = (du, u, p, t) -> mul!(du, A', u)
80-
fo = FunctionOperator(f, x, b; op_adjoint = fadj)
81-
prob = LinearProblem(fo, b)
80+
funcop = FunctionOperator(f, x, b; op_adjoint = fadj)
81+
prob = LinearProblem(funcop, b)
8282
sol1 = solve(prob)
8383
sol2 = solve(prob, LinearSolve.KrylovJL_GMRES())
8484
@test sol1.u == sol2.u
@@ -89,8 +89,8 @@ b = rand(m)
8989
x = rand(n)
9090
f = (du, u, p, t) -> mul!(du, A, u)
9191
fadj = (du, u, p, t) -> mul!(du, A', u)
92-
fo = FunctionOperator(f, x, b; op_adjoint = fadj)
93-
prob = LinearProblem(fo, b)
92+
funcop = FunctionOperator(f, x, b; op_adjoint = fadj)
93+
prob = LinearProblem(funcop, b)
9494
sol1 = solve(prob)
9595
sol2 = solve(prob, LinearSolve.KrylovJL_LSMR())
9696
@test sol1.u == sol2.u
@@ -101,8 +101,8 @@ b = rand(m)
101101
x = rand(n)
102102
f = (du, u, p, t) -> mul!(du, A, u)
103103
fadj = (du, u, p, t) -> mul!(du, A', u)
104-
fo = FunctionOperator(f, x, b; op_adjoint = fadj)
105-
prob = LinearProblem(fo, b)
104+
funcop = FunctionOperator(f, x, b; op_adjoint = fadj)
105+
prob = LinearProblem(funcop, b)
106106
sol1 = solve(prob)
107107
sol2 = solve(prob, LinearSolve.KrylovJL_CRAIGMR())
108108
@test sol1.u == sol2.u

0 commit comments

Comments
 (0)