-
Notifications
You must be signed in to change notification settings - Fork 19
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
Clean up cache #2244
Clean up cache #2244
Conversation
5a050ed
to
86e2517
Compare
I am a little stumped on what to do with the tests that timeout. I cannot reproduce on my laptop and on the cluster, so I am extrapolating some guesses. I possibly narrowed down the problem to an inference issue in the EDMFX precomputed variables. The tests time out because julia cannot even compile the code.
|
86e2517
to
7fbeb9b
Compare
All EDMF cases call the same |
At a closer inspection, all the EDMF cases are affected (with compile and run time slowdowns) |
c92f859
to
f7b4d6a
Compare
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.
Can we break this PR down into smaller, easily merge-able parts? My suggestion of some good peel off PRs would be:
- Remove
comms_ctx
fromp
, and get from the space instead. - Rename
param_set
toparams
(this will be pretty big on its own). Also, I think we use the nameparams
for some other data structure elsewhere, so we'll need to look out for name collisions and decide on how to resolve them. - Remove the
do_dss
bool and compute from the space - Struct-based changes. I might even suggest breaking this PR down into smaller parts.
Most of the commit should work as they are, and there's only a couple of commits that implement more than one change. So, it should be easy to peel off what we want. However, I first want to finalize the larger change (fixing the compilation problems) |
759ff2e
to
2414602
Compare
2259: Clean up: remove underused quantities r=Sbozzolo a=Sbozzolo Peel off #2244. Co-authored-by: Gabriele Bozzola <[email protected]>
2259: Clean up: remove underused quantities r=Sbozzolo a=Sbozzolo Peel off #2244. Co-authored-by: Gabriele Bozzola <[email protected]>
2a3bee7
to
e7fdca9
Compare
e7fdca9
to
747ea7d
Compare
747ea7d
to
58194fd
Compare
Closed in favor of #2287 |
I went ahead and did a large first round of refactoring of the cache. This is what I have done:
scratch
ᶜu
fromp
. It has to bep.precomputed
. I am not super excited about this change and its impact on existing code. I also think that the ideal change would be break down precomputed and make it more modular. However, precomputed is one of the most involved components of the current cache (hyperdiff gets also some conditional quantities depending on EDMF).AtmosModel
except two, now the pattern is something likeprecipitation = precipitation_cache(Y, atmos)
. Dispatch over details of the submodel is used internally (for instanceprecipitation_cache(Y, atmos) = precipitation_cache(Y, atmos, atmos.precip_model)
). The two items that could not fit this pattern are: (1) radiation, depending on the model more arguments are needed, (2) turbconv_model, it currently usesparsed_args
for"imex_edmf_turbconv"
,"imex_edmf_gm"
, and so on (insidedycore_equations_deprecated
, which is why I didn't bother fixing it too much).generate_limiters_func!
that returnslimiters_func!
depending on the model (I did this also to remove the limiter from the cache).AtmosModel
, with a newAtmosNumerics
type.radiation_model
(now everything is inradiation_mode
).Easier steps that can be taken next:
sfc_setup
is used exclusively inupdate_surface_conditions!
inset_precomputed_quantities
.simulation
is pretty much only used forstart_date
for the insolation (+job_id
in the perf/post processing)Difficult step that can be taken next:
precomputed_quantities
is involved, especially with all the EDMF stuff. Theprecomputed
and thehyperdiff
tuples break the idea of ownership because it contains all sorts of variables that logically should belong to other fields. This could be refactored, but it requires thinking about the mechanism for (pre)computing variables.Open questions:
core
containsᶜΦ, ᶠgradᵥ_ᶜΦ, ᶜρ_ref, ᶜp_ref, ᶜT, ᶜf, ∂ᶜK∂ᶠu₃_data
. Iscore
the best name? Should all these variables be here?T_ref
is hardcoded toFT(255)
. Is this correct?ClimaAtmos.jl/src/cache/precomputed_quantities.jl
Lines 315 to 328 in 2da96b1
ClimaAtmos.jl/src/cache/cache.jl
Lines 54 to 61 in 2da96b1
ClimaAtmos.jl/src/cache/temporary_quantities.jl
Lines 61 to 62 in 2da96b1
ClimaAtmos.jl/src/prognostic_equations/advection.jl
Line 26 in 2da96b1
Cleaning up stuff and organizing the cache more neatly while still using
NamedTuples
led to a 5-10 % overall improvement in latency (which compounds the ClimaCore fix for mutable spaces). Moving the cache from aNamedTuple
to a struct ofNamedTuples
bought an additional 5-10 % of improvement in latency. As a result, merging this PR reduces the compile time for jobs in the CI by up to 9 minutes.As an experiment, I turned one of the
NamedTuples
inside the cache into a struct (thecore
one). That led to a percent-level improvement in latency, not enough to stand up the experimental noise, but enough to give another hint that ourNamedTuples
are not the best for compilation.[1] There's some lost julia knowledge about (named) tuples with many elements being slow. We should probably just start avoid large named tuples.
Closes #2217
CC: @charleskawczynski @LenkaNovak @szy21
Todo: