qbmm: hoist s_mom_inv's internal procedures to module scope - #1688
qbmm: hoist s_mom_inv's internal procedures to module scope#1688sbryngelson wants to merge 1 commit into
Conversation
The five procedures contained in s_mom_inv (s_coeff_selector, s_chyqmom, s_hyqmom, f_quad, f_quad2D) reference nothing from their host scope: every apparently-shared name is shadowed by the procedure's own dummy or local. Containment was organizational only. Calling a sibling internal procedure from device code needs the host frame chain, which CCE 21 rejects at runtime: OpenMP Execution Error: m_qbmm.fpp:984 - unsupported access to Fortran host-associated variable in GPU internal procedure (cray_inline=True inlines s_hyqmom into s_chyqmom, so the abort surfaces at the call site.) Module scope removes the construct entirely. Change is move-only: apart from the removed 'contains', all 922 lines are byte-identical after dedent. Verified on Frontier, CCE 21.0.2, 6/6: tests 0501B3DA, 6784C02E, 83291843 pass under both --gpu mp and --gpu acc.
There was a problem hiding this comment.
Pull request overview
This PR resolves a CCE 21.0.x OpenMP offload runtime abort in QBMM by eliminating calls between sibling internal procedures from device code, hoisting the five procedures previously contained within s_mom_inv to module scope in m_qbmm.
Changes:
- Removed the internal
containsblock insides_mom_invand endeds_mom_invbefore the helper procedures. - Hoisted
s_coeff_selector,s_chyqmom,s_hyqmom,f_quad, andf_quad2Dto module scope while keeping their bodies unchanged. - Preserved module encapsulation (module is
privateby default; only the existing public symbols remain exported).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1688 +/- ##
==========================================
+ Coverage 60.49% 61.13% +0.64%
==========================================
Files 84 83 -1
Lines 21189 21047 -142
Branches 3134 3107 -27
==========================================
+ Hits 12819 12868 +49
+ Misses 6303 6126 -177
+ Partials 2067 2053 -14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Independent confirmation from a second worktree, and a note that this PR supersedes a partial fix I had locally. Confirmed on Frontier, CCE 21.0.2 / ROCm 7.2.0, both offload models, on two further QBMM tests beyond the three above. Same abort before the change, clean after. This PR is strictly more complete than what I had. I hoisted only
So I am dropping my version in favour of this one rather than opening a competing PR. Two things worth adding to the record here: The And no other file under Context: the same port produced #1689 (build predicate) and a set of CCE 21 compiler defects with standalone reproducers; this one is application-side and correct to fix regardless of compiler. |
|
Cross-reference, so this is easy to place: This fix is also carried in #1694 (the full Frontier CCE 21.0.2 move) as commit If #1694 lands first, this becomes a no-op and should be closed. If this lands first, #1694 Trail for context:
The defect this fixes was found independently by two sessions working the same port. Worth |
|
Full-suite validation, with this change included: 627/627 on both offload models, zero failures. Frontier, CCE 21.0.2 / ROCm 7.2.0, MPI. Zero For context on what else was needed to get there, since this PR alone is not sufficient to build MFC on CCE 21 — the port needed eight fixes in total, four of them working around compiler defects:
The Performance, same source with the full fix set on both trees, six benchmark cases: CCE 21.0.2 is 5.8% faster than CCE 19.0.0 (328.27 s → 309.10 s total), faster in every case. Reproducers for the compiler defects are in https://github.com/sbryngelson/compiler-bugs/tree/main/cce — eleven entries, six with standalone Fortran reproducers. Four are silent wrong-answer bugs rather than crashes, which is worth knowing for anyone else on CCE 21. One note specific to this PR, from having written a narrower version of the same fix and thrown it away: hoisting only |
Merge orderThis should merge before #1694. #1694 (the CCE 21 port) contains this same hoist, so landing this first means #1694 rebases with its 275-line move-only Suggested order for the CCE 21 work:
This PR has no file overlap with #1696 or #1679, so it can go in whenever it is reviewed. It does not depend on the toolchain move: the construct it removes — calling a sibling internal procedure from device code — is non-portable regardless of which compiler is in use, and CCE 21 is simply the first to reject it outright. |
Problem
The five procedures contained in
s_mom_inv—s_coeff_selector,s_chyqmom,s_hyqmom,f_quad,f_quad2D— are internal procedures called from device code. On CCE 21.0.2 everyQBMM test aborts at runtime:
Line 984 is
call s_hyqmom(myrho, up, M1)insides_chyqmom. Both are internal procedures ofs_mom_inv, sos_chyqmomreaches its sibling through the host frame chain, which CCE 21does not support on device. (
cray_inline=Trueinliness_hyqmomintos_chyqmom, which iswhy the abort surfaces at the call site rather than at the callee.)
Why hoisting is safe
None of the five references anything from its host scope. Every name that appears to be
shared is shadowed by the procedure's own dummy or local:
wght,abscX,abscY,momins_chyqmompres,rho,c,coeffs_coeff_selectorq,r,s,wght_inf_quadmoms,M1,M3,myrho,up,i1sgm_eps,nmom,nnodeparameters (compile-time constants)weight,R0,nbContainment was organizational, not functional. Module scope removes the construct entirely
rather than working around the compiler.
The change is move-only
Apart from the removed
contains, all 922 lines are byte-identical after dedent:No logic, no expressions, no declarations changed.
Verification
Frontier (MI250X), CCE 21.0.2 / ROCm 7.2.0, MPI, 6/6:
--gpu mp--gpu acc0501B3DA1D Viscosity → Bubbles → QBMM → bubble_model=3 → cfl_adap_dt=T6784C02E1D Viscosity → Bubbles → QBMM832918432D Viscosity → Bubbles → QBMM → bubble_model=3Confirmed independently in a second session on two further QBMM tests (
284E0EF5,48B9D0C4). A full-suite run with this change shows zerounsupported access to Fortran host-associated variableaborts across 627 tests, on both backends../mfc.sh precheckpasses (7/7).This is a correctness fix worth taking regardless of compiler: calling a sibling internal
procedure from device code is not portable, and no other file in
src/simulationorsrc/commonstill does it.Context: #1684 (moving Frontier off
cce/19.0.0).