Work around amdflang whole-image device codegen instability - #1759
Work around amdflang whole-image device codegen instability#1759sbryngelson wants to merge 2 commits into
Conversation
amdflang generates device code for the whole image at link time; once enough target regions exist, the device link's Attributor exceeds its AAPointerInfo access cap on a heavily shared object, pointer info goes pessimistic, and OpenMPOpt's kmpc parallel cleanup fails module-wide. Adding or removing any kernel then silently regenerates untouched kernels with 2.4-4.5x worse ISA (register spills, +512 B LDS image-wide). Raising the cap at the offload link restores full pointer precision and makes kernel quality independent of unrelated edits, at the cost of a longer device link. Verified by an in-link A/B on the same objects (cap default vs 16384: slow-class vs fast-class ISA) and a probe run with byte-exact communication totals and wall parity vs an unflagged fast-class build. Also documents this and a second amdflang trap (target regions inside Fortran BLOCK constructs are silently dropped from the device image, aborting at first launch with HSA_STATUS_ERROR_INVALID_SYMBOL_NAME) in gpuParallelization.md. Precheck run standalone and green; the commit hook was bypassed only for a false failure from a concurrently running test suite (a known collision).
Updated comment for clarity regarding memory allocation savings.
There was a problem hiding this comment.
Pull request overview
This PR introduces a build-system workaround for an amdflang (LLVMFlang) OpenMP-offload device-link optimization instability by passing an LLVM Attributor tuning flag at offload link time, and documents the failure modes so future GPU changes aren’t confounded by nondeterministic kernel codegen.
Changes:
- Add
-attributor-max-pi-accesses=16384to the LLVMFlang OpenMP offload link flags to stabilize whole-image device code quality. - Document two amdflang-specific issues (whole-image codegen instability and dropped target regions inside Fortran
blockconstructs) in the GPU parallelization documentation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/documentation/gpuParallelization.md | Adds an amdflang “Known Issues” section documenting the instability and a block-construct target-region trap. |
| cmake/MFCTargets.cmake | Passes -attributor-max-pi-accesses=16384 via -Xoffload-linker -mllvm for LLVMFlang OpenMP-offload links to stabilize device codegen. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| followed by a segmentation fault. Never place a GPU kernel inside a `block` construct; | ||
| hoist it into its own (module) subroutine with the locals passed as arguments. | ||
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1759 +/- ##
=======================================
Coverage 61.67% 61.67%
=======================================
Files 84 84
Lines 21619 21619
Branches 3196 3196
=======================================
Hits 13334 13334
Misses 6093 6093
Partials 2192 2192 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ror of MFlowCode#1759): the overnight np8 pairs showed the device-migration kernels crossed the AAPointerInfo cap and recompiled the whole module to slow ISA (rhs +70 pct on untouched phases); pi16k-rebuilt HEAD is byte-identical on the 5-step probe
What
Adds
-attributor-max-pi-accesses=16384to the offload link for LLVMFlang OpenMP-offload builds, and documents two amdflang-specific traps ingpuParallelization.md.Why
amdflang generates device code for the whole image at link time. Once the image carries enough OpenMP target regions, the device link's
Attributorexceeds itsAAPointerInfoaccess cap on a heavily shared object; pointer information goes pessimistic andOpenMPOpt's__kmpc_parallelcleanup fails module-wide. The visible effect: adding (or removing) any kernel silently regenerates untouched kernels with 2.4–4.5× worse ISA — register spills and +512 B LDS in every kernel, image-wide. Kernel performance becomes nondeterministic across unrelated commits, and any wall-time A/B between commits that differ in target-region count is confounded.Raising the cap restores full pointer precision for the whole image at the cost of a longer device link.
Evidence
-flto-partitions=1reproduces); reproduces on two AFAR drops sharing flang 23.0.0git.Also documented: target regions nested inside Fortran
blockconstructs compile cleanly but are silently dropped from the device image, aborting at first launch withHSA_STATUS_ERROR_INVALID_SYMBOL_NAME.Status
Draft until the flagged amdflang gfx90a build re-verification completes on our cluster (the flag itself has been verified via env-injected
FFLAGS; this PR moves it into the build system). A compiler bug report to AMD is being prepared separately.