perf: split-LDS reads share one barrier, back-to-back exchanges share meetings (16 LDS reads 1.66x on a 4060 Laptop) #576
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/576"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-28T07:39:40Z.
What
A console wave64 compute program that runs as two host waves of 32 (the "split" form, used on NVIDIA) placed a group barrier before every LDS access of the title, even a read right after a read. Every cross-lane exchange also ended with its own barrier. This PR does two things:
s_barrieror exchange between them. The rest is unchanged:v_readlaneexchange. N exchanges in a row now cost N + 1 barriers instead of 2N.The split-LDS barriers now go through
group_sync, so #570's census counts them inadded_barrieras well asbarrier.Why
YUYING234's GPU-timed run on Marvisak/VIctory#3505 (4060 Laptop) shows the title's own compute dispatches take 92 % of GPU time. Blur, reduction and culling passes are LDS-heavy. The exchange bench found that 1 write + 16 reads in the split form cost 17 barriers and ran 1.65× slower than HLSL written for 32-lane waves.
Bench
RTX 4060 Laptop,
exchange_bench(1024 groups × 256 rounds, 30 timed dispatches, median), three alternating before/after runs (spread ≤ 0.001 ms). Every run checks the console's sums.The second pairs sit after all of the group's first pairs, so a lone exchange keeps its old LDS layout. Interleaving them per console wave (4-dword stride) measured 0.242 → 0.249 ms on single exchanges at 256 threads.
Tests
split_lds_reads_share_one_barrier: censusbarrier/added_barriercounts for 1 write + 1–16 reads (always 2) and for 9 interleavings of writes, reads, titles_barrierand ballots. Fails before (3 barriers for 2 reads).back_to_back_exchanges_share_meetings: ballot = 3 barriers, two ballots = 4 (was 5), in groups of 64 and 256, plus the pair each exchange of a run takes ([false, true, false, true], run continues across a title read). Fails before.split_lds_interleavings_give_the_consoles_results(GPU): the 9 interleavings, including write→read(other half)→write→read, runs of reads across both halves, back-to-back writes,s_barrierbetween reads and three ballots in a row. They run in groups of one console wave, and of two where the program exchanges, 1024 groups × 256 rounds, against a lockstep model of the console wave.every_exchange_gives_the_consoles_resultscovers the bench constructs.WaveSize(32)here, so the GPU tests run on NVIDIA only.cargo test -p victory-shader --libon the RTX 4060 Laptop: 371 passed, 21 ignored.cargo check -p victoryandcargo xtask policypass. Full pytest: 1454 passed, 529 skipped.AI use: written, tested and benchmarked by Claude Code (Claude Opus 5.5) for KainanP, on synthetic programs only; no game shader was used.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.