mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:15:52 +01:00
[PR #160] [MERGED] wave64_emulate_opt: a mask pair with one constant half is a lane mask to the planner (OLD-4480) #210
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#210
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/160
Author: @ItsMrDubey
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:wave64-planner-const-half📝 Commits (1)
bed6382wave64_emulate_opt: an SGPR pair with one mask half and one constant half counts as a lane mask📊 Changes
3 files changed (+65 additions, -1 deletions)
View changed files
➕
tests/semantic/fixtures/wave64_mask_const_half.asm(+24 -0)📝
tests/semantic/test_wave64_emulate_opt.py(+34 -0)📝
tools/wave64_emulate_opt.py(+7 -1)📄 Description
Claimed in the coordination issue as: OLD-4480 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7119646964)
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).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.