Skip to content

hw_oracle: native RDNA2 measurement of MODE.FP_ROUND f16/f64 (SHADER-132) - #2202

Closed
Faterek wants to merge 2 commits into
ItsNotRexed:mainfrom
Faterek:shader-132-mode-fp-round-rdna2
Closed

Faterek wants to merge 2 commits into
ItsNotRexed:mainfrom
Faterek:shader-132-mode-fp-round-rdna2

Conversation

@Faterek

@Faterek Faterek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What and why

Closes SHADER-132 (claimed in #2078). Measures f16/f64 rounding under s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2) (nearest-even vs toward-zero) natively on RDNA2 (gfx1036, wave32 and wave64) via tools/hw_oracle for #753 (SHADER-35):

  • All 7 f16 transcendentals (v_rcp_f16, v_rsq_f16, v_sqrt_f16, v_sin_f16, plus the 3 previously unmeasured ops v_cos_f16, v_exp_f16, v_log_f16): 0 / 65,536 inputs differ between RNE and RTZ in both wave32 and wave64 (917,504 evaluations total). This closes the unmeasured gap in docs/design.md and pins the measured words (cos(0x3037) = 0x396a, exp(0x3037) = 0x3c62, log(0x4a37) = 0x4345) in tests/test_mode_round.py.
  • All 17 f16/f64 arithmetic & conversion cases (v_cvt_f16_f32, v_add/sub/mul/fma_f16, v_pk_add/fma_f16, v_fma_mix{lo,hi}_f16 single-rounding & overflow, v_add_f64 exact residual & overflow saturation): 17 / 17 exact in both wave32 and wave64, matching tools/rdna2spirv.py.

No translator change was needed.

Added / Updated

  • tools/mode_round_probe.py — standalone RDNA2 hardware probe (tools/hw_oracle, stdlib-only, --self-test, exit 77 when unavailable/non-GFX10)
  • tests/test_mode_round_probe.py — CPU-only unit tests for the probe
  • tests/test_mode_round.py — added the measured v_cos_f16, v_exp_f16, v_log_f16 words to test_transcendental_f16_nearest_after_rtz_write
  • docs/design.md — updated the MODE.FP_ROUND / f16 transcendentals contract row with the exhaustive gfx1036 wave32/wave64 measurements

Tested

  • Native RDNA2 hardware (tools/mode_round_probe.py): AMD Ryzen 7 9800X3D iGPU (gfx1036, Linux 7.3.4-1-cachyos, AMDGPU DRM via tools/hw_oracle):
    • wave32 (gfx1036): 17/17 f16/f64 RNE/RTZ cases exact; 7/7 f16 transcendentals 0/65536 RNE/RTZ diffs
    • wave64 (gfx1036): 17/17 f16/f64 RNE/RTZ cases exact; 7/7 f16 transcendentals 0/65536 RNE/RTZ diffs
  • CPU tests:
    • python3 -m compileall -q make_game.py tools tests clean
    • pytest -q tests/test_mode_round.py tests/test_mode_round_probe.py tests/test_tool_stdout_encoding.py: 57 passed
  • No game data, keys, or online services.

AI-assisted.

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Checked on an AMD Radeon RX 9070 (RDNA4, gfx1201), Windows 11, merged onto main 4947579 (clean merge). This card is not RDNA2, so it can't give the measurement itself; what I could check:

  • mode_round_probe --self-test: OK.
  • mode_round_probe natively through tools/hw_oracle (AMD clang from rocm-sdk-core): SKIP: gfx1201 is not GFX10 (RDNA1/RDNA2), exit 0. It refuses non-GFX10 hardware cleanly instead of reporting RDNA4 results as RDNA2 ones.
  • tests/test_mode_round.py: 53 passed, tests/test_mode_round_probe.py: 2 passed.
  • scripts/run_gpu_tests.py: 167/180 native and 167/180 with LEONIDA_W64_EMULATE=1, 0 failures. The 13 skips are the 12 run by d3d12_*_test shaders and ps_w64x_readlane (no 64-wide fragment subgroup on this device), the same as main.

AI-assisted (Claude Code); runs on my machine.

@Faterek

Faterek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (49475796, resolving the docs/design.md conflict cleanly; head now 1e0c67fa). Re-verified on AMD Radeon 610M (gfx1036, Linux 7.3.4): tools/mode_round_probe.py passes all 17 f16/f64 RNE vs RTZ cases and 0/65,536 RNE-vs-RTZ diffs across all 7 f16 transcendentals in both wave32 and wave64; test_mode_round, test_mode_round_probe, and repo convention tests pass (72 passed). AI-assisted.

@Faterek
Faterek force-pushed the shader-132-mode-fp-round-rdna2 branch from 1457585 to 1e0c67f Compare November 22, 2026 17:04
ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
# Conflicts:
#	docs/design.md
@Faterek

Faterek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Already merged into main in round 40 as commit 0c73e101 (merging pre-rebase head 14575859; GitHub left the PR open because we force-pushed a rebase shortly before main was pushed). Closing to keep the PR queue clean.

@Faterek Faterek closed this Nov 22, 2026
ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
# Conflicts:
#	docs/design.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants