wave64_emulate_opt: a mask pair with one constant half is a lane mask to the planner (OLD-4480) #160
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!160
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/160/head"
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?
@ItsMrDubey on GitHub · 2026-11-24 02:32 UTC · original
ItsMrDubey:wave64-planner-const-half→main· +65 −1 · 3 files · 1 commits · merged 2026-11-24 03:27 UTCClaimed in the coordination issue as: OLD-4480 (#14)
What and why
Old #4480: in wave64 mode, the
--wave64-emulateplanner (tools/wave64_emulate_opt.py, which decides whichs_cbranch_execzregions it can fold and where barriers can happen) did not count an SGPR pair as a lane mask when one half was a mask and the other half was a constant. Examples arev_cmp_* s[4:5]followed bys_mov_b32 s5, 0, ors_mov_b64 s[12:13], -1followed bys_mov_b32 s13, s5. Its_holds_lane_maskrequired both words to be in thelane_masksmap. That map has no constant (EITHER) entries. The translator'sGen.holds_lane_mask, on the other hand, accepts one mask word plus one 0 / -1 word. Because the planner missed the mask, it folded a region with ans_bcnt1_i32_b64on such a pair as lane-local. The translator then emitted the cross-lane x_split inside the fold, andtranslate()failed withAssertionError: wave64 emulation: x_split inside a folded lane-local region.The fix: for a 64-bit SGPR pair, the planner now treats one mask word as enough. The planner's map does not record constants, so a pair with a mask word and a data word is also counted. That is conservative: it can only cost a fold, never let an unsafe fold through. This matches how the planner already treats
slistpairs.This PR does not add or change a translator rule; the translator's output for these instructions is unchanged. It only makes the planner agree with the translator.
Tested
Windows 11, Python 3.11.9, no GPU needed. Checked with the CPU interpreter only; no GPU was available.
tests/semantic/fixtures/wave64_mask_const_half.asm(both shapes above, counted withs_bcnt1_i32_b64inside an execz region). The new test intest_wave64_emulate_opt.pyruns it under--wave64-emulateon the strict 64/128-thread barrier interpreter and expects (8, 40) for threads >= 16 and (0, 0) below. Native wave64 (no emulate) gives the same words onrun_compute_workgroup, both before and after the fix.python -I tests/semantic/test_wave64_emulate_opt.py: before the fix 3 failures (the new test at 64 and 128 threads hits the assertion above; the new_holds_lane_maskunit checks); after it 31 tests OK.python -I scripts/run_semantic_tests.py tests/semantic: 463 files, 6076 tests, 4 files failed: test_exec_computed, test_image_atomics_guard, test_sopc_validation, test_unary_f16_validation (the same four fail on main on this machine; none touch the planner).python -I scripts/check_no_game_data.pyon the three changed/added files: clean.AI-assisted: yes
Checklist
docs/design.md(planner/translator agreement fix; confirmed on the CPU interpreter).