mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1231] rdna2spirv: model the measured special results of v_rcp/v_rsq/v_sqrt/v_log_f32 (SHADER-F32-SPECIAL-RESULTS) #1263
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1263
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1231
Author: @Sangonapou
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:f32-special-results📝 Commits (2)
1c31b57rdna2spirv: model the measured special results of v_rcp/v_rsq/v_sqrt/v_log_f32bd96a74tests: f32_fuzz and rcp_iflag checks follow the modelled special results📊 Changes
9 files changed (+155 additions, -62 deletions)
View changed files
📝
docs/design.md(+2 -2)📝
tests/semantic/test_alu_rcp.py(+20 -21)📝
tests/semantic/test_alu_rcp_f32.py(+5 -4)📝
tests/semantic/test_valu_f32_transcendentals.py(+34 -9)📝
tests/semantic/test_valu_rcp_fdiv.py(+9 -9)📝
tests/semantic/test_valu_trig_f32.py(+8 -10)📝
tests/test_f32_fuzz.py(+11 -2)📝
tests/test_rcp_iflag_mods.py(+18 -1)📝
tools/rdna2spirv.py(+48 -4)📄 Description
Claimed in the coordination issue as: SHADER-F32-SPECIAL-RESULTS (claim)
What and why
docs/design.md("Denormal flush and special results") lists RDNA2's measured special results as not modelled:v_rcp_f32/v_rcp_iflag_f32(±0)= ±inf,v_rsq_f32(-0)= -inf,v_sqrt_f32(-0)= -0,v_log_f32(±0)= -inf, andv_sqrt/v_rsq/v_logof a negative value =0xffc00000. The translator emittedOpFDiv %f1 xandGLSL.std.450 Sqrt/InverseSqrt/Log2, which SPIR-V leaves undefined for exactly those inputs, so the result was whatever the driver returned. These ops occur 1.17M times in 76% of the corpus (counts in that row).Gen.f32_special_results(used by theF1path andv_rcp_iflag_f32): a special operand reaches the op as 1.0 and the hardware word is selected afterwards, the same technique the f16 forms already use. Every other operand, NaNs included, reaches the op unchanged, so its result is as before.v_rsq_f32(+0)= +inf (IEEE). Denormal handling is unchanged (separate question). The design.md row and the "Still open" list are updated.Tested
tools/vk_fuzz_run, one wave32 lane, opaque operands), 22 cases (16 special inputs across the five ops plus 6 regular ones): base 15/22, this branch 22/22 match the RDNA2 words. On the base, NVIDIA returns0x7ffffffffor every sqrt/rsq/log of a negative value where RDNA2 gives0xffc00000; ±0 cases already matched there by luck of the driver.tools/f32_fuzz.py --programs 500 --seed 20261124: base 463 match / 0 mismatch / 17 undefined in SPIR-V / 20 skipped → this branch 480 match / 0 mismatch / 0 undefined / 20 skipped.python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6169 tests; the only failures were the five tests that asserted the old undefined behaviour (test_alu_rcp,test_valu_f32_transcendentals,test_alu_rcp_f32,test_valu_rcp_fdiv,test_valu_trig_f32), now updated to the hardware words (plus a regular-input check); all pass.python -m compileall,scripts/check_no_game_data.pyon every changed file: clean.GPUs tested: NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32), driver 621.24, Vulkan 1.4.357, Windows 11 Pro build 26300
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.