-
Notifications
You must be signed in to change notification settings - Fork 24
Description
By looking at the profiling results for the runs of LOBSTER model with large number of SugarKelp particles (range of photosynthesis function which involves expensive Newton iteration.
Furthermore, it appears that the heavy photosynthesis calculation is performed 6 times (in _update_traced_tendencies! kernel for :DIC, :O_2, :DOC and :DON tracers and in _tendency_kernel! for :N and :C). As far as I am able to tell the inputs come from current state of the fields and hence do not change between invocations of the _update_traced_tendencies! and _tendency_kernel! for different tracers. Hence, it appears that the same calculation is performed multiple times. This is the impression I got from looking at the code, but need o verify that this is indeed a case by logging values from the run.
If the above is correct, it would be beneficial to refactor 'Individual' models to give them ability to share some result across multiple kernels. I imagine we could allow them to declare some buffer space for each particle, which will be filled by new type of kernel run before _update_traced_tendencies! and _tendency_kernel!. Then when updating tendencies the photosynthesis result could just be read from memory 🤞