Add buffer variables for the Biogeochemical Particles#323
Add buffer variables for the Biogeochemical Particles#323Mikolaj-A-Kowalski wants to merge 5 commits intomainfrom
Conversation
|
In terms of performance of the total time executing the 'update' kernels (both tracer and field tendencies) for Looking in Nsight sytems this is the old:
Basically the majority of the time is now concentrated in the I guess this is just related to the load imbalance in the Newton iteration. The good news is that it probably can be significantly optimised delivering even more gain. The only cost of the change is extra memory (single double) per particle that needs to be stored on the GPU. I imagine though that the memory cost of the particles is much smaller than tracers in practice so it is not too heavy price to pay. I attach the original NSight reports: reports.tar.gz The benchmark script: LOBSTER_3D_profile_particles.jl.txt |
680d1b4 to
d723177
Compare
|
Added test and rebased on |
| #:NO₃, :NH₄, :DIC, :O₂, :DOC, :DON, :bPOC, :bPON | ||
|
|
||
| @inline function (kelp::SugarKelp)(::Val{:NO₃}, t, A, N, C, u, v, w, T, NO₃, NH₄, PAR) | ||
| @inline function (kelp::SugarKelp)(::Val{:NO₃}, t, A, N, C, u, v, w, T, NO₃, NH₄, PAR, P) |
There was a problem hiding this comment.
| @inline function (kelp::SugarKelp)(::Val{:NO₃}, t, A, N, C, u, v, w, T, NO₃, NH₄, PAR, P) | |
| @inline function (kelp::SugarKelp)(::Val{:NO₃}, t, A, N, C, u, v, w, T, NO₃, NH₄, PAR, photosynthesis) |
I in this context its a bit confusing to use P since P almost always refers to phytoplankton
There was a problem hiding this comment.
🫡 I have used P since it is variable name to which the name was assigned, but will change to photosynthesis_val (I want to avoid it making the function from the module scope)
There was a problem hiding this comment.
Done in the recent rebase.
|
This seems like a great idea, thank you for implementing this!
I think its fine to have the same for both since thats what we do with all the other variables.
I think this is fine too since a model could also define a new method like: @inline fill_all_buffer_variables!(particles::BiogeochemicalParticles{N, <:SomeParticleBGC}, model) where N |
Buffer allows to precompute some quantities before tracers update step.
66dc43e to
8800462
Compare
8800462 to
3bb1f6f
Compare
Fair! Ultimately if it becomes relevant for some future model it should not be too difficult to change.
Good point! I haven't though of that overload. |


Resolves #321
Basically it allows a biogeochemical model in the particles to declare buffer for some heavy-to-compute (i.e.
photosynthesisfunction result) variables so they can be reused across multiple kernels that update tendencies for the tracers and particle fields.In contrast to what I said in #321, the buffers need to be filled twice since particle move between tracer and fields tendencies are updated.
It is still a draft so we can discuss alternative/better way to introduce buffers. In particular the following points:
buffer_variableregistration and filling for these steps?Particleand just delegates to a function provided by a specificModel/Individual. But I was wondering if the kernel should not be defined by a specific model so it can be optimised/tailored more to calculation of the specific buffer variable...The performance change will follow in the post shortly.
TODO: