Skip to content

Translator: s_not_b32 on a wave32 lane mask votes its SCC (FUZZ-8 follow-up to #477) - #615

Open
tunczzz wants to merge 2 commits into
ItsNotRexed:mainfrom
tunczzz:fuzz-8-s-not
Open

tunczzz wants to merge 2 commits into
ItsNotRexed:mainfrom
tunczzz:fuzz-8-s-not

Conversation

@tunczzz

@tunczzz tunczzz commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Item: FUZZ-8 follow-up, claimed in #374: #374 (comment)

What

@kotorvr found in #477 that s_not_b32 has its own handler, which still set SCC from the invocation's own bit after #477 moved the 32-bit SOP2 forms to the wave vote. s_not_b32 s11, s8 with s8 = lanes 0-7 should give SCC = 1 in every lane (lanes 8-31 are set). Before this change, lanes 0-7 saw 0. It now goes through scc_logic like the SOP2 forms: a subgroup vote in wave32 when the source holds a lane mask or the result goes to EXEC, and D != 0 otherwise. s_not_b64 already voted.

Impact is small. @kotorvr counted no wave32 s_not_b32 on exec_lo/vcc_lo whose SCC is read in the corpus. This just closes the gap.

Plain-data s_not_b32 SCC is unchanged, so this doesn't overlap #568 (single-lane tests of the same ops).

Tests

  • Ubuntu (WSL), llvm-mc 21, SPIRV-Tools 2026.1, on b8f6c74: pytest tests --ignore=tests/semantic gives 1870 passed, 44 skipped, 1 xfailed; unittest discover -s tests/semantic OK; tests/test_run_gpu_tests.py OK.
  • cf_diff.py: 800 cases with --spirv-val, 800 in the dispatch-loop form, and 400 more after rebasing, all 0 mismatches.
  • build.py cs_scc_mask32 ps_scc_mask32: both translate and pass spirv-val.
  • Not run on a GPU by me (no Vulkan SDK here). cs_scc_mask32 should print out[0..7] = 7 0 0 9 11 13 7 13 on any GPU; wave32 runs natively on NVIDIA.

AI-assisted (Claude Code). No game data.

🤖 Generated with Claude Code

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Verified cs_scc_mask32 on Windows 11, RTX 5080, driver 616.92. The device reported subgroup size 32. One workgroup of 64 threads gave the following eight output words.

Translator GPU readback, words 0–7 Filtered GPU runner
PR b9c3664d5f3a8abc3d6b1c4f1e2a437c8b56fba4 7 0 0 9 11 13 7 13 PASS, exit 0
Parent b8f6c74bcee15c44ba9828c9f3695e787038ede6 7 0 0 4 11 13 7 13 FAIL, exit 1

I ran python -I scripts/run_gpu_tests.py --build build-runtime --filter cs_scc_mask32, then repeated with the PR's runner and only its translator path pointed at the parent checkout. The assembled inputs were byte-identical, and both translations passed spirv-val. The standalone check.py comparison also accepted the PR readback and rejected the parent's. The raw dump executable itself exits 0 on both.

Word 3 is written by lane 3. Complementing the lanes-0–7 mask leaves lanes 8–31 set, so the wave-wide SCC selects 9 even though lane 3's own result bit is zero. The other seven words stayed equal.

AI-assisted hardware verification using the PR's synthetic fixture.

tunczzz added a commit to tunczzz/Leonida that referenced this pull request Nov 22, 2026
Two wave64 findings of tools/cf_diff.py with new mask shapes:

- A register written to exec_lo (s_and_b32 exec_lo, exec_lo, vcc_lo;
  s_mov_b32 exec_lo, s0) set all 64 lanes, and any op but s_mov_b32
  into exec_hi was rejected ("destination exec_hi"). dst() now writes
  one half through exec_half_write; the other half keeps its lanes.
- The SCC of a 32-bit op on one half of a mask (vcc_lo/hi, exec_lo/hi,
  a half-mask SGPR) took the lane's own bit. scc_logic now votes over
  that half (scc_any_half). The half comes from the sources, or from an
  EXEC/VCC destination; an SGPR destination's old half is ignored.

A program with no SCC reader (s_cbranch_scc*, s_cselect, s_addc/subb,
s_cmov*, an scc operand) skips the vote, so --wave64-emulate does not
pay an exchange for an SCC nobody reads (keeps
test_wave64_emulate_reuses_a_mask_exchange at its counts).

Fuzzer: cf_ref treats every _b32 op as a 32-bit word op (halves
included) and models s_cmp_eq/lg_u64 and s_cselect_b64; cf_diff adds
e64 compares into SGPR masks (saveexec, v_cndmask), constant EXEC,
half-EXEC ops, half-mask SCC, s_cmp on masks and s_cselect between
masks, and counts literals in instruction sizes. GPU test
cs_w64_exec_half (wave64 dump; expected 1 0 1 1 0 3 9 9).

Depends on: ItsNotRexed#615

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

@IAmNotSiob IAmNotSiob left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice cleanup, s_not_b32 now goes through scc_logic like the other bitwise ops. tests pass with main (805) :) AI-assisted review (Claude Code).

@matheuskshn

Copy link
Copy Markdown
Contributor

Ran a separate seed on e3b5c3b on Windows 11 / Python 3.12.14. python -I tools/cf_diff.py --programs 12 --seed 17 gave 24 passes across wave32 and wave64, with 0 mismatches, skips, or harness errors. This is CPU differential coverage of the structured campaign. AI-assisted.

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested e3b5c3b on RTX 4090 (driver 621.14, 32-wide subgroups), Windows 11 26200: pass

  • RelWithDebInfo Ninja build of runtime/ (MSVC, Vulkan SDK 1.4.363.0); ctest: 27/27
  • python -I scripts/run_gpu_tests.py: 60/86 passed, 26 skipped (wave64 tests); with LEONIDA_W64_EMULATE=1: 86/86. main c432cdc on the same machine: 59/85 and 85/85. The new cs_scc_mask32 gives 7 0 0 9 11 13 7 13 in both modes
  • python -m unittest discover -s tests/semantic: 805 OK
  • python -m pytest tests --ignore=tests/semantic: 2017 passed, 5 skipped, 1 xfailed (main: 2009 passed)

No game files used. AI-assisted run (Claude Code).

@realmalikov

Copy link
Copy Markdown

Tested #615 (e3b5c3b) on an NVIDIA GTX 1060 6GB (Pascal, subgroup 32..32, NVIDIA 582.78,
Windows 11 10.0.26200). No game files.

cs_scc_mask32, native wave32 (1 group x 64): 0 mismatches,
out[0..7] = 7 0 0 9 11 13 7 13 (the expected words)
AI-assisted.

@Tanju42

Tanju42 commented Nov 22, 2026

Copy link
Copy Markdown

Tested e3b5c3b10cd9b9db3b8518cc67d43205cb1017a4 on two Linux devices, Ubuntu 24.04 (kernel 7.0.0-43-generic), llvm-mc 21.1.8:

  • AMD Ryzen 7 9800X3D iGPU (gfx1036, RADV RAPHAEL_MENDOCINO), Mesa 25.2.8-0ubuntu0.24.04.4, subgroup 32..64
  • NVIDIA GeForce RTX 5060 Ti, driver 595.99.02, subgroup 32..32

cs_scc_mask32 PASSES on both and prints exactly 7 0 0 9 11 13 7 13, matching the expected out[0..7] from the coordination item (FUZZ-11); 1/1 passed, shader translates with spirv-val clean on each device.

The CONFLICTING status against main did not block testing: I ran the PR head in its own worktree with the PR's own run_gpu_tests.py/rdna2spirv.py/check.py, reusing only the harness binaries (this PR touches no C++ under runtime/). So the fix itself is verified on one RDNA2 and one NVIDIA device; the rebase is all that stands between this and a merge. No game files. AI-assisted.

tunczzz and others added 2 commits November 22, 2026 22:36
…low-up to ItsNotRexed#477)

s_not_b32 has its own handler and still set SCC from the lane's own bit
after ItsNotRexed#477 moved the SOP2 forms to the wave vote. It now goes through
scc_logic too (one or two sources). Reported by @kotorvr in ItsNotRexed#477.

- tools/cf_ref.py models s_not_b32/b64; tools/cf_diff.py generates s_not
  in the sccmask/csel shapes; tests/test_cf_diff.py has the two s_not
  regression cases (and they fail with the old per-lane SCC).
- runtime/test/shaders/cs_scc_mask32.asm: @kotorvr's compute test for
  s_and + s_cselect, s_andn2 + s_cbranch_scc1, s_not, s_or, s_xnor,
  registered as a wave32 dump in check.py and run_gpu_tests.py.
- docs/design.md: s_not_b32 in the rule, the ItsNotRexed#477 GPU results and
  @kotorvr's corpus count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es, as main's new rule)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tunczzz added a commit to tunczzz/Leonida that referenced this pull request Nov 22, 2026
Two wave64 findings of tools/cf_diff.py with new mask shapes:

- A register written to exec_lo (s_and_b32 exec_lo, exec_lo, vcc_lo;
  s_mov_b32 exec_lo, s0) set all 64 lanes, and any op but s_mov_b32
  into exec_hi was rejected ("destination exec_hi"). dst() now writes
  one half through exec_half_write; the other half keeps its lanes.
- The SCC of a 32-bit op on one half of a mask (vcc_lo/hi, exec_lo/hi,
  a half-mask SGPR) took the lane's own bit. scc_logic now votes over
  that half (scc_any_half). The half comes from the sources, or from an
  EXEC/VCC destination; an SGPR destination's old half is ignored.

A program with no SCC reader (s_cbranch_scc*, s_cselect, s_addc/subb,
s_cmov*, an scc operand) skips the vote, so --wave64-emulate does not
pay an exchange for an SCC nobody reads (keeps
test_wave64_emulate_reuses_a_mask_exchange at its counts).

Fuzzer: cf_ref treats every _b32 op as a 32-bit word op (halves
included) and models s_cmp_eq/lg_u64 and s_cselect_b64; cf_diff adds
e64 compares into SGPR masks (saveexec, v_cndmask), constant EXEC,
half-EXEC ops, half-mask SCC, s_cmp on masks and s_cselect between
masks, and counts literals in instruction sizes. GPU test
cs_w64_exec_half (wave64 dump; expected 1 0 1 1 0 3 9 9).

Depends on: ItsNotRexed#615

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

tunczzz commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main aa2988cc (now 15a9482e). Only the merge changed: the s_not_b32 fix and cs_scc_mask32 are the same. Conflicts were resolved by keeping main's side and re-adding this PR's lines:

The earlier GPU results still apply: the shader and the translator rule didn't change. Tested in WSL Ubuntu (Python 3.14, llvm-mc 21) together with #663: pytest tests --ignore=tests/semantic gives 6434 passed and 1 failed. The failure is test_u16_high_half.py::test_d16_buffer_store_no_redundant_extract_after_shr16, which fails the same way on plain main aa2988cc here (spirv-val: %135 used before its definition), so it isn't from this PR. AI-assisted (Claude Code).

@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 15a9482e (the rebased head) on NVIDIA GeForce RTX 3060 Ti (subgroup 32..32), driver 580.173.02, Linux (kernel 6.18), Python 3.14: pass.

  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped, 0 failed. cs_scc_mask32 prints 7 0 0 9 11 13 7 13, the expected words.
  • ctest: 47/47 passed.
  • pytest tests/test_cf_diff.py tests/test_run_gpu_tests.py: 83 passed. With main's tools/ (aa2988c), 6 fail. All 6 are the new s_not_b32 cases, because main's cf_ref doesn't model s_not_b32.

No game files. AI-assisted (Claude Code).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 15a9482 (merge base aa2988c) on NVIDIA GeForce RTX 5080, Linux 580.65.06: pass

Tested the PR head merged with current main 03b09a08 (clean merge, not pushed). Runtime harnesses built from main 03b09a08 (no PR in this list changes C++/CMake), llvm-mc 21, Python 3.13, Vulkan SDK 1.4.363, Linux native.

Check main 03b09a08 this PR
run_gpu_tests.py native 164/210 passed, 46 skipped 165/211 passed, 46 skipped
run_gpu_tests.py with LEONIDA_W64_EMULATE=1 195/210 passed, 15 skipped 196/211 passed, 15 skipped
failed (native / emulated) 0 / 0 0 / 0
tests/semantic/regen_fixtures.py --check ok ok
pytest tests/test_cf_diff.py tests/test_run_gpu_tests.py + tests/test_shader_checks.py 156 passed (3 shared files) 162 passed, 286 subtests passed in 3.42s

Line-by-line against my main run (results that differ from main):

  • native:
    • cs_scc_mask32 main: - pr: PASS 7 0 0 9 11 13 7 13
  • emulated:
    • cs_scc_mask32 main: - pr: PASS 7 0 0 9 11 13 7 13

PR-specific: cs_scc_mask32 (the test this PR adds) printed 7 0 0 9 11 13 7 13 natively and emulated, the expected words; tests/test_cf_diff.py and tests/test_run_gpu_tests.py pass (the new s_not_b32 cases included).

Not run: the full unittest discover -s tests/semantic (7456 tests, about 6 minutes; on main alone it shows 7 failures and 2 errors in test_cmp_class_f64, test_loop_ballot_barrier and test_mutations, so I did not repeat it per PR); only the test files this PR touches plus the shared checker tests ran. No other GPU vendor, no Windows. No game files.

AI-assisted (Claude Code).

@Mast3rL

Mast3rL commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 15a9482e on AMD Radeon RX 9070 (RDNA4, gfx1201), RADV / Mesa 26.2.6, Fedora 44 Linux, llvm-mc 21: pass.

  • scripts/run_gpu_tests.py (Linux build of the PR head): 197/211 passed, 14 skipped, 0 failed. The only difference from main (03b09a08, 196/210) is the new cs_scc_mask32: PASS, output 7 0 0 9 11 13 7 13 as expected.
  • tests/test_cf_diff.py (pytest): 43 passed. tests/test_run_gpu_tests.py: OK.
  • tests/semantic: 7 failures + 2 errors, the same 9 as on main at 03b09a08 on this machine (loop/ballot emulation, v_mul_legacy_f32 mutation, v_cmp_class_f64 rejected forms), so none come from this PR.

AI-assisted (Claude Code).

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.

10 participants