From 908605158423b1b4939b32dee351ef6e0a68c35f Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 11 Feb 2024 15:26:11 -0500 Subject: [PATCH 1/2] Avoid constructing any Krylov cache with default dense --- Project.toml | 2 +- src/default.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 9b79023e2..8efa1c37d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LinearSolve" uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" authors = ["SciML"] -version = "2.23.0" +version = "2.23.1" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/default.jl b/src/default.jl index 31c24a020..48e8a9b1f 100644 --- a/src/default.jl +++ b/src/default.jl @@ -121,7 +121,7 @@ function defaultalg(A::Nothing, b::GPUArraysCore.AnyGPUArray, assump::OperatorAs end # Ambiguity handling -function defaultalg(A::GPUArraysCore.AnyGPUArray, b::GPUArraysCore.AbstractGPUArray, +function defaultalg(A::GPUArraysCore.AnyGPUArray, b::GPUArraysCore.AnyGPUArray, assump::OperatorAssumptions{Bool}) if assump.condition === OperatorCondition.IllConditioned || !assump.issq DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization) @@ -152,7 +152,7 @@ function defaultalg(A, b, assump::OperatorAssumptions{Bool}) # Special case on Arrays: avoid BLAS for RecursiveFactorization.jl when # it makes sense according to the benchmarks, which is dependent on # whether MKL or OpenBLAS is being used - if (A === nothing && !(b isa GPUArraysCore.AbstractGPUArray)) || A isa Matrix + if (A === nothing && !(b isa GPUArraysCore.AnyGPUArray)) || A isa Matrix if (A === nothing || eltype(A) <: BLASELTYPES) && ArrayInterface.can_setindex(b) && @@ -296,7 +296,7 @@ cache.cacheval = NamedTuple(LUFactorization = cache of LUFactorization, ...) abstol, reltol, verbose::Bool, assump::OperatorAssumptions) caches = map(first.(EnumX.symbol_map(DefaultAlgorithmChoice.T))) do alg - if alg === :KrylovJL_GMRES + if alg === :KrylovJL_GMRES || alg === :KrylovJL_CRAIGMR || alg === :KrylovJL_LSMR quote if A isa Matrix || A isa SparseMatrixCSC nothing From 91fe4d42e807aecd62c149f4f87cfd96bb215a93 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 11 Feb 2024 15:30:14 -0500 Subject: [PATCH 2/2] fix spell check --- test/default_algs.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/default_algs.jl b/test/default_algs.jl index 5aad1a30c..2dedc13a5 100644 --- a/test/default_algs.jl +++ b/test/default_algs.jl @@ -77,8 +77,8 @@ b = rand(m) x = rand(n) f = (du, u, p, t) -> mul!(du, A, u) fadj = (du, u, p, t) -> mul!(du, A', u) -fo = FunctionOperator(f, x, b; op_adjoint = fadj) -prob = LinearProblem(fo, b) +funcop = FunctionOperator(f, x, b; op_adjoint = fadj) +prob = LinearProblem(funcop, b) sol1 = solve(prob) sol2 = solve(prob, LinearSolve.KrylovJL_GMRES()) @test sol1.u == sol2.u @@ -89,8 +89,8 @@ b = rand(m) x = rand(n) f = (du, u, p, t) -> mul!(du, A, u) fadj = (du, u, p, t) -> mul!(du, A', u) -fo = FunctionOperator(f, x, b; op_adjoint = fadj) -prob = LinearProblem(fo, b) +funcop = FunctionOperator(f, x, b; op_adjoint = fadj) +prob = LinearProblem(funcop, b) sol1 = solve(prob) sol2 = solve(prob, LinearSolve.KrylovJL_LSMR()) @test sol1.u == sol2.u @@ -101,8 +101,8 @@ b = rand(m) x = rand(n) f = (du, u, p, t) -> mul!(du, A, u) fadj = (du, u, p, t) -> mul!(du, A', u) -fo = FunctionOperator(f, x, b; op_adjoint = fadj) -prob = LinearProblem(fo, b) +funcop = FunctionOperator(f, x, b; op_adjoint = fadj) +prob = LinearProblem(funcop, b) sol1 = solve(prob) sol2 = solve(prob, LinearSolve.KrylovJL_CRAIGMR()) @test sol1.u == sol2.u