Repository navigation
feat(rdna2spirv): measure and support VOP3 output modifiers on v_frexp/ldexp_f16 - #4311
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 2c3cc2a8 on Windows 11:
tests/semantic/test_alu_frexp_ldexp_f16.py-> 25 tests, OK (existing coverage, still passes).tests/semantic/test_frexp_ldexp_f16_mods.py-> 7 tests, OK (new output-modifier cases).tests/test_frexp_ldexp_f16_mods_probe.py-> 14 tests, OK (1 skipped).git diff --checkclean.
The translator now accepts mul:2, mul:4, div:2 and clamp on these three ops according to the measured gfx1036 behavior: no-ops on v_frexp_exp_i16_f16, no-ops on the mantissa/v_ldexp_f16 results under console MODE, with clamp still clamping where the existing path did. Other modifiers are still refused. I cannot reproduce the hardware measurement on this NVIDIA host; the semantic/probe tests pin it. No blocking issue.
|
Tested 2c3cc2a exhaustively on a non-AMD GPU: NVIDIA GeForce RTX 3070 (Ampere, wave32), driver 617.42, Windows 11 24H2. The probe measures 30 edge inputs; this runs every binary16 input. All 56 programs, 3,670,016 words, exact against this branch's How: one compute program per For comparison, No game files. AI-assisted (Claude). |
|
Tested
AI-assisted review. |
Flyander
left a comment
There was a problem hiding this comment.
P2 — contradictory FP16 denormal contract (docs/design.md:388)
This edited row says both that f16 denormals are “read as zero” and that they are kept and normalized (v_frexp_mant_f16(0x0001) = 0.5). It also says v_ldexp_f16 produces no denormals, then gives measured denormal results such as 0x0200 and 0x0002. These statements cannot all describe the console MODE documented in this same row, and they make the translator contract unsafe to follow.
Remove the stale “read as zero” and “no denormal results” clauses, keeping the later measured behavior for denorm_mode_16_64=3. The row is the changed contract for these opcodes.
|
Independent second-check of 2c3cc2a, Linux, CPU only (Turing GPU, non-AMD, so the native gfx1036 probe measurements themselves are outside what I can repeat here, and your own probe run covers those):
Code read of the diff and its tests: clean. AI-assisted. |
|
Tested 2c3cc2a (PR head, based on an older main) on NVIDIA GeForce RTX 5050 (Blackwell), NVIDIA 595.104.02, Pop!_OS 24.04: pass. run_gpu_tests.py: 164/210 passed, 46 skipped, 0 failed (same as main at 03b09a0). build.py: 214 shaders, 214 translated, 214 pass spirv-val. No game data. AI-assisted. |
|
Heads-up from #2171 (SHADER-354, approved): both PRs rewrite the same
If this one lands first, I'll fold your sentence into #2171 the same way. |
Conflicts after ItsNotRexed#4311 and main's cs_fmt_all: - docs/design.md: keep main's f16 frexp/ldexp row (ItsNotRexed#4311) and extend its last sentence with this PR's GPU check. - scripts/run_gpu_tests.py: main's verdict_line() for the case above, plus the cs_f16_frexp_ldexp branch. - tests/test_shader_checks.py: both sides added one case to TOTAL (13 -> 14), so the merged total is 15. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Corpus check of
That is expected. No listing in the corpus contains AI-assisted (Claude Code). Counts only. |
AI-assisted (Gemini). Claimed in #4084 (comment) (no overlap with #1970 or #2171; no game files used).
Summary
tools/frexp_ldexp_f16_mods_probe.py): Measures VOP3clamp,mul:2,mul:4,div:2, andclamp+mul:*/div:*across 30 binary16 edge inputs (and 5 exponents forv_ldexp_f16), sourceabs/negmodifiers, dirty upper source halves, and destination high-half preservation across wave32 and wave64 under console MODE (0x1c0), flush control (0x100), and IEEE control (0x3c0).tools/rdna2spirv.py): Acceptsclamp,mul:2,mul:4,div:2, andop_sel:onv_frexp_mant_f16,v_frexp_exp_i16_f16, andv_ldexp_f16:0x1c0:IEEE=0,DX10_CLAMP=1,denorm_mode_16_64=3),mul:2/mul:4/div:2are hardware no-ops onv_frexp_mant_f16andv_ldexp_f16(emitting byte-identical SPIR-V), whileclampsaturates to[0.0, 1.0]both alone and combined withmul:*/div:*.v_frexp_exp_i16_f16(16-bit integer result), bothclampandmul:2/mul:4/div:2are hardware no-ops across every MODE (0x1c0,0x100,0x3c0).mul:8,div:4,op_sel_hi:*,neg_lo:*,neg_hi:*) continue to raiseUnsupported.docs/design.md): Updated thev_frexp_mant_f16,v_frexp_exp_i16_f16,v_ldexp_f16row with the measured rules, counts, GPU/driver info, and test references.tests/test_frexp_ldexp_f16_mods_probe.py,tests/semantic/test_frexp_ldexp_f16_mods.py,tests/semantic/test_alu_frexp_ldexp_f16.py): Unit, translator +spirv_mini_interp, byte-identical SPIR-V,op_sel, inactive-EXEC,Unsupported, andspirv-valvalidation checks.Native RDNA2 Hardware Measurement
AMD Radeon(TM) Graphics(gfx1036), Windows driver32.0.21045.29003python -I tools/frexp_ldexp_f16_mods_probe.py --hw-arch gfx1036:total_words=3466 (grid=3360, src_mods=22, controls=84) across 2 wave(s) x 3 op(s): mismatches=0, wave_diffs=0, omod_diffs=0(exit 0)MODE=0x100(denorm16_64=0) confirmedmul:2/mul:4/div:2scalev_frexp_mant_f16andv_ldexp_f16, whilev_frexp_exp_i16_f16still ignoresclampandmul:*/div:*.MODE=0x3c0(IEEE=1) confirmedmul:*/div:*remain no-ops andclampstill saturatesv_frexp_mant_f16andv_ldexp_f16.Vulkan GPU Verification
Synthetic wave32 compute shader
cs_frexp_ldexp_f16_modstranslated bytools/rdna2spirv.pyand validated withspirv-val --target-env vulkan1.3(VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VKC_SUBGROUP_SIZE=32):32.0.32029.2010):vk_pipeline_check1/1 ok;vk_compute_test1 groups x 64: 0 mismatches, 8/8 exact words (0xdead3800 0xdead0000 0xdead3c00 0xdead0004 0xdeadffe9 0xdead3c00 0xdead3c00 0xdead0000), 0 validation errors.gfx1036, driver32.0.21045.29003):vk_pipeline_check1/1 ok;vk_compute_test1 groups x 64: 0 mismatches, 8/8 exact words, 0 validation errors.CPU & Repository Checks
python -I tools/frexp_ldexp_f16_mods_probe.py --self-test-> exit 0 (1733 synthetic words checked)python -I tests/test_frexp_ldexp_f16_mods_probe.py-> 14/14 passed (withLEONIDA_AMD_CLANGwrapper; 1 skipped without AMD clang)python -m unittest discover -s tests/semantic -p test_*frexp_ldexp_f16*.py -v-> 32/32 passed (includingspirv-val --target-env vulkan1.3)python -m unittest discover -s tests/semantic -v-> 7,463 tests run (7 failures, 2 errors all in pre-existing unrelated files onaa2988cc:test_cmp_class_f64.py,test_loop_ballot_barrier.py,test_mutations.py)python -m compileall -q make_game.py tools tests&python -I make_game.py --help-> exit 0python -I tests/test_semantic_translator_use.py(3/3),tests/test_text_write_line_endings.py(3/3),tests/test_tool_startup.py(2/2),tests/test_tool_stdout_encoding.py(4/4),tests/test_ci_registration.py(8/8),tests/test_i18n_index.py(5/5),tests/semantic/test_spirv_tools_required.pywithLEONIDA_REQUIRE_SPIRV_TOOLS=1(1/1) -> all passedpython -I tests/test_docs_design_rows.py(2/2),tests/test_design_contract_rows.py(4/4),tests/test_docs_links.py(6/6),tests/test_docs_repo_paths.py(2/2),tests/test_docs_table_rows.py(2/2),tests/test_docs_cli_flags.py(3/3),python -I scripts/check_no_game_data.py-> exit 0