compute: return lane 0 for an empty EXEC in split-halves v_readfirstlane_b32 #3356
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3356
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3354"
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?
@Not-Saii on GitHub · 2026-11-28 12:55 UTC · original
Not-Saii:compute/wave64-split-readfirstlane-empty→main· +224 −1 · 4 files · 1 commits · merged 2026-11-29 08:54 UTCChange
A guest wave64 that runs as split halves (two host wave32s exchanging words through group memory) took the upper
half's first active lane whenever EXEC's low word was zero. Under an empty EXEC,
v_readfirstlane_b32thereforereturned guest lane 32 instead of lane 0. The split-halves select now takes the upper half only when EXEC's high word
is not zero. Each half reads its own lane 0 when its EXEC word is zero, so an empty EXEC keeps the lower half's lane 0.
Virtual-wave groups (packed slot-67 state) run each wave as split halves and go through the same select.
This pull request no longer depends on #3354, which is closed. It is one commit,
a9101ed7, onmain212d4b5f.src/gfx1013_direct_compute.inl: the split-halves select inv_readfirstlane_b32.tests/native_wave64_readfirstlane_empty_check.pyandtests/cmake/native_wave64_readfirstlane_empty.cmake: anew fixture. The last guest wave sets EXEC to 0 and stores
v_readfirstlane_b32of(v0 << 8) | 5for everylane. It runs with 64 threads (split halves) and with 128 threads under the packed slot-67 state (virtual waves).
docs/experiments/native-wave64-readfirstlane-empty.md: the note, commands and result.Verification
Commit
a9101ed7, Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 4090(
adapter=NVIDIA GeForce RTX 4090 vendor=10de device=2684,driver=32.0.16.1088), D3D12, DXC from Windows SDK10.0.26100, debug layer not enabled.
native_wave64_readfirstlane_empty_controlspassed: both requests compile to 64 host threads with exchangememory, and the 128-thread request without the packed state is refused ("multi-wave64 exchange requires converged
group control flow").
native_wave64_readfirstlane_empty_hardwarepassed: both requests matched the model in all 2,064 words, guardsincluded.
tests/docs_links_check.pyandtests/bidi_controls_check.pypassed.Evidence and follow-up
Negative control: with the old select (
select(cmp("ne", low, "0"), candidates[0], candidates[1])) put back inthe same tree,
ctest --preset dev --no-tests=error -j 1 -R '^native_wave64_readfirstlane_empty_hardware$' -Vfailed on both requests:
Both readbacks were the lane-32 value. The fixture also checks, on every run, that the readback differs from the
lane-32 expectation.
The program is source-built, assembled with LLVM 15.0.7 (
clang -cc1as, gfx1013,+wavefrontsize64). Oneadapter was tested; WARP was not run. Only an EXEC of 0 is covered here.
Checklist
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Direct compute runs a guest wave64 as two host wave32s that exchange mask words at group barriers. Guest waves that branch apart reach a different number of those barriers, so a group of more than one guest wave with a conditional branch and a mask write, lane read, LDS access or s_barrier was refused ("multi-wave64 exchange requires converged group control flow"). Such a group now runs one host wave32 per guest wave64: host lane j carries guest lanes j and j + 32, and each vector instruction is emitted once per lane set. Every other request compiles to the same module. When a wave can end or skip an s_barrier that the others reach, the program gets one barrier site in a loop, so every thread passes the same barrier the same number of times. An s_barrier inside a guest loop is refused. New tests native_wave64_lane_pairs_controls and _hardware: ten source-built programs with CPU models and 16 negative controls, run as lane pairs (128 and 256 threads) and as split halves (64 threads). native_direct_container_check expects its two divergent multi-wave cases to compile as lane pairs and checks that the converged one keeps split halves. Refs #3237 Co-Authored-By: Claude Mythos 5.2 <[email protected]>02cda8438ato71c69b6e2e71c69b6e2eto71627ab220@KelboLive on GitHub · 2026-11-28 20:54 UTC · original · approved these changes
LGTM — correct fix for empty EXEC in split-halves v_readfirstlane_b32.
Adds a select that falls through to the high word's first active lane when the low word is zero, returning lane 0 for an entirely empty EXEC. The fixture's readfirstlane_empty program verifies both layouts (lane pairs and split halves) match the expected lane 0 behavior.
Ready to land.
@KelboLive on GitHub · 2026-11-28 21:57 UTC · original · approved these changes
LGTM — correct fix for empty EXEC in split-halves v_readfirstlane_b32.
Adds a select that falls through to the high word's first active lane when the low word is zero, returning lane 0 for an entirely empty EXEC. The fixture's readfirstlane_empty program verifies both layouts (lane pairs and split halves) match the expected lane 0 behavior.
Ready to land.
71627ab220toa9101ed711@Leyukaka on GitHub · 2026-11-29 02:10 UTC · original · approved these changes
Approving head
a9101ed7. Diff read againstmain212d4b5f; nothing built or run.The select at
src/gfx1013_direct_compute.inl:3512returns the first active lane for every EXEC: low word non-zero takes the lower half, low zero and high non-zero takes the upper half, both zero takes the lower half. Each half already reads its own lane 0 for an empty word (line 3507), andexchange_halvesreturns the lower half first, so an empty EXEC now gives guest lane 0 instead of lane 32. Only this path changes; the mesh, graphics and gfx2hlsl handlers are untouched.Non-blocking: the fixture only sets EXEC to 0, as the Limits section says. By reading, each of these one-line changes to line 3512 makes the select always return
candidates[0], which still passes the fixture but breaks the case where the first active lane is in the upper half (EXEC low word 0, high word non-zero):select(cmp("ne", read(127), "0"), candidates[1], candidates[0])->candidates[0]cmp("ne", read(127), "0")->cmp("ne", low, "0")cmp("ne", low, "0")->cmp("ne", read(127), "0")I found no other test that runs a split-halves
v_readfirstlane_b32with that EXEC. A second request with, for example, EXEC =0x0000000400000000(expected: the value of guest lane 34) would cover it.CI is green, but neither new test ran on this PR: the
prtest preset's include list does not matchnative_wave64_readfirstlane_empty_*. On pushes tomainthe dev preset runs with-E '_hardware$', so only_controlsis in CI.