Skip to content

rdna2spirv, shader_disasm: VOPC compares in DPP form (SHADER-VOPC-DPP) - #957

Merged
QemmHD merged 1 commit into
ProjectLeonida:mainfrom
quartz-heron-58:vopc-dpp
Nov 24, 2026
Merged

QemmHD merged 1 commit into
ProjectLeonida:mainfrom
quartz-heron-58:vopc-dpp

Conversation

@quartz-heron-58

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: SHADER-VOPC-DPP (#14 (comment))

Depends on: conflicts with #281 in tools/shader_disasm.py (both split disasm into run_mc plus a second pass over the words llvm-mc rejected; whichever merges second needs a small rebase). Builds on none.

What and why

Three of the 2,684 pipeline-library compute programs of 1.0.2.1 hold a VOPC compare whose src0 field is a DPP marker: 4 v_cmp_gt_f32 each, with quad_perm:[1,0,3,2], quad_perm:[2,3,0,1], row_ror:8 (all bound_ctrl:1, masks 0xF) and dpp8:[4,5,6,7,0,1,2,3], beside v_min/max_f32_dpp and v_mov_b32_dpp on the same lanes. llvm-mc (LLVM 21.1.8, gfx1013) rejects the first word, so the listing dropped 7 words per program and the translator refused all three (fall-through into undecodable words). The retail boot asks for these pipelines at device slot 67.

These are the three small programs still refused with #674 + #647 + #593 + #583 applied (2,672 of 2,684 translate then, measured for the first three and counted from the header census for #583; the other 9 are the large vcc-tuple family). This change needs none of them.

  • tools/shader_disasm.py: a rejected VOPC word with a DPP src0 is decoded with its first word turned into v_max_f32 into v0, which takes the same DPP second word, so llvm-mc prints the two sources and the DPP controls; the line then gets the compare's name, a vcc_lo destination and the real encoding back (with_vopc_dpp). A word that does not come out as the stand-in at an instruction boundary is left as it was.
  • tools/rdna2_decode.py: decodes the pair directly. Before, it printed the DPP marker as an operand.
  • tools/rdna2spirv.py (Gen.dpp_insn): a compare takes src0 through the existing DPP lane selection and writes its mask as the plain compare does. Only the forms where every lane writes its bit are translated: row_mask and bank_mask 0xF and either bound_ctrl 1 or DPP8. Any other form, and v_cmpx, is refused (DPP compare with lanes that keep their mask bit).
  • scripts/run_gpu_tests.py: llvm-mc does not assemble the form either (dpp variant of this instruction is not supported), so a .asm can carry a marker line that passes its text through as the listing, the way regen_fixtures.py writes fixtures. cs_dpp_cmp.asm is the only one.
  • docs/design.md: the contract row "DPP on a VOPC compare".

Not measured on hardware. The rule follows from the encoding, LLVM's GFX11 definition of the same form and the VOP2 DPP rules already measured; tools/crosslane_fuzz.py --dpp-sweep --oracle hw does not cover compares and I have no Linux AMD machine for it. That is why the forms that leave a lane unwritten are refused rather than guessed. If someone with the oracle rig can run the four forms above, the row should say so.

Tested

  • The three programs, from an own 1.0.2.1 copy, with this branch alone: 0 invalid words each, 4 compare lines each, 3 of 3 translate and pass spirv-val (--wave64-emulate). With main's listings and translator: 0 of 3.
  • python -I tests/semantic/test_dpp_compare.py: 9 pass. Lane values for 3 compares x 8 forms x 3 EXEC cases in the SPIR-V interpreter against a reference; refusals; both printers give the same line for 5 synthetic pairs (the llvm-mc cases skip without LLVM_MC).
  • python -I scripts/run_semantic_tests.py tests/semantic: 466 files, 6,117 tests, 1 file fails (test_image_cube_store_glc), which also fails on main here.
  • tests/test_rdna2_decode.py, tests/test_shader_disasm.py, tests/semantic/test_dpp_eager_subgroup.py, tests/test_run_gpu_tests*.py, tests/semantic/regen_fixtures.py --check, tests/test_docs_design_rows.py, tests/test_docs_repo_paths.py, tests/test_docs_table_rows.py: pass.
  • scripts/run_gpu_tests.py --filter cs_dpp: cs_dpp_cmp passes (3 2 3 2 1 0 1 0) on all three runs below, with the other cs_dpp* unchanged.
  • Translated shader counts for the main corpus were not re-measured: none of its 26,503 listings holds the form (all translate on main).

GPUs tested: NVIDIA GeForce RTX 4080 (driver 621.24, Windows 11 26300), native 9/10 with cs_dpp_w64 skipped (no 64-wide subgroup) and LEONIDA_W64_EMULATE=1 10/10; AMD Radeon integrated graphics (PCI 1002:13C0, driver 32.0.21042.62, same machine), native 10/10.

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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.

🤖 Generated with Claude Code

Three pipeline-library compute programs of 1.0.2.1 hold v_cmp_gt_f32 with a
DPP16 or DPP8 src0. llvm-mc has no gfx10 decoding for the pair, so the
listing dropped the words and the programs were refused.

shader_disasm.py prints the pair through a VOP2 stand-in that takes the same
DPP word, rdna2_decode.py decodes it directly, and Gen.dpp_insn translates
the compare for the forms where every lane writes its bit. Other forms and
v_cmpx are refused: what an unwritten lane does to VCC is not measured.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@KernelSmoker KernelSmoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on exact head d046559435c22f1dc834001b1e117a992358f89e. In the Fedora 45 container with LLVM 23.1.5 (LLVM_MC=llvm-mc), test_dpp_compare.py passed 9/9 with both llvm-mc-dependent cases enabled; test_rdna2_decode.py 19/19; test_shader_disasm.py 30/30; test_dpp_eager_subgroup.py 7/7; test_run_gpu_tests.py 64/64; test_run_gpu_tests_python_assembler.py 10/10; test_run_gpu_tests_paths.py 21/21; design rows 5/5; docs repo paths 3/3; docs table rows 2/2. regen_fixtures.py --check, check_no_game_data.py, and git diff --check also passed.

These are CPU/interpreter, assembler/disassembler, and fixture checks; I did not run the GPU shader probe locally. No local GPU result is claimed.

@Timon360SB

Copy link
Copy Markdown
Contributor

Independent GPU testing results

Verified the new VOPC DPP compare fixture on NVIDIA Blackwell hardware using both native execution and Wave64 emulation with Vulkan validation enabled.

The new cs_dpp_cmp fixture passed consistently. An existing Wave64 shared-memory validation issue was reproduced on both BASE and HEAD.

Tested revisions

  • BASE: 8f05e09e224656740e8a53f5047e1338d7a52588
  • HEAD: d046559435c22f1dc834001b1e117a992358f89e

Test environment

Component Configuration
CPU AMD Ryzen 7 7800X3D
GPU NVIDIA GeForce RTX 5070 (Blackwell)
VRAM 12227 MiB
RAM 31.11 GiB
GPU driver 621.14
OS Windows 11 Pro, build 26200
Vulkan SDK 1.4.363.0
Vulkan instance version 1.4.363
LLVM 21.1.8
Python 3.14.0
MSVC 19.44.35230
Compute subgroup range 32–32

Test configuration

  • RelWithDebInfo, Ninja Multi-Config.
  • Full builds.
  • GPU test filter: cs_dpp.
  • Native and Wave64 emulation modes.
  • Vulkan and GPU-assisted validation enabled.
  • Synchronization validation requested.
  • Three repetitions per mode and revision per attempt.
  • Three queue attempts.

Both revisions compiled successfully.

Execution logs confirm nine GPU runner invocations per mode on each revision, for 36 GPU runner invocations overall.

Shader translation

Every invocation reported successful translation and SPIR-V validation for all selected shaders.

Property BASE HEAD
Selected shaders 9 10
Successfully translated 9 10
Passed spirv-val 9 10

The additional HEAD shader is cs_dpp_cmp, which is absent from BASE.

GPU test results

Results across all three attempts:

Test BASE Native HEAD Native BASE Wave64 HEAD Wave64
cs_dpp 9/9 9/9 9/9 9/9
cs_dpp8 9/9 9/9 9/9 9/9
cs_dpp_bank 9/9 9/9 9/9 9/9
cs_dpp_bound 9/9 9/9 9/9 9/9
cs_dpp_cmp N/A 9/9 N/A 9/9
cs_dpp_fi 9/9 9/9 9/9 9/9
cs_dpp_mask 9/9 9/9 9/9 9/9
cs_dpp_ops 9/9 9/9 9/9 9/9
cs_dpp_row 9/9 9/9 9/9 9/9
cs_dpp_w64 SKIP ×9 SKIP ×9 FAIL ×9 FAIL ×9

Aggregate fixture results:

Status BASE HEAD Combined
PASS 144 162 306
FAIL 9 9 18
SKIP 9 9 18
Total 162 180 342

The fixture totals exclude aggregate runner summary records.

New VOPC DPP compare fixture

The new cs_dpp_cmp fixture passed in all native and Wave64 emulation executions.

PASS  cs_dpp_cmp    3 2 3 2 1 0 1 0
Output word Expected Actual
0 3 3
1 2 2
2 3 3
3 2 2
4 1 1
5 0 0
6 1 1
7 0 0
Execution mode Result
Native 9/9 PASS
Wave64 emulation 9/9 PASS
Combined 18/18 PASS

All 144 compared output words across the 18 executions matched the expected values.

No validation failure was attributed to the new fixture in the examined runner results.

Existing Wave64 validation issue

Native cs_dpp_w64 execution was skipped on both revisions because the device does not expose a 64-wide compute subgroup:

SKIP (no 64-wide compute subgroup on this device)

Under Wave64 emulation, the fixture produced correct functional output but failed due to validation diagnostics:

FAIL  cs_dpp_w64    1 groups x 64: 0 mismatches
out[0..7] = 1 0 3 2 5 4 7 6

The validation layer reported shared-memory data races during compute dispatch.

Representative diagnostic:

validation: vkCmdDispatch(): A data race was detected on the shared memory variable "[No OpName found, ID 5]" in local invocation index 1 while performing a store operation. (Likely against local invocation index 63)

This race is between two invocations executing the same instruction.

SPIR-V Instruction: OpStore %271 %44

Every affected invocation reported six validation errors.

Property BASE HEAD Combined
Affected Wave64 executions 9 9 18
Output mismatches 0 0 0
Validation errors per execution 6 6 6
Total validation errors 54 54 108

Across both revisions, all 18 affected Wave64 executions reported zero functional output mismatches and a combined 108 validation errors.

The runner returned exit code 1 for these emulated runs. Native runner invocations returned exit code 0.

The issue was already present on BASE and was not newly introduced by this PR. Whether the reported race represents a genuine synchronization defect or a validation-layer issue requires separate investigation.

Test execution note

During the second attempt, live GitHub PR metadata verification was temporarily unavailable because of a network connection failure.

The recorded pinned revisions and merge base remained unchanged. Live PR metadata verification succeeded in the first and third attempts.

Limitations

  • Tested on one NVIDIA Blackwell GPU.
  • Native hardware Wave64 execution was unavailable.
  • Wave64 coverage was provided through emulation.
  • No physical AMD RDNA2 instruction-level oracle was used.
  • No real-title execution or performance benchmark was performed.
  • Validation-disabled execution was not included in this test plan.

Conclusion

Result: PASS for the new VOPC DPP compare fixture; overall suite requires review due to a pre-existing Wave64 validation issue.

The new cs_dpp_cmp fixture passed all 18 native and emulated executions, with every compared output word matching the expected result.

All eight previously existing non-Wave64 DPP fixtures also remained successful.

The existing cs_dpp_w64 validation failure reproduced identically on BASE and HEAD despite correct functional output.

No new functional regression was identified within the tested DPP coverage.

AI-assisted log analysis and report preparation.

@kawaii-shakal

Copy link
Copy Markdown
Contributor

Independent run of d04655943 on the real pipeline library, with a different llvm-mc than the PR's measurement.

Setup: Windows 11 Pro 26300, native llvm-mc 23.1.5 (built with MSVC from the 23.1.5 source release, AMDGPU target), an own 1.0.2.1 copy. tools/shader_library.py --stages cs --disasm from this branch, then tools/rdna2spirv.py --wave64-emulate from this branch over all 2,684 compute programs.

  • The three motion-blur downsample programs (lib_cs_01473..01475; kind-6 hashes 20032d8b…, 50b2f2b9…, 4cf325ec…): 0 invalid words each (7 each on main's listings), with four v_cmp_gt_f32_dpp vcc_lo lines each: quad_perm:[1,0,3,2], quad_perm:[2,3,0,1], row_ror:8 (all bound_ctrl:1, masks 0xf) and dpp8:[4,5,6,7,0,1,2,3], with the encodings as in the blob. So the stand-in decode also works under LLVM 23.1.5, which still rejects the form for both gfx1013 and gfx1030.
  • Whole library: 2,531 / 2,684 translate and pass spirv-val, against 2,528 on main 82a2aab with the same llvm-mc. Exactly these three are added. fall-through into undecodable words goes from 51 to 48, and every other refusal count is unchanged (vcc tuples, lane-mask s_flbit/s_bitreplicate, one normalized encoding).
  • Driver: vk_pipeline_check on the three modules, NVIDIA GeForce RTX 5070 Ti (driver 617.42, subgroup 32): 3/3 modules and 3/3 compute pipelines created, 0 failed. Creation only: the compares' lane results were not read back on this GPU.

AI-assisted.

@QemmHD

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Merging.

Why merged: SHADER-VOPC-DPP decodes and translates VOPC compares in DPP16/DPP8 form. shader_disasm gets a second llvm-mc pass that patches the word llvm-mc rejects to a v_max_f32 stand-in, then restores the name and encoding. KernelSmoker approved it, Timon360SB ran it on Blackwell native and w64, and kawaii-shakal ran all 2,684 CS programs of the real library through it.

Why it's good: on the RTX 4070 SUPER, scripts/run_gpu_tests.py --filter cs_dpp:

  • native: 9/10 pass, and cs_dpp_w64 is skipped (no 64-wide compute subgroup on this device);
  • with LEONIDA_W64_EMULATE=1 under the Khronos validation layer: 10/10 pass, with no VUIDs;
  • cs_dpp_cmp reads the expected 3 2 3 2 1 0 1 0, and all 10 shaders pass spirv-val.

Own tests (dpp_compare, dpp_eager_subgroup, rdna2_decode, shader_disasm, run_gpu_tests*, docs): 207 passed, 0 skipped. The llvm-mc cases ran with a real AMDGPU llvm-mc.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 66d4f5a. With it in, the repo-consistency set gives 573 passed / 5 skipped / 0 failed, and check_no_game_data is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: decoder and translator branches plus the tool changes above, with no binaries, downloads, network calls or CI changes. Heads-up from the PR body: this conflicts with #281 in shader_disasm.py, so #281 will need a rebase.

AI-assisted (Claude Code, Claude Opus 5.5).

@QemmHD
QemmHD merged commit 6261ca9 into ProjectLeonida:main Nov 24, 2026
6 of 13 checks passed
OreoFR added a commit to OreoFR/leonida that referenced this pull request Nov 25, 2026
Extend ProjectLeonida#957's DPP VOPC compare to v_cmpx: the same lane selection, with the
result written to EXEC. v_cmpx prints no destination, so src0 is its first
operand. Only the forms where every lane writes its bit are taken, as for
v_cmp. 78 pipeline-library pixel shaders of 1.0.2.1 were refused for it; all
78 now translate and pass spirv-val.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aslan2142 pushed a commit that referenced this pull request Nov 26, 2026
…ing, as run_gpu_tests.py does (TEST-TRANSLATE-TEXT-ONLY)

translator-tests fails on main since 6261ca9 (the merge of #957), which added runtime/test/shaders/cs_dpp_cmp.asm:
tests/test_translate.py::test_gpu_samples_translate_and_validate[cs_dpp_cmp.asm] and
::test_wave64_emulate_uses_no_subgroup_ops[cs_dpp_cmp.asm] stop at the llvm-mc assertion of conftest.Shader with
"dpp variant of this instruction is not supported" (2 failed, 1879 passed on a runner with llvm-mc 21; the same two
with 23.1.4).

llvm-mc has no gfx1013 encoding for a VOPC compare in DPP form, so the fixture carries the line
"; run_gpu_tests: text only, ..." and assemble_to_s in scripts/run_gpu_tests.py writes its listing from the text.
conftest.Shader assembled every sample with llvm-mc and did not know the line. It now does the same as the GPU
runner for a sample that carries it, so both tests translate and validate the fixture instead of failing before
they reach the translator.

Two new tests: the line is spelled in conftest as in run_gpu_tests.py, and only a sample that carries it skips
llvm-mc (the same lines without it still go to llvm-mc and fail there). Controls: with the line spelled
differently in conftest the spelling test and both cs_dpp_cmp tests fail; with every sample taking the text path
the second new test fails.

The translator-tests step with the workflow's file list (37 files, pytest 9.2.0, llvm-mc 23.1.4, without numpy
and Pillow, so 134 skipped): 2 failed, 1618 passed on main 89d7dfc; 1622 passed here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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