Repository navigation
Conversation
M = M >= DATA ? M - DATA : M + DATA2, the old value returned, as a Workgroup CAS loop; 16 cases measured natively on gfx1036. lds_access takes the phi predecessor from the block the access ended in, so a looping access works under the LDS bound check. GPU fixture cs_w32_ds_wrap, semantic test test_lds_wrap.py, design.md row. AI-assisted.
|
Overlap check with #3817 and #3932 (SHADER-715), which change
So either order works. I'll do the docs text merge on #3932 if this lands first. AI-assisted. |
|
Tested
GPU-AV (Khronos validation 1.4.363,
Windows 11, Vulkan SDK 1.4.363, llvm-mc AMD LLVM 23.0.0git. Synthetic data only, no game files. AI-assisted (Claude Code). |
|
Tested 8c5d717 on RTX 2070 (Turing, subgroup 32..32), NVIDIA 620.73.04, Vulkan 1.4.357, CachyOS Linux (kernel 7.3.5), llvm-mc 23.1.5. Native Linux build of the test tools (main aa2988c, unchanged by this PR), no game files.
Adds a Linux Turing (32-wide) data point to your Windows AMD + RTX 5080 results. AI-assisted (Tacit). |
|
Tested 8c5d717 (merge base = main aa2988c) on NVIDIA GeForce RTX 5080, driver 580.65.06, Ubuntu 22.04 (Linux): pass Commands (llvm-mc 21, spirv-val from Vulkan SDK 1.4.363.1,
Not tested: the AMD RDNA2 run and the Windows run (no such hardware here). The C++ runtime binaries used were a prebuilt Linux build of another branch; this PR only touches Python, so the GPU test programs are not affected. The compare-operator negative control from the PR text was not repeated. No game data was used. AI-assisted run. |
slopradish
left a comment
There was a problem hiding this comment.
CPU verification: checked out pull/4009/head in an isolated worktree.
pytest -q tests/test_translate.py: 583 passed, 4 skippedpytest -q tests/semantic/test_lds_wrap.py: 3 passed, 16 subtests
The change is complete and consistent: translator opcode, semantic test, semantic fixture, GPU fixture, checker registration, GPU runner registration and the contract-table row all move together. The semantic test drives the real translator (not a private model) and covers wrap-around, return-value and inactive-lane cases through the fixture.
I could not exercise the GPU fixture on this host, so the hardware-visible part of ds_wrap_rtn_b32 is unverified by me; the author's RDNA2 measurements are cited in the PR. The CPU side is solid.
No game files or keys involved.
Requested by Lucas · project thread
Claimed in the coordination issue as: EGEN-DS-WRAP, #3796 (comment)
What and why
ds_wrap_rtn_b32raisedUnsupported, though it is a valid gfx1013 LDS form. I found it by translating every gfx1013 opcode form onmain. Searching the open PR diffs, only #2323's decoder tables name it.The RDNA ISA text says: tmp = M; M = (tmp >= DATA) ? tmp - DATA : tmp + DATA2; vD = tmp. The compare is unsigned and both results wrap at 32 bits.
Change (
tools/rdna2spirv.py,Gen.lds_op):OpAtomicCompareExchangeloop on the LDS dword, like the other LDS CAS atomics.Gen.lds_accessnow takes the OpPhi predecessor from the block the access ended in, not the block it started in. A looping access then stays valid SPIR-V when the LDS bound check (lds_bound) wraps it. For the existing straight-line accesses those two are the same block.Measured natively on RDNA2 gfx1036 (Radeon iGPU of a Ryzen 9 9950X3D, driver 26.10.1,
tools/hw_oracleraw kernel, v0-v15 / s4-s15). There are 16 single-lane cases, and all of them match the ISA text. They cover both branches, M = DATA, wraps below 0 and above 0xffffffff, DATA = 0xffffffff, and DATA2 = 0.New contract row in
docs/design.md.Tested
Windows 11, LLVM
llvm-mc(-mcpu=gfx1013),VK_LOADER_LAYERS_DISABLE=~implicit~, one GPU at a time,python -I scripts/run_gpu_tests.py --filter cs_w32_ds_wrap:10 155 4 104 4294967280 4294967248 2147483648 1runtime/test/shaders/cs_w32_ds_wrap.asm. In it, 32 lanes runds_wrap_rtn_b32on one word with DATA = 10 and DATA2 = 1. Every lane applies the same map, so the final value (10) and the sum of the returned values (155) do not depend on the order. Lane 0 then runs three of the measured single-lane cases. The words are derived in the header. The fixture is registered incheck.py,run_gpu_tests.pyandregen_fixtures.py.tests/semantic/test_lds_wrap.pychecks the 16 measured cases and an offset throughspirv_mini_interp, plus a plain-Python reference against the same words.mainthe test errors withUnsupported: ds_wrap_rtn_b32.>instead of>=in the compare. The test fails 4 cases, and the Radeon run fails with 155 becoming 177. Reverted.python -m unittest discover -s tests/semantic(no new failures: the 7 failures and 3 errors it reports fail the same way onmainaa2988cc, intest_loop_ballot_barrier(emulate),test_vcmp16_opsel(spirv-val),test_cmp_class_f64(TEST-853) andtest_mutations(v_mul_legacy_f32anchor)),python tests/semantic/regen_fixtures.py --check(clean),python -I tests/test_shader_checks.py, andpytest tests/test_docs_design_rows.py tests/test_run_gpu_tests.py.AI-assisted.
Checklist
docs/design.md, with how it was confirmed.