mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:55:52 +01:00
[PR #1043] rdna2spirv: a lane mask read as a number is the wave's mask word (SHADER-MASK-AS-DATA) #1081
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#1081
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/1043
Author: @thesubtleties
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:mask-as-data📝 Commits (3)
02d6293rdna2spirv: a lane mask read as a number is the wave's mask word (SHADER-MASK-AS-DATA)68b964elane_masks: follow a copied mask through VGPR copies before deciding how it is read (SHADER-MASK-AS-DATA)4d58a05Merge main into mask-as-data (SHADER-MASK-AS-DATA)📊 Changes
10 files changed (+307 additions, -18 deletions)
View changed files
📝
docs/design.md(+1 -0)➕
tests/semantic/test_mask_as_data.py(+182 -0)📝
tests/semantic/test_salu64_bitwise_data.py(+2 -2)📝
tests/semantic/test_salu_movrels_lane_mask.py(+1 -1)📝
tests/semantic/test_scselect_b64_data.py(+1 -1)📝
tests/semantic/test_slot67_operand_forms.py(+1 -5)📝
tools/lane_masks.py(+89 -5)📝
tools/rdna2spirv.py(+21 -3)📝
tools/wave32_pixel_scan.py(+3 -0)📝
tools/wave64_emulate_opt.py(+6 -1)📄 Description
Claimed in the coordination issue as: SHADER-MASK-AS-DATA
What and why
A lane mask is one word for the wave on hardware; the translator keeps each lane's own 0 / ~0. An op that read the mask as a number therefore got a different wrong value per lane, with no error: with mask
0x3ff,s_add_u32 d, mask, 1was 0 or 1 andv_mov_b32 v, maskwas 0 or ~0 (crosslane_fuzz.py"maskdata", the old #293).s_bcnt/s_ff/s_flbitalready rebuild the word. This does the same for:lane_masks.NUMBER_READERS);v_mov_b32of a mask, when nov_readfirstlane_b32or vector bitwise op reads that value as a mask. Each copy is followed forward, through VGPR-to-VGPR copies (second commit).The emulation planner counts such an op as an exchange, it never joins an active run, and
wave32_pixel_scan.pycounts it asmask_word.Partial on purpose. Not covered: the values excluded above (the v_mov / v_or3 / v_readfirstlane idiom needs each lane's own bit), compares, SDWA and DPP, and 16-bit, float and 64-bit ops.
Three existing tests changed:
test_salu_movrels_lane_mask,test_scselect_b64_dataandtest_salu64_bitwise_dataread a mask back withv_mov_b32and expected the lane's own 0 / ~0; they now expect the mask word.Tested
Measured on base
82a2aabc, then rebased; the semantic suite and the touched tests were rerun after the rebase.tests/semantic/test_mask_as_data.py(wave32, native wave64, partial EXEC, the through-a-VGPR idiom, emulated translation): fails onmain, passes here.run_semantic_tests.py: 0 files failed.crosslane_fuzz.py, hard mismatches, main -> this PR; no program fails here that passed on main:--ext, seed 880606 (300), 3080 and gfx1036--ext, seed 880707 (300), gfx1036The 880xxx main rows were run on
98a977b4. With--no-maskdatathere are no hard mismatches there on main. Correction: the first version of this text said the remaining mismatches werev_readfirstlanereads. Minimizing them showed most came from a plain VGPR-to-VGPR copy that the first commit counted as a mask read; the second commit fixes that. What is left on wave32 seeds 991201, 991202 and 993301 (11 mismatches, plus 4 programs with a hypothesis op) is now minimized on the 3080: every reduction contains av_mov_b32of a mask into a VGPR that av_readfirstlane_b32or a vector bitwise op then reads, the idiom this PR leaves alone. The shortest isv_cmp_ne_u32_e32 vcc_lo, 9, v6/v_mov_b32_e32 v2, vcc_lo/v_readfirstlane_b32 s8, v2. The wave64 leftovers (seed 880606 emulated on the 3080, seed 880707 native on gfx1036) minimize to the same idiom. Caveat: two hard reductions stayed at 14 and 17 lines, where the pattern is present but not shown to be the cause, and the six programs with a hypothesis op (4 wave32, 2 wave64 native) are not explained.cf_diff.py: 2,000 programs on the second commit (wave32 and wave64), 0 mismatches.run_gpu_tests.py: per-test results identical to main: 3080 201/252, 3080 emulated 233/252, gfx1036 234/252, gfx1036 emulated 234/252; only the two known tfe fixtures fail (#31). Rerun on the second commit.GPUs tested: NVIDIA RTX 3080 (620.73.04) and AMD RDNA2 iGPU gfx1036 (RADV, Mesa 26.3.1), CachyOS Linux 7.3.5
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.