feat(rdna2-ref): port all 16 MIMG image_atomic_* instructions to Rust #353

Manually merged
github merged 2 commits from github-bot/gh-353 into main 2026-11-26 15:26:27 +00:00 AGit
Owner

@⁠Lewandox on GitHub · 2026-11-26 11:54 UTC · original
Lewandox:feat/rust-mimg-image-atomics → main · +243 −7 · 4 files · 2 commits · merged 2026-11-26 15:21 UTC

Summary

Ports all 16 RDNA 2 MIMG image_atomic_* 2D instructions (32-bit and 64-bit) and the 4 raw integer image formats (32_UINT, 32_SINT, 32_32_UINT, 32_32_SINT) from the Python oracle (#309) to the Rust reference interpreter (crates/anyxboxx-rdna2-ref), restoring 100% Python/Rust parity for MIMG.

  • crates/anyxboxx-rdna2-ref/src/image_desc.rs:
    • Added FORMAT_32_UINT (20), FORMAT_32_SINT (21), FORMAT_32_32_UINT (62), FORMAT_32_32_SINT (63) to texel_bytes.
    • Added Op::Atomic covering all 16 image_atomic_* mnemonics (swap, cmpswap, add, sub, smin, umin, smax, umax, and, or, xor, inc, dec, fcmpswap, fmin, fmax).
    • Extracted MIMG glc (bit 13) in instruction_fields, added atomic_width / atomic_format_ok / is_cmpswap, and updated check_instruction and address_count (2 VGPRs in 2D).
  • crates/anyxboxx-rdna2-ref/src/image_texel.rs:
    • Added raw 32-bit and 64-bit integer format read/write support (alpha = integer 1) to texel and store_texel.
  • crates/anyxboxx-rdna2-ref/src/image_exec.rs:
    • Implemented atomic_op reusing atomic::apply for all 16 integer and float atomic operations in 32-bit and 64-bit, enforcing format/width compatibility, glc return-old behavior (preserving vdata when glc=0 and cmp VGPRs), OOB guards (no memory write, 0 returned when glc=1), and safe vdata/vaddr overlap.
  • tests/test_rdna2_ref_parity.py:
    • Added test_image_atomic_programs_match_the_python_model comparing Rust and Python line-by-line across all 16 image_atomic_* ops (32-bit & 64-bit, wave32 & wave64, glc=0/1, OOB, NSA, overlap, multi-lane contention, NaN/±0, raw integer load/store, and refused dmask/format mismatches).

Verification

  • cargo fmt -p anyxboxx-rdna2-ref -- --check: passed.
  • cargo clippy -p anyxboxx-rdna2-ref --no-deps --all-targets -- -D warnings: 0 warnings.
  • cargo test -p anyxboxx-rdna2-ref: 134 passed, 0 failed.
  • ruff check --select W605,F,E9 PrototypeScarlett tests tools: All checks passed!
  • python -m pytest -q tests/test_rdna2_ref_parity.py tests/test_readme_sync.py: 48 passed, 1 skipped (0 failed).
**@⁠Lewandox** on GitHub · 2026-11-26 11:54 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/353) `Lewandox:feat/rust-mimg-image-atomics` → `main` · +243 −7 · 4 files · 2 commits · merged 2026-11-26 15:21 UTC ## Summary Ports all 16 RDNA 2 `MIMG` `image_atomic_*` 2D instructions (32-bit and 64-bit) and the 4 raw integer image formats (`32_UINT`, `32_SINT`, `32_32_UINT`, `32_32_SINT`) from the Python oracle (#309) to the Rust reference interpreter (`crates/anyxboxx-rdna2-ref`), restoring 100% Python/Rust parity for MIMG. - `crates/anyxboxx-rdna2-ref/src/image_desc.rs`: - Added `FORMAT_32_UINT` (20), `FORMAT_32_SINT` (21), `FORMAT_32_32_UINT` (62), `FORMAT_32_32_SINT` (63) to `texel_bytes`. - Added `Op::Atomic` covering all 16 `image_atomic_*` mnemonics (`swap`, `cmpswap`, `add`, `sub`, `smin`, `umin`, `smax`, `umax`, `and`, `or`, `xor`, `inc`, `dec`, `fcmpswap`, `fmin`, `fmax`). - Extracted MIMG `glc` (bit 13) in `instruction_fields`, added `atomic_width` / `atomic_format_ok` / `is_cmpswap`, and updated `check_instruction` and `address_count` (`2` VGPRs in 2D). - `crates/anyxboxx-rdna2-ref/src/image_texel.rs`: - Added raw 32-bit and 64-bit integer format read/write support (alpha = integer `1`) to `texel` and `store_texel`. - `crates/anyxboxx-rdna2-ref/src/image_exec.rs`: - Implemented `atomic_op` reusing `atomic::apply` for all 16 integer and float atomic operations in 32-bit and 64-bit, enforcing format/width compatibility, `glc` return-old behavior (preserving `vdata` when `glc=0` and `cmp` VGPRs), OOB guards (no memory write, `0` returned when `glc=1`), and safe `vdata`/`vaddr` overlap. - `tests/test_rdna2_ref_parity.py`: - Added `test_image_atomic_programs_match_the_python_model` comparing Rust and Python line-by-line across all 16 `image_atomic_*` ops (32-bit & 64-bit, wave32 & wave64, `glc=0/1`, OOB, NSA, overlap, multi-lane contention, NaN/`±0`, raw integer load/store, and refused `dmask`/format mismatches). ## Verification - `cargo fmt -p anyxboxx-rdna2-ref -- --check`: passed. - `cargo clippy -p anyxboxx-rdna2-ref --no-deps --all-targets -- -D warnings`: 0 warnings. - `cargo test -p anyxboxx-rdna2-ref`: **134 passed, 0 failed**. - `ruff check --select W605,F,E9 PrototypeScarlett tests tools`: **All checks passed!** - `python -m pytest -q tests/test_rdna2_ref_parity.py tests/test_readme_sync.py`: **48 passed, 1 skipped** (0 failed).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:59:17 +00:00
github manually merged commit 84aa3c324e into main 2026-11-26 15:26:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.