rdna2spirv: support directed MODE.FP_ROUND[3:2] (+inf/-inf) and dynamic s_setreg_b32 (OLD-9982) #1163

Closed
ambroseautomation wants to merge 2 commits from upstream-pr/1163 into main
ambroseautomation commented 2026-11-24 19:26:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T19:26:21Z.


Claimed in the coordination issue as: OLD-9982 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141822512)

What and why

Carries forward old-pr/9982 (draft #247, original commit author Lewandox preserved; indexed in #17), rebased cleanly onto current main.

Extends MODE.FP_ROUND[3:2] support in tools/rdna2spirv.py to all four IEEE 754 rounding modes (RN, +inf, -inf, RTZ) and dynamic s_setreg_b32:

  • Adds directed rounding (+inf / -inf) for f16 conversions, f16 arithmetic/OMOD overflow, and f64 arithmetic when MODE.FP_ROUND[3:2] is set via s_round_mode, s_setreg_imm32_b32, or dynamic s_setreg_b32.
  • Adds tests/semantic/test_mode_fp_round_directed.py (5 test cases covering f16 conversions across all four modes, f16 directed arithmetic & cancellation sign, f16 OMOD overflow, s_round_mode + dynamic s_setreg_b32, and f64 directed arithmetic/overflow) and updates tests/semantic/test_scalar_noop_waitcnt.py.

Tested

  • python -m unittest discover -s tests/semantic -p test_mode_fp_round_directed.py -v: 5 tests, OK.
  • python -m unittest discover -s tests/semantic -p test_scalar_noop_waitcnt.py -v: 13 tests, OK.
  • python -I scripts/run_semantic_tests.py tests/semantic: 471 files, 6,173 tests, 0 files failed.
  • python -m compileall -q make_game.py tools tests: exit 0.
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_mode_fp_round_directed.py tests/semantic/test_scalar_noop_waitcnt.py: exit 0 (no game data).

GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (extends existing MODE.FP_ROUND[3:2] rule)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478859027 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1163). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T19:26:21Z. --- Claimed in the coordination issue as: OLD-9982 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141822512) ### What and why Carries forward `old-pr/9982` (draft #247, original commit author `Lewandox` preserved; indexed in #17), rebased cleanly onto current `main`. Extends `MODE.FP_ROUND[3:2]` support in `tools/rdna2spirv.py` to all four IEEE 754 rounding modes (`RN`, `+inf`, `-inf`, `RTZ`) and dynamic `s_setreg_b32`: - Adds directed rounding (`+inf` / `-inf`) for f16 conversions, f16 arithmetic/OMOD overflow, and f64 arithmetic when `MODE.FP_ROUND[3:2]` is set via `s_round_mode`, `s_setreg_imm32_b32`, or dynamic `s_setreg_b32`. - Adds `tests/semantic/test_mode_fp_round_directed.py` (5 test cases covering f16 conversions across all four modes, f16 directed arithmetic & cancellation sign, f16 OMOD overflow, `s_round_mode` + dynamic `s_setreg_b32`, and f64 directed arithmetic/overflow) and updates `tests/semantic/test_scalar_noop_waitcnt.py`. ### Tested - `python -m unittest discover -s tests/semantic -p test_mode_fp_round_directed.py -v`: 5 tests, OK. - `python -m unittest discover -s tests/semantic -p test_scalar_noop_waitcnt.py -v`: 13 tests, OK. - `python -I scripts/run_semantic_tests.py tests/semantic`: 471 files, 6,173 tests, 0 files failed. - `python -m compileall -q make_game.py tools tests`: exit 0. - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_mode_fp_round_directed.py tests/semantic/test_scalar_noop_waitcnt.py`: exit 0 (no game data). GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (extends existing `MODE.FP_ROUND[3:2]` rule)
madhyn commented 2026-11-24 19:28:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T19:28:54Z.


Verified e9033887d on Arch Linux (Python 3.14):

  • PYTHONPATH=tests/semantic python3 -m unittest tests/semantic/test_mode_fp_round_directed.py tests/semantic/test_scalar_noop_waitcnt.py: 18 tests passed (2.845 s)

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142157365 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1163#issuecomment-7142157365). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T19:28:54Z. --- Verified `e9033887d` on Arch Linux (Python 3.14): - `PYTHONPATH=tests/semantic python3 -m unittest tests/semantic/test_mode_fp_round_directed.py tests/semantic/test_scalar_noop_waitcnt.py`: **18 tests passed** (2.845 s) AI-assisted: yes
KernelSmoker commented 2026-11-24 19:31:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T19:31:34Z.

Review: CHANGES_REQUESTED


Reviewed exact head e9033887d401d6039caa33b93d0c7a6a18b88d0a. Independent verification: test_mode_fp_round_directed.py 5/5, test_scalar_noop_waitcnt.py 13/13, the full semantic suite 471 files / 6,173 tests / 0 failed files, compileall passed, and the explicit no-game-data scan passed. I also generated representative f16/f64 modules from this head; both passed spirv-val --target-env vulkan1.2. These are CPU interpreter tests plus SPIR-V validation; I did not run a GPU test and make no RDNA2 hardware claim.

One project-contract item remains: docs/design.md only mentions the MODE rounding field in prose; its translator contract table has no MODE.FP_ROUND[3:2] entry. This change adds RTP/RTN and dynamic s_setreg_b32, so please add a contract row covering the 0=RNE, 1=RTP, 2=RTN, 3=RTZ mapping, supported write forms/operations, and how the Fraction-oracle semantic tests confirm it. The contribution rules require a new/expanded translator rule to be recorded in that table with its confirmation method. I can recheck the updated head after that documentation is added.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045971305 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1163#pullrequestreview-6045971305). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T19:31:34Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head e9033887d401d6039caa33b93d0c7a6a18b88d0a. Independent verification: `test_mode_fp_round_directed.py` 5/5, `test_scalar_noop_waitcnt.py` 13/13, the full semantic suite 471 files / 6,173 tests / 0 failed files, `compileall` passed, and the explicit no-game-data scan passed. I also generated representative f16/f64 modules from this head; both passed `spirv-val --target-env vulkan1.2`. These are CPU interpreter tests plus SPIR-V validation; I did not run a GPU test and make no RDNA2 hardware claim. One project-contract item remains: `docs/design.md` only mentions the MODE rounding field in prose; its translator contract table has no `MODE.FP_ROUND[3:2]` entry. This change adds RTP/RTN and dynamic `s_setreg_b32`, so please add a contract row covering the 0=RNE, 1=RTP, 2=RTN, 3=RTZ mapping, supported write forms/operations, and how the Fraction-oracle semantic tests confirm it. The contribution rules require a new/expanded translator rule to be recorded in that table with its confirmation method. I can recheck the updated head after that documentation is added.
Deedlyy commented 2026-11-24 20:11:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:11:35Z.


Recommendation: [MERGE]

Reasoning: Carries #247: extends MODE.FP_ROUND support to directed rounding (+inf/-inf) for f16 conversions/arithmetic and f64, and handles dynamic s_setreg_b32. Significant translator change (+521) with a 386-line semantic test. Verified by madhyn (18 tests) and KernelSmoker (full semantic suite: 6,173 tests, 0 failed). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 5/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143170743 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1163#issuecomment-7143170743). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:11:35Z. --- **Recommendation:** [MERGE] **Reasoning:** Carries #247: extends `MODE.FP_ROUND` support to directed rounding (+inf/-inf) for f16 conversions/arithmetic and f64, and handles dynamic `s_setreg_b32`. Significant translator change (+521) with a 386-line semantic test. Verified by madhyn (18 tests) and KernelSmoker (full semantic suite: 6,173 tests, 0 failed). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 5/10
ambroseautomation commented 2026-11-24 21:04:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T21:04:29Z.


Thanks for the thorough review and verification, @KernelSmoker — added the MODE.FP_ROUND[3:2] contract row to docs/design.md in commit cbd842a86 covering the

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144440374 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1163#issuecomment-7144440374). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T21:04:29Z. --- Thanks for the thorough review and verification, @KernelSmoker — added the MODE.FP_ROUND[3:2] contract row to docs/design.md in commit cbd842a86 covering the

Pull request closed

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
ProjectLeonida/mandy!1163
No description provided.