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

Open
github-bot wants to merge 2 commits from github-bot/gh-1163 into main AGit
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 19:26 UTC · original
ambroseautomation:carry/old-9982-mode-fp-round-directed → main · +522 −49 · 4 files · 2 commits · open

Claimed in the coordination issue as: OLD-9982 (#14)

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)
**@⁠ambroseautomation** on GitHub · 2026-11-24 19:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1163) `ambroseautomation:carry/old-9982-mode-fp-round-directed` → `main` · +522 −49 · 4 files · 2 commits · open Claimed in the coordination issue as: OLD-9982 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:40:58 +00:00
Author
Owner

@⁠madhyn on GitHub · 2026-11-24 19:28 UTC · original

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

**@⁠madhyn** on GitHub · 2026-11-24 19:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1163#issuecomment-7142157365) 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
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 19:31 UTC · original · requested changes

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.

**@⁠KernelSmoker** on GitHub · 2026-11-24 19:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1163#pullrequestreview-6045971305) · **requested changes** 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.
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:11 UTC · original

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

**@⁠Deedlyy** on GitHub · 2026-11-24 20:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1163#issuecomment-7143170743) **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
Author
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 21:04 UTC · original

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

**@⁠ambroseautomation** on GitHub · 2026-11-24 21:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1163#issuecomment-7144440374) 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
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1163/head:github-bot/gh-1163'
git switch 'github-bot/gh-1163'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1163'
git switch 'github-bot/gh-1163'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1163'
git switch 'github-bot/gh-1163'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1163'
git switch 'main'
git merge --squash 'github-bot/gh-1163'
git switch 'main'
git merge --ff-only 'github-bot/gh-1163'
git switch 'main'
git merge 'github-bot/gh-1163'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.