Preserve LDS atomic ordering between divergent half-waves #204

Open
github-bot wants to merge 1 commit from github-bot/gh-204 into main AGit
Owner

@⁠feanorsun on GitHub · 2026-11-26 11:29 UTC · original
feanorsun:fix/order-divergent-lds-atomics → main · +115 −8 · 1 files · 1 commits · open

Refs #182

The Wave32 lowering analysis for divergent regions classified every non-read LDS operation as write-only. An atomic minimum followed by an atomic add can therefore get synchronization only at the region boundaries. In a 64-lane wave with 33 active lanes, all lanes first clear one shared word and then increment it. The CPU reference ends at 33. If one half finishes before the other clears the word, the result can be 1 or 32.

Account for the read side of LDS read-modify-write instructions, including operations without a return register. A region containing just one kind of commuting, non-returning integer reduction can still take the existing lowering. The existing flag proof remains available.

The synthetic regression exercises both returning and non-returning adds. On upstream 0dec5dcc228b the original control flow was incorrectly accepted for Wave32. After the change, the public emitter uses the existing EXEC-skip rewrite for the mixed operations and emits Wave32 with the operations in blocks all lanes reach. Two identical non-returning adds still take the direct Wave32 path.

Tested on Windows with a CPU reference and the in-memory shader emitter. The new exact test failed before the fix. It and the existing positive and negative flag-region tests passed afterwards. The three tests were listed individually, then run with cargo test --offline --locked -j 1 -p victory-shader --lib <test> -- --exact --test-threads=1.

The 128- and 1024-thread programs discussed in #37 use LDS atomics. This test addresses an ordering hazard when lowering that class of operation. It does not reproduce the four reported shader binaries, establish why those particular programs were refused, or measure rendering on the RTX 3070. No GPU or driver validation was run locally.

**@⁠feanorsun** on GitHub · 2026-11-26 11:29 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/204) `feanorsun:fix/order-divergent-lds-atomics` → `main` · +115 −8 · 1 files · 1 commits · open Refs #182 The Wave32 lowering analysis for divergent regions classified every non-read LDS operation as write-only. An atomic minimum followed by an atomic add can therefore get synchronization only at the region boundaries. In a 64-lane wave with 33 active lanes, all lanes first clear one shared word and then increment it. The CPU reference ends at 33. If one half finishes before the other clears the word, the result can be 1 or 32. Account for the read side of LDS read-modify-write instructions, including operations without a return register. A region containing just one kind of commuting, non-returning integer reduction can still take the existing lowering. The existing flag proof remains available. The synthetic regression exercises both returning and non-returning adds. On upstream `0dec5dcc228b` the original control flow was incorrectly accepted for Wave32. After the change, the public emitter uses the existing EXEC-skip rewrite for the mixed operations and emits Wave32 with the operations in blocks all lanes reach. Two identical non-returning adds still take the direct Wave32 path. Tested on Windows with a CPU reference and the in-memory shader emitter. The new exact test failed before the fix. It and the existing positive and negative flag-region tests passed afterwards. The three tests were listed individually, then run with `cargo test --offline --locked -j 1 -p victory-shader --lib <test> -- --exact --test-threads=1`. The 128- and 1024-thread programs discussed in #37 use LDS atomics. This test addresses an ordering hazard when lowering that class of operation. It does not reproduce the four reported shader binaries, establish why those particular programs were refused, or measure rendering on the RTX 3070. No GPU or driver validation was run locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:30:52 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/204/head:github-bot/gh-204'
git switch 'github-bot/gh-204'

Merge

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