Wave64 own bits: refuse a scalar-joined bit loop whose set is read after the loop (host waves read their half's last bit) #286
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!286
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-286"
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?
@sharan104 on GitHub · 2026-11-26 14:27 UTC · original
sharan104:fix/opt-audit→main· +36 −1 · 1 files · 1 commits · openown_bitslets a wave64 program running as two host waves of 32 use each host wave's own half of a wave-wide OR in a "visit each set bit" loop. That's only safe when the set of bits still to visit isn't read outside the loop.Ctx::sitechecked this, but only for the form where the set is kept in a VGPR and read back with a first-lane read. In the form where the set is joined in an SGPR itself (cur == r), the checkif cur != r && !self.joins(cur).is_empty()skipped the joins that read it.That form leaves the loop when one bit is left, so the SGPR holds the OR's highest bit after the loop. Carried out through the exit's join and read there, it was taken as the lane's own. So each host wave of 32 read the highest bit of its own half instead of the wave64's: a miscompile.
Fix: the joins of the set are checked in both forms:
if !self.joins(cur).is_empty().Test:
the_last_bits_left_read_after_a_scalar_loop_are_not_the_lanes_ownbuilds the scalar form of the light loop, withs_mov_b32 s8, s7…again: s_mov_b32 s8, s9. It asserts the loop is still found as before, and that it's refused onces8is read after the loop (v_mov_b32 v6, s8). The test fails before the fix and passed 10 runs out of 10 after it. The existingown_bitstests, VGPR form included, are unchanged and pass.Results:
cargo test -p victory-shader --locked: 303 passed, 0 failed, 4 ignored.-D warningsis clean, with and without--all-features.This doesn't overlap #269, which also touches the optimizer (
opt.rs, FxHash tables).🤖 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.