Skip to content

Commit 8e5e41e

Browse files
committed
Preallocate more caches
1 parent e37a60a commit 8e5e41e

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.2"
4+
version = "2.23.3"
55

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

src/default.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ function defaultalg(A, b, assump::OperatorAssumptions{Bool})
159159
(__conditioning(assump) === OperatorCondition.IllConditioned ||
160160
__conditioning(assump) === OperatorCondition.WellConditioned)
161161
if length(b) <= 10
162-
DefaultAlgorithmChoice.GenericLUFactorization
162+
# DefaultAlgorithmChoice.GenericLUFactorization
163+
DefaultAlgorithmChoice.RFLUFactorization
163164
elseif appleaccelerate_isavailable()
164165
DefaultAlgorithmChoice.AppleAccelerateLUFactorization
165166
elseif (length(b) <= 100 || (isopenblas() && length(b) <= 500) ||

src/factorization.jl

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,24 @@ function init_cacheval(alg::QRFactorization, A, b, u, Pl, Pr,
173173
ArrayInterface.qr_instance(convert(AbstractMatrix, A), alg.pivot)
174174
end
175175

176+
const PREALLOCATED_QR_ColumnNorm = ArrayInterface.qr_instance(rand(1, 1), ColumnNorm())
177+
178+
function init_cacheval(alg::QRFactorization{ColumnNorm}, A::Matrix{Float64}, b, u, Pl, Pr,
179+
maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
180+
return PREALLOCATED_QR_ColumnNorm
181+
end
182+
176183
function init_cacheval(alg::QRFactorization, A::Union{<:Adjoint, <:Transpose}, b, u, Pl, Pr,
177184
maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
178185
A isa GPUArraysCore.AnyGPUArray && return qr(A)
179186
return qr(A, alg.pivot)
180187
end
181188

182-
const PREALLOCATED_QR = ArrayInterface.qr_instance(rand(1, 1))
189+
const PREALLOCATED_QR_NoPivot = ArrayInterface.qr_instance(rand(1, 1))
183190

184191
function init_cacheval(alg::QRFactorization{NoPivot}, A::Matrix{Float64}, b, u, Pl, Pr,
185-
maxiters::Int, abstol, reltol, verbose::Bool,
186-
assumptions::OperatorAssumptions)
187-
PREALLOCATED_QR
192+
maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
193+
return PREALLOCATED_QR_NoPivot
188194
end
189195

190196
function init_cacheval(alg::QRFactorization, A::AbstractSciMLOperator, b, u, Pl, Pr,
@@ -1010,7 +1016,16 @@ function init_cacheval(alg::NormalCholeskyFactorization, A, b, u, Pl, Pr,
10101016
maxiters::Int, abstol, reltol, verbose::Bool,
10111017
assumptions::OperatorAssumptions)
10121018
A_ = convert(AbstractMatrix, A)
1013-
return ArrayInterface.cholesky_instance(Symmetric(Matrix{eltype(A)}(undef,0,0)), alg.pivot)
1019+
MType = ArrayInterface.parameterless_type(A_)
1020+
return ArrayInterface.cholesky_instance(Symmetric(MType{eltype(A), 2}(undef,0,0)), alg.pivot)
1021+
end
1022+
1023+
const PREALLOCATED_NORMALCHOLESKY = ArrayInterface.cholesky_instance(
1024+
Symmetric(rand(1, 1)), NoPivot())
1025+
1026+
function init_cacheval(alg::NormalCholeskyFactorization, A::Matrix, b, u, Pl, Pr,
1027+
maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
1028+
return PREALLOCATED_NORMALCHOLESKY
10141029
end
10151030

10161031
function init_cacheval(alg::NormalCholeskyFactorization,

0 commit comments

Comments
 (0)