Repository navigation
SCC26: Collapse only spatial loops in per-variable GPU kernels - #2087
Draft
AppleChen17 wants to merge 1 commit into
Draft
AppleChen17 wants to merge 1 commit into
AppleChen17 wants to merge 1 commit into
Conversation
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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lines of Code
|
|
Claude Code Review Head SHA: 21c80ba 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.90% 61.90%
=======================================
Files 86 86
Lines 22885 22885
Branches 3369 3369
=======================================
Hits 14166 14166
Misses 6220 6220
Partials 2499 2499 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wilfonba
marked this pull request as draft
October 17, 2026 15:59
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Performance
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.