lane_masks, rdna2spirv: wrap parked v_writelane/v_readlane slots mod 32 in wave32 (LANE-MASKS-WAVE32-SLOT) #1803
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1803"
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 ubiquitarianism/leonida. Originally posted by ShotTechOp on 2026-11-25T12:19:24Z.
Summary
Claimed in #1608 as
LANE-MASKS-WAVE32-SLOT: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162135689In wave32 (
wave64=False), RDNA2v_writelane_b32andv_readlane_b32mask the lane selector byS1[4:0](& 31, mod 32) — whichtools/rdna2spirv.pyalready emits at lines 8818 and 8837 (self.cu(63 if self.wave64 else 31)). However,lane_masks.lane_slot()always masked by& 63andlane_masks.parked()/rdna2spirv.pydid not passwave64:32(32 & 31 == 0) with plain data in wave32 failed to invalidate a mask parked in lane0, so a subsequentv_readlane_b32returned the stale parked mask ([0xffffffff, 0xffffffff, 0, 0]) instead of the written scalar ([0x55aa] * 4).32in wave32 and reading it back from lane0missed the parked slot and broadcast lane 0's bit across all lanes instead of restoring each lane's bit.Changes
tools/lane_masks.py:lane_slot(vgpr, lane, wave64=True): mask lane index by63 if wave64 else 31, and reject multi-dword VGPRs (n != 1) orabs/neg-modified operands.step()andparked(blocks, masks, wave64=True): threadwave64intolane_slot()(defaultTruepreserves existing callers).tools/rdna2spirv.py:wave64=self.wave64tolane_masks.parked()(park_masks) andlane_masks.lane_slot()(v_readlane_b32/v_writelane_b32).tests/test_lane_masks.py&tests/semantic/test_lane_masks_edge_cases.py:spirv_mini_interp.run_workgroup.Testing
Environment: Windows 11 x64, Python 3.12.10, CPU-only (no GPU or game files; based on
0d80bc5).main(0d80bc5):python -I tests/test_lane_masks.py->AssertionErrorintest_wave32_parked_lane_wraps_mod_32python -m unittest discover -s tests/semantic -p test_lane_masks_edge_cases.py->FAIL([0xffffffff, 0xffffffff, 0, 0]!=[0x55aa] * 4)python -I tests/test_lane_masks.py->okpython -m unittest discover -s tests/semantic -p "test_*lane_mask*.py"-> all OKpython -m compileall -q/scripts/check_no_game_data.py/git diff --check-> all cleanAI-assisted: yes (Antigravity). Synthetic inputs only; no game data.
Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T12:20:06Z.
Tested
87fde5c8don Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain0d80bc5df(translator/bookkeeping PR; binaries from the build at66d4f5aa3):python3 -I tests/test_lane_masks.py: ok at this head; onmainit fails with anAssertionErrorin the parked-slot-32 case.tests/semantic/test_lane_masks_edge_cases.py(fromtests/semantic): OK at this head; onmain1 failure.--filter cs_w32_maskon MoltenVK 1.4.2: 1/1 PASS (cs_w32_mask_imm2056 20 2 6152 2050 4112 258 32).AI-assisted; synthetic fixtures only, no game data.
Imported from ubiquitarianism/leonida. Originally posted by EvgHaze on 2026-11-25T12:58:50Z.
Apple check — no change on the GPU words, and one gap worth naming.
scripts/run_gpu_tests.py --filter lane, identical on both drivers and on main:cs_w32_lane_wrap25 16 777 777cs_w32_permlane_fi1000 0 4 1 1000 0 52 49cs_w64x_readfirstlane,cs_w64x_readlane,cs_w64x_writelaneps_w64x_readlane2/6 passed, 4 skipped — before and after the diff, same words.
Semantic suite: main is
489 files, 6288 tests, 0 failed; with this diff489 files, 6289 tests, 0 failed— the one extra test being this PR's.The gap:
cs_w32_lane32_overwriteandcs_w32_lane32_restoreare built insidetests/semantic/test_lane_masks_edge_cases.pyand never reach the GPU registry, so the wave32 slot wrap has no hardware fixture. A 32-wide host is exactly where those two programs run natively instead of being split, so if a GPU fixture ever gets added here, an Apple run is the one that would exercise it without emulation.AI-assisted. No game data: hand-written programs, and the numbers above are test output.
Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T13:50:37Z.
Tested
87fde5c8dmerged ontomain98c2f7777(clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14, VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja, llvm-mc 21.1.8.run_gpu_tests.py: 209/263 passed, 53 skipped, identical tomain, so the wave32 slot wrap changes no fixture result on this 32-wide GPU.ctest -j 6: 439 of 439 passed.AI-assisted (Claude)
Imported from ubiquitarianism/leonida. Originally posted by tyr0nsur on 2026-11-25T14:57:40Z.
Hardware readback for the two parked-mask patterns in this PR, including slots close to the row and wave boundaries. On a desktop RTX 4060, Windows 11 Pro build 26300, NVIDIA 32.0.16.2114, the Vulkan harness reported a fixed 32-lane subgroup.
0d80bc5df7c887fde5c8daccI kept the same native
vk_compute_testexecutable from the PR for both runs and changed the translator checkout. Each program used a 32×1×1 group. I tested 0↔32, 1↔33 and 31↔63 in both directions, both overwriting a parked mask with0x55aaand restoring a compare mask for lanes 0–16. I checked all 32 output words each time. On the parent, every overwrite case failed all 32 words. On the PR, both operations matched throughout.The standalone probe uses your translator, Python SPIR-V assembler and native Vulkan readback. Run
python probes/leonida_lane_slots.py <leonida-checkout> <path-to-vk_compute_test>against each checkout. All inputs are hand-written. AI assistance: OpenAI Codex (GPT-6) prepared and ran the probe.Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-28T03:51:38Z.
#1803 | head
87fde5c8da| python -I -m unittest discover -s tests/semantic -p test_lane_masks_edge_cases.py & python -I tests/test_lane_masks.py | red: test_lane_masks_edge_cases Ran 8 tests - FAILED (failures=1); test_lane_masks AssertionError in test_wave32_parked_lane_wraps_mod_32 | green: test_lane_masks_edge_cases Ran 8 tests in 0.180s - OK; test_lane_masks ok | full suite: 505 files, 6398 tests, 0 files failed in 386 s (vs main02f71ccfe7: 505 files, 6397 tests, 0 failed); stdlib 514/521 passed (0 new failures); compileall=0; node viewer_streaming=0 | Windows 11, Python 3.14.7, no game files | AI-assisted: yes, Antigravity (Gemini)main02f71ccfe7;scripts/check_no_game_data.pypassed (0).mainand pass completely once merged.Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T13:23:09Z.
Review: APPROVED
Independently verified
87fde5c8dmerged cleanly ontomain(d48a957bb) on Windows 11 across two Vulkan GPUs (zero game files):32.0.16.1664,LEONIDA_W64_EMULATE=1)gfx1036) (driver32.0.21030.2001,LEONIDA_W64_EMULATE=0)Red on
main(d48a957bb) control:pytest tests/test_lane_masks.py: 1 failed, 10 passed (test_wave32_parked_lane_wraps_mod_32).scripts/run_semantic_tests.py tests/semantic -p test_lane_masks_edge_cases.py: 1 failed, 7 passed (test_wave32_writelane_lane_32_aliases_lane_0_for_parked_masks).Green on
#1803(87fde5c8d):pytest tests/test_lane_masks.py: 11/11 passed.scripts/run_semantic_tests.py tests/semantic -p test_lane_masks_edge_cases.py: 8/8 passed.scripts/run_gpu_tests.py --filter cs_w64 --require-pass: 24/24 passed (25/25translated &spirv-valclean, includingcs_w64x_readlane,cs_w64x_writelane,cs_w64x_readfirstlane) on both RTX 5080 and AMD Radeongfx1036.LGTM.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:46:41Z.
Native Windows 11 + NVIDIA GeForce RTX 3090 Verification (
PASS)Verified commit
87fde5c8damerged ontomain(a9e247cd69) on Windows 11 (10.0.26200, Python3.12.10) with physical NVIDIA GeForce RTX 3090 (driver610.88, native 32-lane subgroup32..32, Vulkan1.4+VK_LAYER_KHRONOS_validation1.4.363.1):main+ PR tests):python -I tests/test_lane_masks.py->AssertionErrorintest_wave32_parked_lane_wraps_mod_32(writing plain data viav_writelane_b32 v5, s9, 32failed to invalidate parked mask slot("lane", 5, 0)in wave32).python -I -m unittest discover -s tests/semantic -p test_lane_masks_edge_cases.py -v->FAILED (failures=1)([0xFFFFFFFF, 0xFFFFFFFF, 0, 0] != [0x55AA, 0x55AA, 0x55AA, 0x55AA]).87fde5c8da+main):python -I tests/test_lane_masks.py->ok.python -I -m unittest discover -s tests/semantic -p test_lane_masks_edge_cases.py -v->8/8OK(0.219s).vk_compute_testwithLEONIDA_VK_VALIDATION=1on both wave32 shaders translated & validated withspirv-as/spirv-val):cs_w32_overwrite(v_writelane_b32 v5, mask, 0overwritten byv_writelane_b32 v5, 0x55aa, 32->v_readlane_b32 s14, v5, 0):rc=0,out[0..7] = 0x55AAacross all lanes (0mismatches,0validation errors).cs_w32_restore(v_cmp_lt_u32_e64 s12, v0, 2parked viav_writelane_b32 v5, s12, 32->v_readlane_b32 s14, v5, 0->v_cndmask_b32_e64 v2, 10, 20, s14):rc=0,out[0..7] = [20, 20, 10, 10, 10, 10, 10, 10](0mismatches,0validation errors).python -I scripts/check_no_game_data.pyclean (0issues).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:00:39Z.
Tested
87fde5c8dmerged (no commit) withmainaa918e5d9. Python 3.12.4, Windows 11 10.0.26300, CPU only, withLLVM_MC(conda-forge llvm-tools) and SPIRV-Tools from the Vulkan SDK 1.4.363.1.check_no_game_data.pyis clean.tests/semantic/test_lane_masks_edge_cases.py(8 tests) andtests/test_lane_masks.pypass.tools/lane_masks.pyandtools/rdna2spirv.pyback tomain, both fail: the edge-case file with[4294967295, 4294967295, 0, 0] != [21930, 21930, 21930, 21930], andtest_lane_masks.pywith anAssertionErrorintest_wave32_parked_lane_wraps_mod_32.Overlap check across #1973, #1977, #1990, #1943, #1994, #1996 and #1803 (same translator area):
s_wqm, #1990 forsrc64_data/is_mask_op;s_movintoexec_hi, #1996 form0/scc;docs/design.md, between #1990, #1943 and #1994.main(docs/design.mdtaken frommain), each PR's own test file passes. The full semantic suite (scripts/run_semantic_tests.py tests/semantic -j 4, 528 files, 6513 tests) fails in 2 files:test_valu_cvt_f16_int16_mods, which fails on plainmaintoo;test_wave64_emulate_opt, which comes from #1990 alone (see #1990).No blocker from my side.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:14:31Z.
Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto
main1cb5df073without conflict, and its test file(s) (tests/semantic/test_lane_masks_edge_cases.py,tests/test_lane_masks.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.