Skip to content

tests/semantic: ballots and votes through the translator; drop the v_dot2acc_f16_f16 model (TEST-603) - #3261

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
TheHoracio:semantic-debt-603
Nov 23, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
TheHoracio:semantic-debt-603

Conversation

@TheHoracio

Copy link
Copy Markdown
Contributor

TEST-603, released to me by @tupacfan04 in #2891 and claimed in #3047: #3047 (comment)

What and why

Two files in tests/semantic/ checked their own models and never ran tools/rdna2spirv.py, so they passed whatever the translator did. #2992's guard lists both as DEBT:.

  • test_ballot_votes.py is rewritten. It now translates a wave64 and a wave32 compute listing and runs every lane with spirv_mini_interp.run_workgroup.
    • Each listing builds a lane mask in VCC from two push constants: lane i gets bit i of s4:s5.
    • It reads the mask the ways the translator turns into subgroup operations:
      • s_bcnt1 (bit count);
      • s_ff1 (lowest lane, -1 when none);
      • s_cmp_eq vcc, exec (vote all) and s_cmp_lg vcc, 0 (vote any);
      • a per-lane v_cndmask (bit extract);
      • s_and_saveexec with v_readfirstlane and s_bcnt1 exec under the mask as EXEC, then EXEC restored.
    • Masks: 12 for wave64 and 9 for wave32: empty, full, single lanes at both ends and at the lane 31/32 edge, halves, checkerboards, and irregular ones.
    • The expected values come from the input pattern alone.
  • test_alu_dot2acc_f16.py is removed. There is nothing to translate:
    • v_dot2acc_f16_f16 is not an instruction: llvm-mc 21.1.8 answers "invalid instruction" for gfx1013, gfx1030 and gfx1100.
    • The f16 dot2 forms that do exist (v_dot2_f32_f16, v_dot2c_f32_f16) are "not supported on this GPU" for gfx1013, the console's class.
    • The translator implements none of them.
    • Whether the translator needs a rule for them is a corpus question. I'll post it as a finding rather than guess.

#2992's DEBT entries for these two files can be dropped once both PRs are in. Its DEBT dict isn't checked for stale entries, so neither PR has to wait for the other.

Tested

Windows 11 Pro 26300, Python 3.12, CPU only. No GPU, llvm-mc or game files needed. llvm-mc was used only to check the mnemonics.

  • The new file: python -m unittest discover -s tests/semantic -p test_ballot_votes.py: 3 tests OK.

  • The full suite: python -m unittest discover -s tests/semantic: 4080 tests OK.

  • Negative control: I mutated tools/rdna2spirv.py so that s_bcnt1 or s_ff1 drop the high half of a lane mask (hi = self.cu(0) after their wave_mask), then restored it.

    Mutation New file Old file (main)
    s_bcnt1 8 failures 31/31 OK
    s_ff1 3 failures 31/31 OK
  • tests: a semantic test must reach tools/rdna2spirv.py #2992's guard: its offenders() from pr-2992, with an empty DEBT, on this tree reports only test_valu_div_fixup.py (TEST-545). The new test_ballot_votes.py reaches the translator.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…dot2acc_f16_f16 model (TEST-603)

test_ballot_votes.py modelled OpGroupNonUniform* in its own Python interpreter and never translated anything, so
it passed whatever tools/rdna2spirv.py did. It now translates a wave64 and a wave32 compute listing and runs every
lane with spirv_mini_interp.run_workgroup: a lane mask built in VCC from s4:s5, read through s_bcnt1, s_ff1,
s_cmp_eq vcc/exec (vote all), s_cmp_lg vcc/0 (vote any), a per-lane v_cndmask, and s_and_saveexec with
v_readfirstlane and s_bcnt1 exec (then EXEC restored), over 12 wave64 and 9 wave32 masks (lane 31/32 edges,
halves, checkerboards). Expected values come from the input pattern only.

Mutating the translator so s_bcnt1 or s_ff1 drop the high half of a lane mask fails the new file (8 and 3
failures); the old file passed 31/31 under both.

test_alu_dot2acc_f16.py is removed: v_dot2acc_f16_f16 is no RDNA2 instruction (llvm-mc 21.1.8: "invalid
instruction" for gfx1013, gfx1030 and gfx1100), the f16 dot2 forms that do exist (v_dot2_f32_f16,
v_dot2c_f32_f16) are not on gfx1013 and the translator implements none of them, so there is nothing to translate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted CPU review of f9de6c128ed9b86dca9a94691aececf87bea39e5.

The fixture can miss incomplete EXEC restoration for nonempty masks. The per-lane bit stores run before s_and_saveexec, and only two wave-wide values are written to shared addresses after the restore. In a scratch copy I moved the restore below those two stores. All 8 nonempty wave32 cases and all 11 nonempty wave64 cases produced identical memory. The empty cases did detect the missing EXEC-count store. A lane-indexed store immediately after the restore makes this observable. With bits 1 and 31 or 63 set, the delayed-restore control wrote only those two lane slots, while the intact listing wrote all slots. Could you add a lane-indexed write after the restore and assert every slot? Fixture and assertions

@TheHoracio

Copy link
Copy Markdown
Contributor Author

@whattheflop, thanks: you were right. Fixed in e8f5997f.

  • The change: after the restore, every lane writes a mark to its own slot at 0x200 + 4 * lane, and check() asserts all wave slots are 1.
  • Your control: I re-ran it by moving the restore below that store. It now fails all 19 nonempty masks (8 wave32, 11 wave64), with 19 failures in the new assertion. The listing as written still passes 3/3.

Windows 11, Python 3.12, CPU only. AI-assisted.

From @whattheflop's review of ItsNotRexed#3261: the per-lane stores ran before s_and_saveexec and only two wave-wide values
after the restore, so a restore that came too late passed for every nonempty mask. Each lane now writes a mark
after the restore and every slot is asserted. Moving the restore below that store fails all 19 nonempty masks
(8 wave32, 11 wave64); the listing as written passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted CPU retest of e8f5997f71fb24eaeb7a193a939da2409c45fad0. An independent bit-level oracle matched all lanes for 138 wave32 and 235 wave64 masks, including 352 masks beyond the fixture. Moving the restore below the marker store on eight masks outside the fixture made exactly the selected lanes write markers and tripped the new assertion each time, including a wave64 mask spanning lanes 31 and 32. This resolves my EXEC-restoration finding.

Both revised listings assembled with WSL LLVM 21.1.8 on gfx1013 and gfx1030. Both translated modules passed Vulkan 1.3 SPIR-V validation. uv CPython 3.12.13, synthetic inputs only.

@SebSilent

Copy link
Copy Markdown
Contributor

Second check on Linux (CachyOS, Python 3.14.10 venv, llvm-mc 23.1.5, CPU only, no game files), head e8f5997.

  • pytest tests/semantic/test_ballot_votes.py -q: 3 passed, 23 subtests passed.
  • Independent negative control: I added hi = self.cu(0) after the s_bcnt1 wave_mask in tools/rdna2spirv.py (dropping the high lane-mask half, as your mutation table describes). The wave64 case then fails 8 subtests (masks 0x5555..., 0xaaaa..., 0xffffffff00000000, ...); restoring the translator returns it to green. So the rewritten test genuinely exercises the translator and catches a high-half regression the old self-model test would have missed.
  • Confirmed the dot2acc removal: llvm-mc answers "invalid instruction" for v_dot2acc_f16_f16 and "not supported on this GPU (gfx1013)" for v_dot2_f32_f16, so there is nothing to translate there.

No blocking issue. AI-assisted (Tacit).

@ItsNotRexed
ItsNotRexed merged commit aa0f04b into ItsNotRexed:main Nov 23, 2026
5 of 7 checks passed
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.

4 participants