Skip to content

Commit 9229567

Browse files
Re-enable some precompilation
Fix precompilation, requires the `@generated` function move until after the defaults are all defined. A bit ehh, but it works.
1 parent 39e538b commit 9229567

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

src/LinearSolve.jl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,29 @@ include("init.jl")
6666
include("extension_algs.jl")
6767
include("deprecated.jl")
6868

69+
@generated function SciMLBase.solve!(cache::LinearCache, alg::AbstractFactorization;
70+
kwargs...)
71+
quote
72+
if cache.isfresh
73+
fact = do_factorization(alg, cache.A, cache.b, cache.u)
74+
cache.cacheval = fact
75+
cache.isfresh = false
76+
end
77+
y = _ldiv!(cache.u, get_cacheval(cache, $(Meta.quot(defaultalg_symbol(alg)))),
78+
cache.b)
79+
80+
#=
81+
retcode = if LinearAlgebra.issuccess(fact)
82+
SciMLBase.ReturnCode.Success
83+
else
84+
SciMLBase.ReturnCode.Failure
85+
end
86+
SciMLBase.build_linear_solution(alg, y, nothing, cache; retcode = retcode)
87+
=#
88+
SciMLBase.build_linear_solution(alg, y, nothing, cache)
89+
end
90+
end
91+
6992
@static if INCLUDE_SPARSE
7093
include("factorization_sparse.jl")
7194
end
@@ -82,7 +105,6 @@ isopenblas() = IS_OPENBLAS[]
82105

83106
import PrecompileTools
84107

85-
#=
86108
PrecompileTools.@compile_workload begin
87109
A = rand(4, 4)
88110
b = rand(4)
@@ -110,7 +132,6 @@ PrecompileTools.@compile_workload begin
110132
sol = solve(prob) # in case sparspak is used as default
111133
sol = solve(prob, SparspakFactorization())
112134
end
113-
=#
114135

115136
export LUFactorization, SVDFactorization, QRFactorization, GenericFactorization,
116137
GenericLUFactorization, SimpleLUFactorization, RFLUFactorization,

src/factorization.jl

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,6 @@ function _ldiv!(x::Vector, A::Factorization, b::Vector)
66
ldiv!(A, x)
77
end
88

9-
@generated function SciMLBase.solve!(cache::LinearCache, alg::AbstractFactorization;
10-
kwargs...)
11-
quote
12-
if cache.isfresh
13-
fact = do_factorization(alg, cache.A, cache.b, cache.u)
14-
cache.cacheval = fact
15-
cache.isfresh = false
16-
end
17-
y = _ldiv!(cache.u, get_cacheval(cache, $(Meta.quot(defaultalg_symbol(alg)))),
18-
cache.b)
19-
20-
#=
21-
retcode = if LinearAlgebra.issuccess(fact)
22-
SciMLBase.ReturnCode.Success
23-
else
24-
SciMLBase.ReturnCode.Failure
25-
end
26-
SciMLBase.build_linear_solution(alg, y, nothing, cache; retcode = retcode)
27-
=#
28-
SciMLBase.build_linear_solution(alg, y, nothing, cache)
29-
end
30-
end
31-
329
#RF Bad fallback: will fail if `A` is just a stand-in
3310
# This should instead just create the factorization type.
3411
function init_cacheval(alg::AbstractFactorization, A, b, u, Pl, Pr, maxiters::Int, abstol,

0 commit comments

Comments
 (0)