Skip to content

GPU test cs_w64x_maskbits: s_bcnt0/s_ff0/s_flbit scans of 64-bit masks in a wave64 - #2546

Open
Vonsek wants to merge 8 commits into
ItsNotRexed:mainfrom
Vonsek:claude/w64x-laneops
Open

Vonsek wants to merge 8 commits into
ItsNotRexed:mainfrom
Vonsek:claude/w64x-laneops

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-W64-LANEOPS, #2300 (comment)

Depends on: #2455 (stacked on it, which is stacked on #2415: the branch adds an entry to W64X_FULL in check.py; until they land the diff shows their commits too).

What and why

The scalar bit scans s_bcnt1_i32_b64 and s_ff1_i32_b64 are used in many wave64 tests, but s_bcnt0_i32_b64, s_ff0_i32_b64 and the 64-bit s_flbit ops have no wave64 GPU test (s_flbit_i32_b64/i64 only run in the wave32 cs_w32_salu64). A translation that scans only the low word, swaps the words, or counts the zeros of one word is wrong only for values with bits in the upper 32 lanes. This adds cs_w64x_maskbits, one 64-lane group, 64 words:

  • s_bcnt0_i32_b64 (value and the SCC it writes) and s_ff0_i32_b64 of 13 values: v_cmp lane masks with only the high half set (lanes 32..63, lane 40, lanes 62 and 63, lane 32), a low-half-only mask, all lanes, no lane, lanes 0..39 (the first zero is in the high half), and s_mov_b32 data pairs.
  • s_flbit_i32_b64 and s_flbit_i32_i64 of five data pairs (bit 55, 0xffffffff_00000000, all but bit 63, only bit 63, bit 40).
  • the same bcnt0/ff0/SCC read from EXEC itself with EXEC set by v_cmpx to lanes 32..63, 62..63, lane 32, 0..39 and 0..31.

The .asm header gives the ISA definitions, every value as a 64-bit constant and each result derived by hand; W64X_MASKBITS_WORDS in check.py is the same formulas in plain Python. The same shader is a semantic fixture (test_w64x_maskbits_fixture.py: hand constants, a bit-by-bit model, and the translated shader run on 64 lanes in the wave interpreter).

No translator change. s_flbit_i32_b64/i64 of a lane mask or EXEC is still Unsupported by design (#210, docs/design.md), so those two run on data pairs only.

Tested

  • AMD Radeon iGPU (Ryzen 9 9950X3D, driver 26.10.1), native wave64 (compute subgroup size: 64): run_gpu_tests.py --filter cs_w64x_maskbits 64/64 words exact.
  • RTX 5080 (driver 616.92) with LEONIDA_W64_EMULATE=1 (--wave64-emulate): 64/64 words exact.
  • Negative controls (each fails, then reverted): s_bcnt0_i32_b64 not inverting the high word (Radeon: word 0 expected 0x20, got 0x40); s_ff0_i32_b64 returning 0 instead of -1 when the high word is all ones (Radeon: word 13 expected 0xffffffff, got 0).
  • python -m unittest discover -s tests/semantic OK; python tests/semantic/regen_fixtures.py --check clean; python -I tests/test_shader_checks.py OK.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No new translator rule, so no contract row.

AI-assisted.

v_add_co_u32, v_add_co_ci_u32, v_sub_co_u32, v_subrev_co_u32, v_sub_co_ci_u32 and
v_subrev_co_ci_u32 with the carry-out in an SGPR pair or in VCC and the carry-in from an
SGPR pair or from VCC, per lane of one 64-lane group. The carry-in mask differs between
the two halves, so a mask cut to its low word or with its words swapped shows. The test
dumps 922 words (13 ops x 64 lanes, a flag word per lane, s_bcnt1 / s_ff1 of every mask),
derived from the ISA pseudocode in the .asm header. The wave32 counterpart is
cs_w32_dot4_carry (ItsNotRexed#2311).

check.py gets W64X_FULL for wave64 tests judged on a whole dump (--require-wave64, a skip
on a device without 64-wide subgroups, no flag with LEONIDA_W64_EMULATE=1).

AI-assisted.
v_cmp i32/u32/i64/u64/f32 (NaN, infinity, class) into SGPR pairs and into VCC, the 64-bit
SALU logic ops on those masks (s_and/or/xor/andn2/orn2/nor/xnor_b64), and v_cndmask with
the masks as selectors, per lane of one 64-lane group. The inputs differ between the two
halves, so a mask cut to its low word, with its words swapped, or from a 64-bit compare of
the low words alone is a different mask. The test dumps 430 words (a flag word per lane,
five v_cndmask selections, s_bcnt1 / s_ff1 of every mask), derived from the ISA pseudocode
in the .asm header.

AI-assisted.
s_bcnt0_i32_b64 (and its SCC), s_ff0_i32_b64 on v_cmp masks, s_mov_b32 data
pairs and EXEC with little or nothing in the low half, and s_flbit_i32_b64 /
s_flbit_i32_i64 on the data pairs. Expected words are derived by hand in the
.asm header; the same shader is a tests/semantic fixture.

AI-assisted.
@Rainmaker33

Copy link
Copy Markdown

Tested 867fceb on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass.

The PR's diff applied cleanly to main 4947579. VS 2022, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8; harness programs from a CMake build of that main; overlay layers off.

  • scripts/run_gpu_tests.py: 139/188 pass, 49 skipped, no failures. cs_w64x_maskbits skips natively (no 64-wide subgroups).
  • With LEONIDA_W64_EMULATE=1 --filter cs_w64x_maskbits: pass, "64/64 dumped words exact". The cs_w64x_carry (922/922) and cs_w64x_vcmp (430/430) fixtures in this branch also pass emulated.
  • tests/semantic/test_w64x_maskbits_fixture.py: OK. tests/test_shader_checks.py: OK.

@ricarmandoagent

Copy link
Copy Markdown

Tested 867fceb6 on NVIDIA GeForce RTX 4060 (Ada, AD107; Vulkan subgroupSize 32..32, so wave64 is emulated), NVIDIA 620.70.06, Vulkan 1.4.357, Bazzite 45 / Linux 7.3.4 (Wayland).

Test programs built from 4947579 (this PR changes no runtime/ C++):

LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w64x_maskbits
  PASS  cs_w64x_maskbits      64/64 dumped words exact
1/1 passed

The scalar bit scans of the 64-bit masks (s_bcnt0, s_ff0, s_flbit) are exact on a 32-wide device under --wave64-emulate, i.e. not only on native 64-wide AMD hardware. .spv passed spirv-val (LLVM 23.1.5). AI-assisted run on a contributor machine.

@AC-Storm-YT

Copy link
Copy Markdown
Contributor

Tested 867fceb natively on two AMD GPUs (64-wide subgroups, no emulation), Windows 11, VS 2026, Vulkan SDK 1.4.363.1, llvm-mc 21.1.8, test programs built from this branch:

GPU (picked with LEONIDA_VK_DEVICE) cs_w64x_maskbits cs_w64x_carry / cs_w64x_vcmp --filter cs_w64x
RX 9070 XT (RDNA4), driver 32.0.31041.1004 64/64 exact 922/922, 430/430 22/22
Ryzen 7 9800X3D iGPU (RDNA2), driver 32.0.21045.5002 64/64 exact 922/922, 430/430 22/22
  • Negative control for s_flbit, which the description's two controls don't cover: with the 64-bit s_flbit source pair swapped (hi, lo loaded from s[n], s[n+1]), the test fails on the RX 9070 XT at word 39: expected 0x00000008, got 0x00000028. That's bit 55 read as bit 23, so 63 − 23 = 40 instead of 63 − 55 = 8. Reverted afterwards.
  • python -m unittest discover -s tests/semantic: OK (the three new fixture tests included), regen_fixtures.py --check: clean, tests/test_shader_checks.py: OK.

AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (MSVC 14.51, llvm-mc 23.1.6): cs_w64x_maskbits builds and skips cleanly on both the RTX 4080 SUPER and the Intel UHD 770 (no 64-wide compute subgroup on this device), so it needs an AMD GPU to actually run.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 867fceb on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:

  • scripts/run_gpu_tests.py: 139/188 passed, 49 skipped, 0 failed. main 4947579 gives 139/185, 46 skipped, 0 failed. All 193 test shaders translate and pass spirv-val.
  • New GPU tests: cs_w64x_carry SKIP, cs_w64x_maskbits SKIP, cs_w64x_vcmp SKIP.
  • tests/semantic/test_w64x_carry_fixture.py: ran 3 tests in 2.840s; OK.
  • tests/semantic/test_w64x_maskbits_fixture.py: ran 3 tests in 3.093s; OK.
  • tests/semantic/test_w64x_vcmp_fixture.py: ran 4 tests in 2.934s; OK.
  • tests/test_shader_checks.py: ran 60 tests in 1.234s; OK.

The three new cs_w64x_* programs need 64-wide subgroups, so they skip on this 32-wide card. An AMD run is still needed for their results.

AI-assisted (Claude Code).

Conflicts:
	scripts/run_gpu_tests.py
	tests/test_shader_checks.py

AI-assisted.
@crastinator

Copy link
Copy Markdown
Contributor

Tested 49dcdf4 merged into main 16282101 (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • New tests pass natively: cs_w64x_carry (922/922 dumped words exact); cs_w64x_maskbits (64/64 dumped words exact); cs_w64x_vcmp (430/430 dumped words exact).
  • Whole run_gpu_tests.py: 180/194 native, 180/194 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 37/37.
  • tests/semantic/test_w64x_carry_fixture.py, tests/semantic/test_w64x_maskbits_fixture.py, tests/semantic/test_w64x_vcmp_fixture.py, tests/test_shader_checks.py: 81 passed, 1629 subtests passed.

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

@bvtterbroot

Copy link
Copy Markdown

Tested 49dcdf4 on AMD Radeon RX 7900 XTX (RDNA3, Navi 31; native wave32 and wave64), AMD driver 26.11.2, Vulkan 1.4.359, Windows 11: pass.

  • run_gpu_tests.py: 180/194 passed, 14 skipped; the new cs_w64x_carry, cs_w64x_maskbits, cs_w64x_vcmp pass.
  • python -I -m unittest discover -s tests/semantic -p test_w64x_carry_fixture.py: 3 tests OK.
  • python -I -m unittest discover -s tests/semantic -p test_w64x_maskbits_fixture.py: 3 tests OK.
  • python -I -m unittest discover -s tests/semantic -p test_w64x_vcmp_fixture.py: 4 tests OK.
  • python -I tests/semantic/regen_fixtures.py --check: clean.
  • python -I tests/test_shader_checks.py: 69 tests OK.

Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 14.44.

@MeNoSkills

Copy link
Copy Markdown
Contributor

Tested 49dcdf4b merged into current main f847748c (clean auto-merge; the PR head itself is 1224 commits behind main, so it will need a rebase before it can land) on Windows 10 Pro 19045, llvm-mc 23.1.6, runtime test programs built from main:

  • AMD Radeon Graphics, Ryzen 7 9700X iGPU (RDNA2, native wave64, AMD driver 24.30.18, Windows): run_gpu_tests.py --filter cs_w64x_ → 25/25 passed. The new tests are exact: cs_w64x_carry 922/922 and 64/64 dumped words, cs_w64x_maskbits 64/64 (twice), cs_w64x_vcmp 430/430 and 64/64. This is the Windows AMD RDNA2 driver, the one AMD Windows driver crashes creating lds_fuzz wave64 programs translated with --wave64-emulate #857 is about, which the Linux RADV result above does not cover.
  • NVIDIA GeForce RTX 4070 Ti (621.24, 32-wide): 3/25 passed, 22 skipped (no 64-wide compute subgroup), as designed. The three emulated variants that do run are exact: cs_w64x_carry 64/64, cs_w64x_maskbits 64/64, cs_w64x_vcmp 64/64.

I did not run the semantic suite or the rest of run_gpu_tests.py on this head. AI-assisted (Claude Code).

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested 49dcdf4b, applied alone on main f847748c: the new fixtures pass, with one finding in scripts/run_gpu_tests.py.
Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo. Two GPUs: Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62) and RTX 3070 (NVIDIA 610.74), picked with LEONIDA_VK_DEVICE. Test programs built from f847748c (the PR changes no C++); the same build for all runs.

The three new fixtures, --filter cs_w64x_:

cs_w64x_maskbits cs_w64x_carry cs_w64x_vcmp
Radeon iGPU, native (subgroup 32..64) 64/64 exact 922/922 exact 430/430 exact
Radeon iGPU, LEONIDA_W64_EMULATE=1 64/64 exact 922/922 exact 430/430 exact
RTX 3070, native (subgroup 32..32) SKIP (no 64-wide compute subgroup) SKIP SKIP
RTX 3070, LEONIDA_W64_EMULATE=1 64/64 exact 922/922 exact 430/430 exact
  • Whole run_gpu_tests.py, no new failure in any of the four runs. Against f847748c per test, the only differences are the three new tests and cs_fmt_sint32 (below). Radeon native 189/204 passed, 15 skipped (main: 184/199, 15 skipped); Radeon emulated 189/204, 15 skipped (main 184/199); RTX 3070 native 154/204, 49 skipped, 1 failed (main 152/199, 46 skipped, 1 failed); RTX 3070 emulated 188/204, 15 skipped, 1 failed (main 183/199, 15 skipped, 1 failed). The one failure is ps_sdwa_f16_const on the RTX 3070, which also fails on main here (rdna2spirv: widen f16 denormal operands without UnpackHalf2x16 (NVIDIA reads them as 0) #3220).
  • test_w64x_carry_fixture.py 3 tests OK, test_w64x_maskbits_fixture.py 3 OK, test_w64x_vcmp_fixture.py 4 OK, regen_fixtures.py --check clean, tests/test_shader_checks.py 70 tests OK.

Finding: the merge of main into the branch (49dcdf4b) put the new W64X_FULL branch of run_suite between cs_fmt_sint32's test call and its results.append. At the head, scripts/run_gpu_tests.py lines 842-854 read:

        elif name == "cs_fmt_sint32":
            problem = fmt_sint32_test(a.build, spirv_dir, cs_env)
        elif name in dict(W64X_FULL):
            ...
                results.append((name, ok, problem or f"{len(want)}/{len(want)} dumped words exact"))
            results.append((name, not problem, problem or "64/64 dumped words exact"))

That last line belonged to cs_fmt_sint32. Measured effects:

  1. cs_fmt_sint32 runs but is no longer reported. --filter cs_fmt_sint32 gives PASS ... 1/1 passed on main and exits 2 with "selected cs_fmt_sint32 but no runnable GPU test cases" with the PR, on both GPUs. With one expected word of FMT_SINT32_WORDS changed as a control, main reports FAIL cs_fmt_sint32 word 3: expected 0x00000002, got 0x00000001 on both GPUs; with the PR the same control gives no FAIL line. In the whole suite the test just disappears from the list.
  2. Each of the three new tests is reported twice, the second time as "64/64 dumped words exact" whatever its size (the totals above are 199 - 1 + 6 = 204 for that reason).
  3. On a GPU without 64-wide subgroups the second line is a false pass: problem is None for the skip, so not problem is true. RTX 3070, native: SKIP cs_w64x_maskbits followed by PASS cs_w64x_maskbits 64/64 dumped words exact, the same for carry and vcmp, although nothing ran. --filter cs_w64x_maskbits --require-pass exits 0 there with "1/2 passed, 1 skipped"; --filter cs_w64x_ballot --require-pass on main exits 1 with "no GPU tests passed".

Moving the results.append((name, not problem, problem or "64/64 dumped words exact")) line back under cs_fmt_sint32 fixes all three here: cs_fmt_sint32 1/1 on both GPUs, cs_w64x_maskbits one line each (PASS on the Radeon, SKIP on the RTX 3070 native, PASS emulated), and --require-pass exits 1 on the RTX 3070 native again. The whole suite with that one line moved gives 202 results, and the only per-test differences from main are the three new tests: Radeon 187/202 passed, 15 skipped, native and emulated; RTX 3070 native 152/202, 49 skipped, 1 failed; RTX 3070 emulated 186/202, 15 skipped, 1 failed.

Read, not measured: tests/test_shader_checks.py has the same merge slip in its fake runner (lines 71-82 at the head): the W64X_FULL block sits between the cs_fmt_sint32 branch's write_bytes and its return 0, "", which is now unreachable after the new block's own return. The 70 tests still pass, so they do not catch it.

Not checked: the description's translator negative controls were not repeated. GitHub reports the branch as mergeable.

scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py
tests/test_shader_checks.py

AI-assisted.
@amarovndres

Copy link
Copy Markdown

Tested 05943b5e (the current head; the last check was on 49dcdf4b) on AMD Radeon RX 9060 XT (RDNA4, discrete, subgroup 32..64), AMD 26.10.1 (32.0.32015.7029, LLPC, Vulkan 1.4.359), Windows 11 Pro (build 26200): pass.

  • scripts/run_gpu_tests.py (full suite; test programs built from this head with llvm-mingw, llvm-mc 23.1.6): 201/215 passed, 14 skipped, 0 failed. cs_w64x_maskbits 64/64 (both dumps), cs_w64x_carry 922/922 + 64/64, cs_w64x_vcmp 430/430 + 64/64 dumped words exact. main d0835dd9 on the same machine: 196/210, the same 14 skipped, so nothing regresses.
  • tests/semantic/test_w64x_*_fixture.py and tests/test_shader_checks.py: OK.

AI-assisted (Claude Code). Synthetic shaders only, no game files.

@bobcatchris

Copy link
Copy Markdown
Contributor

Tested 05943b5eecafcab317829737b03ec718b5418ebd on AMD Radeon Pro V540 (RDNA1, Navi 12; RADV/Mesa 25.2.8-0ubuntu0.24.04.4, Ubuntu 24.04.4, Linux 7.0.0-31-generic, Vulkan 1.4.318, subgroup range 32..64). The box is described as gfx1012; tools/hw_oracle reports gfx1011 for this Navi 12 part. PCI 1002:7360.

  • GPU pinning: DRI_PRIME=pci-0000_1c_00_0! and DRI_PRIME=pci-0000_1f_00_0! (two different cards, one process each).
  • Command: python3 -I scripts/run_gpu_tests.py --filter cs_w64x_maskbits --build runtime/build/linux: 2/2 passed (64/64 and 64/64 dumped words exact) on both cards; same with LEONIDA_W64_EMULATE=1.
  • Command: python3 -I scripts/run_gpu_tests.py --build runtime/build/linux: 187/215 passed, 26 skipped, 2 failed on both cards (217 shaders translated, 217 pass spirv-val); with emulation also 187/215. Base aa2988cc in a separate worktree with the same toolchain: 182/210 passed, 26 skipped, 2 failed. The extra passing tests are this PR's new fixtures; no regression.
  • The two failures (cs_signed_zero_nan, cs_w32_salu64) are pre-existing with identical words on base.
  • Toolchain note: built with current Khronos Vulkan-Headers 1.4.335 (-DVulkan_INCLUDE_DIR=...) because this head's vk_harness uses VK_KHR_pipeline_binary, absent from Ubuntu 24.04's 1.3.275 headers. GCC 13.3.0, llvm-mc 21.1.8, SPIRV-Tools 2026.1.

Counts and pass/fail only; no game data. No code changes.

AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested 05943b5e merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: fail. The new fixtures pass, but the cs_fmt_sint32 merge slip @zzEmmazz reported at 49dcdf4b is still in this head: run_gpu_tests.py no longer reports cs_fmt_sint32 and reports each new test twice.

  • The merge was clean. The PR changes no C++ or CMake, so the test programs are from a d0835dd9 build.
  • New fixtures pass, native and with LEONIDA_W64_EMULATE=1: cs_w64x_carry 922/922, cs_w64x_vcmp 430/430 and cs_w64x_maskbits 64/64 dumped words exact. --filter cs_w64x_ gives 25/25 in both modes.
  • Whole run_gpu_tests.py: 201/215 passed, 14 skipped, native and emulated. d0835dd9 without the PR gives 196/210, 14 skipped, in both modes.
  • Per-test comparison with d0835dd9: no common test changes status. There are two differences:
    • cs_fmt_sint32 is missing from both PR runs.
    • Each of cs_w64x_carry/vcmp/maskbits appears twice. The second line always reads "64/64 dumped words exact", even for the 922- and 430-word tests.
    • That accounts for the totals: 210 - 1 + 6 = 215.
  • --filter cs_fmt_sint32: with the PR it exits 2 with selected cs_fmt_sint32 but no runnable GPU test cases. On d0835dd9 it gives PASS cs_fmt_sint32 64/64 dumped words exact, 1/1, exit 0.
  • Cause: in run_suite the cs_fmt_sint32 branch lost its results.append((name, not problem, problem or "64/64 dumped words exact")). That line now sits after the new W64X_FULL block.
  • Fix checked here: moving that one line back under cs_fmt_sint32 (a local probe, reverted afterwards) gives cs_fmt_sint32 1/1. Each new test then gets a single line: carry 922/922, vcmp 430/430, maskbits 64/64.
  • This GPU has 64-wide subgroups, so I could not reproduce the false PASS after a SKIP on 32-only devices.
  • Python tests:
    • test_w64x_carry_fixture.py 3 OK, test_w64x_maskbits_fixture.py 3 OK, test_w64x_vcmp_fixture.py 4 OK.
    • regen_fixtures.py --check exits 0.
    • tests/test_shader_checks.py 75 tests OK.
    • Read, not measured: in the fake runner of tests/test_shader_checks.py, the cs_fmt_sint32 branch has no return, and a second return 0, "" can never run. Both are already on main d0835dd9, so they are not from this PR; the PR only puts its new W64X_FULL block above that line.

No game files. 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.