Remove vertical chunking from aux vars and tendency terms - #473
Conversation
ae5ec57 to
5375e80
Compare
BenchmarksSingle node runs using the baroclinic channel CPU runs
GPU runs
In addition to these benchmarks, on aurora CPU I measured the fraction of vectorized instructions using the
SummaryExcept for aurora GPU, everything is faster without vertical chunking. |
8f6b9d3 to
031a705
Compare
TestingCTest unit tests
Polaris
|
There was a problem hiding this comment.
Pull request overview
This PR removes vertical chunking from Omega ocean auxiliary-variable and
tendency-term computations, switching operators to team-parallel (outer) +
layer-range (inner) patterns that better align with active-layer bounds.
Changes:
- Refactor ocean tendency-term operators to accept
TeamMemberand iterate over
active-layerRange{KMin, KMax}instead of chunk indices. - Refactor auxiliary-variable computations (vorticity, del2, tracer, pseudo
thickness, kinetic aux) to the same non-chunked, active-layer approach. - Update unit tests and add
subviewUnmanagedto reduce overhead in hot paths.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| components/omega/test/ocn/TendencyTermsTest.cpp | Updates test kernels to call the new team-based tendency operators. |
| components/omega/test/ocn/AuxiliaryVarsTest.cpp | Updates test kernels to call the new team-based auxiliary-variable operators. |
| components/omega/src/ocn/TendencyTerms.h | Removes chunked operators and rewrites tendency terms using active-layer ranges and team scratch. |
| components/omega/src/ocn/TendencyTerms.cpp | Wires new members (e.g., NVertLayers, min/max layer arrays) into tendency-term constructors. |
| components/omega/src/ocn/Tendencies.cpp | Updates tendency assembly to launch non-chunked team kernels (often with per-team scratch). |
| components/omega/src/ocn/auxiliaryVars/VorticityAuxVars.h | Refactors vorticity aux computations to team + active-layer ranges. |
| components/omega/src/ocn/auxiliaryVars/VorticityAuxVars.cpp | Adds NVertLayers initialization needed for scratch-sized temporaries. |
| components/omega/src/ocn/auxiliaryVars/VelocityDel2AuxVars.h | Refactors velocity del2 aux computations to team + active-layer ranges with scratch. |
| components/omega/src/ocn/auxiliaryVars/VelocityDel2AuxVars.cpp | Adds NVertLayers initialization for scratch allocation sizing. |
| components/omega/src/ocn/auxiliaryVars/TracerAuxVars.h | Refactors tracer aux computations to team + active-layer ranges with scratch and unmanaged subviews. |
| components/omega/src/ocn/auxiliaryVars/TracerAuxVars.cpp | Adds NVertLayers initialization needed by refactored tracer aux kernels. |
| components/omega/src/ocn/auxiliaryVars/PseudoThicknessAuxVars.h | Refactors pseudo-thickness aux computations to team + active-layer ranges with scratch. |
| components/omega/src/ocn/auxiliaryVars/PseudoThicknessAuxVars.cpp | Adds NVertLayers initialization for scratch-sized temporaries. |
| components/omega/src/ocn/auxiliaryVars/KineticAuxVars.h | Refactors kinetic aux computations to team + active-layer ranges with scratch. |
| components/omega/src/ocn/auxiliaryVars/KineticAuxVars.cpp | Adds NVertLayers initialization for scratch-sized temporaries. |
| components/omega/src/ocn/AuxiliaryState.cpp | Updates auxiliary-state assembly to call new team-based aux kernels. |
| components/omega/src/infra/OmegaKokkos.h | Adds subviewUnmanaged helper used by refactored kernels. |
031a705 to
af042eb
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (2)
components/omega/src/ocn/AuxiliaryState.cpp:152
- The LaunchConfig scratch sizing uses TeamScratch(2 * VCoord->NVertLayers), but LocKineticAux::computeVarsOnCell allocates two ScratchArray1DReal views (KineticEnergyCellTmp and VelocityDivCellTmp). Use a 2-view TeamScratch calculation to ensure enough scratch bytes (per-view padding/alignment can make this larger than a single 2*N allocation).
LaunchConfig({Mesh->NCellsAll},
TeamScratch<Real>(2 * VCoord->NVertLayers)),
KOKKOS_LAMBDA(int ICell, const TeamMember &Team) {
components/omega/test/ocn/AuxiliaryVarsTest.cpp:468
- This kernel launches with TeamScratch(2 * VCoord->NVertLayers), but VorticityAuxVars::computeVarsOnVertex allocates two separate scratch views (PseudoThickVertex and RelVortVertexTmp). Use TeamScratch<Real, Real>(VCoord->NVertLayers, VCoord->NVertLayers) so the scratch allocation matches the sum of both views.
parallelForOuter(
LaunchConfig({Decomp->NVerticesHaloH(0)},
TeamScratch<Real>(2 * VCoord->NVertLayers)),
KOKKOS_LAMBDA(int IVertex, const TeamMember &Team) {
VorticityAux.computeVarsOnVertex(Team, IVertex, PseudoThickCell,
NormalVelEdge);
});
|
@brian-oneill, can you take a look at this when you get a chance? Thanks! |
Vertical chunking is on its way out of Omega (PR #473 removes it from the auxiliary variables and tendency terms), so this branch should not add more of it. The EOS is not touched by that PR, so remove chunking here across the board rather than leaving the new specific volume derivative code to be converted later. The functors now follow the same pattern as the de-chunked auxiliary variables: each takes a TeamMember and a cell index and loops over the active layers with parallelForInner(Team, Range{KMin, KMax}, INNER_LAMBDA(int K) { ... }); so the callers in Eos.cpp reduce to a single call inside parallelForOuter, with no vertRangeChunked and no inner loop over chunks. Dropping the chunk loop also removes VecLength from the TEOS-10 polynomial helpers. calcPCoeffs, calcPCoeffsDTt, calcPCoeffsDSs, calcDelta, calcDeltaDeriv and calcDeltaDP took arrays sized 6 * VecLength or 5 * VecLength together with a KVec index into them; they now take plain [6] and [5] arrays and no index. That storage was never shared between layers -- the coefficients are recomputed for every layer -- so nothing is lost, and the point-wise calcSpecVolAndDerivsAtPoint and the calcAlpha and calcBeta helpers no longer allocate VecLength times more stack than they use. With the chunk loop gone, the array-level derivative routine is exactly calcSpecVolAndDerivsAtPoint evaluated at each cell and layer, so it now calls it instead of repeating the polynomial evaluation. That leaves a single implementation of the TEOS-10 derivatives. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Vertical chunking is on its way out of Omega (PR E3SM-Project#473 removes it from the auxiliary variables and tendency terms), so this branch should not add more of it. The EOS is not touched by that PR, so remove chunking here across the board rather than leaving the new specific volume derivative code to be converted later. The functors now follow the same pattern as the de-chunked auxiliary variables: each takes a TeamMember and a cell index and loops over the active layers with parallelForInner(Team, Range{KMin, KMax}, INNER_LAMBDA(int K) { ... }); so the callers in Eos.cpp reduce to a single call inside parallelForOuter, with no vertRangeChunked and no inner loop over chunks. Dropping the chunk loop also removes VecLength from the TEOS-10 polynomial helpers. calcPCoeffs, calcPCoeffsDTt, calcPCoeffsDSs, calcDelta, calcDeltaDeriv and calcDeltaDP took arrays sized 6 * VecLength or 5 * VecLength together with a KVec index into them; they now take plain [6] and [5] arrays and no index. That storage was never shared between layers -- the coefficients are recomputed for every layer -- so nothing is lost, and the point-wise calcSpecVolAndDerivsAtPoint and the calcAlpha and calcBeta helpers no longer allocate VecLength times more stack than they use. With the chunk loop gone, the array-level derivative routine is exactly calcSpecVolAndDerivsAtPoint evaluated at each cell and layer, so it now calls it instead of repeating the polynomial evaluation. That leaves a single implementation of the TEOS-10 derivatives. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
bcbf20e to
90f0f6f
Compare
|
@mwarusz, when building on pm-gpu (gnugpu) I see the following errors: |
90f0f6f to
00f7a37
Compare
|
I pushed a fix and rebased on |
|
Passes CTests and Polaris
|
|
Passes Polaris
|
This PR removes vertical chunking from all auxiliary variables and tendency terms computations. Vertical chunking was originally introduced to help with vectorization on CPUs. However, in its current form, it doesn't seem to improve CPU performance, and often makes things slower. Removing the chunking makes the code cleaner and makes it much simpler to limit vertical bounds to active layers.
I still need to finish running a couple of benchmarks to prove that this is beneficial, but I am opening this PR to show examples of how to write operators without vertical chunking.
This is just the first from a planned series of PRs to remove vertical chunking from all of Omega.
Checklist
Linting
Building
Testing
aurora, oneapi-ifx, mpich
chrysalis, oneapi-ifx, openmpi
frontier, craygnu, mpich
frontier, craygnu-mphipcc, mpich
pm-cpu, gnu, mpich
pm-gpu, gnugpu, mpich
Provide relevant details in a comment to the PR titled
Testingwith the following:have been run on and indicate that are all passing.
has passed, using the Polaris
e3sm_submodules/Omegabaseline-pfor both the baseline (Polarise3sm_submodules/Omega) and the PR build