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

Closed
leonida/mandy
ambroseautomation wants to merge 0 commits from carry/old-9982-mode-fp-round-directed into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

ambroseautomation commented 2026-11-24 19:26:21 +00:00

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)
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

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

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 reviewed 2026-11-24 19:31:34 +00:00
KernelSmoker left a comment
No description provided.
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

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

**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

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

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
Sign in to join this conversation.
No description provided.