Skip to content

default_controller type-unstable for most algorithms #2855

@topolarity

Description

@topolarity

--trim is almost compatible with ImplicitEuler, except for this:

since this is ::Symbol, the compiler does not know which branch of default_controller(::ImplicitEuler) we'll take and we end up with Union{PIController{...}, IController{...}, PredictiveController{...}}, which is moderately type-unstable (and rapidly worsens once put into a type parameter)

If I override this behavior manually:

@eval OrdinaryDiffEqSDIRK OrdinaryDiffEqCore.ispredictive(alg::OrdinaryDiffEqNewtonAdaptiveAlgorithm) = false
@eval OrdinaryDiffEqSDIRK OrdinaryDiffEqCore.isstandard(alg::OrdinaryDiffEqNewtonAdaptiveAlgorithm) = false

Then the solver trims OK:

function @main(ARGS)
    prob = ODEProblem(ODEFunction{true, SciMLBase.FullSpecialize}(lorenz), u0, tspan)
    solver = ImplicitEuler(autodiff=AutoForwardDiff(; chunksize=1))
    sol = solve(prob, solver)
    println(Core.stdout, sol.t[end])
    println(Core.stdout, sum(sol.u[end]))
end
$ julia --project=../NonlinearSolve.jl/test/trim ./contrib/juliac/juliac.jl --trim=safe --experimental --output-exe trimmed_solve ../NonlinearSolve.jl/test/trim/main_once_per_process.jl
$ ./trimmed_solve 0.5
100.0
10.029437251508632

so this is the last issue blocking ImplicitEuler from being --trim compatible

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions