perf(shader): join proven compute loop exits without changing safety aborts #648

Open
github-bot wants to merge 7 commits from github-bot/gh-648 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-05 23:23 UTC · original
tommiehansen:perf/loop-abort-join-20261206 → main · +383 −0 · 7 files · 7 commits · draft

Why

Compute shaders can contain separate normal-loop and safety-limit exits. Where both paths can share a control-flow exit without changing lane behavior, simpler structure may reduce translation or generated control-flow overhead. The safety limit must not be weakened: aborted lanes must still stop executing.

What changes

Restrict the opt-in VICTORY_JOIN_LOOP_ABORTS=1 pass to proven single-entry natural loops with a private latch and exactly two exit edges. Keep normal phi values, original instructions and original abort target. Reuse the predecessor graph until an accepted rewrite, and reject additional exits. Separate cache identity. Inspired by cool_fox / CNF-Larp #247, but deliberately does not continue aborted lanes.

Benchmark results

No representative elapsed-time improvement has yet been established. The following are correctness counts, not timings.

Exact WARP coverage Result
Original loop limit / both wave widths 28/28
Nested/divergent fixture, enabled CI job 28/28

Why this should be merged

The restricted transformation offers an avenue to simpler compute control flow without changing the existing safety behavior. Keep draft until translation, ISA and execution costs establish scoped value.

Validation and compatibility

Original CI, extra-exit refusal, and latest four-job CI at 5f1d8d0. The latter corrects a VOPC source encoding error in the original nested test fixture and checks divergent continuation and abort at the 4096 limit (including 4095 and 4097). Prior full Windows suite contains the known baseline descriptor PSO failure (435 passed, one failed, five ignored); scoped production checks pass.
Reproduce on Windows with the option off/on: cargo test --locked --release -p victory-shader --lib loop_abort_join_nested_native_exact -- --nocapture --test-threads=1. Request matched AMD compiler and runtime comparisons on representative compute loops. #646/#647's neutral ACO audit is not evidence for this separate pass.

Paired nested-loop cost validation

CI 47595460624, head 25d0a84: all four jobs passed; 64 exact WARP paired arms with one actual join enabled, zero disabled. Eight ABBA/BAAB blocks per guest wave width. Median block medians (µs); paired time changes below (negative = improvement):

Guest wave Lowering before → after Paired lowering Preparation before → after Paired preparation Dispatch before → after Paired dispatch
32 243.30 → 240.05 −2.93% 1210.73 → 1172.80 +2.55% 4922.67 → 5152.33 +4.80%
64 244.10 → 235.43 −2.21% 1137.18 → 1175.55 +3.37% 6257.38 → 6821.08 +8.28%

Dispatch wins 1/8 and 0/8; DXIL grows 12 bytes in both cases. This fixture establishes correctness but not net profitability. Park this mechanism, retain draft/default off; avoid repeating unchanged benchmark pending a materially better candidate or representative evidence. Raw artifact. No physical GPU timing claim.

**@⁠tommiehansen** on GitHub · 2026-12-05 23:23 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/648) `tommiehansen:perf/loop-abort-join-20261206` → `main` · +383 −0 · 7 files · 7 commits · draft ## Why Compute shaders can contain separate normal-loop and safety-limit exits. Where both paths can share a control-flow exit without changing lane behavior, simpler structure may reduce translation or generated control-flow overhead. The safety limit must not be weakened: aborted lanes must still stop executing. ## What changes Restrict the opt-in `VICTORY_JOIN_LOOP_ABORTS=1` pass to proven single-entry natural loops with a private latch and exactly two exit edges. Keep normal phi values, original instructions and original abort target. Reuse the predecessor graph until an accepted rewrite, and reject additional exits. Separate cache identity. Inspired by cool_fox / CNF-Larp #247, but deliberately does not continue aborted lanes. ## Benchmark results No representative elapsed-time improvement has yet been established. The following are correctness counts, not timings. | Exact WARP coverage | Result | |---|---:| | Original loop limit / both wave widths | 28/28 | | Nested/divergent fixture, enabled CI job | 28/28 | ## Why this should be merged The restricted transformation offers an avenue to simpler compute control flow without changing the existing safety behavior. Keep draft until translation, ISA and execution costs establish scoped value. ## Validation and compatibility [Original CI](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47581771112), [extra-exit refusal](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47584581478), and [latest four-job CI](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47587223016) at `5f1d8d0`. The latter corrects a VOPC source encoding error in the original nested test fixture and checks divergent continuation and abort at the 4096 limit (including 4095 and 4097). Prior full Windows suite contains the known baseline descriptor PSO failure (435 passed, one failed, five ignored); scoped production checks pass. Reproduce on Windows with the option off/on: `cargo test --locked --release -p victory-shader --lib loop_abort_join_nested_native_exact -- --nocapture --test-threads=1`. Request matched AMD compiler and runtime comparisons on representative compute loops. #646/#647's neutral ACO audit is not evidence for this separate pass. ### Paired nested-loop cost validation [CI 47595460624](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47595460624), head 25d0a84: all four jobs passed; 64 exact WARP paired arms with one actual join enabled, zero disabled. Eight ABBA/BAAB blocks per guest wave width. Median block medians (µs); paired time changes below (negative = improvement): | Guest wave | Lowering before → after | Paired lowering | Preparation before → after | Paired preparation | Dispatch before → after | Paired dispatch | |---|---:|---:|---:|---:|---:|---:| | 32 | 243.30 → 240.05 | −2.93% | 1210.73 → 1172.80 | +2.55% | 4922.67 → 5152.33 | +4.80% | | 64 | 244.10 → 235.43 | −2.21% | 1137.18 → 1175.55 | +3.37% | 6257.38 → 6821.08 | +8.28% | Dispatch wins 1/8 and 0/8; DXIL grows 12 bytes in both cases. This fixture establishes correctness but not net profitability. Park this mechanism, retain draft/default off; avoid repeating unchanged benchmark pending a materially better candidate or representative evidence. [Raw artifact](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47595460624/artifacts/15964931520). No physical GPU timing claim.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 23:24:36 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/648/head:github-bot/gh-648'
git switch 'github-bot/gh-648'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-648'
git switch 'github-bot/gh-648'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-648'
git switch 'github-bot/gh-648'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-648'
git switch 'main'
git merge --squash 'github-bot/gh-648'
git switch 'main'
git merge --ff-only 'github-bot/gh-648'
git switch 'main'
git merge 'github-bot/gh-648'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.