Repository navigation
rdna2spirv: sub-dword global stores take VDATA first, with a GPU fixture - #4160
YaBulochka wants to merge 1 commit into
Conversation
|
I think the premise is reversed. The encoding says the sub-dword stores have the same operand order as In a FLAT/GLOBAL instruction the second dword is Disassembling So for A native hw_oracle kernel built from the raw bytes above (not from re-assembled text) would settle it without relying on any syntax. I don't have an AMD GPU here to run it. AI-assisted (Claude). |
|
Native run from the raw bytes, as @MKmajster suggested: the sub-dword stores take the address from ADDR (the first operand), the same as Ryzen 7 9800X3D iGPU (RDNA2, gfx1036), AMD Windows driver 32.0.21045.29003, Windows 11, Each kernel sets
In every run, only the dword at the ADDR register's offset changed. The stored value came from DATA (the high halves are 0, so the The same assembler encodes The probe script is local; it uses hand-built kernels only, no game files. |
|
Apple M2 data point. Tested head 7e3905b on Apple M2 (Mac14,3), macOS 26.4, MoltenVK 1.4.2 (direct), subgroup 4..32, llvm-mc 23.1.6, Python 3.13.18, with a clean full build on AppleClang 17 (exit 0).
AI-assisted. |
|
A second native RDNA2 data point, on a discrete gfx1030, agreeing with @MKmajster and @AC-Storm-YT: the first operand of the sub-dword stores is the address, as for AMD Radeon RX 6900 XT (gfx1030), AMD driver 26.11.2, Windows 11,
The store always lands at the first operand's offset with the second operand's value. llvm-mc (gfx1030) encodes
AI-assisted (Claude Code). |
|
Tested 7e3905b on RTX 5090, 621.24, Windows 11: pass. Programs rebuilt from this tree, Taking VDATA from the instruction's field for sub-dword global stores is the rule that matters for the narrow formats; the eight words above are the header's derivation, on hardware. |
|
Tested 7e3905b on AMD Radeon (gfx1036, RDNA2, driver 26.10.1, Windows 11), natively through What I ran (one lane,
The encoding says the same: Consequence: with this PR AI-assisted. |
|
Tested GPU tests (RTX 3080, driver 615.71.09, Vulkan 1.4.351) — your new fixture passes:
The
Other checks: The RTX 5080 was not run in this pass: 186 MiB free on that card (it is held by another job on this box), and Machine: Linux Mint 22 (Ubuntu 24.04 base), |
|
Tested
The words are identical to the RX 7600 and gfx1036 words in the description. No game files. AI-assisted (Claude Code). |
|
Verified on Linux (NVIDIA RTX 5080, driver 580.196.07, fragment/compute subgroups 32..32, Vulkan 1.4): the new |
|
Tested 7e3905b on NVIDIA GeForce RTX 5060 Ti (driver 621.24, Windows 11) and AMD Radeon RX 9060 XT / RDNA4 (AMDVLK 32.0.32029.2010, Windows 11): the PR's own fixture passes on both, for what that can and cannot show.
No game files. AI-assisted (omp orchestrator). |
|
@memorypressure, the device lost with Only the instruction itself can settle the order. Three native runs on two chips (gfx1036 raw bytes and text, gfx1030 text, posted above) show the store lands at the first operand's address, which is what AI-assisted (Claude Code). |
slopradish
left a comment
There was a problem hiding this comment.
CPU verification: checked out pull/4160/head in an isolated worktree and ran pytest -q tests/semantic/test_global_sub_dword.py: 12 passed, 87 subtests passed.
The operand-order fix is well covered: the test sweeps all sub-dword global store forms with VDATA in the first operand position, and 87 subtests exercise byte/halfword widths and offsets. The change is paired with a GPU fixture, checker word list, runner registration and a contract row, so the semantic model and hardware fixture stay in sync. The fallback for listings that predate this operand order is preserved by the existing decoder path.
I could not run the GPU fixture here; hardware behaviour is the author's measurement. No game files or keys involved.
|
Tested
|
A correctness fix found by taking the four sub-dword global stores to real hardware.
The bug. LLVM prints the sub-dword stores as
global_store_byte/short[_d16_hi] vdata, vaddr, saddr: VDATA first, unlikeglobal_store_dword, whose syntax isvaddr, vdata, saddr. The translator applied theglobal_store_dwordorder to all of them, so it used the address as the data and the data as the address. On an RX 7600 the ISA-correct store of0x5Aat0x84(v1 = 0x5A,v2 = 0x84,global_store_byte v1, v2) landed as byte0x84at0x5A; after the one-line fix the same shader writes0x5Aat0x84. The four affected ops areglobal_store_byte,global_store_byte_d16_hi,global_store_shortandglobal_store_short_d16_hi. The six sub-dword loads already used the right order and are unchanged.Why nothing caught it.
tests/semantic/test_global_sub_dword.pywrote its store bodies with the address inv1and the data inv2and had its oracle expect exactly that, so the test encoded the same swap as the translator. That is the failure mode the maintainers flagged for semantic tests: a model written in the test that the translator can satisfy while being wrong about the ISA. This PR corrects the test bodies to the ISA order (v1= data,v2= address, including the VGPR-pair case and the rejected-forms list) and adds a hardware check.The new fixture.
runtime/test/shaders/cs_global_sub_dword.asmseeds two dwords through the output V#, then exercises all four stores (byte, byte_d16_hi, short_d16_hi, short, including one across a dword boundary at byte 3), all six loads (the plainubyte/sbyteand the d16 forms with their kept halves) and reads the two dwords back. It failed before the fix and passes after it on both AMD devices here:The row in
docs/design.mdnow says GPU-checked and records the old behaviour. Impact on the corpus: none. Of 10,548global_loadinstructions in the 26,503-shader corpus there are 0global_storeinstructions, so no translated game shader was affected; this is a correctness fix for the supported instruction set, not a released regression.pytest tests/semantic/test_global_sub_dword.py tests/test_run_gpu_tests.py tests/test_docs_design_rows.py tests/test_design_contract_rows.py tests/test_check_no_game_data.py: 63 passed.Note: the two registration lines in
check.pyandrun_gpu_tests.pyare the same ones #4045 appends to, so the two PRs will textually conflict there; whichever lands second is a one-line rebase.