[PR #410] rdna2spirv: treat VOP3P v_dot2_f32_f16 clamp as hardware no-op (SHADER-DOT2-F32-F16-CLAMP) #462

Open
opened 2026-11-26 20:17:57 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/410
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/shader-dot2-f32-f16-clamp


📝 Commits (1)

  • abb68a9 rdna2spirv: treat VOP3P v_dot2_f32_f16 clamp as hardware no-op (SHADER-DOT2-F32-F16-CLAMP)

📊 Changes

3 files changed (+23 additions, -4 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_alu_dot_complete.py (+18 -2)
📝 tools/rdna2spirv.py (+4 -1)

📄 Description

Claimed in the coordination issue as: SHADER-DOT2-F32-F16-CLAMP

Problem

tools/rdna2spirv.py applied clamp_mods ([0.0, 1.0] saturation) when VOP3P v_dot2_f32_f16 had the clamp modifier set. As noted in docs/design.md, v_dot2_f32_f16 had not previously been hardware-measured on RDNA2.

Measured natively on AMD RDNA2 (gfx1036 via tools/hw_oracle) across all four ieee / dx10_clamp / denorm32 / denorm16_64 MODE combinations: the VOP3P clamp bit on v_dot2_f32_f16 is a hardware no-op:

  • 1.0*1.0 + 1.0*1.0 + 1.0 with clamp -> 0x40400000 (+3.0f), whereas the translator returned 0x3f800000 (1.0f).
  • -1.0*1.0 + -1.0*1.0 + -1.0 with clamp -> 0xc0400000 (-3.0f), whereas the translator returned 0x00000000 (0.0f).
  • +inf with clamp -> 0x7f800000; NaN with clamp -> 0x7fc00000.

Fix

  • Do not apply clamp_mods on VOP3P v_dot2_f32_f16 in tools/rdna2spirv.py.
  • Update tests/semantic/test_alu_dot_complete.py to match the hardware-measured no-op behavior and add explicit +3.0f / -3.0f / +inf regression assertions.
  • Record the hardware-measured result in docs/design.md.

Verification

  • CPU semantic tests: python -I tests/semantic/test_alu_dot_complete.py -> OK.
  • Hardware differential verification (Native AMD RDNA2 vs. Translated Vulkan + spirv-val):
    • Native reference: AMD GFX1036 (RDNA2) via tools/hw_oracle -> 4/4 dwords across +3.0f, -3.0f, +inf, and op_sel+neg_lo+clamp (verified across all 4 MODE combinations).
    • Translated execution: NVIDIA GeForce RTX 5060 Ti (driver 617.42, Windows 11) via vk_compute_test.exe:
      • Wave32: 4/4 exact dwords (spirv-val PASS)
      • Wave64 (--wave64-emulate): 4/4 exact dwords (spirv-val PASS)
  • No game files used (synthetic assembly only).
  • AI-assisted: Yes (Antigravity).
中文翻译

在协调帖 #14 中认领的 ID:SHADER-DOT2-F32-F16-CLAMP

问题描述

tools/rdna2spirv.py 此前对带有 clamp 的 VOP3P 指令 v_dot2_f32_f16 施加了 [0.0, 1.0] 截断(docs/design.md 注明此前尚未在 RDNA2 硬件实测)。

经原生 AMD RDNA2(gfx1036)在全部 4 种 ieee / dx10_clamp / denorm MODE 组合下实测确认:VOP3P v_dot2_f32_f16 的 clamp 位为硬件空操作(+3.0f 保持 0x40400000、-3.0f 保持 0xc0400000、+inf 保持 0x7f800000、NaN 保持 0x7fc00000)。

修复方案

  • 在 tools/rdna2spirv.py 中对 VOP3P v_dot2_f32_f16 不再施加 clamp_mods。
  • 更新 tests/semantic/test_alu_dot_complete.py 并新增 +3.0f / -3.0f / +inf 回归用例。
  • 在 docs/design.md 契约表中记录硬件实测结果。

验证结果

  • CPU 语义测试:tests/semantic/test_alu_dot_complete.py 全部通过。
  • 跨架构硬件差分验证(原生 AMD GFX1036 vs 翻译后 NVIDIA RTX 5060 Ti,驱动 617.42):Wave32 4/4 精确一致,Wave64 模拟(--wave64-emulate)4/4 精确一致,spirv-val 全部通过。
  • 仅使用手写合成汇编,无游戏文件。
  • AI 辅助:是(Antigravity)。

🔄 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/410 **Author:** [@tahffo68hk-hash](https://github.com/tahffo68hk-hash) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/shader-dot2-f32-f16-clamp` --- ### 📝 Commits (1) - [`abb68a9`](https://github.com/ubiquitarianism/leonida/commit/abb68a9ab2964fce5c39e652b66095df11a94b64) rdna2spirv: treat VOP3P v_dot2_f32_f16 clamp as hardware no-op (SHADER-DOT2-F32-F16-CLAMP) ### 📊 Changes **3 files changed** (+23 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_alu_dot_complete.py` (+18 -2) 📝 `tools/rdna2spirv.py` (+4 -1) </details> ### 📄 Description Claimed in the coordination issue as: `SHADER-DOT2-F32-F16-CLAMP` ## Problem `tools/rdna2spirv.py` applied `clamp_mods` (`[0.0, 1.0]` saturation) when VOP3P `v_dot2_f32_f16` had the `clamp` modifier set. As noted in `docs/design.md`, `v_dot2_f32_f16` had not previously been hardware-measured on RDNA2. Measured natively on AMD RDNA2 (`gfx1036` via `tools/hw_oracle`) across all four `ieee` / `dx10_clamp` / `denorm32` / `denorm16_64` MODE combinations: the VOP3P `clamp` bit on `v_dot2_f32_f16` is a **hardware no-op**: - `1.0*1.0 + 1.0*1.0 + 1.0` with `clamp` -> `0x40400000` (`+3.0f`), whereas the translator returned `0x3f800000` (`1.0f`). - `-1.0*1.0 + -1.0*1.0 + -1.0` with `clamp` -> `0xc0400000` (`-3.0f`), whereas the translator returned `0x00000000` (`0.0f`). - `+inf` with `clamp` -> `0x7f800000`; `NaN` with `clamp` -> `0x7fc00000`. ## Fix - Do not apply `clamp_mods` on VOP3P `v_dot2_f32_f16` in `tools/rdna2spirv.py`. - Update `tests/semantic/test_alu_dot_complete.py` to match the hardware-measured no-op behavior and add explicit `+3.0f` / `-3.0f` / `+inf` regression assertions. - Record the hardware-measured result in `docs/design.md`. ## Verification - **CPU semantic tests**: `python -I tests/semantic/test_alu_dot_complete.py` -> OK. - **Hardware differential verification (Native AMD RDNA2 vs. Translated Vulkan + `spirv-val`)**: - Native reference: AMD GFX1036 (RDNA2) via `tools/hw_oracle` -> 4/4 dwords across `+3.0f`, `-3.0f`, `+inf`, and `op_sel`+`neg_lo`+`clamp` (verified across all 4 MODE combinations). - Translated execution: NVIDIA GeForce RTX 5060 Ti (driver 617.42, Windows 11) via `vk_compute_test.exe`: - Wave32: **4/4 exact dwords** (`spirv-val` PASS) - Wave64 (`--wave64-emulate`): **4/4 exact dwords** (`spirv-val` PASS) - No game files used (synthetic assembly only). - AI-assisted: Yes (Antigravity). <details> <summary>中文翻译</summary> 在协调帖 #14 中认领的 ID:`SHADER-DOT2-F32-F16-CLAMP` ## 问题描述 `tools/rdna2spirv.py` 此前对带有 `clamp` 的 VOP3P 指令 `v_dot2_f32_f16` 施加了 `[0.0, 1.0]` 截断(`docs/design.md` 注明此前尚未在 RDNA2 硬件实测)。 经原生 AMD RDNA2(`gfx1036`)在全部 4 种 `ieee` / `dx10_clamp` / `denorm` MODE 组合下实测确认:VOP3P `v_dot2_f32_f16` 的 `clamp` 位为**硬件空操作**(`+3.0f` 保持 `0x40400000`、`-3.0f` 保持 `0xc0400000`、`+inf` 保持 `0x7f800000`、`NaN` 保持 `0x7fc00000`)。 ## 修复方案 - 在 `tools/rdna2spirv.py` 中对 VOP3P `v_dot2_f32_f16` 不再施加 `clamp_mods`。 - 更新 `tests/semantic/test_alu_dot_complete.py` 并新增 `+3.0f` / `-3.0f` / `+inf` 回归用例。 - 在 `docs/design.md` 契约表中记录硬件实测结果。 ## 验证结果 - CPU 语义测试:`tests/semantic/test_alu_dot_complete.py` 全部通过。 - 跨架构硬件差分验证(原生 AMD GFX1036 vs 翻译后 NVIDIA RTX 5060 Ti,驱动 617.42):Wave32 **4/4 精确一致**,Wave64 模拟(`--wave64-emulate`)**4/4 精确一致**,`spirv-val` 全部通过。 - 仅使用手写合成汇编,无游戏文件。 - AI 辅助:是(Antigravity)。 </details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#462
No description provided.