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

Break up parameters struct in CloudMicrophysics.jl 0, 1, 2 - moment microphysics schems #160

Closed
Tracked by #1980
charleskawczynski opened this issue Aug 15, 2023 · 7 comments · Fixed by #211
Closed
Tracked by #1980
Assignees
Labels
enhancement New feature or request GPU

Comments

@charleskawczynski
Copy link
Member

charleskawczynski commented Aug 15, 2023

The parameters (

Base.@kwdef struct CloudMicrophysicsParameters{FT, TP} <:
) is a huge struct, and it looks like (at first glance) that it could be broken into smaller parts (like how surface fluxes handles parameters).

Tasks

No tasks being tracked yet.
@trontrytel
Copy link
Member

Hi @charleskawczynski - Thank you for taking a look. I don't think I full understand what you are suggesting. If I end up defining a couple of different structs would I end up having to pass different parameter structs inside CM.jl functions?

Right now all the functions look like foo(param_set::AbstractCloudMicrophysicsParameters, ...)

Would it turn into foo(aerosol_param_set::AbstarctAerosolMicrophysicsParameters, ...) bar(micro_param_set::AbstractMicrophysicsParameters, ...)

If yes, I think it would create too much friction with creating those different parametr sets and passing them in different fucntions. I would rather have everything in one place

@charleskawczynski
Copy link
Member Author

I suspect that we can use composition— are there subsets of parameters that cannot be used together? If so, then those incompatibilities outline the exchangeable parts.

I think we do this in surface fluxes.

@trontrytel
Copy link
Member

What is the benefit of splitting it up?

@trontrytel trontrytel added enhancement New feature or request GPU labels Aug 16, 2023
@trontrytel trontrytel added this to the GPU support milestone Aug 16, 2023
@trontrytel trontrytel changed the title Break up parameters Break up parameters struct in CloudMicrophysics.jl Aug 21, 2023
@trontrytel
Copy link
Member

First example thanks to @sriharshakandala: #201

@charleskawczynski
Copy link
Member Author

What is the benefit of splitting it up?

I think there’s two benefits, one is modularization, and the other is performance. Very large structs, as I understand it, are a performance issue. I think the reasoning is that the struct may not fit into registers, resulting in register spilling (hurting performance). We can benchmark to confirm, but it’s also probably just not a pattern that we want to use (or spread).

@trontrytel
Copy link
Member

Agreed. It was making things easy while developing CloudMicrophysics. Because you just had to pass in one struct everywhere and not think which parameter lives in which struct. But I agree that with 100+ parameters and on the way to add more thats just not sustainable

@sriharshakandala sriharshakandala linked a pull request Sep 27, 2023 that will close this issue
1 task
@trontrytel trontrytel changed the title Break up parameters struct in CloudMicrophysics.jl Break up parameters struct in CloudMicrophysics.jl 0, 1, 2 - moment microphysics schems Oct 2, 2023
@trontrytel
Copy link
Member

This is done. I'll open a new issue to track the parameter struct updates in the remaining modules of the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GPU
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants