Repository navigation
fix(shader): count a meet's lanes by their own path where predication runs others too - #688
Merged
pragyaangaur merged 4 commits intoNov 28, 2026
Conversation
… others too Where selective predication runs a block in a meet region (an early out whose lanes run on as nothing, a one-sided guard run in every lane), every lane of the host wave runs it, also those whose path is elsewhere. They added to a site's `resolved` count by their own branch there, and again on their real path; they were counted done after a site's wait, and in the lanes at the region's branch block. A half's count then passed its `count` (the other half waited to the fuse at a site this one had left) or reached it while its lanes were still on their way (the other half read its ballot as 0). Now the meet's counts and ballots take only the lanes whose path is through the block (its predicate), as the predicated in-step ballot already does. A test program in the shape of the compute programs this changes: an early out, then a guard predication leaves divergent (its body holds an end of the program, so it is neither a skip guard nor a flat diamond) around a lane mask read as data, the upper half's lanes there late behind a long dependent chain the host compiler cannot fold. It meets with predication on and is refused without the rendezvous (native), and gives the console's ballot on every GPU (Windows). Its upper half would have counted 32 done, its lane count, with 8 lanes still on their way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d-lanes # Conflicts: # crates/victory-shader/src/emit/halves_tests.rs
…r#680) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ZebeastSantaCruz83142069
added a commit
to ZebeastSantaCruz83142069/VIctory-macOS831
that referenced
this pull request
Nov 28, 2026
Upstream took pragyaangaur#688, pragyaangaur#689, pragyaangaur#694-pragyaangaur#697, pragyaangaur#700, pragyaangaur#701 and new loader and HLE switches overnight. Conflicts: - bindless.rs: our slot vector, net range counting and timing stay; upstream's pragyaangaur#701 fix lives in CopySpans and merged cleanly; its heap walk cache (VICTORY_HEAP_WALK_CACHE) joins our uploads walk. - host.rs: list steps timed upstream's way (refreshes and slots one in 16); prep phases counted in nanoseconds, the flight trace's per-thread phases too; the frame report keeps our uploads-by-step line and gains upstream's evicting line. - Our runs of table slots now ask VICTORY_SLOT_ONCE first, so upstream's switch reaches the batched path. - run.rs: VICTORY_PROFILE and VICTORY_GUARD_LOOKUP both start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a miscount in the halves meet from #511 where selective predication runs a block of a meet region. Two captured compute programs, 65de113e and 804b342c, are lowered wrong on main: each has lane-mask sites in a meet region whose leaving edges (10 of them) sit in predicated blocks.
The bug
Selective predication (
lower/predicate.rs) runs some blocks in every lane of the host wave, with a predicate saying which lanes the block's code is really for: an early out's lanes run on as nothing, and a one-sided guard's body runs in every lane. The meet's bookkeeping inlower/meet.rsdidn't look at that predicate. In a predicated block:meet_leaveadded to a site'sresolvedword for every lane that ran the block, also for lanes whose real path is elsewhere. Those lanes then counted again on their own path.A half's
resolvedcould then pass itscount, so the other half waited at a site this one had left until the spin fuse ran out. Or it could reachcountwhile some of its lanes were still on their way to the site, so the other half took them as absent and read their ballot bits as 0. Both give a wrong ballot without any report.The fix
The meet's counts and ballots now take only the lanes whose path goes through the block: they AND with the block's predicate where it has one (
lanes_here), as the predicated in-step ballot already does. That covers the leaving-edge adds, the add after the wait, the site ballot inmeet_masks, and the count published inmeet_start. Unpredicated blocks lower as before.Tests
In
lower/tests.rsthere is a synthetic program in the shape of the two programs. The lanes from 56 leave through an early out, so predication runs every block after it in all lanes. The lanes below 40 then go through a guard that predication leaves divergent: its body holds an end of the program (lanes from 63 end; none of the guard's lanes do), so it is neither a skip guard nor a flat diamond. There the lanes put an even-lane compare in VCC, then move both dwords into VGPRs (a lane-mask site). Before the site, the upper half's lanes there (32 to 39) run a long dependent ALU chain (multiply and xor with the thread id, 15000 steps, result stored), so the host compiler can neither fold it nor drop it. Since #655, main lays out flat the nested-guard shape the two programs have, so the test uses one it doesn't.On main, the upper half counts its lanes done as follows. The 8 lanes leaving at the early out count. The guard's block runs in all 32 lanes and adds 24 for the lanes skipping it, of which 8 (the lanes that already left) are bogus. That makes 32, the half's whole count, before its 8 late lanes reach the site. With the fix it counts 24. I confirmed this with a temporary dump of the lowering of the program, on main before and after #655, since removed.
a_mask_behind_predicated_guards_meets(native): with the rendezvous it translates for 64, 128 and 256 threads on a 32-lane host. Without it, it is refused as before.a_mask_behind_predicated_guards_matches_the_console_on_every_gpu(halves_tests.rs, Windows): every lane matches the console's ballot in groups of one, two and four console waves.Results
The test fails on main and passes with the fix, on main both before and after #655. Under Wine on an M5 Pro, each tree rebuilt from scratch:
victory-shadersuite passes: lib 535 passed, 0 failed, 5 ignored;resource_tracking3 passed, 1 ignored.Checks
cargo test -p xtask(10 passed) andcargo xtask policy(352 files) pass.-D warningsis clean onx86_64-pc-windows-gnullvm, for the whole workspace and all targets, with and without--all-features.cargo test -p victory-shader: 279 passed, 2 ignored.a_mask_behind_predicated_guards_meetspasses on main with the test added, before and after fix(shader): keep lanes that break out of a counted loop in it, in halves #655: without the rendezvous the program is refused there too.🤖 Generated with Claude Code