shader: lower quad-local DPP16 and DPP8 binary16 arithmetic and rounding in pixel_aot #1964

Merged
KomaGuy merged 2 commits from upstream-pr/1971 into main 2026-11-24 23:48:34 +00:00
KomaGuy commented 2026-11-24 22:20:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-24T22:20:57Z.


Summary

Follow-up to #1941 lowering the quad-local DPP16 and DPP8 forms of the 8 binary16 arithmetic and rounding opcodes already contracted under #839 (+16 forms on gfx1013 and rdna2):

  • VOP2 binary16 arithmetic (8 forms): v_add_f16_dpp, v_sub_f16_dpp, v_subrev_f16_dpp, v_mul_f16_dpp (DPP16 + DPP8)
  • VOP1 binary16 rounding (8 forms): v_floor_f16_dpp, v_ceil_f16_dpp, v_trunc_f16_dpp, v_rndne_f16_dpp (DPP16 + DPP8)

Implementation Details

  • Added half16_dpp_source() in tools/pixel_aot.py: enforces the shared low-16-only and static finite-proof contract (known_ssa_bits or known_half, rejecting unproven runtime sources and non-finite halves), with bit-15 abs/neg modifiers allowed on DPP16 and refused on DPP8.
  • src0 is quad-swizzled via emit_quad_swizzle_u32 while src1 stays on the current lane; overflowing VOP2 results are refused via f16_vop2_result; destinations are tagged ("half16", alu) with proven low-16 bits recorded in known_half for chaining.
  • Explicit half_denorm="preserve" at shader entry and HW_REG_MODE RNE rounding remain enforced; WORD_1/whole-word reads, DPP8 source modifiers, bound_ctrl/fi, partial masks, cross-quad dpp8, and unlowered binary16 DPP neighbours (v_min/max_f16_dpp, v_fract_f16_dpp, v_fmac/ldexp_f16_dpp, transcendentals) stay refused.
  • Extended pixel_aot_dpp_f16_{warp,hardware} with four 4-channel programs (arith_dpp16, arith_dpp8, round_dpp16, round_dpp8) testing noisy upper-16 halves, destination sentinels, subnormals (in both default mode and -denorm ftz), -0.0, ties-to-even, half16 chaining, and 12 op/modifier mutations; added all 4 to check_binary, added check_dpp_f16_arith_round_forms() in tests/form_coverage_check.py, and updated docs/experiments.md.

Verification

  • Tested locally on Linux:
    • python3 -B tests/pixel_aot_check.py — passed
    • python3 -B tests/rdna2_tools_check.py — 152 tests OK
    • form_coverage_check: check_f16_arith_forms, check_f16_round_forms, check_dpp_f16_arith_round_forms, check_shader_records — all passed (+16 forms on gfx1013 and rdna2)
    • All 16 expected 16-bit results verified against f16_vop2_result / f16_round_result
    • Assembled all 4 programs with llvm-mc-19 -triple=amdgcn--amdpal -mcpu=gfx1013 and verified round-trip translation through both disasm_rdna2 and libLLVM-19.so
    • docs_links_check.py, bidi_controls_check.py, git diff --check — passed
  • Windows DXC / WARP draw execution (pixel_aot_dpp_f16_warp) and LLVM 15 fixture assembly are pending CI.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592569181 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1971). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-24T22:20:57Z. --- ### Summary Follow-up to #1941 lowering the quad-local `DPP16` and `DPP8` forms of the 8 binary16 arithmetic and rounding opcodes already contracted under #839 (**+16 forms** on `gfx1013` and `rdna2`): - **VOP2 binary16 arithmetic (8 forms):** `v_add_f16_dpp`, `v_sub_f16_dpp`, `v_subrev_f16_dpp`, `v_mul_f16_dpp` (`DPP16` + `DPP8`) - **VOP1 binary16 rounding (8 forms):** `v_floor_f16_dpp`, `v_ceil_f16_dpp`, `v_trunc_f16_dpp`, `v_rndne_f16_dpp` (`DPP16` + `DPP8`) ### Implementation Details - Added `half16_dpp_source()` in `tools/pixel_aot.py`: enforces the shared low-16-only and static finite-proof contract (`known_ssa_bits` or `known_half`, rejecting unproven runtime sources and non-finite halves), with bit-15 `abs`/`neg` modifiers allowed on `DPP16` and refused on `DPP8`. - `src0` is quad-swizzled via `emit_quad_swizzle_u32` while `src1` stays on the current lane; overflowing VOP2 results are refused via `f16_vop2_result`; destinations are tagged `("half16", alu)` with proven low-16 bits recorded in `known_half` for chaining. - Explicit `half_denorm="preserve"` at shader entry and `HW_REG_MODE` RNE rounding remain enforced; `WORD_1`/whole-word reads, `DPP8` source modifiers, `bound_ctrl`/`fi`, partial masks, cross-quad `dpp8`, and unlowered binary16 DPP neighbours (`v_min/max_f16_dpp`, `v_fract_f16_dpp`, `v_fmac/ldexp_f16_dpp`, transcendentals) stay refused. - Extended `pixel_aot_dpp_f16_{warp,hardware}` with four 4-channel programs (`arith_dpp16`, `arith_dpp8`, `round_dpp16`, `round_dpp8`) testing noisy upper-16 halves, destination sentinels, subnormals (in both default mode and `-denorm ftz`), `-0.0`, ties-to-even, `half16` chaining, and 12 op/modifier mutations; added all 4 to `check_binary`, added `check_dpp_f16_arith_round_forms()` in `tests/form_coverage_check.py`, and updated `docs/experiments.md`. ### Verification - Tested locally on Linux: - `python3 -B tests/pixel_aot_check.py` — passed - `python3 -B tests/rdna2_tools_check.py` — 152 tests OK - `form_coverage_check`: `check_f16_arith_forms`, `check_f16_round_forms`, `check_dpp_f16_arith_round_forms`, `check_shader_records` — all passed (+16 forms on `gfx1013` and `rdna2`) - All 16 expected 16-bit results verified against `f16_vop2_result` / `f16_round_result` - Assembled all 4 programs with `llvm-mc-19 -triple=amdgcn--amdpal -mcpu=gfx1013` and verified round-trip translation through both `disasm_rdna2` and `libLLVM-19.so` - `docs_links_check.py`, `bidi_controls_check.py`, `git diff --check` — passed - Windows DXC / WARP draw execution (`pixel_aot_dpp_f16_warp`) and LLVM 15 fixture assembly are pending CI.
tedin7 commented 2026-11-24 23:03:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T22:39:00Z.

Review: COMMENTED


Review of head d8b51b5fc9. Not mergeable yet.

P2 (blocking): the new pixel_aot_dpp_f16 test fails on Win2025, warp and hardware.
In check_dpp_f16_draw (tests/pixel_aot_check.py, around line 9841), one of the arith_round_mutations cases is expected to report mismatch but reports pass. The mutated shader gives the same readback as the original, so that mutation is not killed. Either the mutation does not change the result for the chosen constants or lane layout, or the expected words do not separate it. Please pick inputs that make each listed mutation visible, or drop the ones that cannot be seen.

Failing tests on Win2025 (Debug, ctest --preset dev -R ^pixel_aot): pixel_aot_dpp_f16_warp, pixel_aot_dpp_f16_hardware. The other 174 pixel_aot_* tests passed.
pixel_aot_attribute_sampled_{warp,hardware} also failed (whole_quad: unexpected result). That test is not touched by this PR, so I treat it as unrelated to this head.

Read the diff (tools/pixel_aot.py, tests, docs). The lowering looks consistent with the stated contract:

  • src0 is quad-swizzled and src1 stays on the current lane.
  • Modifiers are refused on DPP8.
  • Overflow, non-finite and unproven operands are refused.
  • Both branches require half_denorm="preserve".

No P1 found in the lowering. Clean-room: no concerns in the changed files.

Commands run locally, with results:

  • git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts.
  • gh pr checks 1971: Linux Python checks pass, Windows build pass, /O2 build skipped, gfx1013 fixtures pending.
  • python3 tests/docs_links_check.py: PASS (386 links).
  • python3 tests/bidi_controls_check.py: PASS.
  • git diff --check origin/main...HEAD: PASS.
  • python3 tests/form_coverage_check.py: could not run locally (iced_x86 missing on this host). CI Linux job passes, so this is not counted against the PR.
  • python3 tests/pixel_aot_check.py on Linux: exits 0 but runs no draws. Source mutations are only checked on Win2025.
  • x2w_pipe.py win2025 1971 --scope direct --regex '^pixel_aot' (Debug): FAIL as above. The default full-scope run could not start (PowerShell command too long), so I used the focused regex. Release /O2 was not run, because Debug already fails.
  • Local source mutations (drop a src1 line; swizzle src1): no draw runs on Linux, so they were not killed locally. I did not use them as evidence. Reverted with git checkout -- ..

No approval and no merge. Please fix the unkilled mutation and push a new head.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6048516334 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1971#pullrequestreview-6048516334). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T22:39:00Z. **Review:** COMMENTED --- Review of head d8b51b5fc98b631e4cf496d6dccfec5517e0e76b. Not mergeable yet. **P2 (blocking): the new `pixel_aot_dpp_f16` test fails on Win2025, warp and hardware.** In `check_dpp_f16_draw` (`tests/pixel_aot_check.py`, around line 9841), one of the `arith_round_mutations` cases is expected to report `mismatch` but reports `pass`. The mutated shader gives the same readback as the original, so that mutation is not killed. Either the mutation does not change the result for the chosen constants or lane layout, or the expected words do not separate it. Please pick inputs that make each listed mutation visible, or drop the ones that cannot be seen. Failing tests on Win2025 (Debug, `ctest --preset dev -R ^pixel_aot`): `pixel_aot_dpp_f16_warp`, `pixel_aot_dpp_f16_hardware`. The other 174 `pixel_aot_*` tests passed. `pixel_aot_attribute_sampled_{warp,hardware}` also failed (`whole_quad: unexpected result`). That test is not touched by this PR, so I treat it as unrelated to this head. Read the diff (`tools/pixel_aot.py`, tests, docs). The lowering looks consistent with the stated contract: - src0 is quad-swizzled and src1 stays on the current lane. - Modifiers are refused on DPP8. - Overflow, non-finite and unproven operands are refused. - Both branches require `half_denorm="preserve"`. No P1 found in the lowering. Clean-room: no concerns in the changed files. Commands run locally, with results: - `git merge-tree --write-tree --name-only origin/main HEAD`: clean, no conflicts. - `gh pr checks 1971`: Linux Python checks pass, Windows build pass, `/O2` build skipped, gfx1013 fixtures pending. - `python3 tests/docs_links_check.py`: PASS (386 links). - `python3 tests/bidi_controls_check.py`: PASS. - `git diff --check origin/main...HEAD`: PASS. - `python3 tests/form_coverage_check.py`: could not run locally (`iced_x86` missing on this host). CI Linux job passes, so this is not counted against the PR. - `python3 tests/pixel_aot_check.py` on Linux: exits 0 but runs no draws. Source mutations are only checked on Win2025. - `x2w_pipe.py win2025 1971 --scope direct --regex '^pixel_aot'` (Debug): FAIL as above. The default full-scope run could not start (PowerShell command too long), so I used the focused regex. Release `/O2` was not run, because Debug already fails. - Local source mutations (drop a src1 line; swizzle src1): no draw runs on Linux, so they were not killed locally. I did not use them as evidence. Reverted with `git checkout -- .`. No approval and no merge. Please fix the unkilled mutation and push a new head. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 00:04:45 +00:00
tedin7 commented 2026-11-25 00:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:09:56Z.

Review: COMMENTED


Review of head f1ade5b348550f71ed7dba292ff6f1ea9384fbdc.

Scope: tools/pixel_aot.py, tests/pixel_aot_check.py, tests/form_coverage_check.py, docs/experiments.md. No CMake change. Lowering reuses the existing finite-proof, quad-swizzle and narrow16 helpers. Clean-room: no external code, no new tables.

Findings: P1 = 0, P2 = 0.

Semantics checked:

  • src0 is quad-swizzled and src1 stays on the current lane.
  • abs/neg are refused on DPP8.
  • Non-finite and overflowing results are refused.
  • Operands without a finite proof are refused.
  • HALF_RTZ is refused, and denorm "preserve" is required.
  • The destination is tagged ("half16", alu) with its proven bits.

Commands executed locally:

  • git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts.
  • python3 tests/pixel_aot_check.py: PASS.
  • python3 tests/docs_links_check.py: PASS (386 links).
  • python3 tests/bidi_controls_check.py: PASS.
  • git diff --check origin/main...HEAD: clean.
  • python3 tests/form_coverage_check.py: not runnable locally (iced_x86 missing). The Linux CI job passed it.
  • python3 x2w_pipe.py win2025 1971 --regex '^pixel_aot_dpp_f16_warp$' --py-checks tests/pixel_aot_check.py: Debug --preset dev 1/1 passed; Release /O2 --preset release 1/1 passed; Windows pixel_aot_check.py ok.

Mutations (each reverted with git checkout -- .):

  1. VOP2_F16["subrev"] changed to {0} - {1}: pixel_aot_check.py fails (f16_arith_controls_no_ref). Killed.
  2. VOP1_F16_ROUND["ceil"] changed to floor({0}): fails (check_f16_round_controls). Killed.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6048867072 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1971#pullrequestreview-6048867072). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:09:56Z. **Review:** COMMENTED --- Review of head `f1ade5b348550f71ed7dba292ff6f1ea9384fbdc`. Scope: `tools/pixel_aot.py`, `tests/pixel_aot_check.py`, `tests/form_coverage_check.py`, `docs/experiments.md`. No CMake change. Lowering reuses the existing finite-proof, quad-swizzle and `narrow16` helpers. Clean-room: no external code, no new tables. Findings: P1 = 0, P2 = 0. Semantics checked: - `src0` is quad-swizzled and `src1` stays on the current lane. - `abs`/`neg` are refused on DPP8. - Non-finite and overflowing results are refused. - Operands without a finite proof are refused. - `HALF_RTZ` is refused, and denorm "preserve" is required. - The destination is tagged `("half16", alu)` with its proven bits. Commands executed locally: - `git merge-tree --write-tree --name-only origin/main HEAD`: clean, no conflicts. - `python3 tests/pixel_aot_check.py`: PASS. - `python3 tests/docs_links_check.py`: PASS (386 links). - `python3 tests/bidi_controls_check.py`: PASS. - `git diff --check origin/main...HEAD`: clean. - `python3 tests/form_coverage_check.py`: not runnable locally (`iced_x86` missing). The Linux CI job passed it. - `python3 x2w_pipe.py win2025 1971 --regex '^pixel_aot_dpp_f16_warp$' --py-checks tests/pixel_aot_check.py`: Debug `--preset dev` 1/1 passed; Release `/O2` `--preset release` 1/1 passed; Windows `pixel_aot_check.py` ok. Mutations (each reverted with `git checkout -- .`): 1. `VOP2_F16["subrev"]` changed to `{0} - {1}`: `pixel_aot_check.py` fails (`f16_arith_controls_no_ref`). Killed. 2. `VOP1_F16_ROUND["ceil"]` changed to `floor({0})`: fails (`check_f16_round_controls`). Killed. AI-assisted; commands listed were executed locally.
KomaGuy commented 2026-11-25 01:01:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KomaGuy on 2026-11-24T23:05:40Z.


Thanks for catching this on Win2025!

Found the unkilled mutation: in arith_dpp8, mutating v_add_f16_dpp v24, v20, v21 to v_sub_f16_dpp v24, v20, v21 operated on (-0.0, -0.0) where src0 came through QuadReadLaneAt (non-constant) and src1 folded to constant -0.0f, so DXC simplified fsub %x, -0.0 to %x and returned 0x8000 just like the original. Every other mutation in arith_round_mutations changes the numerical value by at least 1.0.

Pushed f1ade5b3 which:

  • Replaces the signed-zero-only arith_dpp8 mutation with numerically distinct mutations (v24 src1 v21 -> v22 giving -0.0 -> +1.0, v25 sub -> add giving -1.5 -> +3.5, plus mul -> add on v27 for both arith_dpp16 and arith_dpp8), so every mutation in DPP_F16_ARITH_ROUND_MUTATIONS changes an exported channel by at least 1.0.
  • Prints each mutation's batch status and includes (name, old, new) in the assertion message if any mutation escapes, matching check_f16_arith_draw.

Verified locally on Linux (pixel_aot_check.py, docs_links_check.py, bidi_controls_check.py, git diff --check, and a Python check confirming every listed mutation changes an exported channel by |delta| >= 1.0). Ready for another Win2025 check.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147005757 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1971#issuecomment-7147005757). Originally posted by [KomaGuy](https://github.com/KomaGuy) on 2026-11-24T23:05:40Z. --- Thanks for catching this on Win2025! Found the unkilled mutation: in `arith_dpp8`, mutating `v_add_f16_dpp v24, v20, v21` to `v_sub_f16_dpp v24, v20, v21` operated on `(-0.0, -0.0)` where `src0` came through `QuadReadLaneAt` (non-constant) and `src1` folded to constant `-0.0f`, so DXC simplified `fsub %x, -0.0` to `%x` and returned `0x8000` just like the original. Every other mutation in `arith_round_mutations` changes the numerical value by at least `1.0`. Pushed `f1ade5b3` which: - Replaces the signed-zero-only `arith_dpp8` mutation with numerically distinct mutations (`v24` `src1` `v21 -> v22` giving `-0.0 -> +1.0`, `v25` `sub -> add` giving `-1.5 -> +3.5`, plus `mul -> add` on `v27` for both `arith_dpp16` and `arith_dpp8`), so every mutation in `DPP_F16_ARITH_ROUND_MUTATIONS` changes an exported channel by at least `1.0`. - Prints each mutation's batch status and includes `(name, old, new)` in the assertion message if any mutation escapes, matching `check_f16_arith_draw`. Verified locally on Linux (`pixel_aot_check.py`, `docs_links_check.py`, `bidi_controls_check.py`, `git diff --check`, and a Python check confirming every listed mutation changes an exported channel by `|delta| >= 1.0`). Ready for another Win2025 check.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1964
No description provided.