Repository navigation
SCC26: Collapse only spatial loops in per-variable GPU kernels - #2087
Conversation
|
Claude Code Review Head SHA: d573124 Files changed:
Findings: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2087 +/- ##
=======================================
Coverage 61.95% 61.95%
=======================================
Files 86 86
Lines 22901 22901
Branches 3376 3376
=======================================
Hits 14189 14189
Misses 6206 6206
Partials 2506 2506 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Eight loops copy or difference every variable of a field using collapse=4 over the variable and three spatial dimensions. Move the variable loop innermost and execute it sequentially, collapsing only the three spatial loops. In the flux-difference loops, the inverse grid spacing is also computed outside the variable loop. Affected routines: - m_rhs: s_compute_rhs, s_compute_advection_source_term - m_riemann_state: s_finalize_riemann_solver, s_finalize_riemann_solver_hatR - m_weno: s_pack_weno_input_arr The per-variable numerical expressions and spatial loop order are preserved; outputs are bit-identical to the baseline in our tests.
21c80ba to
d573124
Compare
Lines of Code
|
|
i can't replicate your speedup on gh |
|
Thanks for testing this on GH! All the performance numbers in the PR description were measured on H200 with On one H200 SXM, comparing this PR's current head (277b517) against its master parent (961cde5), with three interleaved runs per variant in the same allocation, the grind time changed as follows (the final restart files matched master bit-for-bit in every run):
We observed a few factors that affect the measured speedup:
These are observations from H200 only, so they may not explain what you see on GH, and we can't verify that directly. If these factors don't seem to account for what you're seeing, we'd appreciate any details about your GH configuration and results that you could share ( case, grid size, compiler, case-optimization, grind time ... ) . We'd be happy to look into the difference further. |
Summary
Eight GPU loops in
m_rhs,m_riemann_state, andm_wenocopy or difference every variable of a field usingcollapse=4over the variable and three spatial dimensions. This PR collapses only the three spatial loops and executes the variable loop sequentially inside each GPU thread.On H200, this reduces grind time by 5.4–10.3% across three example cases, with 8.0–10.3% improvements on one GPU. Results were measured with NVHPC 25.9 and 26.3 on one GPU, and NVHPC 26.3 on two GPUs. Nsight Compute shows 59–67% fewer executed instructions in the changed kernels, with essentially unchanged DRAM traffic.
Outputs are bit-identical to
masterin our comparisons, and the full GPU and CPU test suites pass.This PR is from the NTHU team ( Team NTHU SCC ) participating in the SC26 Student Cluster Competition.
Changes
The modification applies to the following routines:
m_rhs.fpps_compute_rhsm_rhs.fpps_compute_advection_source_termm_riemann_state.fpps_finalize_riemann_solver,s_finalize_riemann_solver_hatRm_weno.fpps_pack_weno_input_arrEach loop follows the same transformation (example from
m_weno.fpp):Before:
After:
The numerical expressions and spatial loop order are preserved. In the three flux-difference loops, the inverse grid spacing is also computed outside the variable loop, avoiding repeated evaluation for each variable.
Why this is faster
With
collapse=4, each (variable, cell) pair is a separate GPU iteration, requiring its own collapsed-index decomposition and spatial offset calculations. Withcollapse=3, each thread processes all variables at one spatial cell, allowing spatial index calculations to be reused across variables.Nsight Compute profiling of the changed kernels on H200 (
3D_performance_test, NVHPC 26.3) shows:Nsys profiling further shows that the improvement comes from the modified kernels:
3D_performance_test: total GPU kernel time decreased by 10.2%, with 99.6% of the saving attributable to the eight changed kernels.2D_shockdroplet: total GPU kernel time decreased by 11.5%. The six applicable changed kernels each improved by 36–44%, while the other kernels collectively remained nearly unchanged.Environment
masterat47568a0(baseline) and this PR./mfc.sh build --mpi --gpu acc --case-optimization,MFC_CUDA_CC=90-fast -O3 -acc -gpu=cc90 -Minline -Mfprelaxed -march=native./mfc.sh run <case.py> --case-optimization -n {1,2} -N 1 -b mpirunPerformance
Grind time (ns/gp/eq/rhs),
master→ this PR. Each entry is the mean of three interleaved runs per variant within the same allocation.All runs use H200, double precision, and
--case-optimization. Two-GPU runs use two MPI ranks on one node.3D_performance_test(201³, WENO5, 30 steps)3D_shockdroplet(201×101×101, WENO3, 1000 steps)2D_shockdroplet(4800×1200, WENO3, 565 steps)Maximum run-to-run spread was 1.24% (NVHPC 26.3, 1 GPU), 0.18% (NVHPC 25.9, 1 GPU), and 3.55% (NVHPC 26.3, 2 GPUs).
The cases are the
examples/cases unchanged except for a shortert_step_stop(2D_shockdropletis run with its--res 4 --mach 1.4 --cfl 0.2option).Testing
All comparisons use
masterat47568a0as the baseline.masteracross the measured configurations, including case-optimized builds.CPU builds also use the reordered loops. Our shared-node CPU measurements were too noisy to establish a reliable performance difference; upstream CI benchmarks can provide additional coverage.
Contribution Policy
All contributions are expected to demonstrate:
If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.