Skip to content

GPU test cs_w64x_carry: carry chains over the 64 lanes of a wave64 - #2415

Open
Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-w64x-carry
Open

Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-w64x-carry

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-CARRY, #2300 (comment)

What and why

The carry ops 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 have a wave32 GPU test (cs_w32_dot4_carry, #2311) but none for wave64, where the carry-out and carry-in are a 64-bit SGPR pair or VCC. This adds cs_w64x_carry, one 64-lane group (a cs_w64x_* cross-half test):

  • 13 ops: a plain add, an add with carry-in, a three-stage carry ripple through SGPR pairs, v_sub_co, v_subrev_co, v_sub_co_ci, v_subrev_co_ci, a VOP2 v_sub_co_ci_u32 with VCC as carry-in and carry-out, and a three-stage VCC chain.
  • The carry-in mask is 0x0ff0a55b_5a5a5a5a, so it differs between the halves, and the boundaries (carry at lane 22, 32, 47) sit on lanes whose carry-in decides the result. A mask cut to its low word, with its words swapped, or a carry-in read from the wrong word changes the output.
  • 922 words: the result of every op per lane, one flag word per lane (the carry mask read back with v_cndmask, so the check does not depend on how an SGPR pair reads as data), and s_bcnt1_i32_b64 / s_ff1_i32_b64 of every mask.
  • The .asm header derives the masks and sample words from the ISA pseudocode; W64X_CARRY_WORDS in check.py is the same formulas in plain Python.

check.py gets W64X_FULL, a list of wave64 tests judged on every word of the dump (--require-wave64, a skip where the device has no 64-wide subgroup, no flag under LEONIDA_W64_EMULATE=1), and run_gpu_tests.py runs it. The same shader is a semantic fixture (test_w64x_carry_fixture.py: hand constants, a plain-Python model, and the translated shader run on 64 lanes in the wave interpreter). No translator change; it passed as it was.

Tested

  • AMD Radeon iGPU (Ryzen 9 9950X3D, driver 26.10.1), native wave64 (compute subgroup size: 64): run_gpu_tests.py --filter cs_w64x_carry 922/922 words exact.
  • RTX 5080 (driver 616.92) with LEONIDA_W64_EMULATE=1 (--wave64-emulate, 32-wide subgroups): 922/922 words exact.
  • Negative controls (each fails, then reverted): s_bcnt1_i32_b64 of a lane mask counting only the low word (word 896 expected 0x20, got 0, on both devices); dropping the carry that comes from adding the carry-in in the _co_ci ops (Radeon: word 257 expected 0x80000000, got 0x7fffffff).
  • python -m unittest discover -s tests/semantic: 2570 tests OK (3 skipped); 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.
@duudiis

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Tested cbb7d4f11ae7c6070a2e4525d2dde99eea9e2ce5 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro build 26300: pass.

I translated the checked-in synthetic cs_w64x_carry.s fixture with WAVE64_EMULATE=True, assembled and validated it for Vulkan 1.2 with SPIRV-Tools 2026.4, and used the repo's vk_compute_test with required subgroup size 32. All 922 words matched in each of five independent dispatches. The two words past the expected writes retained their fill pattern. A local negative control zeroing only the upper carry-in mask word caused 74 differences against the unchanged expected output.

All 60 test_shader_checks.py tests and all three focused carry-fixture CPU tests passed. This is verification of emulated wave64 on NVIDIA. Synthetic inputs only. AI-assisted verification.

@TurboSosiska304

Copy link
Copy Markdown

Tested cbb7d4f on AMD Radeon RX 570 (Polaris 10, gfx803), RADV Mesa 26.2.6-arch3.1, Vulkan 1.4.354, CachyOS (kernel 7.3.4). Compute subgroup 64..64, so this is native wave64 on a GCN4 part — a different generation and driver from the runs in the description.

  • python3 -I scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w64x_carry → PASS, 922/922 dumped words exact.
  • python3 -m unittest discover -s tests/semantic -p "test_w64x_carry_fixture.py" → 3 tests OK.
  • python3 -I tests/test_shader_checks.py → 60 tests OK.

No failures and no skips on this device. A full run_gpu_tests.py run on the same commit is still going; I will add its counts here when it finishes.

On the code: W64X_FULL + dump_test(..., wave64=True) returns None on exit 77 and asks for the compute subgroup size: 64 confirmation, which matches how W64X_DUMPS is skipped, and it drops --require-wave64 under LEONIDA_W64_EMULATE=1 as the other wave64 tests do. Nothing looked off in the 922-word model.

@TurboSosiska304

Copy link
Copy Markdown

Full run on the same commit (cbb7d4f), RX 570 / RADV Mesa 26.2.6, native wave64: 143/186 passed, 42 skipped, 1 failed, build.py 191/191 translated and spirv-val clean.

The single failure is not from this PR:

  FAIL  cs_barrier_loop       4008636142 4008636142 4008636142 4008636142 128 64 64 4008636142

That is #2407: on a device with only 64-wide subgroups the runner judges this wave32 fixture after vk_compute_test answers compute subgroup size: 32 not available. I reproduced it on plain main (4947579) without any PR, and #2411 turns it into a skip (143/186 passed, 43 skipped, 0 failed). Everything else, including cs_w64x_carry, passes.

@gilangjavier

Copy link
Copy Markdown

Tested cbb7d4f on two GPUs in one laptop, Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (WSL Debian), VK_LOADER_LAYERS_DISABLE=~implicit~, GPU picked with LEONIDA_VK_DEVICE: pass.

GPU, driver Mode run_gpu_tests.py --filter cs_w64x_carry
AMD Radeon 680M (gfx1035, RDNA2), 25.10.30.14 native wave64 PASS, 922/922 dumped words exact
NVIDIA RTX 3050 6GB Laptop, 582.05 LEONIDA_W64_EMULATE=1 PASS, 922/922 dumped words exact
NVIDIA RTX 3050 6GB Laptop, 582.05 without emulation SKIP (no 64-wide compute subgroup), as intended

python -m unittest discover -s tests/semantic -p test_w64x_carry_fixture.py: 3 tests OK. No game data involved. AI-assisted.

@ricarmandoagent

Copy link
Copy Markdown

Tested cbb7d4f1 on NVIDIA GeForce RTX 4060 (Ada, AD107; Vulkan subgroupSize 32..32, so wave64 has to be 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++), shaders translated with this PR's tools/rdna2spirv.py and the cross-half fixture enabled through emulation:

LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w64x_carry

  PASS  cs_w64x_carry         922/922 dumped words exact

1/1 passed

So the carry chains over the 64 lanes are exact under --wave64-emulate on a 32-wide device, not only on a native 64-wide one. .spv passed spirv-val (LLVM 23.1.5).

AI-assisted run on a contributor machine.

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

AI-assisted.
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py
tests/test_shader_checks.py

AI-assisted.
@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown

Tested 4a4a230 on NVIDIA GeForce RTX 5070 Ti Laptop GPU (Blackwell, 621.24, subgroup 32..32) and AMD Radeon 610M (RDNA2 iGPU, AMD 26.11.2 / 32.0.21045.29003, subgroup 32..64), Windows 11 Home 26200: pass.

Same laptop, one GPU at a time through LEONIDA_VK_DEVICE. Test programs rebuilt from this head with llvm-mingw 23.1.6; llvm-mc 23.1.6 (conda-forge), SPIRV-Tools v2026.4 (Vulkan SDK 1.4.363.0), Python 3.13.14.

scripts/run_gpu_tests.py Result cs_w64x_carry
RTX 5070 Ti Laptop, native 164/211 passed, 47 skipped, 0 failed SKIP (no 64-wide compute subgroup) for the wave64 check; 64/64 dumped words exact
RTX 5070 Ti Laptop, LEONIDA_W64_EMULATE=1 196/211 passed, 15 skipped, 0 failed 922/922 dumped words exact and 64/64 dumped words exact
Radeon 610M, native wave64 190/211 passed, 21 skipped, 0 failed 922/922 dumped words exact and 64/64 dumped words exact
  • 215 shaders translated, 215 pass spirv-val in each run.
  • CPU: python -m unittest discover -s tests/semantic -p test_w64x_carry_fixture.py (3 tests) and python -I tests/test_shader_checks.py (75 tests) pass.

So the fixture is exact natively on a wave64 RDNA2 device and under emulation on a 32-wide one. One run of each. No game files. AI-assisted (Claude Code).

@lunarminus

Copy link
Copy Markdown

Tested 4a4a2308 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: fail. The cs_w64x_carry fixture is exact, but the run_gpu_tests.py hunk drops cs_fmt_sint32 from the results and reports cs_w64x_carry twice.

  • The merge was clean. The test programs are the d0835dd9 build, since the PR changes no C++/CMake.
  • python -m unittest discover -s tests/semantic -p test_w64x_carry_fixture.py: 3 tests OK. python -I tests/test_shader_checks.py: 75 tests OK. python tests/semantic/regen_fixtures.py --check: exit 0, no output.
  • scripts/run_gpu_tests.py, full suite, native and with LEONIDA_W64_EMULATE=1: 197/211 passed, 14 skipped, 0 failed in both modes. 215 shaders translated, 215 pass spirv-val.
  • cs_w64x_carry: 922/922 dumped words exact, native wave64 and emulated, in the full run and with --filter cs_w64x_carry (which also prints the second 64/64 line: 2/2 passed).
  • Per-test comparison with d0835dd9 without the PR (196/210 passed, 14 skipped, both modes), matching each PASS/FAIL/SKIP line by status and name. The same difference shows up in both modes:
    • PASS cs_fmt_sint32 appears only in the baseline.
    • PASS cs_w64x_carry appears twice in the PR runs: 922/922 dumped words exact, then 64/64 dumped words exact.
    • Every other line is the same.

Cause: in scripts/run_gpu_tests.py (merged file, line 874), the new elif name in dict(W64X_FULL): block went in between problem = fmt_sint32_test(...) and the results.append((name, not problem, problem or "64/64 dumped words exact")) that belongs to the cs_fmt_sint32 branch.

  • cs_fmt_sint32 still runs, but its result is never recorded. On this PR, run_gpu_tests.py --filter cs_fmt_sint32 exits 2 with no runnable GPU test cases. On d0835dd9 the same filter gives PASS cs_fmt_sint32 64/64 dumped words exact.
  • cs_w64x_carry picks up that 64/64 line as a second result. On a device without 64-wide subgroups, problem is None turns it into a PASS next to the SKIP. That matches the SKIP ...; 64/64 dumped words exact row in the RTX 5070 Ti table above, and the 211 there.

Fix: move the new elif below the cs_fmt_sint32 results.append line, so the new branch ends at its own append. tests/test_shader_checks.py only covers check.py, not run_gpu_tests.py, so it does not catch this.

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.

7 participants