Skip to content

[Experimental] Fixed device-array bounds for all compilers (USING_AMD = True) - #1938

Open
sbryngelson wants to merge 1 commit into
MFlowCode:masterfrom
sbryngelson:exp/fixed-bounds-all-compilers
Open

sbryngelson wants to merge 1 commit into
MFlowCode:masterfrom
sbryngelson:exp/fixed-bounds-all-compilers

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

Experiment — do not merge. Opened to get CI benchmark numbers on NVHPC, CCE, and GNU.

Question

Do the fixed device-array bounds behind the USING_AMD guards speed up the other compilers too, without case optimization?

Why

On AFAR 24.3 (amdflang, MI210), turning the guards off gives correct results but makes AMD 3.8–5.3x slower on ./mfc.sh bench (master vs guards-off, same node):

case guards on guards off
5eq_rk3_weno3_hll 2.13 8.59
5eq_rk3_weno3_hllc 2.02 9.09
5eq_rk3_weno3_lf 1.94 8.74
hypo_hll 1.63 7.12
ibm 4.45 23.44
igr 2.28 2.28
viscous_weno5_sgb_acoustic 3.49 13.33

rocprofv3 on 5eq_rk3_weno3_hllc puts 98% of the added kernel time in two places. In the WENO kernel (m_weno.fpp:1005, guard at :921), the private poly/alpha/omega/beta/dvd arrays become runtime-sized: scratch goes 0 → 400 B per thread and the kernel is 11x slower. In HLLC (l899), the num_fluids/sys_size arrays make it 4.9x slower. With compile-time bounds the arrays stay in registers.

Non-case-optimized NVHPC and CCE builds have always used the runtime-sized arrays. This PR checks whether they pay a similar cost.

Change

One line: USING_AMD = True for every compiler. This turns on the guarded fixed bounds (3 fluids, nb ≤ 3, 60 species, sys_size ≤ 70, WENO 0:4, QBMM 32) and the matching s_check_amd limits for all non-case-optimized builds. OpenMP directive selection (omp_macros.fpp) checks the compiler ID directly, so it is unchanged.

If the numbers favor it, the real PR will rename the guards so they no longer say AMD, keep the limits as named maxima, and leave case optimization as the way past them.

Verification

  • CPU (gfortran) build plus a 106-test subset spanning CBC, wave_speeds=2, IBM, surface tension, QBMM, viscous, HLLD/MHD, Lagrange/Euler bubbles, chemistry, WENO7, 3-fluid, hypoelastic, acoustic: 106/106 passed (HPCFund job 446850)
  • CI benchmarks: see the Bench jobs on this PR.

This PR was prepared with Claude Code (AI-assisted). The measurements were run on HPCFund MI210 nodes with AFAR 24.3.0.

Acknowledgement

  • I confirm this PR meets the above expectations and reflects my own understanding and real-world context.

… True)

Measures in CI whether the compile-time bounds behind the USING_AMD guards
speed up non-case-optimized NVHPC, CCE, and GNU builds as they do amdflang
(3.8-5.3x on AFAR 24.3). Not for merge.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It is explicitly a do-not-merge experiment pending cross-compiler benchmark results.

Review effort: Balanced
Findings: None

What changed in this PR

This experimental PR enables AMD-style fixed array bounds across all compilers to collect comparative CI benchmarks.

Changes:

  • Sets USING_AMD unconditionally for fixed bounds and associated runtime limits.
  • Leaves compiler-specific OpenMP directive selection unchanged.
File Description
src/​common/​include/​shared_parallel_macros.fpp Enables fixed device-array bounds for every compiler.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Claude Code Review

Head SHA: 55c5708

Files changed:

  • 1
  • src/common/include/shared_parallel_macros.fpp

Findings:

  • src/common/include/shared_parallel_macros.fpp:9: USING_AMD is hardcoded to True, with a comment calling it an "experiment". Every compiler (NVHPC, CCE, GNU, Intel) now takes the AMD-only path that substitutes fixed AMD_*_MAX extents for device-global array bounds. This changes behavior on all CI-gated compilers. Any case that exceeds the fallback extents would hit out-of-bounds device arrays or hit the sys_size/species consistency assumptions. When case optimization is off, it also wastes memory. The original MFC_COMPILER == AMD_COMPILER_ID condition should be restored before merge.

@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.70%. Comparing base (ed7a238) to head (55c5708).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1938      +/-   ##
==========================================
- Coverage   62.82%   62.70%   -0.13%     
==========================================
  Files          86       86              
  Lines       22394    22311      -83     
  Branches     3305     3305              
==========================================
- Hits        14070    13989      -81     
+ Misses       6071     6069       -2     
  Partials     2253     2253              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants