[PR #475] [CLOSED] SHADER-F64-OMODS: the binary64 VALU ops take clamp and nothing else from their omod #525

Closed
opened 2026-11-26 20:18:10 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/475
Author: @fiestorra
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: carry/f64-omod-clamp


📝 Commits (3)

  • 9948f1f rdna2spirv: the f64 VALU ops keep only clamp, not their omod
  • e3a5bea docs+translator: say only clamp applies, as the reviewer asked
  • e983b38 test_f64_round: cover the omod on the three rounding ops the existing case leaves open

📊 Changes

11 files changed (+108 additions, -67 deletions)

View changed files

📝 docs/design.md (+3 -3)
📝 runtime/test/shaders/check.py (+1 -1)
📝 runtime/test/shaders/cs_f64_add.asm (+2 -1)
📝 runtime/test/shaders/ps_f64_mods.asm (+7 -4)
📝 scripts/run_gpu_tests.py (+2 -2)
📝 tests/semantic/test_f64_round.py (+22 -1)
📝 tests/semantic/test_valu_add_f64.py (+10 -8)
📝 tests/test_f64_diff.py (+8 -3)
📝 tests/test_f64_output_modifiers.py (+21 -22)
📝 tests/test_f64_transcendentals.py (+13 -15)
📝 tools/rdna2spirv.py (+19 -7)

📄 Description

Claimed in the coordination issue as: SHADER-F64-OMODS (claim comment).

What this changes

The VOP3 profiles for the binary64 VALU ops carry both HasClamp and HasOMod (binary64 is a modifier type), so a v_add_f64 / v_rcp_f64 / v_rsq_f64 / v_sqrt_f64 / v_trunc_f64 / v_ceil_f64 / v_rndne_f64 / v_floor_f64 encoding can name mul:2, mul:4 or div:2 in its omod field. On a gfx1036 iGPU those omods do nothing for these ops while binary64 denormals are kept, which is the mode this translator assumes: they only take effect with MODE.IEEE off and f64 denormals flushed. clamp is the one that applies in the mode we model. Measured on the device with runtime/test/shaders/ps_f64_mods.asm and cs_f64_add.asm, written up in the "v_add_f64 output modifiers" row and named in the v_rcp_f64, v_rsq_f64, v_sqrt_f64 and v_trunc_f64, v_ceil_f64, v_rndne_f64, v_floor_f64 rows of docs/design.md.

So the translator must not model them. tools/rdna2spirv.py now passes only the clamp part of the modifier list to clamp_mods_f64 and dst_f64 for the binary64 arithmetic and rounding ops ([m for m in mods if m == "clamp"]), with a comment naming the measurement and the row that records it, and a caller whose own row measured an omod still gets its own behaviour. A listing that names mul:2 on a v_add_f64 now compiles to the same value as the same listing without the omod, instead of a scaled one.

About the rebase

This is the content of the branch the private tracker carried as #4371, rebased onto ece4ba5b3 as three commits (9948f1f2f, e3a5bea41, e983b38f6). Both conflicts were in one file, tests/test_f64_output_modifiers.py: main writes the VGPR word of the destination directly, and my first version of the test read it through an OpAccessChain-style register load, so I kept main's side of both hunks. My fourth commit, 382366e5d ("tests: read the f64 destination write the way a VGPR word is written now"), existed only to adapt that test to the older shape and models nothing, so it is not in this branch: I dropped it with git rebase --skip. Nothing else was dropped, and the diff over main is the same 11 files:

docs/design.md                       |  6 ++---
runtime/test/shaders/check.py        |  2 +-
runtime/test/shaders/cs_f64_add.asm  |  3 ++-
runtime/test/shaders/ps_f64_mods.asm | 11 +++++----
scripts/run_gpu_tests.py             |  4 ++--
tests/semantic/test_f64_round.py     | 23 ++++++++++++++++++-
tests/semantic/test_valu_add_f64.py  | 18 ++++++++-------
tests/test_f64_diff.py               | 11 ++++++---
tests/test_f64_output_modifiers.py   | 43 ++++++++++++++++++------------------
tests/test_f64_transcendentals.py    | 28 +++++++++++------------
tools/rdna2spirv.py                  | 26 ++++++++++++++++------
11 files changed, 108 insertions(+), 67 deletions(-)

Evidence on ece4ba5b3

Head e983b38f6. Tools: CPython 3.13.14, pytest 9.2.0, llvm-mc 21.1.8 built by scripts/build_llvm_mc.ps1, spirv-as/spirv-val from Vulkan SDK 1.4.363.0, Windows build 26300. LEONIDA_HW_ARCH=gfx1036 was set for the device measurement described above, which was made on this machine's gfx1036 iGPU on 2026-11-22 and 2026-11-23 on the previous base; nothing in today's re-measurement needed a GPU.

  • py -3.13 -m pytest tests/test_f64_output_modifiers.py tests/test_f64_diff.py tests/test_f64_transcendentals.py -q — clean ece4ba5b3: 35 passed, 591 subtests passed in 2.83s. This branch: 35 passed, 591 subtests passed in 2.83s. Nothing that passes today stops passing.
  • py -3.13 -I -m unittest discover -s tests/semantic -p "test_f64_round.py" — clean ece4ba5b3: Ran 6 tests / OK. This branch: Ran 7 tests / OK. test_valu_add_f64.py: Ran 8 tests / OK both sides.
  • Negative control (same tests, tools/rdna2spirv.py from ece4ba5b3): py -3.13 -m pytest tests/test_f64_output_modifiers.py tests/test_f64_diff.py tests/test_f64_transcendentals.py -q → 9 failed, 34 passed, 583 subtests, including SUBFAILED(op='v_rsq_f64_e64', mods='clamp div:2') and SUBFAILED(op='v_sqrt_f64_e64', mods='clamp mul:4'), and the semantic files fail as test_f64_round FAILED (failures=4) and test_valu_add_f64 FAILED (failures=5). So every new assertion fails against main's translator and passes with this change.
  • Full semantic suite (py -3.13 -I scripts/run_semantic_tests.py tests/semantic), with llvm-mc on PATH and LLVM_MC unset: clean ece4ba5b3 465 files, 6103 tests, 0 files failed in 440 s with 16 jobs. This branch: 465 files, 6104 tests, 0 files failed in 458 s with 16 jobs. Same 465 files, nothing red either side, and the one extra test is the added rounding case.

Written with an AI assistant.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/475 **Author:** [@fiestorra](https://github.com/fiestorra) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `carry/f64-omod-clamp` --- ### 📝 Commits (3) - [`9948f1f`](https://github.com/ubiquitarianism/leonida/commit/9948f1f2f1386f32388b9f73286acd63ea7f7e3f) rdna2spirv: the f64 VALU ops keep only clamp, not their omod - [`e3a5bea`](https://github.com/ubiquitarianism/leonida/commit/e3a5bea41d28854fb109223b742be648ea32a1f7) docs+translator: say only clamp applies, as the reviewer asked - [`e983b38`](https://github.com/ubiquitarianism/leonida/commit/e983b38f6bf0adbe12b86f4d8d069b412ebd625d) test_f64_round: cover the omod on the three rounding ops the existing case leaves open ### 📊 Changes **11 files changed** (+108 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+3 -3) 📝 `runtime/test/shaders/check.py` (+1 -1) 📝 `runtime/test/shaders/cs_f64_add.asm` (+2 -1) 📝 `runtime/test/shaders/ps_f64_mods.asm` (+7 -4) 📝 `scripts/run_gpu_tests.py` (+2 -2) 📝 `tests/semantic/test_f64_round.py` (+22 -1) 📝 `tests/semantic/test_valu_add_f64.py` (+10 -8) 📝 `tests/test_f64_diff.py` (+8 -3) 📝 `tests/test_f64_output_modifiers.py` (+21 -22) 📝 `tests/test_f64_transcendentals.py` (+13 -15) 📝 `tools/rdna2spirv.py` (+19 -7) </details> ### 📄 Description Claimed in the coordination issue as: `SHADER-F64-OMODS` ([claim comment](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122051420)). ### What this changes The VOP3 profiles for the binary64 VALU ops carry both `HasClamp` and `HasOMod` (binary64 is a modifier type), so a `v_add_f64` / `v_rcp_f64` / `v_rsq_f64` / `v_sqrt_f64` / `v_trunc_f64` / `v_ceil_f64` / `v_rndne_f64` / `v_floor_f64` encoding can name `mul:2`, `mul:4` or `div:2` in its omod field. On a gfx1036 iGPU those omods do nothing for these ops while binary64 denormals are kept, which is the mode this translator assumes: they only take effect with `MODE.IEEE` off and f64 denormals flushed. `clamp` is the one that applies in the mode we model. Measured on the device with `runtime/test/shaders/ps_f64_mods.asm` and `cs_f64_add.asm`, written up in the "v_add_f64 output modifiers" row and named in the `v_rcp_f64, v_rsq_f64, v_sqrt_f64` and `v_trunc_f64, v_ceil_f64, v_rndne_f64, v_floor_f64` rows of `docs/design.md`. So the translator must not model them. `tools/rdna2spirv.py` now passes only the clamp part of the modifier list to `clamp_mods_f64` and `dst_f64` for the binary64 arithmetic and rounding ops (`[m for m in mods if m == "clamp"]`), with a comment naming the measurement and the row that records it, and a caller whose own row measured an omod still gets its own behaviour. A listing that names `mul:2` on a `v_add_f64` now compiles to the same value as the same listing without the omod, instead of a scaled one. ### About the rebase This is the content of the branch the private tracker carried as #4371, rebased onto `ece4ba5b3` as three commits (`9948f1f2f`, `e3a5bea41`, `e983b38f6`). Both conflicts were in one file, `tests/test_f64_output_modifiers.py`: `main` writes the VGPR word of the destination directly, and my first version of the test read it through an `OpAccessChain`-style register load, so I kept `main`'s side of both hunks. My fourth commit, `382366e5d` ("tests: read the f64 destination write the way a VGPR word is written now"), existed only to adapt that test to the older shape and models nothing, so it is not in this branch: I dropped it with `git rebase --skip`. Nothing else was dropped, and the diff over `main` is the same 11 files: ``` docs/design.md | 6 ++--- runtime/test/shaders/check.py | 2 +- runtime/test/shaders/cs_f64_add.asm | 3 ++- runtime/test/shaders/ps_f64_mods.asm | 11 +++++---- scripts/run_gpu_tests.py | 4 ++-- tests/semantic/test_f64_round.py | 23 ++++++++++++++++++- tests/semantic/test_valu_add_f64.py | 18 ++++++++------- tests/test_f64_diff.py | 11 ++++++--- tests/test_f64_output_modifiers.py | 43 ++++++++++++++++++------------------ tests/test_f64_transcendentals.py | 28 +++++++++++------------ tools/rdna2spirv.py | 26 ++++++++++++++++------ 11 files changed, 108 insertions(+), 67 deletions(-) ``` ### Evidence on `ece4ba5b3` Head `e983b38f6`. Tools: CPython 3.13.14, `pytest 9.2.0`, `llvm-mc` 21.1.8 built by `scripts/build_llvm_mc.ps1`, `spirv-as`/`spirv-val` from Vulkan SDK 1.4.363.0, Windows build 26300. `LEONIDA_HW_ARCH=gfx1036` was set for the device measurement described above, which was made on this machine's gfx1036 iGPU on 2026-11-22 and 2026-11-23 on the previous base; nothing in today's re-measurement needed a GPU. * `py -3.13 -m pytest tests/test_f64_output_modifiers.py tests/test_f64_diff.py tests/test_f64_transcendentals.py -q` — clean `ece4ba5b3`: `35 passed, 591 subtests passed in 2.83s`. This branch: `35 passed, 591 subtests passed in 2.83s`. Nothing that passes today stops passing. * `py -3.13 -I -m unittest discover -s tests/semantic -p "test_f64_round.py"` — clean `ece4ba5b3`: `Ran 6 tests / OK`. This branch: `Ran 7 tests / OK`. `test_valu_add_f64.py`: `Ran 8 tests / OK` both sides. * Negative control (same tests, `tools/rdna2spirv.py` from `ece4ba5b3`): `py -3.13 -m pytest tests/test_f64_output_modifiers.py tests/test_f64_diff.py tests/test_f64_transcendentals.py -q` → `9 failed, 34 passed, 583 subtests`, including `SUBFAILED(op='v_rsq_f64_e64', mods='clamp div:2')` and `SUBFAILED(op='v_sqrt_f64_e64', mods='clamp mul:4')`, and the semantic files fail as `test_f64_round` `FAILED (failures=4)` and `test_valu_add_f64` `FAILED (failures=5)`. So every new assertion fails against `main`'s translator and passes with this change. * Full semantic suite (`py -3.13 -I scripts/run_semantic_tests.py tests/semantic`), with `llvm-mc` on `PATH` and `LLVM_MC` unset: clean `ece4ba5b3` `465 files, 6103 tests, 0 files failed in 440 s with 16 jobs`. This branch: `465 files, 6104 tests, 0 files failed in 458 s with 16 jobs`. Same 465 files, nothing red either side, and the one extra test is the added rounding case. Written with an AI assistant. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:10 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#525
No description provided.