Skip to content

test_wave64_emulate_opt: a mask pair with a constant half stays a mask through a copy (EGEN-LANEMASK-PAIR-TEST) - #6492

Open
evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:claude/lane-masks-mixed-pair
Open

evilclanker9000 wants to merge 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:claude/lane-masks-mixed-pair

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: EGEN-LANEMASK-PAIR-TEST (Vonsek4), #4933 (comment)

Depends on: none. It adds a test to tests/semantic/test_wave64_emulate_opt.py. #4479 (SHADER-798) concerns the wave64 planner for the same kind of pair, not lane_masks.kind through a copy, and shares no code with this test.

What and why

tools/lane_masks.py kind() answers MASK for a two-SGPR operand when one half is a lane mask and the other half is the constant 0 or -1 (if n == 2 and any(k in MASK_KINDS for k in ks)). A copy of such a pair (s_mov_b64 s[6:7], s[4:5]) then carries the mask kind to the copy; if kind() answered "data" the copy would be translated as plain data and each lane would see only its own bit.

I changed that any to all in a copy of tools/ and ran every tests/semantic/test_*.py file (396 files) against it: nothing that passes on main failed (only test_loop_ballot_barrier, red on main already). The new test fails on that mutant.

The test: v_cmp_gt_u32_e64 s[4:5], 5, lane (lanes 0-4 of each wave), s_mov_b32 s5, 0, s_mov_b64 s[6:7], s[4:5], s_bcnt1_i32_b64 s10, s[6:7], store s10 from every lane of a 64- and a 128-thread workgroup under --wave64-emulate. The popcount of {lanes 0-4, 0} is 5 in every lane; as plain data a lane would count 32 (its own all-ones word) or 0.

Tested

No GPU needed (CPU interpreter in the test file).

  • python -I -m unittest discover -s tests/semantic -p test_wave64_emulate_opt.py -k constant_half: OK on this branch.
  • Negative control: any -> all in kind(): the test fails (test_wave64_emulate_opt.py was green without the change).
  • No translator change, so no corpus run.

Notes

  • My first version used s_and_b64 exec, exec, s[6:7]; it also passed under the mutant (in data mode the AND of per-lane bits gives the same lanes), so I switched to the popcount, where the two readings differ.
  • Other mutants of lane_masks.py that no test in the 13 mask-related files kills: return ks[0] without the set check (likely equivalent: a pair with no mask half only holds EITHER), lane & 63 -> & 31 in lane_slot, and dropping -1 from the EITHER immediates. I have not looked at those further.

AI-assisted.

…k through a copy

s[4:5] = lanes 0-4 of each wave, s5 = 0, then s[6:7] = s[4:5] and s_bcnt1_i32_b64 s10, s[6:7]. lane_masks.kind answers MASK for a pair with one mask half and one EITHER half, so the copy is a mask and the popcount is 5 in every lane. Changing any() to all() in that rule turned the copy into plain data (each lane then sees only its own bit) and left every test that passes on main green.
@TillusStark26

Copy link
Copy Markdown

Tested 3e9f8066e on Windows 11 (Python 3.14.7, CPU only, no game files, AI-assisted): pass.

  • python -I -m unittest discover -s tests/semantic -p test_wave64_emulate_opt.py: 30 tests OK (including the new test_a_mask_pair_with_a_constant_half_is_still_a_mask across both (64, 1, 1) and (128, 1, 1) workgroups).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 3e9f806 merged with main 86d1c86 on Linux/Python 3.12.16: pass

Test-only (one new test in tests/semantic/test_wave64_emulate_opt.py, test_a_mask_pair_with_a_constant_half_is_still_a_mask, for local sizes 64 and 128).

  • python -I -m unittest discover -s tests/semantic -p test_wave64_emulate_opt.py: 31 tests OK
  • Negative control (mutation, since no source file changes): in tools/lane_masks.py kind() the SGPR-pair rule if n == 2 and any(k in MASK_KINDS for k in ks): return MASK disabled with if False and .... The same command then fails test_a_mask_pair_with_a_constant_half_is_still_a_mask for both local=(64, 1, 1) and (128, 1, 1) (FAILED, failures=2). Restored with git checkout HEAD --.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants