-
-
Notifications
You must be signed in to change notification settings - Fork 239
RFC: Precompilation Preferences #1727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think what we want is the type choices to be done at the DiffEqBase level, and each of the solver packages then have solver preferences, and the combination then is precompiled in each solver package. DiffEqBase.jl then could define a |
|
For example, currently it precompiles |
|
|
||
| solver_list = [] | ||
| for (solvername, solver) in nonstiff_solver_options | ||
| if Preferences.@load_preference(solvername, "true") == "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit simpler would be
| if Preferences.@load_preference(solvername, "true") == "true" | |
| if Preferences.@load_preference(solvername, true) |
or
| if Preferences.@load_preference(solvername, "true") == "true" | |
| if Preferences.@load_preference(solvername, true) === true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't used or experimented with preferences much, but the README gave me the impression it could only load/save strings, while default could be anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ForwardDiff e.g. uses Bool and Int: https://github.com/JuliaDiff/ForwardDiff.jl/blob/61e4dd486a67cd0bdc6f61e58e452afcea388b7c/src/prelude.jl#L2-L3 I think everything that is supported by TOML might work (e.g., tuples didn't work but arrays did).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, how can one actually set these preferences to try without deving ForwardDiff?
My understanding is that @set_preferences! sets preferences with respect to the module in which it is located, meaning there has to be some function within ForwardDiff that includes @set_preferences!. As there are not, it is impossible to actually set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@set_preferences! uses the current module but users would want to use set_preferences!: https://juliadiff.org/ForwardDiff.jl/dev/user/advanced/#Fixing-NaN/Inf-Issues There the first argument is the module or the UUID of the project for which you want to set preferences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importantly (for the diffeq ecosystem), it also accepts the uuid, thus we can set_preferences! without first loading the module.
| end | ||
| end | ||
| for (solvername, default, solvertype) in stiff_solver_options | ||
| options = split(Preferences.@load_preference(solvername, default), ';') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit simpler here would also be
| options = split(Preferences.@load_preference(solvername, default), ';') | |
| options = Preferences.@load_preference(solvername, default) |
and use defaults of e.g. [true, false, false, true].
| Preferences.@load_preference("Float64", "true") == "true" && push!(eltypes, Float64) | ||
| Preferences.@load_preference("Float32", "false") == "true" && push!(eltypes, Float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Preferences.@load_preference("Float64", "true") == "true" && push!(eltypes, Float64) | |
| Preferences.@load_preference("Float32", "false") == "true" && push!(eltypes, Float64) | |
| Preferences.@load_preference("Float64", true) === true && push!(eltypes, Float64) | |
| Preferences.@load_preference("Float32", false) === true && push!(eltypes, Float64) |
|
I'm not a fan of That said, if we go with That is because |
This PR offers a bad API that we probably don't want to commit to.
I still need to test whether this actually works, e.g. if turning all of them off reduces precompile time.
Maybe much of the work here should be done outside of the
SnoopPrecompile.@precompile_all_callsblock?