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

Refactor surface #2809

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Refactor surface #2809

merged 1 commit into from
Mar 19, 2024

Conversation

charleskawczynski
Copy link
Member

@charleskawczynski charleskawczynski commented Mar 19, 2024

This PR refactors the surface surface_state_to_conditions by:

  • Making surface_state_to_conditions take the wrapped surface setup, and a local surface_state is then made inside.
  • Made sfc_prognostic_temp a non-optional argument and removed the splatting (sometimes this is difficult for the compiler to infer).

There's several benefits to the first bullet:

  • Expressions directly inside broadcast expressions are treated differently than if they were called inside, and sometimes this will result in allocations / runtime calls (Creating types inside broadcast expressions can lead to allocations ClimaCore.jl#1649).
  • The compiler may be able to better optimize this because it is explicitly clear that surface_state's can be locally defined, and a full field of surface_state's is not necessary.
  • We also explicitly pass the local geometry and interior z fewer times to the function

According to my local tests, this PR allows us to use always_inline for this kernel.

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.

Thanks!

src/surface_conditions/surface_conditions.jl Show resolved Hide resolved
@charleskawczynski
Copy link
Member Author

Nice, this also appears to fix 7 JET failures in update_surface_conditions! for the GPU job.

The additional allocations very well could just be from JuliaGPU/Adapt.jl#79. So, I'm going to bump the allocation limit and merge.

@charleskawczynski charleskawczynski added this pull request to the merge queue Mar 19, 2024
Merged via the queue into main with commit b47d970 Mar 19, 2024
11 checks passed
@charleskawczynski charleskawczynski deleted the ck/refactor_surface branch March 19, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants