Skip to content

Commit

Permalink
Merge pull request #316 from SciML/precompilation
Browse files Browse the repository at this point in the history
Re-enable some precompilation
  • Loading branch information
ChrisRackauckas authored Jun 1, 2023
2 parents 39e538b + 07604b3 commit 6169a76
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ pages = ["index.md",
"Solvers" => Any["solvers/solvers.md"],
"Advanced" => Any["advanced/developing.md"
"advanced/custom.md"],
"Release Notes" => "release_notes.md"
"Release Notes" => "release_notes.md",
]
12 changes: 6 additions & 6 deletions docs/src/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## v2.0

* `LinearCache` changed from immutable to mutable. With this, the out of place interfaces like
`set_A` were deprecated for simply mutating the cache, `cache.A = ...`. This fixes some
correctness checks and makes the package more robust while improving performance.
* The default algorithm is now type-stable and does not rely on a dynamic dispatch for the choice.
* IterativeSolvers.jl and KrylovKit.jl were made into extension packages.
* Documentation of the solvers has changed to docstrings
- `LinearCache` changed from immutable to mutable. With this, the out of place interfaces like
`set_A` were deprecated for simply mutating the cache, `cache.A = ...`. This fixes some
correctness checks and makes the package more robust while improving performance.
- The default algorithm is now type-stable and does not rely on a dynamic dispatch for the choice.
- IterativeSolvers.jl and KrylovKit.jl were made into extension packages.
- Documentation of the solvers has changed to docstrings
25 changes: 23 additions & 2 deletions src/LinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@ include("init.jl")
include("extension_algs.jl")
include("deprecated.jl")

@generated function SciMLBase.solve!(cache::LinearCache, alg::AbstractFactorization;
kwargs...)
quote
if cache.isfresh
fact = do_factorization(alg, cache.A, cache.b, cache.u)
cache.cacheval = fact
cache.isfresh = false
end
y = _ldiv!(cache.u, get_cacheval(cache, $(Meta.quot(defaultalg_symbol(alg)))),
cache.b)

#=
retcode = if LinearAlgebra.issuccess(fact)
SciMLBase.ReturnCode.Success
else
SciMLBase.ReturnCode.Failure
end
SciMLBase.build_linear_solution(alg, y, nothing, cache; retcode = retcode)
=#
SciMLBase.build_linear_solution(alg, y, nothing, cache)
end
end

@static if INCLUDE_SPARSE
include("factorization_sparse.jl")
end
Expand All @@ -82,7 +105,6 @@ isopenblas() = IS_OPENBLAS[]

import PrecompileTools

#=
PrecompileTools.@compile_workload begin
A = rand(4, 4)
b = rand(4)
Expand Down Expand Up @@ -110,7 +132,6 @@ PrecompileTools.@compile_workload begin
sol = solve(prob) # in case sparspak is used as default
sol = solve(prob, SparspakFactorization())
end
=#

export LUFactorization, SVDFactorization, QRFactorization, GenericFactorization,
GenericLUFactorization, SimpleLUFactorization, RFLUFactorization,
Expand Down
23 changes: 0 additions & 23 deletions src/factorization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@ function _ldiv!(x::Vector, A::Factorization, b::Vector)
ldiv!(A, x)
end

@generated function SciMLBase.solve!(cache::LinearCache, alg::AbstractFactorization;
kwargs...)
quote
if cache.isfresh
fact = do_factorization(alg, cache.A, cache.b, cache.u)
cache.cacheval = fact
cache.isfresh = false
end
y = _ldiv!(cache.u, get_cacheval(cache, $(Meta.quot(defaultalg_symbol(alg)))),
cache.b)

#=
retcode = if LinearAlgebra.issuccess(fact)
SciMLBase.ReturnCode.Success
else
SciMLBase.ReturnCode.Failure
end
SciMLBase.build_linear_solution(alg, y, nothing, cache; retcode = retcode)
=#
SciMLBase.build_linear_solution(alg, y, nothing, cache)
end
end

#RF Bad fallback: will fail if `A` is just a stand-in
# This should instead just create the factorization type.
function init_cacheval(alg::AbstractFactorization, A, b, u, Pl, Pr, maxiters::Int, abstol,
Expand Down

0 comments on commit 6169a76

Please sign in to comment.