Skip to content

rdna2spirv: accept slc and dlc cache-policy modifiers on global_atomic_* - #7488

Open
DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:feat/rdna2-global-atomic-slc-dlc
Open

DenRakEiw wants to merge 1 commit into
ItsNotRexed:mainfrom
DenRakEiw:feat/rdna2-global-atomic-slc-dlc

Conversation

@DenRakEiw

Copy link
Copy Markdown
Contributor

Claim: #7231 (comment)

Summary

Accept slc and dlc cache-policy modifiers on global_atomic_* across all three translator paths in tools/rdna2spirv.py:

  • Gen.global_atomic (32-bit integer atomics, cmpswap, inc/dec/csub, fcmpswap)
  • Gen.global_atomic_float (fmin/fmax)
  • Gen.global_atomic_x2 (and_x2/or_x2/xor_x2/swap_x2)

This matches buffer_atomic_*, global_load_dword*, and global_store_dword*: all emitted SPIR-V OpAtomic* instructions already use Scope::Device, so slc and dlc are safe cache-policy hints. lds and any unknown modifier flags continue to raise Unsupported, and unsupported carrying 64-bit _x2 ops (such as global_atomic_add_x2) remain Unsupported.

Strictly scoped to global_atomic* (global_sub is untouched).

Tests

Added tests/semantic/test_global_atomic_slc_dlc.py covering:

  • 32-bit (global_atomic_add, global_atomic_cmpswap), float (global_atomic_fmin, global_atomic_fmax, global_atomic_fcmpswap), and 64-bit x2 (global_atomic_and_x2/or_x2/xor_x2/swap_x2) across all 6 modifier combinations (slc, dlc, slc+dlc, glc+slc, glc+dlc, glc+slc+dlc)
  • llvm-mc -arch=amdgcn -mcpu=gfx1030 binary assemble -> rdna2_decode -> rdna2spirv -> spirv-val --target-env vulkan1.2 round-trip tests
  • Rejection of lds, unknown modifier flags, and carrying global_atomic_add_x2 with slc/dlc
  • Updated existing negative assertions in test_global_atomics.py, test_global_atomic_float.py, and test_atomic_inc_dec.py to test lds/tfe rejection instead of slc/dlc

Verification (Windows 11 + NVIDIA GeForce RTX 5090)

  • python -I -m unittest discover -s tests/semantic -p test_global_atomic_slc_dlc.py -v (with WSL LLVM 21 llvm-mc and Vulkan SDK 1.4.363.0 spirv-as/spirv-val): 9/9 OK
  • python -I -m unittest discover -s tests/semantic -p test_global_*.py -v: 79/79 OK
  • python -I -m unittest discover -s tests/semantic -p test_atomic_*.py -v: 17/17 OK
  • python -I -m compileall -q tools tests and git diff --check: clean

AI-assisted (Gemini 4 Neon).

@Alpha325

Copy link
Copy Markdown

Independent CPU test at 923173f742 on Windows 11 / CPython 3.12.14:

  • python -I -m unittest discover -s tests/semantic -p test_global_atomic_slc_dlc.py -v: 9 tests, OK with 2 skipped (LLVM AMDGPU assembler unavailable).
  • python -I -m unittest discover -s tests/semantic -p "test_global_*.py": 79 tests, OK with 4 skipped.
  • Negative control: retaining this PR’s tests and restoring only tools/rdna2spirv.py from the parent gives 3 failures and 55 subtest errors in the new suite. Restoring the PR file passes again. Worktree is clean afterward.

The executed tests check the interpreter’s memory results and returned atomic values across the cache modifier combinations. Binary round-trip and SPIR-V validation were outside this environment. Synthetic inputs only. AI-assisted testing.

@javdc

javdc commented Nov 23, 2026

Copy link
Copy Markdown

Tested 923173f on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass

  • python3 -m pytest tests/semantic/test_global_atomic_slc_dlc.py tests/semantic/test_global_atomics.py tests/semantic/test_atomic_inc_dec.py tests/semantic/test_global_atomic_float.py -q — 40 passed, 2 skipped, 608 subtests passed

AI-assisted (OpenCode).

@RAINighty

Copy link
Copy Markdown

Tested 923173f74 merged with main dde82f27e (clean merge) on Windows 11 (10.0.26300), Python 3.13.15, with the full toolchain: llvm-mc 21.1.8 with the AMDGPU target (built by scripts/build_llvm_mc.ps1, LLVM_MC set) and SPIRV-Tools v2026.4 (spirv-val from Vulkan SDK 1.4.363.0), LEONIDA_REQUIRE_SPIRV_TOOLS=1: pass.

  • tests/semantic/test_global_atomic_slc_dlc.py: 9 tests, OK, none skipped, so the llvm-mc assemble -> rdna2_decode -> rdna2spirv -> spirv-val round-trip tests ran (another report on this PR had them skipped for lack of the AMDGPU assembler).
  • The other three touched files: test_global_atomics.py 12 OK, test_atomic_inc_dec.py 11 OK, test_global_atomic_float.py 10 OK.
  • Negative control: this PR's tests with main's tools/rdna2spirv.py: test_global_atomic_slc_dlc.py fails (3 failures, 85 errors), test_atomic_inc_dec.py and test_global_atomic_float.py fail 1 each; test_global_atomics.py still passes.
  • Whole suite (python -I scripts/run_semantic_tests.py tests/semantic, 448 files, 5,965 tests): 3 files fail, test_image_atomics_guard, test_image_cube_store_glc and test_image_store_d16. They fail the same way on main dde82f27e without this PR, so they are not from it.
  • Code not reviewed beyond running it. No GPU or game files.

AI-assisted (Claude Code).

@carlos-seiffert

Copy link
Copy Markdown

Tested 923173f (merged onto main 976b3ec) on NVIDIA GeForce RTX 2060 (Turing), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 (10.0.26300), subgroup size 32: pass (no regression)

What I ran: python -I scripts/run_gpu_tests.py with the Vulkan tools built from 976b3ec (llvm-mingw + Ninja, -DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF, Vulkan-Headers 6802bb47), llvm-mc 23.1.6 and SPIRV-Tools from conda-forge.

main 976b3ec this PR on main
full GPU suite 192/241 passed, 48 skipped, 1 fail 192/241 passed, 48 skipped, 1 fail (same as main)

No GPU test changed status against main. This PR adds no GPU fixture of its own, so the run checks that the change breaks none of the existing GPU tests; it does not exercise the new rule directly.

Unit tests changed by the PR: tests/semantic/test_atomic_inc_dec.py, tests/semantic/test_global_atomic_float.py, tests/semantic/test_global_atomic_slc_dlc.py, tests/semantic/test_global_atomics.py: OK.

The one failure on both sides is ms_wave_info_s3, which fails on main on this GPU (10/10 runs) and is fixed by #7136 / #5741 / #5855; it is unrelated to this PR.

AI-assisted run (Claude Code); the numbers are from my machine.

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.

5 participants