Skip to content
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

Improve buoyancy_gradients design #2367

Merged
merged 1 commit into from
Jan 18, 2024
Merged

Conversation

charleskawczynski
Copy link
Member

This PR does two things:

  • Renames EnvBuoyGrad to EnvBuoyGradVars and defines EnvBuoyGrad as a singleton for dispatching. This is a bit simpler of a pattern being that, in the existing design, EnvBuoyGrad contains all of the variables for all AbstractEnvBuoyGradClosure specializations. This does mean that we need to pass an extra variable around, but that one is solely used for dispatch. Being that we currently have only one concrete subtype of AbstractEnvBuoyGradClosure, we could just do away with the extra parameter and duplicate structs, but I thought that adding the additional parameter wasn't too painful so that we can easily extend / dispatch.
  • Modifies the outer constructor of EnvBuoyGradVars to take a thermo state. This should hopefully improve the memory loads, since the thermo function calls can all occur in registers after the thermo state is loaded. Alternatively, we could make EnvBuoyGradVars simply hold the thermo state ( or just bypass that altogether ), but then those thermo call would need to be sprinkled in buoyancy_gradients and buoyancy_gradient_chain_rule, and it's not clear to me that that is worth the additional compute, not to mention it may just make the code look a bit more complicated.

@charleskawczynski
Copy link
Member Author

Perhaps this will help with CliMA/Thermodynamics.jl#157?

@charleskawczynski charleskawczynski force-pushed the ck/buoy_grad_kernel branch 7 times, most recently from 394f6b0 to e9ea81a Compare January 16, 2024 20:25
Copy link
Member

@szy21 szy21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change looks good to me, thanks!

@charleskawczynski charleskawczynski added this pull request to the merge queue Jan 18, 2024
Merged via the queue into main with commit 315b80a Jan 18, 2024
9 of 10 checks passed
@charleskawczynski charleskawczynski deleted the ck/buoy_grad_kernel branch January 18, 2024 17:32
@charleskawczynski
Copy link
Member Author

Should help with #2530.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants