Skip to content

Commit

Permalink
Try recompiling invalidations
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 25, 2023
1 parent 786e8d3 commit 93f87cf
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions src/NonlinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ if isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@max_m
@eval Base.Experimental.@max_methods 1
end

using DiffEqBase, LinearAlgebra, LinearSolve, SparseArrays, SparseDiffTools
import ArrayInterface: restructure
import ForwardDiff

import ADTypes: AbstractFiniteDifferencesMode
import ArrayInterface: undefmatrix, matrix_colors, parameterless_type, ismutable, issingular
import ConcreteStructs: @concrete
import EnumX: @enumx
import ForwardDiff: Dual
import LinearSolve: ComposePreconditioner, InvPreconditioner, needs_concrete_A
import RecursiveArrayTools: ArrayPartition,
AbstractVectorOfArray, recursivecopy!, recursivefill!
import Reexport: @reexport
import SciMLBase: AbstractNonlinearAlgorithm, NLStats, _unwrap_val, has_jac, isinplace
import StaticArraysCore: StaticArray, SVector, SArray, MArray
import UnPack: @unpack
import PrecompileTools

PrecompileTools.@recompile_invalidations begin
using DiffEqBase, LinearAlgebra, LinearSolve, SparseArrays, SparseDiffTools
import ArrayInterface: restructure

import ADTypes: AbstractFiniteDifferencesMode
import ArrayInterface: undefmatrix, matrix_colors, parameterless_type, ismutable, issingular
import ConcreteStructs: @concrete
import EnumX: @enumx
import ForwardDiff
import ForwardDiff: Dual
import LinearSolve: ComposePreconditioner, InvPreconditioner, needs_concrete_A
import RecursiveArrayTools: ArrayPartition,
AbstractVectorOfArray, recursivecopy!, recursivefill!
import SciMLBase: AbstractNonlinearAlgorithm, NLStats, _unwrap_val, has_jac, isinplace
import StaticArraysCore: StaticArray, SVector, SArray, MArray
import UnPack: @unpack

using ADTypes, LineSearches, SciMLBase, SimpleNonlinearSolve
end

@reexport using ADTypes, LineSearches, SciMLBase, SimpleNonlinearSolve

Expand Down Expand Up @@ -81,25 +87,20 @@ include("jacobian.jl")
include("ad.jl")
include("default.jl")

import PrecompileTools

@static if VERSION v"1.10-"
PrecompileTools.@compile_workload begin
for T in (Float32, Float64)
prob = NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2))

precompile_algs = (NewtonRaphson(), TrustRegion(), LevenbergMarquardt(),
PseudoTransient(), GeneralBroyden(), GeneralKlement(), nothing)
PrecompileTools.@compile_workload begin
for T in (Float32, Float64)
probs = (
NonlinearProblem{false}((u, p) -> u .* u .- p, T(0.1), T(2)),
NonlinearProblem{false}((u, p) -> u .* u .- p, T[0.1], T[2]),
NonlinearProblem{true}((du, u, p) -> du .= u .* u .- p, T[0.1], T[2])
)

for alg in precompile_algs
solve(prob, alg, abstol = T(1e-2))
end
precompile_algs = (NewtonRaphson(), TrustRegion(), LevenbergMarquardt(),
PseudoTransient(), GeneralBroyden(), GeneralKlement(), nothing)

prob = NonlinearProblem{true}((du, u, p) -> du[1] = u[1] * u[1] - p[1], T[0.1],
T[2])
for alg in precompile_algs
solve(prob, alg, abstol = T(1e-2))
end
for prob in probs, alg in precompile_algs
solve(prob, alg, abstol = T(1e-2))
end
end
end
Expand Down

0 comments on commit 93f87cf

Please sign in to comment.