shaders: keep native Wave64 when VICTORY_WAVE32_RELAX is on #96

Manually merged
github merged 1 commit from github-bot/gh-95 into main 2026-12-05 17:43:40 +00:00 AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 11:54 UTC · original
SovietBearz0r:wave32-relax-guard → main · +5 −1 · 1 files · 1 commits · merged 2026-12-05 17:40 UTC

Fix a correctness bug in the VICTORY_WAVE32_RELAX=1 path on native Wave64 GPUs (AMD RDNA 2/3/4).

What was wrong

When a console wave64 compute program either crosses 32-lane halves or shares LDS across a group of more than 32 threads, the relaxation path cannot use plain 32-lane waves and falls into the split emulation: two host waves of 32 with a group barrier before every LDS access and a cross-half exchange pair for lane numbers/masks. That emulation only makes sense on 32-lane-max hosts (NVIDIA), where a 64-lane wave cannot be requested.

On a native Wave64 host with VICTORY_WAVE32_RELAX=1, the same code nevertheless built that emulation, injecting barriers the hardware wave does not need and an LDS exchange pair no wave uses — exactly what can hang or read the wrong half. The fork this was found in (ReVictory-RDNA3's RX 7000 edition) guards the branch with host_max_wave() == 32, so a native 64-lane host keeps its hardware Wave64.

Change

crates/victory-shader/src/emit/lower/mod.rs: the split-wave branch is now taken only when host_max_wave() == 32, with a comment recording why.

  • 32-lane-max hosts (NVIDIA): unchanged.
  • Native Wave64 hosts: with relax off (the default) nothing changes; with VICTORY_WAVE32_RELAX=1 the program keeps 64-lane waves instead of the split emulation.
  • Wave64 programs that do not cross halves and use no cross-wave LDS still relax to 32-lane waves as before.

Verification

  • cargo test -p victory-shader --lib: 320 passed, 2 ignored, 0 failed.
  • No unit test for the guard: VICTORY_WAVE32_RELAX is a process-static env switch (a test cannot flip it after the first read), and the split path runs only during lowering of a real LDS-heavy wave64 program; the fix is a host-capability guard rather than new lowering behaviour. Behaviour on NVIDIA (all CI hosts here are 64-lane AMD, so the 32-lane branch is reasoned) is untouched.
  • Source: ReVictory-RDNA3, crates/victory-shader/src/emit/lower/mod.rs (RX 7000 edition).
**@⁠SovietBearz0r** on GitHub · 2026-12-05 11:54 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/95) `SovietBearz0r:wave32-relax-guard` → `main` · +5 −1 · 1 files · 1 commits · merged 2026-12-05 17:40 UTC Fix a correctness bug in the `VICTORY_WAVE32_RELAX=1` path on native Wave64 GPUs (AMD RDNA 2/3/4). ## What was wrong When a console wave64 compute program either crosses 32-lane halves or shares LDS across a group of more than 32 threads, the relaxation path cannot use plain 32-lane waves and falls into the split emulation: two host waves of 32 with a group barrier before every LDS access and a cross-half exchange pair for lane numbers/masks. That emulation only makes sense on 32-lane-max hosts (NVIDIA), where a 64-lane wave cannot be requested. On a native Wave64 host with `VICTORY_WAVE32_RELAX=1`, the same code nevertheless built that emulation, injecting barriers the hardware wave does not need and an LDS exchange pair no wave uses — exactly what can hang or read the wrong half. The fork this was found in (ReVictory-RDNA3's RX 7000 edition) guards the branch with `host_max_wave() == 32`, so a native 64-lane host keeps its hardware Wave64. ## Change `crates/victory-shader/src/emit/lower/mod.rs`: the split-wave branch is now taken only when `host_max_wave() == 32`, with a comment recording why. - 32-lane-max hosts (NVIDIA): unchanged. - Native Wave64 hosts: with relax off (the default) nothing changes; with `VICTORY_WAVE32_RELAX=1` the program keeps 64-lane waves instead of the split emulation. - Wave64 programs that do *not* cross halves and use no cross-wave LDS still relax to 32-lane waves as before. ## Verification - `cargo test -p victory-shader --lib`: **320 passed, 2 ignored, 0 failed**. - No unit test for the guard: `VICTORY_WAVE32_RELAX` is a process-static env switch (a test cannot flip it after the first read), and the split path runs only during lowering of a real LDS-heavy wave64 program; the fix is a host-capability guard rather than new lowering behaviour. Behaviour on NVIDIA (all CI hosts here are 64-lane AMD, so the 32-lane branch is reasoned) is untouched. - Source: ReVictory-RDNA3, `crates/victory-shader/src/emit/lower/mod.rs` (RX 7000 edition).
The wave32 relaxation path chose the split two-wave emulation for any
program that crosses 32-lane halves or shares LDS across a group over 32
threads. That emulation injects group barriers and cross-half LDS exchange
and is only valid on 32-lane-max hosts (NVIDIA), where a 64-lane wave cannot
be asked for. On a native Wave64 host (AMD RDNA 2/3/4) VICTORY_WAVE32_RELAX=1
therefore asked for barriers the hardware wave does not need, and an exchange
pair no wave uses: keep the hardware Wave64 there instead.

From ReVictory-RDNA3's RX 7000 edition.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 11:55:40 +00:00
github manually merged commit 6f8332fb32 into main 2026-12-05 17:43:40 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.