feat(rdna2-ref): run half-precision VOPC and VOP3 compares #502

Merged
Lewandox merged 1 commit from upstream-pr/502 into main 2026-11-27 15:53:39 +00:00
Lewandox commented 2026-11-27 14:20:45 +00:00 (Migrated from github.com)

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


Change

Port the 34 half-precision (f16) compare instructions of emu/rdna2_exec_cmpf16.py to crates/anyxboxx-rdna2-ref (cmpf16.rs, compare.rs) across VOPC and VOP3:

  • The 16 IEEE predicates in v_cmp_*_f16 (writing VCC in VOPC or the SGPR destination in VOP3) and v_cmpx_*_f16 (writing EXEC), clearing inactive lanes on the full mask write.
  • v_cmp_class_f16 and v_cmpx_class_f16, extending compare::float_class to 16-bit binary16 (5 exponent bits, 10 mantissa bits) and reading S1 through the same 16-bit source path (so float inline constants decode as binary16 bits per ISA section 12.9).
  • Matching VOP3 abs/neg on bit 15 of float sources and shared refusals (SDWA/DPP, op_sel, clamp, omod, and abs/neg on the class mask S1).

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

Verification

cargo +stable-x86_64-pc-windows-gnu test -p anyxboxx-rdna2-ref → 142 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_cmpf16_parity.py tests/test_rdna2_ref_parity.py tests/test_readme_sync.py → 57 passed, 1 skipped

Oracle and test data

  • Oracle: PrototypeScarlett/emu/rdna2_exec_cmpf16.py (AMD RDNA 2 ISA sections 3.9, 6.2.5, 12.9).
  • Test data: synthetic encodings built in tests/test_rdna2_ref_cmpf16_parity.py, covering all 34 mnemonics in VOPC and VOP3 (wave32 and wave64), an exhaustive 65,536-input × 10-class-bit sweep for v_cmp_class_f16, all refusal paths, and 250 seeded multi-instruction programs.
  • Failure case without this change: tests/test_rdna2_ref_cmpf16_parity.py fails because anyxboxx-rdna2-ref refuses all 34 f16 compare 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_cmpf16.py is in this repository).

AI assistance: implemented and verified with AI coding assistance.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5528179108 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/502). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-27T14:20:45Z. --- ## Change Port the 34 half-precision (`f16`) compare instructions of `emu/rdna2_exec_cmpf16.py` to `crates/anyxboxx-rdna2-ref` (`cmpf16.rs`, `compare.rs`) across `VOPC` and `VOP3`: - The 16 IEEE predicates in `v_cmp_*_f16` (writing `VCC` in `VOPC` or the `SGPR` destination in `VOP3`) and `v_cmpx_*_f16` (writing `EXEC`), clearing inactive lanes on the full mask write. - `v_cmp_class_f16` and `v_cmpx_class_f16`, extending `compare::float_class` to 16-bit binary16 (`5` exponent bits, `10` mantissa bits) and reading `S1` through the same 16-bit source path (so float inline constants decode as binary16 bits per ISA section 12.9). - Matching `VOP3` `abs`/`neg` on bit 15 of float sources and shared refusals (`SDWA`/`DPP`, `op_sel`, `clamp`, `omod`, and `abs`/`neg` on the class mask `S1`). Linked issue: Refs #482 (part 2 of 3) ## Verification ``` cargo +stable-x86_64-pc-windows-gnu test -p anyxboxx-rdna2-ref → 142 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_cmpf16_parity.py tests/test_rdna2_ref_parity.py tests/test_readme_sync.py → 57 passed, 1 skipped ``` ## Oracle and test data - Oracle: `PrototypeScarlett/emu/rdna2_exec_cmpf16.py` (AMD RDNA 2 ISA sections 3.9, 6.2.5, 12.9). - Test data: synthetic encodings built in `tests/test_rdna2_ref_cmpf16_parity.py`, covering all 34 mnemonics in `VOPC` and `VOP3` (`wave32` and `wave64`), an exhaustive 65,536-input × 10-class-bit sweep for `v_cmp_class_f16`, all refusal paths, and 250 seeded multi-instruction programs. - Failure case without this change: `tests/test_rdna2_ref_cmpf16_parity.py` fails because `anyxboxx-rdna2-ref` refuses all 34 `f16` compare 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_cmpf16.py` is in this repository). AI assistance: implemented and verified with AI coding assistance.
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!502
No description provided.