Repository navigation
Conversation
…FunctionWrapper
Under FullSpecialize, each continuous callback's IntervalNonlinearProblem holds its
zero_func_struct in an IntervalNonlinearFunction{false, FullSpecialize}, so the stored
problem type is concrete (a Union of at most four problem types when the continuous
callbacks differ in type). Other specializations, and any case where that type is not
concrete, keep the FunctionWrapper{Float64, Tuple{Float64, NullParameters}}.
The wrapper calls through a function pointer set at run time, which static compilation
(--trim, WasmCodegen) cannot resolve.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #4917.
Under
FullSpecialize, each continuous callback's discontinuity problem (IntervalNonlinearProblem) now holds itszero_func_structin anIntervalNonlinearFunction{false, FullSpecialize}, instead of aFunctionWrapper{Float64, Tuple{Float64, NullParameters}}.Unionof at most four problem types.find_discontinuityreads the zero function back through_disco_zeroin both cases.Why: the wrapper calls through a function pointer that is set at run time (
reinit_wrapper/gen_fptr), which static compilation (--trim, WasmCodegen) can't resolve. The wrapper exists so the bracketing solve compiles once whatever the callback.FullSpecializealready opts in to compiling per function type, so there it can be dropped.Compared with #4917:
Vectorbracket, BracketingNonlinearSolve splats it, which static compilation also rejects; ModAB, ITP: read the bracket without splattingprob.tspanNonlinearSolve.jl#1397 fixes that on the solver side. This PR doesn't depend on it natively.SVector) states isn't included either.Tests
lib/OrdinaryDiffEqCore/test/disco_fullspec_tests.jl. It covers:code_typed(find_discontinuity)under FullSpecialize;Vector{Any}callback set;Union;maybe_discontinuity = false;SVectorandMVectorstates;reinit!.disco_fullspec_tests.jlanddisco_scalar_state_tests.jl;test/Integrators_I/disco_tests.jl, without the RadauIIA5 blocks (FIRK wasn't in my env). I ran it once as is and once with everyODEProblemmadeFullSpecialize.FullSpecializeis within noise (≈ +0.07 s on about 2.8 s), and AutoSpecialize is unchanged.prob.tspanNonlinearSolve.jl#1397: 9 MTK models with continuous and discrete events build, and all 9 match native results in Node. Each module has 2 fewer functions than with Type the zero-function reads in find_discontinuity #4917, because the wrapper call path is gone. Without Let--trim=safeaccept the re-initialization path (workaround for discussion) JuliaLang/FunctionWrappers.jl#38 they build as well, since no wrapper is reachable from the discontinuity path any more.🤖 Generated with Claude Code