compute: return lane 0 for an empty EXEC in split-halves v_readfirstlane_b32 #3354
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-28T12:55:58Z.
Change
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 #3352, 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
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:54:41Z.
Review: APPROVED
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.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:30Z.
Review: APPROVED
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.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T02:10:08Z.
Review: APPROVED
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.