wave64: never emit a barrier a group cannot reach, and cover the whole group in the wave-wide decision #81

Open
Pavl3000 wants to merge 4 commits from upstream-pr/81 into main
Pavl3000 commented 2026-11-26 02:27:10 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Pavl3000 on 2026-11-26T02:27:10Z.


Four changes to the wave-wide form (widen) for console wave64 compute programs on a 32-lane host. Measured on an RTX 3080 Ti (D3D12 min=32 max=32), tree 0a43566; the context and the numbers are in #37.

What it does

  1. A barrier is never emitted where not every lane runs. exchange_halves puts two group barriers in the current block, and wave_wide only checked that the branch block is all-lane. group_sync now records need(block) for a block that is not, which is the need widen already reacts to, and widen treats an emission that leaves needs as stuck and refuses the program when nothing is left to widen. Such a barrier is a guaranteed 0x887A0006.
  2. The branches that leave a loop holding a barrier are taken wave-wide too (loop_exits_around): a barrier inside a loop whose two halves leave on different iterations waits for threads that are not there.
  3. The wave-wide decision covers the whole group. Each console wave already writes its own pair of exchange dwords (exchange_pair: slot + 2 * (thread >> 6)) and the barrier at the end of exchange_halves has them all in place, so wave_wide ORs every pair of threads.div_ceil(64) instead of only its own half's. No new primitive; 2n LDS loads per thread at a widened branch. widen no longer refuses a group holding several console waves.
  4. all_lanes no longer says a block is left out by some lanes when the structure has no entry for it: all.get(b).copied().unwrap_or(true). false there put spurious needs in front of the widening, which then looked for branches around a block no lane region holds and gave up (WAVE64-WIDE stopped with 1 branches wave-wide: a branch around it cannot be).

Measured

At pipeline creation on the title's nine refused programs (verified by making the pipelines, not by reading logs):

9 refused → 1. Now created: CS_Visibility, CS_Tiling_Generate_Opaque, CS_TransmissionVolumetrics_Tiled, _LocalLights, _Submerged, _VolumePortalsOnly, CS_DefragHeap_ComputeRelocations (128-thread group), CS_CollectTriangles_Meshlets (1024-thread group). Still refused: CS_AlphTransmissionPrefilterMip (2da4beb386509b77, 256).

With VICTORY_WAVE_WHY=1 the barriers each emits and how many stand in a block not every lane runs: 3/0, 51/0, 613/0, 767/0, 255/0, 326/30, 2854/78. The five that ran in a game run, including both world passes, had none.

What is still wrong

The card is still lost (0x887A0006) after about 74 s of frames in the open world. So legality and a group-wide decision are necessary but not sufficient: what is left is v_mbcnt and lane masks read as data inside divergent regions, and the 32 KiB shared-memory budget of the 1024-thread group — the two items #37 names beyond these.

How it can be tested cheaply

A branch of mine also lets translate --warm <file of hashes> take --pipelines, which makes the pipeline for each named hash and drops it: nine programs in about two seconds instead of a sweep of all 26 000 (that sweep cost 2.7 CPU-hours and produced nothing). I left it out of this PR to keep it to the translator; it can be a second one if wanted.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6618177465 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/81). Originally posted by [Pavl3000](https://github.com/Pavl3000) on 2026-11-26T02:27:10Z. --- Four changes to the wave-wide form (`widen`) for console wave64 compute programs on a 32-lane host. Measured on an RTX 3080 Ti (D3D12 `min=32 max=32`), tree `0a43566`; the context and the numbers are in #37. ## What it does 1. **A barrier is never emitted where not every lane runs.** `exchange_halves` puts two group barriers in the current block, and `wave_wide` only checked that the *branch* block is all-lane. `group_sync` now records `need(block)` for a block that is not, which is the need `widen` already reacts to, and `widen` treats an emission that leaves needs as stuck and refuses the program when nothing is left to widen. Such a barrier is a guaranteed `0x887A0006`. 2. **The branches that leave a loop holding a barrier are taken wave-wide too** (`loop_exits_around`): a barrier inside a loop whose two halves leave on different iterations waits for threads that are not there. 3. **The wave-wide decision covers the whole group.** Each console wave already writes its own pair of exchange dwords (`exchange_pair`: `slot + 2 * (thread >> 6)`) and the barrier at the end of `exchange_halves` has them all in place, so `wave_wide` ORs every pair of `threads.div_ceil(64)` instead of only its own half's. No new primitive; `2n` LDS loads per thread at a widened branch. `widen` no longer refuses a group holding several console waves. 4. **`all_lanes` no longer says a block is left out by some lanes when the structure has no entry for it**: `all.get(b).copied().unwrap_or(true)`. `false` there put spurious needs in front of the widening, which then looked for branches around a block no lane region holds and gave up (`WAVE64-WIDE stopped with 1 branches wave-wide: a branch around it cannot be`). ## Measured At pipeline creation on the title's nine refused programs (verified by making the pipelines, not by reading logs): **9 refused → 1.** Now created: `CS_Visibility`, `CS_Tiling_Generate_Opaque`, `CS_TransmissionVolumetrics_Tiled`, `_LocalLights`, `_Submerged`, `_VolumePortalsOnly`, `CS_DefragHeap_ComputeRelocations` (128-thread group), `CS_CollectTriangles_Meshlets` (1024-thread group). Still refused: `CS_AlphTransmissionPrefilterMip` (`2da4beb386509b77`, 256). With `VICTORY_WAVE_WHY=1` the barriers each emits and how many stand in a block not every lane runs: 3/0, 51/0, 613/0, 767/0, 255/0, 326/30, 2854/78. The five that ran in a game run, including both world passes, had none. ## What is still wrong The card is still lost (`0x887A0006`) after about 74 s of frames in the open world. So legality and a group-wide decision are necessary but not sufficient: what is left is `v_mbcnt` and lane masks read as data inside divergent regions, and the 32 KiB shared-memory budget of the 1024-thread group — the two items #37 names beyond these. ## How it can be tested cheaply A branch of mine also lets `translate --warm <file of hashes>` take `--pipelines`, which makes the pipeline for each named hash and drops it: nine programs in about two seconds instead of a sweep of all 26 000 (that sweep cost 2.7 CPU-hours and produced nothing). I left it out of this PR to keep it to the translator; it can be a second one if wanted.
Bladureau commented 2026-11-26 14:47:18 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Bladureau on 2026-11-26T14:47:18Z.


Tested on an RTX 4060 Laptop GPU 8 GB (driver 617.14, D3D12 min=32 max=32), Windows 11, title 1.0.2.1: avatarmanz/main a9400a6 + #209 + this PR, VICTORY_WAVE_WIDE=1, VICTORY_SHADER_KEY=source, every shader translated beforehand with the same settings, Series S.

The device hung during the world load, 3.6 minutes in; the process exited with 0x887A0005. DRED (light): in the first list that did not finish, 8 of 17 commands completed. The first uncompleted one is an indirect dispatch of 2561af9577c47289 (ptfx_CS_lightAtlas_Sprite), followed in the same barrier interval by dispatches of cabb87599722e59a (its NonLocalLights variant).

Offline, the forms these two programs take:

2561af9577c47289 cabb87599722e59a
#209, VICTORY_WAVE_WIDE=1 2 branches taken wave-wide 4e964d2f953f1c29
#209 + this PR, VICTORY_WAVE_WIDE=1 4 branches taken wave-wide 4e964d2f953f1c29
#209 + this PR, no VICTORY_WAVE_WIDE local waves (APPROXIMATE), without early-outs 4e964d2f953f1c29

Without VICTORY_WAVE_WIDE, the same build ran 6.8 minutes with no device removal. So on this GPU the wave-wide form of ptfx_CS_lightAtlas_Sprite still hangs with this PR, although the PR widens two more of its branches. That is the program emit/mod.rs names as the reason VICTORY_WAVE_WIDE is off by default. I did not run #209 with VICTORY_WAVE_WIDE=1 but without this PR in game.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7195328331 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/81#issuecomment-7195328331). Originally posted by [Bladureau](https://github.com/Bladureau) on 2026-11-26T14:47:18Z. --- Tested on an RTX 4060 Laptop GPU 8 GB (driver 617.14, D3D12 `min=32 max=32`), Windows 11, title 1.0.2.1: avatarmanz/main `a9400a6` + #209 + this PR, `VICTORY_WAVE_WIDE=1`, `VICTORY_SHADER_KEY=source`, every shader translated beforehand with the same settings, Series S. The device hung during the world load, 3.6 minutes in; the process exited with 0x887A0005. DRED (`light`): in the first list that did not finish, 8 of 17 commands completed. The first uncompleted one is an indirect dispatch of `2561af9577c47289` (`ptfx_CS_lightAtlas_Sprite`), followed in the same barrier interval by dispatches of `cabb87599722e59a` (its `NonLocalLights` variant). Offline, the forms these two programs take: | | `2561af9577c47289` | `cabb87599722e59a` | |---|---|---| | #209, `VICTORY_WAVE_WIDE=1` | 2 branches taken wave-wide | `4e964d2f953f1c29` | | #209 + this PR, `VICTORY_WAVE_WIDE=1` | 4 branches taken wave-wide | `4e964d2f953f1c29` | | #209 + this PR, no `VICTORY_WAVE_WIDE` | local waves (APPROXIMATE), without early-outs | `4e964d2f953f1c29` | Without `VICTORY_WAVE_WIDE`, the same build ran 6.8 minutes with no device removal. So on this GPU the wave-wide form of `ptfx_CS_lightAtlas_Sprite` still hangs with this PR, although the PR widens two more of its branches. That is the program `emit/mod.rs` names as the reason `VICTORY_WAVE_WIDE` is off by default. I did not run #209 with `VICTORY_WAVE_WIDE=1` but without this PR in game.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/81:upstream-pr/81'
git switch 'upstream-pr/81'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/81'
git switch 'upstream-pr/81'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/81'
git switch 'upstream-pr/81'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/81'
git switch 'main'
git merge --squash 'upstream-pr/81'
git switch 'main'
git merge --ff-only 'upstream-pr/81'
git switch 'main'
git merge 'upstream-pr/81'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
avatarmanz/VIctory-7900XTX!81
No description provided.