Skip to content

test(gpu): exercise s_absdiff_i32, s_mul_hi_i32 and s_lshl1..4_add_u32 - #3275

Open
YaBulochka wants to merge 1 commit into
ItsNotRexed:mainfrom
YaBulochka:gpu-salu-fixtures
Open

YaBulochka wants to merge 1 commit into
ItsNotRexed:mainfrom
YaBulochka:gpu-salu-fixtures

Conversation

@YaBulochka

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #1745 (comment)

What and why

s_absdiff_i32, s_mul_hi_i32 and s_lshl1..4_add_u32 are covered by semantic tests and by one-off hardware probes recorded in docs/design.md, but nothing in runtime/test/shaders runs them, so a regression in the emitted SPIR-V would not show up in the GPU suite. This adds one wave32 fixture with the expected words derived from the ISA first:

  • s_absdiff_i32(0x7fffffff, 0x80000000): the difference wraps to 0xffffffff, |.| gives 1, SCC 1;
  • s_absdiff_i32(0x80000000, 0x80000000) gives 0;
  • s_mul_hi_i32(0x40000000, 0x40000000) = 0x10000000 (high word of 2^60);
  • s_lshl1_add_u32(0x40000000, 0x1000) = 0x80001000, nothing leaves the 64-bit sum, SCC 0;
  • s_lshl2_add_u32(0x80000000, 0) = 0 and s_lshl3_add_u32(0x20000000, 1) = 1, both with bits shifted out, SCC 1;
  • s_lshl4_add_u32(0x0fffffff, 0) = 0xfffffff0, SCC 0.

Registered in runtime/test/shaders/check.py (wave32 lists, lane-mask skip list, expected words) and scripts/run_gpu_tests.py (runner tuple and cs_dump_wants).

This overlaps #3208 in the same two registration lists; whichever lands second needs a one-line rebase.

Tested

AMD Radeon RX 7600 (gfx1102), RADV Mesa 27.0.0-devel, Linux 7.3.3, llvm-mc 23.1.5.

  • run_gpu_tests.py --filter cs_w32_salu_abs_lshl -> 1/1 passed:
    PASS  cs_w32_salu_abs_lshl  1 1 0 268435456 2147487744 0 1 4294967280
    
  • Full suite: 195 shaders, 195 translated, 195 pass spirv-val; 176/190 passed, 14 skipped, 0 failed.
  • ctest: 34/36; the two failures (vk_pipeline_check_cli, xdxr_build_check) are present on clean 16282101 with these changes stashed, so they are not from this PR.

Checklist

  • No game data, keys or decryption; hand-written assembly with seeds and expected words in the header.
  • No new translator rule; the docs rows already describe the behaviour.

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 check of head 4093161 (macOS 26.4, MoltenVK 1.4.2 direct, subgroup 4..32, llvm-mc 23.1.6, Python 3.13.18): the new fixture translates but cannot be judged here.

python -I scripts/run_gpu_tests.py --filter cs_w32_salu_abs_lshl --build runtime/build/linux: 1 shader translated, 1 pass spirv-val; 0/1 passed, 1 skipped — SKIP (no 64-wide compute subgroup on this device). I am not claiming a pass on this Mac. This is the same 32-wide-device limitation discussed on the board; open PR #2886 changes how exact-32 tests are handled on MoltenVK.

Full build fails on AppleClang 17 at vk_pipeline_check.cpp:567 (BUILD-822, fixed by open PR #2927); GPU binaries built, so the translation/skip result is valid. Head fetched read-only; no rebase/edit/push. Synthetic shader only, no game files.

AI-assisted.

@emirduran707

Copy link
Copy Markdown
Contributor

Tested 4093161 on AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.10.44 (LLPC, Vulkan driver 2.0.395), Windows 11 Pro 10.0.26300, subgroup 32..64: pass. The checks above have no AMD run from outside the author; this adds an AMD card with native 64-wide subgroups.

  • python -I scripts/run_gpu_tests.py --build <build> --filter <fixture>, one run per new fixture:
    • cs_w32_salu_abs_lshl: PASS, 1 1 0 268435456 2147487744 0 1 4294967280; same with LEONIDA_W64_EMULATE=1
  • Whole suite (native wave64): 195 shaders translated, 195 pass spirv-val; 176/190 passed, 14 skipped, 0 failed. The skips are the 14 fixtures the d3d12_* tests run.
  • build.py + check.py: 215 shaders: 215 translated, 215 pass spirv-val; 165 of 168 pass, 3 skipped; ok for cs_w32_salu_abs_lshl.
  • CPU: tests/test_shader_checks.py 69 OK, tests/test_run_gpu_tests.py 34 OK, tests/semantic/regen_fixtures.py --check clean. I did not run the whole tests/semantic suite.

Test programs: an MSVC 14.44 build of main ec8ec4c; this PR's runtime C++ and CMake are identical to that commit, and the translator, runner and check.py are this PR's. llvm-mc 21.1.8 (native), Vulkan SDK 1.4.363.0. No negative control run here. No game files. AI-assisted (Claude Code).

@chpeu

chpeu commented Nov 22, 2026

Copy link
Copy Markdown

Tested 4093161e (main 16282101 is an ancestor, so it applies without a rebase) on two NVIDIA cards,
Linux, CPU-only otherwise, no game files.

Machine: Linux Mint 22 (Ubuntu 24.04 base), NVIDIA driver 615.71.09, Vulkan loader 1.3.275 with the pinned
Vulkan-Headers fetched by CMake (-DLEONIDA_VULKAN_HEADERS_FETCH=ON), GCC 13.3, Python 3.12.3,
llvm-mc 20.1.2, SPIRV-Tools 2025.1~rc1. Built with cmake -S runtime -B runtime/build/linux && cmake --build runtime/build/linux --parallel.

RTX 3080 (the card pick_device() chooses here),
LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py --build runtime/build/linux --llvm-mc /usr/lib/llvm-20/bin/llvm-mc:
175/190 passed, 15 skipped, 0 failed. The same command on main gives 174/189 passed, 15 skipped,
so the new program is the only difference.

RTX 5080 (LEONIDA_VK_DEVICE="RTX 5080", same command): 175/190 passed, 15 skipped, 0 failed.

cs_w32_salu_abs_lshl reads back exactly the eight words listed in check.py:
1 1 0 268435456 2147487744 0 1 4294967280 (= 0x10000000, 0x80001000, 0xFFFFFFF0).

One thing to confirm: without LEONIDA_W64_EMULATE=1 the new program skips with
“no 64-wide compute subgroup on this device” on both cards (NVIDIA's widest subgroup is 32). It is the only
member of WAVE32_LANE_DUMPS that skips that way — cs_lds_b64_cmpst, cs_w32_mask_imm and
cs_mask_vgpr_exec all pass on the same device without the variable, so I read this list as the 32-lane path.
Is the skip intended for a cs_w32_* program on a 32-wide device, or should the wave32 lane-mask path run
without emulation here?

llvm-mc 20.1.2 assembled everything this suite needs (it still rejects the 16-bit op_sel VOP3 forms your
docs reserve for valu_fuzz --family f16, which is not reached here). AI-assisted testing, results read through
by hand.

@crastinator

Copy link
Copy Markdown
Contributor

Tested f125331 merged into main f847748c (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 test passes natively: cs_w32_salu_abs_lshl (1 1 0 268435456 2147487744 0 1 4294967280).
  • Whole run_gpu_tests.py: 186/200 native, 186/200 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 41/41.

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

@Impre-visible

Copy link
Copy Markdown

Tested f125331 on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18): pass, no regression.

Native build of runtime/ from this head (Ninja, RelWithDebInfo, clang 23.1.5), llvm-mc 23.1.5, SPIRV-Tools v2026.4.

  • tests/semantic: 4142 OK
  • build.py: 215 shaders, 215 translated, 215 pass spirv-val; check.py: 133 of 168 pass, 35 skipped (wave64 without emulation, mesh fixtures)
  • run_gpu_tests.py: 195 shaders: 195 translated, 195 pass spirv-val; 143/190 passed, 47 skipped, 0 failed
  • LEONIDA_W64_EMULATE=1 run_gpu_tests.py: 175/190 passed, 15 skipped, 0 failed
  • New fixture cs_w32_salu_abs_lshl: on this 32-wide device the native run skips it (SKIP (no 64-wide compute subgroup on this device)), so here it only executes under LEONIDA_W64_EMULATE=1, where it passes. If the fixture is meant to be wave32 (its name says w32), it is being built as wave64 and 32-wide GPUs do not cover it natively.

AI-assisted run (Claude). Synthetic programs only, no game files involved.

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Code read of 2c84542b. Ran on Windows 11, RTX 4070 (NVIDIA 621.01, subgroup 32..32), llvm-mc 23.1.6, SPIRV-Tools 2026.4, with vk_compute_test built from this commit. build.py translates all 235 shaders and check.py gives cs_w32_salu_abs_lshl ok (150 of 185 pass, 35 skipped); the expected words match the derivation in the .asm header.
One problem: python -I scripts/run_gpu_tests.py --build runtime/build --filter cs_w32_salu_abs_lshl --require-pass reports SKIP (no 64-wide compute subgroup on this device) (0/1, exit 1) on this 32-wide GPU. The name was added to the dump tuple and to cs_dump_wants (scripts/run_gpu_tests.py:957) but not to the wave64 = name not in (...) exclusion list below it (where cs_w32_salu64, cs_w32_new_ops, … are), so the runner passes --require-wave64. Adding "cs_w32_salu_abs_lshl" to that tuple locally gives PASS ... 1 1 0 268435456 2147487744 0 1 4294967280 (1/1); changing one expected word then makes it FAIL, so the comparison is live. Without the fix the test only runs under run_gpu_tests.py on devices with 64-wide subgroups. pytest tests/test_shader_checks.py tests/test_run_gpu_tests.py: 119 passed.
Minor: the SCC results noted in the header for s_lshl2_add_u32/s_lshl3_add_u32 are not stored, so only the first s_absdiff_i32 SCC is checked.
AI-assisted code read (Claude).

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 2c84542b9facb3a522548d1595490bd44e069cb4 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Checked the shift-add SCC coverage gap on Linux RTX 5090. The submitted runner skipped this wave32 fixture for lack of a 64-wide subgroup. With the fixture marked wave32 locally, the original shader passed all eight expected result words.

I then captured SCC with s_cselect_b32 immediately after each scalar shift-add and exported those flags in words 4–7. The translated shader passed SPIR-V validation and returned 0, 1, 1, 0 for s_lshl1_add_u32 through s_lshl4_add_u32, respectively. The first four output words stayed at 1, 1, 0, 0x10000000. This confirms the four flag expectations in the fixture comments for these inputs. The checked-in shader currently exports the arithmetic results for those four instructions.

AI-assisted (Codex).

AI-assisted verification.

@kapitche

Copy link
Copy Markdown
Contributor

Ran 2c84542b merged with main 3eb4410b on Windows 11, RTX 4080 SUPER + Intel UHD 770 (MSVC 14.51). Neither GPU can run this fixture, so this is not a pass: scripts/run_gpu_tests.py --filter cs_w32_salu_abs_lshl translates and passes spirv-val (1/1), then reports SKIP (no 64-wide compute subgroup on this device) on both (NVIDIA subgroup 32, Intel UHD 770 at most 32). It needs a wave64-capable device (AMD).

@tylerstraub

Copy link
Copy Markdown
Contributor

Replying to @kapitche.

Your skip is reproducible at 2c84542b. The fixture itself runs on a 32-wide GPU: the dump runner mistakenly passes --require-wave64. The one-line fix against this PR’s branch corrects the classification. At 10210d2 the same fixture passed with --require-pass on a Linux RTX 5090 and retained its original eight expected words. That branch gives you a direct retest on the Windows adapters.

AI-assisted (Codex).

AI-assisted.

@lunarminus

Copy link
Copy Markdown

Tested 2c84542b merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • The merge was clean. This PR changes no C++ or CMake, so the test programs are the d0835dd9 build.
  • Full scripts/run_gpu_tests.py, run natively and again with LEONIDA_W64_EMULATE=1. Both runs gave the same result: 215 shaders, 215 translated, 215 pass spirv-val; 197/211 passed, 14 skipped, 0 failed.
  • I compared each test's PASS/FAIL/SKIP result with d0835dd9 without the PR (196/210 passed, 14 skipped in both modes). The only difference is the new cs_w32_salu_abs_lshl, which passed in both modes: 1 1 0 268435456 2147487744 0 1 4294967280.
  • run_gpu_tests.py --filter cs_w32_salu_abs_lshl --require-pass: 1/1 passed, native and emulated.
  • build.py + check.py, both modes: 235 translated, 235 pass spirv-val; 182 of 185 pass, 3 skipped (the mesh fixtures); cs_w32_salu_abs_lshl ok.
  • pytest tests/test_shader_checks.py tests/test_run_gpu_tests.py: 119 passed.
  • Subgroup size: the fixture is still not in the wave64 = name not in (...) tuple (scripts/run_gpu_tests.py:1058), so the runner passes --require-wave64. With the runner's arguments (VKC_SUBGROUP_SIZE=32 plus --require-wave64), vk_compute_test reported subgroup size 64 here. This means the native PASS above ran 64-wide. Run directly with VKC_SUBGROUP_SIZE=32 and no --require-wave64, it ran at subgroup size 32 and returned the same eight words. This device has 64-wide subgroups, so it can't show the skip reported on 32-wide GPUs. What it does show is that the wave32 path gives the expected words on RDNA3.

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

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 9b0e4cc13ccbfad3e531d66f7dafdde6a7586ecf on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

At 9b0e4cc1 the checked-in runner still skips cs_w32_salu_abs_lshl on the Linux RTX 5090 (driver 595.99.02). Translation and SPIR-V validation passed, then the runner required a 64-wide subgroup for this wave32 fixture.

Changing only the local runner's subgroup selection to wave32 let the unchanged shader run. All eight expected words matched: 1 1 0 0x10000000 0x80001000 0 1 0xfffffff0. A separate instrumented run captured SCC immediately after each of the four shift-adds and returned 0 1 1 0, in instruction order. Both controls passed SPIR-V validation.

Adding the fixture to the runner's wave32 list would let 32-wide devices exercise the checked-in arithmetic expectations.

AI-assisted verification.

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