feat(rdna2-ref): run half-precision transcendental instructions #503

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

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


Change

Port the 7 scalar half-precision (f16) transcendental instructions of emu/rdna2_exec_f16.py to crates/anyxboxx-rdna2-ref (f16_trans.rs) in VOP1 and VOP3:

  • v_rcp_f16, v_sqrt_f16, v_rsq_f16, v_log_f16, v_exp_f16, v_sin_f16, v_cos_f16 (including exact quadrant/turn reduction before multiplying by 2\pi for v_sin_f16 and v_cos_f16, matching sin(-0) = -0, sin(±65504) = +0, cos(±65504) = +1, cos(0.25) = +0).
  • Matching VOP3 op_sel (source bit 0 and destination bit 3 while preserving the untouched half), abs/neg on bit 15, clamp to [0, 1], and shared refusals (SDWA/DPP, omod, op_sel high half on constants).

Linked issue: Refs #482 (part 3 of 3)

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_f16_trans_parity.py tests/test_readme_sync.py → 12 passed, 1 skipped

Oracle and test data

  • Oracle: PrototypeScarlett/emu/rdna2_exec_f16.py (AMD RDNA 2 ISA section 12.8, opcodes 84–88 and 96–97).
  • Test data: tests/test_rdna2_ref_f16_trans_parity.py compares Rust against Python bit-for-bit on all 65,536 binary16 inputs (0x0000..=0xFFFF) for each of the 7 transcendentals (458,752 evaluations), plus VOP3 modifier cases, shared refusals, and 200 seeded programs.
  • Failure case without this change: tests/test_rdna2_ref_f16_trans_parity.py fails because anyxboxx-rdna2-ref refuses all 7 f16 transcendental instructions 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_f16.py is in this repository).

AI assistance: implemented and verified with AI coding assistance.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5528288894 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/503). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-27T14:28:38Z. --- ## Change Port the 7 scalar half-precision (`f16`) transcendental instructions of `emu/rdna2_exec_f16.py` to `crates/anyxboxx-rdna2-ref` (`f16_trans.rs`) in `VOP1` and `VOP3`: - `v_rcp_f16`, `v_sqrt_f16`, `v_rsq_f16`, `v_log_f16`, `v_exp_f16`, `v_sin_f16`, `v_cos_f16` (including exact quadrant/turn reduction before multiplying by $2\pi$ for `v_sin_f16` and `v_cos_f16`, matching `sin(-0) = -0`, `sin(±65504) = +0`, `cos(±65504) = +1`, `cos(0.25) = +0`). - Matching `VOP3` `op_sel` (source bit 0 and destination bit 3 while preserving the untouched half), `abs`/`neg` on bit 15, `clamp` to `[0, 1]`, and shared refusals (`SDWA`/`DPP`, `omod`, `op_sel` high half on constants). Linked issue: Refs #482 (part 3 of 3) ## 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_f16_trans_parity.py tests/test_readme_sync.py → 12 passed, 1 skipped ``` ## Oracle and test data - Oracle: `PrototypeScarlett/emu/rdna2_exec_f16.py` (AMD RDNA 2 ISA section 12.8, opcodes 84–88 and 96–97). - Test data: `tests/test_rdna2_ref_f16_trans_parity.py` compares Rust against Python bit-for-bit on **all 65,536 binary16 inputs** (`0x0000..=0xFFFF`) for each of the 7 transcendentals (458,752 evaluations), plus `VOP3` modifier cases, shared refusals, and 200 seeded programs. - Failure case without this change: `tests/test_rdna2_ref_f16_trans_parity.py` fails because `anyxboxx-rdna2-ref` refuses all 7 `f16` transcendental instructions 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_f16.py` is in this repository). AI assistance: implemented and verified with AI coding assistance.
LooperSalty commented 2026-11-27 15:54:04 +00:00 (Migrated from github.com)

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


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:7222616692 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/503#issuecomment-7222616692). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-27T15:54:04Z. --- 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:07:23 +00:00 (Migrated from github.com)

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


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

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