Repository navigation
rdna2spirv: translate v_div_scale_f64 from RDNA2 measurements - #2703
evilclanker9000 wants to merge 9 commits into
Conversation
v_div_scale_f64 stopped translation. The rule is measured natively on RDNA2 gfx1036 with tools/hw_oracle (2,008 operand triples, wave32 and wave64); it differs from the ISA pseudocode. Translated with 32-bit integer operations only, so no Float64 capability is needed. Adds the cs_div_scale_f64 GPU compute dump (13 cases, words derived by hand), a semantic test with a plain-Python reference, the docs/design.md contract row, and counts the sdst of v_div_scale as a lane mask in tools/lane_masks.py. AI-assisted.
|
Independent RTX 5070 / 621.24 Vulkan run of The shaders covered VCC and SGPR lane-mask destinations, independently loaded S0, S0 equal to denominator/numerator, This checks the Vulkan implementation against the reported gfx1036 rule. It does not independently measure native RDNA2 behavior or the full division sequence. |
|
Tested |
|
Additional check on The RTX 5070 sweep and the 5070 Ti pass above already cover the dynamic-triple matrix, so this adds only: a third NVIDIA part/driver on the fixture, the exact main-side failure end to end, an independent negative control, and a hand re-derivation of all 13 fixture cases from the published rule. Head: Before side, only Which is the "Red on main" claim. Negative control (independent of the one in the description: drop the numerator scaling of the Exactly the word the description predicts, and only that word. Translator restored ( Independent derivation: I re-derived all 13 fixture cases by hand from the rule table in the description. The checkpoints that matter all agree with the .asm header, What this GPU cannot confirm, plainly: the rule itself is the native gfx1036 measurement, and the RTX 4060 only verifies the translator's 32-bit implementation of it on Ada. It does not measure RDNA2, and it says nothing about the rest of the f64 division sequence (the PR depends on others for that). Semantic side: Verdict: LGTM. AI-assisted review. |
# Conflicts: # docs/design.md # runtime/test/shaders/check.py # scripts/run_gpu_tests.py # tests/test_shader_checks.py # tools/rdna2spirv.py
|
Tested Both through the full path, built from the PR head (CMake/Ninja, RelWithDebInfo, GCC 16.2.1) with The second run is the same command with Unit tests: The 13 cases really discriminate the rule branches. Two local mutations of
So case 4 fails when the AI-assisted. |
docs/design.md AI-assisted.
|
Rechecked in real wave64 with the hw_oracle fix in #2961: same words. AI-assisted. |
All 2,008 cases were run again with IEEE off, DX10_CLAMP on and f32 denormals flushed (the game's MODE): identical words, so omod stays ignored and a NaN keeps its payload for this op. AI-assisted.
AI-assisted.
docs/design.md tests/test_shader_checks.py AI-assisted.
docs/design.md scripts/run_gpu_tests.py tests/semantic/regen_fixtures.py tests/test_shader_checks.py tools/lane_masks.py tools/rdna2spirv.py AI-assisted.
|
Tested
AI-assisted (Claude Code). Synthetic shaders only, no game files. |
docs/design.md AI-assisted.
|
Tested ace5bf6 (merge base 7b7d73f) on NVIDIA GeForce RTX 5080, Linux 580.65.06: pass Tested the PR head merged with current main
Line-by-line against my main run (results that differ from main):
Not run: the full AI-assisted (Claude Code). |
|
Tested ace5bf6 merged with main 98fa503 on Linux (Python 3.12.16) and Windows (RTX 4080 SUPER, UHD 770): pass. test_value_semantics, test_shader_checks, test_run_gpu_tests 3/3 ok. run_gpu_tests.py cs_div_scale_f64 1/1 on RTX 4080 SUPER and UHD 770. Negative control with main's tools/rdna2spirv.py: test_value_semantics errors (1 error) and the GPU case fails to translate (no .spv). |
|
Independent hardware verification of
AI-assisted (Gemini 4 Neon). |
|
Tested ace5bf6 on Intel UHD 630 (Mesa 25.2.8 ANV): run_gpu_tests.py --filter div_scale with LEONIDA_VK_DEVICE=Intel passes, "PASS cs_div_scale_f64 64/64 dumped words exact", and a nonexistent device name fails it with "no Vulkan physical device matches". tests/semantic test_value_semantics.DivScaleF64 passes (2 tests), and test_lane_masks.py, test_isa_coverage.py, test_shader_meta.py and test_shader_checks.py give 126 passed, 4 skipped (the skips need LEONIDA_RDNA2_ISA_XML). The 2,008-case hardware oracle comparison was not run here and the full tests/semantic suite was not run. AI-assisted. |
|
Tested ace5bf6 on the local f64 fuzzer (tools/f64_diff.py from #4536 plus extra references only on the local branch leonida/FUZZ-f64-ext, not published). CPU interpreter, Windows 11. Seed 1, AI-assisted (OpenBot team). |
docs/design.md tests/semantic/regen_fixtures.py tests/test_shader_checks.py AI-assisted.
|
Tested |
|
Tested 4aa20c8 on two Vulkan devices, Windows 11, Vulkan SDK 1.4.363, MSVC 14.50, llvm-mc 23.1.6 (AMDGPU, LLVM-MinGW build):
AI-assisted. No game files. |
Requested by Lucas · project thread
Claimed in the coordination issue as: EGEN-F64-DIV-SCALE (claim comment)
What and why
v_div_scale_f64stopped translation withUnsupported. It is the first step of LLVM's double division (v_div_scalex2,v_rcp_f64,v_fma_f64,v_div_fmas_f64,v_div_fixup_f64); the other f64 ops of that sequence are in open PRs (#2244, #2441, #2477, #1976), this one was not.The rule comes from native RDNA2 measurements (
tools/hw_oracleon the gfx1036 iGPU, 2,008 operand triples, wave32 and wave64), because the hardware differs from the ISA pseudocode in several places. With e1, e2 the exponent fields of S1 (denominator) and S2 (numerator), the first match wins:Also measured:
0xfff8000000000000. The sdst bit still follows the table, so 0/1 sets it, unlike the pseudocode's VCC = 0.neg, and a copy of S1 in another register counts as equal.clampgives +0 for NaN, zero and negatives, and 1.0 from 1.0 up.omodis accepted by the assembler and ignored. VOP3b has noabs.The translation uses 32-bit integer operations only: exponent compares, exponent-field add/subtract, normalisation of a denormal S0, and a rounded right shift for the denormal results. It needs no
Float64capability, so it does not depend onshaderFloat64or on how a device handles f64 denormals. Operands are VGPR/SGPR pairs or inline constants; a 32-bit literal staysUnsupported, because which half it fills is SHADER-366 (#2057).tools/lane_masks.pynow counts the sdst ofv_div_scale_f32/f64as a lane mask, likev_add_co_u32's carry.runtime/test/shaders/cs_div_scale_f64.asm: compute dump, 13 cases x (D.lo, D.hi, vcc), with each expected word derived by hand in the header. It covers both forms of every rule, zero to NaN, sNaN payload,negon src0,clampon the NaN, and the ignoredmul:2. A compute dump, so the NaN words never pass through a float render target.tests/semantic/test_value_semantics.pyDivScaleF64: a plain-Python reference of the rule gives the 39 words, and the translated fixture produces them in the interpreter (no f64 needed there either).docs/design.md: a contract row.Tested
tests/semantic/spirv_mini_interp.py: 0 mismatches against hardware. The 13 fixture cases were also run on the oracle in both wave32 and wave64 with the same words.scripts/run_gpu_tests.py --filter div_scale:cs_div_scale_f64gives 64/64 dumped words exact and passesspirv-val, on NVIDIA GeForce RTX 5080 (driver 616.92) and AMD Radeon RDNA2 iGPU (Ryzen 9 9950X3D, driver 26.10.1), Windows 11.Unsupported: v_div_scale_f64for the fixture (semantic test errors, no SPIR-V for the GPU test).e1 - e2 >= 768rule (one line) fails on both GPUs (word 7: expected 0x15f00000, got 0x0df00000) and inDivScaleF64. Reverted.python -m unittest discover -s tests/semantic,python tests/semantic/regen_fixtures.py --check,python -I tests/test_shader_checks.py,tests/test_lane_masks.py,tests/test_isa_coverage.py,tests/test_shader_meta.py: OK.AI-assisted.
Checklist
docs/design.md, with how it was confirmed.