feat(rdna2-ref): run f16 integer/norm conversions, packs and min3/max3/med3 #505

Merged
Lewandox merged 1 commit from upstream-pr/505 into main 2026-11-27 19:38:44 +00:00
Lewandox commented 2026-11-27 14:34:00 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-27T14:34:00Z.


Change

Port the 14 half-precision integer/normalized conversion, pack and three-operand min/max/med3 instructions (20 VOP1 and VOP3 encodings) added to the Python model in #275 (emu/rdna2_exec_f16conv.py) to crates/anyxboxx-rdna2-ref (f16conv.rs):

  • VOP1 and VOP3: v_cvt_f16_u16, v_cvt_f16_i16, v_cvt_u16_f16, v_cvt_i16_f16, v_cvt_norm_i16_f16, v_cvt_norm_u16_f16.
  • VOP3-only: v_cvt_pknorm_i16_f16, v_cvt_pknorm_u16_f16, v_cvt_pknorm_i16_f32, v_cvt_pknorm_u16_f32, v_pack_b32_f16, v_min3_f16, v_max3_f16, v_med3_f16.
  • Exact single-rounding ties-to-even normalized scaling (24 f32 significand bits × 16-bit scale = 40 bits, exact in 53-bit f64), ISA v_med3_f16 NaN/±0 rules, low-16-bit inline float constants on 16-bit integer sources, and all shared VOP1/VOP3 refusals (SDWA/DPP, omod, clamp on integer/packed results, op_sel restrictions).

Linked issue: Refs #482 (follow-up covering #275)

Verification

cargo +stable-x86_64-pc-windows-gnu test -p anyxboxx-rdna2-ref → 141 passed; 0 failed
cargo +stable-x86_64-pc-windows-gnu clippy -p anyxboxx-rdna2-ref --all-targets -- -D warnings → 0 warnings
cargo +stable-x86_64-pc-windows-gnu fmt --check -p anyxboxx-rdna2-ref → clean
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!
python -m pytest tests/test_rdna2_ref_f16conv_parity.py tests/test_readme_sync.py → 12 passed, 1 skipped

Oracle and test data

  • Oracle: PrototypeScarlett/emu/rdna2_exec_f16conv.py (AMD RDNA 2 ISA sections 6.2.5, 12.7, 12.8, 12.12).
  • Test data: tests/test_rdna2_ref_f16conv_parity.py checks all 65,536 16-bit inputs across all 6 unary conversions (393,216 evaluations), fixed VOP3 encodings and shared refusals across all 20 encodings, and 250 seeded multi-instruction programs.
  • Failure case without this change: tests/test_rdna2_ref_f16conv_parity.py fails because anyxboxx-rdna2-ref refuses all 20 encodings with error untranslated.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: the same change in the English and French READMEs (test_readme_sync.py checks it; collected count stays 1900+).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: limited to what rule 2 of AGENTS.md allows; none used here.
  • Code taken from another project: none (emu/rdna2_exec_f16conv.py is in this repository).

AI assistance: implemented and verified with AI coding assistance.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5528363365 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/505). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-27T14:34:00Z. --- ## Change Port the 14 half-precision integer/normalized conversion, pack and three-operand min/max/med3 instructions (20 `VOP1` and `VOP3` encodings) added to the Python model in #275 (`emu/rdna2_exec_f16conv.py`) to `crates/anyxboxx-rdna2-ref` (`f16conv.rs`): - `VOP1` and `VOP3`: `v_cvt_f16_u16`, `v_cvt_f16_i16`, `v_cvt_u16_f16`, `v_cvt_i16_f16`, `v_cvt_norm_i16_f16`, `v_cvt_norm_u16_f16`. - `VOP3`-only: `v_cvt_pknorm_i16_f16`, `v_cvt_pknorm_u16_f16`, `v_cvt_pknorm_i16_f32`, `v_cvt_pknorm_u16_f32`, `v_pack_b32_f16`, `v_min3_f16`, `v_max3_f16`, `v_med3_f16`. - Exact single-rounding ties-to-even normalized scaling (`24` `f32` significand bits × `16`-bit scale = `40` bits, exact in `53`-bit `f64`), ISA `v_med3_f16` NaN/`±0` rules, low-16-bit inline float constants on 16-bit integer sources, and all shared `VOP1`/`VOP3` refusals (`SDWA`/`DPP`, `omod`, `clamp` on integer/packed results, `op_sel` restrictions). Linked issue: Refs #482 (follow-up covering #275) ## Verification ``` cargo +stable-x86_64-pc-windows-gnu test -p anyxboxx-rdna2-ref → 141 passed; 0 failed cargo +stable-x86_64-pc-windows-gnu clippy -p anyxboxx-rdna2-ref --all-targets -- -D warnings → 0 warnings cargo +stable-x86_64-pc-windows-gnu fmt --check -p anyxboxx-rdna2-ref → clean python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! python -m pytest tests/test_rdna2_ref_f16conv_parity.py tests/test_readme_sync.py → 12 passed, 1 skipped ``` ## Oracle and test data - Oracle: `PrototypeScarlett/emu/rdna2_exec_f16conv.py` (AMD RDNA 2 ISA sections 6.2.5, 12.7, 12.8, 12.12). - Test data: `tests/test_rdna2_ref_f16conv_parity.py` checks all 65,536 16-bit inputs across all 6 unary conversions (393,216 evaluations), fixed `VOP3` encodings and shared refusals across all 20 encodings, and 250 seeded multi-instruction programs. - Failure case without this change: `tests/test_rdna2_ref_f16conv_parity.py` fails because `anyxboxx-rdna2-ref` refuses all 20 encodings with `error untranslated`. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: the same change in the English and French READMEs (`test_readme_sync.py` checks it; collected count stays `1900+`). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: limited to what rule 2 of `AGENTS.md` allows; none used here. - [x] Code taken from another project: none (`emu/rdna2_exec_f16conv.py` is in this repository). AI assistance: implemented and verified with AI coding assistance.
LooperSalty commented 2026-11-27 15:54:06 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T15:54:06Z.


Thanks! #501 and #502 were just merged and this PR now conflicts with main (same anyxboxx-rdna2-ref files). Could you rebase it on main? It is otherwise ready to merge.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7222617237 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/505#issuecomment-7222617237). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-27T15:54:06Z. --- Thanks! #501 and #502 were just merged and this PR now conflicts with main (same `anyxboxx-rdna2-ref` files). Could you rebase it on main? It is otherwise ready to merge.
Lewandox commented 2026-11-27 16:08:17 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-27T16:08:17Z.


Rebased on \main\ and re-verified \cargo test -p anyxboxx-rdna2-ref\ — ready to merge!

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7222901095 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/505#issuecomment-7222901095). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-27T16:08:17Z. --- Rebased on \main\ and re-verified \cargo test -p anyxboxx-rdna2-ref\ — ready to merge!
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
LooperSalty/AnyXboxX!505
No description provided.