Skip to content

Tests: GPU test for ds_and/or/xor_b32, ds_sub_u32 and ds_and_b64 - #2125

Open
Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-ds-bitops
Open

Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-ds-bitops

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-GPU-DS-BITOPS (#1902 (comment))

What and why

An opcode inventory of tools/rdna2spirv.py against main (4eb6155) lists LDS atomics that only the CPU tests run. This adds a GPU test for five of them: ds_and_b32, ds_or_b32, ds_xor_b32, ds_sub_u32 and ds_and_b64. ds_or_b64/ds_xor_b64 are in #1850 and are left out here.

runtime/test/shaders/cs_w32_lds_bitops.asm: lane 0 of a wave32 group seeds LDS words, then after s_barrier all 32 lanes run the atomics on the same words, so a word is only right when every lane's read-modify-write lands:

word op expected
0 ds_and_b32 of ~(1 << (L & 15)) into 0xFFFFFFFF 0xFFFF0000
1 ds_or_b32 offset:4 of 1 << (L & 30) into 0x80000000 0xD5555555
2 ds_xor_b32 offset:8 of 1 << L into 0x12345678 0xEDCBA987
3 ds_sub_u32 offset:12 of L + 1, EXEC = lanes 0..19, from 100 (wraps) 0xFFFFFF92
4, 5 ds_and_b64 offset:16, low ~(1 << (L & 15)), high ~(1 << ((L & 15) + 16)), into 0xF0F0F0F0_FFFFFFFF 0xFFFF0000, 0x0000F0F0
6, 7 ds_sub_u32 of L at the per-lane address 4 * (L & 3) + 64, from 1000 864 (lanes 3, 7, ..), 888 (lanes 0, 4, ..)

The derivation from the ISA pseudocode is in the header. Registered like cs_lds_b64_cmpst (WAVE32_DUMPS/CS_DUMPS in check.py, the dump list and wave32 exclusion in run_gpu_tests.py), plus the fixture from regen_fixtures.py. test_value_semantics.py (LdsBitwiseAtomics) checks the words against a plain-Python model of the pseudocode, checks that both runners expect them, and runs the translated fixture in spirv_mini_interp. That interpreter keeps LDS per invocation and rejects OpControlBarrier, so the CPU run is lane 0 alone without the two s_barrier lines (the model gives those words too); the 32-lane words are the GPU's.

No translator change: all five match on both GPUs.

Tested

Windows 11, python -I scripts/run_gpu_tests.py --filter cs_w32_lds_bitops:

GPU driver result
AMD Radeon (RDNA2 iGPU, Ryzen 9 9950X3D) 26.10.1 PASS, 8/8 words exact
NVIDIA GeForce RTX 5080 616.92 PASS, 8/8 words exact

Negative control: LDS_ATOMICS["ds_and_b32"] set to OpAtomicOr (one line). cs_w32_lds_bitops fails on both GPUs (word 0 0xffffffff, want 0xffff0000) and test_translated_shader_lane0 fails. Reverted.

python -m unittest discover -s tests/semantic: 1674 tests OK (2 skipped). python tests/semantic/regen_fixtures.py --check clean, python -I tests/test_shader_checks.py and python -I tests/test_run_gpu_tests.py OK.

AI-assisted.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No new rule.)

cs_w32_lds_bitops has all 32 lanes of a wave32 group run the atomics on
shared LDS words (ds_sub_u32 also EXEC-masked and at per-lane addresses);
lane 0 stores the eight results. Registered in check.py and
run_gpu_tests.py, with the fixture and a value check in
test_value_semantics.py. Passes on an RDNA2 iGPU and an RTX 5080.

AI-assisted.
@AvantBras

Copy link
Copy Markdown
Contributor

Tested 1378873a32d487e569dfc154910285bc3f75eac8 on RTX 3060 12 GB, NVIDIA 580.178.04, Pop!_OS 22.04. Ran python -I scripts/run_gpu_tests.py --build <build> --filter cs_w32_lds_bitops with this PR’s translator and runner and the Linux Vulkan harnesses built at #2048’s head (UBO tail off). The module passed spirv-val; 1/1 fixture passed, no skips. All eight result words matched, including the contended LDS operations and the masked subtraction. No game files. AI-assisted verification.

@Rainmaker33

Copy link
Copy Markdown

Tested 1378873 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 4eb6155. 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: 137/181 pass, 44 skipped (wave64), no failures (main: 136/180). cs_w32_lds_bitops: 0xffff0000 0xd5555555 0xedcba987 0xffffff92 0xffff0000 0xf0f0 0x360 0x378.
  • tests/semantic/test_value_semantics.py: OK.

@dandasma

Copy link
Copy Markdown
Contributor

Tested 1378873 on AMD Radeon RX 9070 (RDNA4, subgroup 32..64), AMD 26.10.1 (LLPC), Vulkan 1.4.359, Windows 11 26300: pass. Python 3.12.10, llvm-mc 21.1.8, Vulkan SDK 1.4.363.0; harness programs built from main 4eb6155 (this PR's base; it changes no C++), with LEONIDA_VK_DEVICE=9070 so no other GPU could take the run.

  • build.py: 200 shaders, 200 translated, 200 pass spirv-val (main: 199; the one added is cs_w32_lds_bitops).
  • check.py: 157 of 161 pass, 4 skipped, cs_w32_lds_bitops ok (main: 156 of 160, the same 4 skips).
  • run_gpu_tests.py --filter cs_w32_lds_bitops: 1/1 in three runs, the same eight words each time: 0xffff0000 0xd5555555 0xedcba987 0xffffff92 0xffff0000 0xf0f0 0x360 0x378.
  • Full run_gpu_tests.py: 168/181 passed, 13 skipped, 0 failed (main 4eb6155: 167/180, the same 13 skips: 12 D3D12-run fixtures and ps_w64x_readlane).

GitHub now reports a conflict with current main; this run is on the PR's base 4eb6155.
AI-assisted (Claude Code).

Conflicts:
	tests/semantic/regen_fixtures.py

AI-assisted.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged main (871cffb) again; CPU checks and the PR's GPU tests pass on Radeon RDNA2 iGPU. AI-assisted.

runtime/test/shaders/check.py
scripts/run_gpu_tests.py

AI-assisted.
runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py

AI-assisted.
@zneel

zneel commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 7085aeed on AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64), AMD 26.11.2, Windows 11 Pro 10.0.26300, AMD Ryzen 7 9800X3D CPU (64 GB RAM), Python 3.12.10: pass.

Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows llvm-mc 21.1.8, Vulkan SDK 1.4.363.0. No game files.

run result
run_gpu_tests.py (whole suite, native wave64) 197/211, 14 skipped, 0 failed (main 49475796: 170/185)
same with LEONIDA_W64_EMULATE=1 197/211, 14 skipped, 0 failed
pytest tests/test_shader_checks.py tests/test_run_gpu_tests.py 119 passed, 276 subtests passed in 2.72s
unittest discover -s tests/semantic -p test_value_semantics.py 42 OK
tests/semantic/regen_fixtures.py --check clean

This PR's shaders:

  • native: PASS cs_w32_lds_bitops 0xffff0000 0xd5555555 0xedcba987 0xffffff92 0xffff0000 0xf0f0 0x360 0x378; emulated: PASS cs_w32_lds_bitops 0xffff0000 0xd5555555 0xedcba987 0xffffff92 0xffff0000 0xf0f0 0x360 0x378

cs_w32_lds_bitops passes on RDNA4, native and emulated, with all 32 lanes' read-modify-writes landing on the shared words.

AI-assisted (Claude Code); I checked the results.

@crastinator

Copy link
Copy Markdown
Contributor

Tested 7085aee merged into main aa2988cc (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_lds_bitops (0xffff0000 0xd5555555 0xedcba987 0xffffff92 0xffff0000 0xf0f0 0x360 0x378).
  • Whole run_gpu_tests.py: 197/211 native, 197/211 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 47/47.
  • tests/semantic/test_value_semantics.py: 42 passed, 284 subtests passed.

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.

6 participants