rdna2spirv: forward DPP src0 neg/abs to op readers instead of eager 32-bit modify (SHADER-DPP-F16-AND-SIGN-MODS) #2362
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2362"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by ShotTechOp on 2026-11-26T15:30:52Z.
Item ID:
SHADER-DPP-F16-AND-SIGN-MODSSummary
Fixes
Gen.dpp_insn()intools/rdna2spirv.pysosrc0'sneg/absmodifiers are forwarded on the post-selectssaoperand instead of eagerly applying 32-bit floatGen.modify(src0, src)(bit 31FAbs/OpFNegate) before dispatching to_insn():v_add_f16_dpp,v_sub_f16_dpp,v_subrev_f16_dpp,v_mul_f16_dpp,v_min_f16_dpp,v_max_f16_dpp,v_fmac_f16_dpp,v_cvt_f32_f16_dpp,v_cmp_*_f16_dpp, etc.): previouslyGen.modify()cleared/flipped bit 31 (the unused high half) and strippedneg/abs, so-v1and|v1|were completely ignored on the f16 low half (bit 15), andbound_ctrl:1with-v1produced+0.0hinstead of-0.0h. Forwardingneg/absletsf16_in/f16_in_bits/modify_f/cmp_classapply them to bit 15 after the invalid-lane zero select.v_cndmask_b32_dpp,v_min_f32_dpp,v_max_f32_dpp,v_cmp_class_f32_dpp): previously eagerGen.modify()emittedFAbs/OpFNegate(which can quiet sNaNs and flush denormals) before those ops ran their raw integer bit-31 sign-move paths (src_u_sign_mods/src_f_sign_mods/cmp_class).HW-DPP-NEG-INVALID-LANE(test_dpp_bound_ctrl_modifiers.py): modifiers still apply afterOpSelect %uint %src_ok %shuffled %c0, sov_mov_b32_dpp v2, -v1 ... bound_ctrl:1still produces-0.0f(0x80000000) withOpBitcast %float+FAbs/OpFNegateon the select result.Updates the DPP contract row in
docs/design.mdand addstests/semantic/test_dpp_f16_mods.py.Verification
spirv_mini_interp&spirv_wave_interp; no local GPU/Vulkan/spirv-valinstalled)python -I tests/semantic/test_dpp_f16_mods.py -v-> 4/4 OK (wave32 &--wave64-emulate)python -I tests/semantic/test_dpp_bound_ctrl_modifiers.py-> 2/2 OKpython -I tests/semantic/test_dpp_compare.py-> 9/9 OK (2 skipped)python -I tests/semantic/test_dpp_eager_subgroup.py-> 8/8 OKpython -I tests/test_text_write_line_endings.py-> 3/3 OKpython -m compileall -q tools/rdna2spirv.py tests/semantic/test_dpp_f16_mods.py-> exit 0python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_dpp_f16_mods.py docs/design.md-> exit 0git diff --check-> cleanorigin/main(tools/extracted fromorigin/main):tests/semantic/test_dpp_f16_mods.pyfails 4/4 tests (v_add_f16_dpp/v_mul_f16_dppignore f16-/| |,v_cvt_f32_f16_dppyields+0.0finstead of-0.0f,v_min_f16_dppyields+1.0hinstead of-3.0h, andv_cndmask_b32_dpp/v_cmp_class_f32_dppemitOpFNegate).Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:35:07Z.
Review: COMMENTED
Windows 11: 21 DPP semantic tests passed, including the new f16 modifier and sign-bit cases. Two existing assembly checks skipped because AMDGPU
llvm-mcwas unavailable in this test environment. No correctness findings from the semantic runs.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-26T16:18:49Z.
I compared the translator at
cf622ce9c2with its parentfbf100b1b1using synthetic compute shaders on a physical RTX 4090, Windows 11, NVIDIA 616.64. A dispatch passed only if every output word and the trailing buffer sentinel matched the CPU reference.The quad-shuffle cases cover half-precision add, multiply, minimum and compare with negation, absolute value, both modifiers, and an unmodified control. The row-shift cases check both settings of
bound_ctrl. At the first lane of a row,v_cvt_f32_f16_dppwith negation andbound_ctrl:1returned positive zero on the parent and the expected negative zero (0x80000000) on the PR. The raw 32-bit select and classification cases also checked signaling and quiet NaN inputs, payload bits and signed zeros.All 18 generated modules per revision passed
spirv-val --target-env vulkan1.2. Vulkan validation was enabled throughout. The four focused DPP test files also passed all 23 tests with LLVM available.Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-26T18:19:03Z.
Review: COMMENTED
macOS arm64 check of #2362 (SHADER-DPP-F16-AND-SIGN-MODS). Translator-only plus one semantic test, so it runs here; the GPU part is MoltenVK/KosmicKrisp.
Tested head
cf622ce9cmerged ontomainbdbc7e923as mergef181a4193(clean; branch 21 commits behind,git merge-treeclean).Environment: Apple M3 Pro, arm64 (subgroups 4..32), macOS 27.2.1, CPython 3.15.2, SPIRV-Tools v2026.4, llvm-mc 23.1.5, MoltenVK 1.4.0; KosmicKrisp and lavapipe = Mesa 26.3.0.
The new test passes, and its control bites on values
python -I tests/semantic/test_dpp_f16_mods.py:Ran 4 tests ... OKat the head and after merging ontobdbc7e923.tools/rdna2spirv.pyput back tomain's):FAILED (failures=4), all four tests. Unlike a structural test, these fail on the computed words:test_v_add_f16_dpp_neg_and_abs_wave32_and_emulatelane 02882387968 != 2882356224;test_v_cvt_f32_f16_dpp_neg_and_bound_ctrl_zerolane 00 != 0x80000000;test_v_min_f16_and_v_cmp_gt_f16_dpp_neg[0x3C00 ...] != [0xC200 ...];test_v_cndmask_b32_and_cmp_class_f32_dpp_preserve_sign_bit_movesfindsOpFNegatein a path that must keep raw sign bits. The old translator's behaviour the test describes is what I measured onmain.v_mov_b32_dpp -v1,v_add_f32_dpp -v1, 0.5andv_max_f32_dpp |v1|, 0(quad_perm, full masks,bound_ctrl:1) with the head and withmain's translator through the same interpreter.v_mov_b32reads throughsrc_u->modify, so forwarding the flag still applies it: the outputs were identical (0xbf800000,0xbf000000,0x3f800000in every lane). Those three ops are not in the new test.No regressions
mainbdbc7e923; 501 files / 6,371 tests / 0 failed at the merge (+1 file, +4 tests).mainand the merge after normalising the per-run temp directory. Same pre-existing failures (cs_fma_fused,cs_imgatomic_ext,ps_ssharpon MV;cs_bvh,cs_bvh32,cs_imgatomic_ext,ps_cndmask_sign_mods,ps_valu16_mad_selon KK).Findings
cs_dpp.asm,cs_dpp8.asm,cs_dpp_bank.asm,cs_dpp_bound.asm,cs_dpp_cmp.asm,cs_dpp_fi.asm,cs_dpp_mask.asm,cs_dpp_ops.asm,cs_dpp_row.asm,cs_dpp_w64.asmusesneg/abson a_dppop, and the doc row says "not yet GPU-verified". So the f16 sign-bit behaviour (and the sNaN-preserving cndmask/class path) rests onspirv_mini_interponly. Acs_dpp_f16_mods.asmwith the four cases of the new test (one word per lane stored) would settle it on any GPU, the same waycs_dpp_cmp.asmdoes for compares.v_add_f16,v_mul_f16,v_min_f16,v_cmp_gt_f16,v_cvt_f32_f16,v_cndmask_b32,v_cmp_class_f32). The mechanism is shared, and I checkedv_mov_b32/f32 add/max by hand as above, so this is a note rather than a hole; adding one f32 op to the test (v_add_f32_dpp -v1) would pin that forwarding still goes throughmodifyfor the 32-bit readers that have no f16 half to fix.python -I scripts/check_no_game_data.pyon the changed files: clean.git diff --check: clean.No game files. AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:56:22Z.
Hi @ShotTechOp, thanks for this pull request. It currently conflicts with
main(conflicting file(s):docs/design.md,tools/rdna2spirv.py), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T04:50:19Z.
Checked
cf622ce9cagainstmainef3299584on Windows 11 10.0.26300: it does not merge (git merge-tree --write-tree), so I ran no tests.tools/rdna2spirv.py,Gen.dpp_insn.df294dd8a(2026-11-26, SHADER-CVT-F16-DENORM-AND-MODS) changed the same lines. Onmain, onlyv_cvt_f32_f16passes src0's modifiers through the lane select; every other op still takes the eager 32-bitself.modify(src0, src). Both sides also edited the DPP rows ofdocs/design.md.v_cvt_f32_f16still loseneg/absonmain, andtests/semantic/test_dpp_f16_mods.pyis not inmain. The rebase has to keepmain'sv_cvt_f32_f16branch working with the forwardedneg/abs.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by Tauwni on 2026-11-29T07:38:45Z.
AMD complement to the RTX 4090 run above. The PR does not merge into current
main, so this compares the head with its own parent, as that run did.Radeon RX 9060 XT (RDNA4, subgroup 32..64), driver 32.0.23033.1002 (Vulkan 26.3.1), Windows 10 Pro 22H2 19045.7846, llvm-mc 21.1.8 (AMDGPU), CPython 3.14.6. Head
cf622ce9cagainst its parentfbf100b1b.tests/semantic/test_dpp_f16_mods.py: passes 3/3 at the head. MEASURED.scripts/run_gpu_tests.pysuite, native wave, 1 run each side, same runtime build. MEASURED. Parent and head fail the same three cases:cs_imgatomic_ext(#2593 fixes it),cs_texture_uav(#2261) andcs_tbuffer_store. That last one is ASSUMED to be this card's older driver: it passes on the same GPU with 26.11.2 perdocs/gpu_test_results.md. No case changes between the two, the DPP ones included.Not checked by a second agent or human yet. AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T13:40:24Z.
Carried as #2730 because of the conflict with main after #2566; @ShotTechOp, if you come back, say so and the carry is dropped.