Repository navigation
tools: decode the pipeline-library compute programs llvm-mc refuses - #998
Conversation
llvm-mc 21 cannot decode SMEM loads whose SOFFSET is null (0x7D), so whole pipeline-library compute programs of 1.0.2.1 came out with invalid words and failed to translate. For compute programs, shader_disasm now falls back to rdna2_decode when that decodes more of the program, and rdna2_decode reads VOPC with DPP16/DPP8 as the 8-byte form it is. rdna2spirv: - SMEM with vcc as its base reads the vcc_lo/vcc_hi pair. - s_flbit_i32_b64 of a lane mask reads the wave's 64-bit mask (18 library programs), as s_ff1_i32_b64 already does. - s_bitreplicate_b64_b32 of a lane mask into plain scalar data replicates the wave's mask word (6 library programs); into exec/vcc it stays Unsupported. test_salu_flbit_64: the lane-mask case now translates (the subgroup op is outside the single-invocation interpreter), so the test checks that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alid words Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The retail boot reached 50 pipeline-library compute programs that had no translation. Dumped from the running game, they all translate and pass spirv-val after these changes: - fspx_unpack.code_range: some programs carry a 24-byte hash prologue (two VOP3 words, then s_inst_prefetch) instead of 36 bytes; two or three hash words now count (shader_library uses the same range). - fspx_unpack --last-endpgm: early exits branch past the first s_endpgm, and data after the code can hold s_endpgm words, so a program ends at the first s_endpgm whose listing keeps every branch inside the code. - rdna2spirv: v_cmp_*_dpp into vcc (12 compares in reductions), taken when every lane writes (full row/bank masks with bound_ctrl:1, or DPP8). - rdna2spirv: s_bitreplicate_b64_b32 of a constant into vcc (6 programs), as the exec form does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te programs llvm-mc refuses Conflicts with ProjectLeonida#583 (merged just before) in fspx_unpack.code_range and its test: both handle the two-hash-word, 24-byte prologue of some pipeline-library programs. ProjectLeonida#998's version counts the hash words (two or three) and covers ProjectLeonida#583's case, so it is kept; ProjectLeonida#583's two constants, used only there, are dropped and its measurement comment (50 of 2,684 programs) stays. Both PRs' tests are kept and pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent check of head I matched the three slot-67 failures in a local DadaCap On the same runtime, supplementing the shader index with only those three translations removed the three slot-67 The PR head's |
bobcatchris
left a comment
There was a problem hiding this comment.
Reviewed bec14f225 on a second vendor and LLVM version: Windows 11, LLVM 21.1.8, Python 3.12, an AMD Radeon RX 7900 XTX in the box but no GPU work. AI-assisted.
Tests. The seven files you list pass (145 tests).
Rebase. It is 257 commits behind main (507029d1e) and conflicts in two files. Both conflicts are in code main already has from the VOPC-DPP change: the compare-with-DPP-src0 block in tools/rdna2_decode.py, and the compare branch of the DPP path in tools/rdna2spirv.py. I merged main in locally and took main's side of both. That leaves your rdna2_decode.py identical to main and your diff at 7 files, +154/−23. One trap: your self.dpp_guard = None if lane_mask_dst else write merges cleanly, but lane_mask_dst is then defined nowhere, and main already returns before that line for compares. It should go back to self.dpp_guard = write; left as it is, every DPP instruction that is not a compare raises NameError. With that, your seven files plus test_dpp_compare and test_dpp_eager_subgroup pass (161 tests).
Coverage. The first 700 compute programs of the 1.0.2.1 library in index order, --wave64-emulate, each tree with its own listing path:
| tree | translated | pass spirv-val |
|---|---|---|
main |
599 of 700 | 599 |
this PR merged on main |
700 of 700 | 700 |
- The 101 refusals on
mainare 90fall-through into undecodable words, 6undecodable words (cannot re-anchor), 4s_flbit_i32_b64 of a lane maskand 1s_bitreplicate_b64_b32 on a lane mask. - 96 of the 700 listings take the decoder fallback, and all 96 translate.
- Nothing that
maintranslates is lost. 592 of the 599 shared modules are byte-identical. The other 7 (lib_cs_00857tolib_cs_00867) differ only by two or threeOpAccessChaineach: they holds_bitreplicate_b64_b32 exec, IMM, which is theexecpath you changed, so this is a behaviour change for programsmainalready translated.
The stated cause. The docstring says llvm-mc 21 does not decode SMEM loads whose SOFFSET is null. On 21.1.8 it decodes those: s_load_dwordx8 s[16:23], s[2:3], null assembles and disassembles. What it rejects is a scalar register tuple that reaches s106/s107:
s_load_dwordx4/x8/x16with its data ats[104:107],s[100:107]ors[96:107];s_buffer_load_*with its four-register descriptor ats[104:107];- from the listings, image instructions with the sampler at
s[104:107].
In the 115 flagged listings I had at the time, the 40 most common shapes of the rejected words come to about 3,200 of this kind against 37 of any other. Your fix covers them either way, because the decoder prints the [s100,...,vcc_lo,vcc_hi] form shader_ir.py already reads. The comment should name the tuple, so that the rule says how it was confirmed.
One decision to make in the open. On a program that takes the fallback, the listing's encodings are the code bytes (finish() stores code[pc:pc + nbytes]), so check_printed_encodings can no longer see a word llvm-mc would have printed differently; and the decoder does not check must-be-zero bits. I flipped every bit of a set of reference instructions and compared the two decoders. Where llvm-mc rejects or renormalises a flip, the decoder returns the same instruction for the scalar-memory reserved bits (w0 13, 15, 17 and w1 21 to 24) and for DPP16 w1[17].
- Over all 2,684 compute programs (17.7M instructions) no scalar-memory reserved bit is ever set.
- DPP16
w1[17]is set in 24 instructions of 4 programs:lib_cs_21476,lib_cs_21500,lib_cs_21520,lib_cs_21521. maintranslates 1 of those 4 and refuses 3. With this PR all 4 translate, with the bit read as clear.
main refuses a reachable word of that kind, so this changes the policy for those programs. Either is defensible, but I think it should be a choice in the PR and not a side effect of the fallback. The smallest options are to have the fallback listing count such words and refuse, or to write the choice into the contract table.
Contract table. The PR changes two rules that docs/design.md still describes the old way. The s_flbit_i32_b64 row says a pair that lane_masks.py marks as a lane mask stays Unsupported. The s_quadmask/s_bitreplicate row says a lane-mask source or an EXEC/VCC destination raises Unsupported. Neither row is updated, and the fallback listing is a third rule without a row.
Not run. No translated program on a GPU. --last-endpgm and branch_closed_end only through test_fspx_unpack.py. The other 1,984 programs are not compared yet; I will add the full-corpus count when I have it.
Recommendation: Fix first. The rebase and the contract rows; the rest as you decide.
|
Full-corpus numbers, as promised: all 2,684 compute programs of the 1.0.2.1 library,
Correction to my first review. Its 700-program sample was the first 700 in index order, and that is not a fair sample: the programs with rejected words cluster by index. Per decile of the 2,684, 18, 41, 100, 146, 73, 144, 197, 133, 46 and 25 are flagged. The sample showed 14% of programs refused; the whole corpus is 37%. Order of merging. #623 hands llvm-mc its input in 64-byte lines. With Still not run: nothing on a GPU, and |
|
GPU results, to close the "not run" line from my review: I built this PR's runtime test runners (RelWithDebInfo, MSVC 19.39, Ninja) and ran the GPU shader suite on the machine from my first review — Windows 11, AMD Radeon RX 7900 XTX (gfx1100), driver 26.10.1, Vulkan SDK 1.4.341. AI-assisted.
The two failures are They are not from this PR. I built the merge-base What this adds to the review: the ops the PR changes are covered by fixtures that passed on the 7900 XTX in both modes, including Separately, and good news rather than a tracker item: the same two fixtures pass on |
|
I rebased the three commits onto current What main landed since your base, and how the conflicts resolved
Verification, all on the rebased branch
The corpus number is the headline: On the GPU suite: the one failure is Still only Not pushed to your branch, not merged, and nothing dispatched in the title. Build note for reviewers on Windows: configure with |
…ct-table sentence ProjectLeonida#998 added the rule (a 32-bit EXEC/VCC half as S0, read through Gen.wave_mask) without a test or a design.md entry. test_lane_mask_bitreplicate_flbit.py now runs it on every lane of a wave64 in the CPU interpreter, from exec_lo/exec_hi and from a compare's vcc_lo/vcc_hi, against the ISA pseudocode. design.md says it is interpreter-checked only, not measured on hardware, and that a VCC destination stays wave64-only (ProjectLeonida#984's rule).
37 upstream commits after 86dc3d8: ProjectLeonida#2138 (integration/boot-combined), ProjectLeonida#2094 (geometry-view eviction on range release, reaped after the replays that may name them), ProjectLeonida#998/ProjectLeonida#1317/ProjectLeonida#1281/ProjectLeonida#583 heads (pipeline-library compute programs by code hash, shader_disasm prints the dot4 op_sel words llvm-mc rejects, FSPX short prologue with the literal-form check), null-resource texture barriers and null-view RTV clears on the console list, and the removal of the title's executable addresses from code (read from the environment). Conflicts, on merit: - d3d12_xs_device.cpp: both. Our title heap sync (LEONIDA_TITLE_HEAP_SYNC) and upstream's null-RTV marks sit side by side; heap_release unregisters the sync or the range as before and also drops the heap's null-RTV marks; CreateDescriptorHeap keeps our desc argument and takes upstream's RTV real range. Our value-op/upload-ring slots and upstream's slot 146 barrier conversion both stay. - startup_trace.h: our thread and watchdog-table logging stays, and follows upstream's rule: the watchdog table's store and table RVAs come from LEONIDA_WATCHDOG_TABLE (off when unset, documented in runtime/README.md); upstream's environment-driven pool diagnostic replaces the fixed address. - fspx_unpack.py: ours (the code end is found from one rdna2_decode pass, not an llvm-mc run per s_endpgm: the OOM and 15-minute fix). Its test takes upstream's short-prologue case, which checks the literal form our code also requires. - rdna2spirv.py: ours (s_bitreplicate_b64_b32 into VCC in wave32 stays translated: 6 pipeline-library programs), plus the point behind upstream's refusal: in wave32 VCC's high word is data, so it is now written to vcc_hi as source bits 16..31 replicated (replicate_bits16, shared with the scalar form). Tests: ours kept, one added for the vcc_hi word; test_salu_flbit_64 keeps ours (this tree translates i64 of a lane mask). - xs_proxy_mock_test.cpp: upstream's empty Barrier call, our chained-submission reference count. Every line the merge removes from our side is upstream's own or one of the resolutions above (checked against the merge base, D:\GTA6\analysis\lostlines.sh). The touched Python suites pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
llvm-mc 21 cannot decode SMEM loads whose SOFFSET is null (0x7D). Because of that, whole pipeline-library compute programs of 1.0.2.1 disassembled with invalid words and failed to translate. A retail boot also reached 50 more library programs that had no translation; dumped from the running game, all 50 now translate and pass spirv-val.
Changes
compute=True, passed by shader_library and fspx_unpack), it falls back tordna2_decode.disasm_byteswhen that leaves fewer invalid words than llvm-mc.--last-endpgm: early exits branch past the first s_endpgm, and data after the code can hold s_endpgm words, so a program ends at the first s_endpgm whose listing keeps every branch inside the code.vccas its base reads the vcc_lo/vcc_hi pair.s_flbit_i32_b64of a lane mask reads the wave's 64-bit mask (18 library programs), ass_ff1_i32_b64already does.s_bitreplicate_b64_b32of a lane mask into plain scalar data replicates the wave's mask word (6 library programs). From a constant into vcc it sets each lane's bit as the exec form does (6 programs).v_cmp_*_dppinto vcc (12 compares in reductions) is taken when every lane writes (full row/bank masks with bound_ctrl:1, or DPP8).test_salu_flbit_64: the lane-mask case now translates; the subgroup op is outside the single-invocation interpreter, so the test checks that.test_fspx_unpack: the invalid-word case takes the decoder's listing; new cases cover the two-word prologue,code_range_lastand branch checks.test_salu_quadmask_bitreplicate: new case for bitreplicate into vcc.Result
Library programs: 2633 of 2684 translated after the first commit; the 50 the retail boot then dumped as missing all translate after the second.
Testing
These pass:
tests/semantic/test_salu_flbit_64.pytests/semantic/test_salu_quadmask_bitreplicate.pytests/test_fspx_unpack.pytests/test_shader_library.pytests/test_rdna2_decode.pytests/test_shader_disasm.pytests/test_rdna2spirv_decode.pyThe VOPC-DPP path is checked only by spirv-val, since the interpreter runs no subgroup ops. Tested on an RTX 3080 Laptop, i7-11800H, Windows 10.
🤖 Generated with Claude Code