Repository navigation
Conversation
…he float flush_f32 took FAbs, a compare with FLT_MIN, a bitcast to uint for the sign mask, a bitcast back and a float select per flush. Gen.flush_u does the same on the bits with four integer ops: a zero exponent field (zero or subnormal) becomes the sign bit alone, anything else (normal, inf, NaN) is unchanged. Integer ops only, so the driver's own f32 denormal handling can't affect the test. tests/semantic/test_flush_on_bits.py checks the edges (FLT_MIN, the largest subnormals of each sign, +-0, inf, NaN) through v_mad_f32 and that the module has no FAbs or float compare. The two tests that looked for the float form (the legacy multiply's flush count, the min3/max3/mad sabotage check) now look for flush_u's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Checked Across four 64×64 draws, all 65,536 output words met the oracle. The smallest and largest subnormals of both signs flushed to the corresponding signed zero. Both zeros, ±FLT_MIN, the next normal magnitude above FLT_MIN on each sign, and ±infinity matched bit for bit. For the four signed quiet/signaling NaN inputs I checked only that the arithmetic result was NaN. Negative control: in the generated assembly I replaced the signed-zero arm of the 20 flush selects with unsigned zero, then reassembled and validated for Vulkan 1.2. The same draws produced exactly 12,288 mismatched words: the two negative subnormal cases and the negative zero case each lost their sign at every pixel. All other cases still passed. AI-assisted (OpenAI Codex). |
Hiiva
left a comment
There was a problem hiding this comment.
Independent Windows compute review at e3934c08b36abb1fb37d3d848e4331ae6808182c, compared with unchanged main 3faac557b1584d39004357918e60325b4d4ff0fe. No blocking findings in the changed flush helper. This adds Radeon native-subgroup and main/head comparison evidence to the existing fragment-shader review.
CPU and source review
Reviewed all four changed files, including preservation of the exponent/sign bits and the revised sabotage test. The three changed test files pass: 29 methods and 1,115 subtests. The adjacent FMA-mix and dot2 tests pass: 81 methods and 91 subtests. Against main, the new test file's value/NaN checks pass and only its integer-structure check fails, as expected.
GPU controls
Two external, hand-written compute fixtures use the ordinary LLVM 21.1.8 gfx1013 -> translator -> spirv-val --target-env vulkan1.2 pipeline. Main and head receive identical assembly listings and raw uint input buffers. Each fixture launches 64 threads over 32 distinct input triples, repeated once, and stores the source bits back alongside the results. The 32/64 metadata agrees with the requested native subgroup width; no wave64 emulation is used.
Coverage: positive/negative smallest and largest subnormals, signed zeros, FLT_MIN and the next normal value, finite extrema, signed infinity, signed quiet/signaling NaNs, product/sum underflow, pre/post-output-modifier flushing, and the legacy zero-times-infinity/NaN rule. Result columns exercise v_mad_f32, v_mac_f32, legacy multiply/MAD/MAC, div:2, mul:2, source negation/absolute value, and a runtime-input FMA-mix identity.
| Device and Windows driver | Native subgroup | Main | PR head |
|---|---|---|---|
NVIDIA RTX 4080, 610.62 (32.0.16.1062) |
32 | pass | pass |
AMD Radeon(TM) Graphics, 32.0.21043.5001 |
32 | pass | pass |
AMD Radeon(TM) Graphics, 32.0.21043.5001 |
64 | pass | pass |
Each of the six runs checks 462 bit-exact arithmetic results, 114 NaN-class results, and 256 raw input/tag echo words, plus unchanged input and padding regions. The independent arithmetic oracle uses exact rational arithmetic with binary32 round-to-nearest-even. NaN payload/sign after arithmetic are not constrained; finite values, infinity signs and zero signs are exact. Main/head readbacks are byte-identical within each device/mode pair.
All four production modules validate. Runs use the same unchanged main-source vk_compute_test binary, Windows 11, MSVC 19.44 and SDK/Khronos validation 1.4.363, with error/warning output captured. Zero VUIDs or validation errors in the six runs.
Negative control: replace only the signed-zero arms of the head module's 44 flushes with positive zero, reassemble and validate, then repeat the RTX 4080/32 run. The oracle catches 84 result mismatches, including loss of negative zero; source echoes and padding remain intact.
This is translated Vulkan execution at native subgroup widths, not native AMD ISA measurement. Dot2 has CPU coverage here, not an added GPU claim. No game files, corpus result, timing claim or production edits. AI-assisted.
kacper-serewis
left a comment
There was a problem hiding this comment.
AI-assisted independent review. At e3934c0, all 200 randomly selected cached shaders (seed 5347) translated and validated on both revisions. The 185 modules containing changed flushes all shrank; the other 15 were byte-identical. Total SPIR-V fell from 127,224,340 to 123,669,916 bytes (2.79%). In each module additional integer flush sequences matched the decreases in both FAbs and OpFOrdLessThan, totaling 177,734 replacements. CPU validation on this slice.
|
Independent NVIDIA run on the exact PR head CPU translator checks (no game data): GPU: filtered runs assembled/translated four existing synthetic fixtures; all four passed Coverage limit: these existing GPU fixtures do not directly exercise |
Kam471
left a comment
There was a problem hiding this comment.
Reviewed e3934c0
python tests/semantic/test_flush_on_bits.py -v-> 3 tests OK;python tests/semantic/test_valu_mul_legacy_denorm.py-> 4 OK;python tests/semantic/test_valu_f32_min3_max3_mad.py-> 22 OK.- Flush consumers:
test_alu_dot_complete.py9 OK,test_valu_fma_mix.py15 OK,test_valu_dot2_f16.py66 OK. - Full
tests/semantic(pytest-xdistis not installed here, so no-n 10; ran the 397 files as 8 parallel pytest processes): 6,243 passed, 4 skipped, 1 xfailed, 5 failed. The 5 failures are thetest_loop_ballot_barriersubtests, and-k loop_ballotonorigin/main3faac557gives the same 5SUBFAILEDnames (emulate_64/128/40_sg32, nested loops, bug4b). - Negative control:
test_flush_on_bits.pyon3faac557->FAILED (failures=1),test_integer_ops_only("FAbs unexpectedly found"), as the PR says; the edge-value tests pass there because the old flush computes the same values. git diff --checkclean.
flush_u is equivalent on every exponent class (zeros/subnormals -> signed zero, normals/inf/NaN unchanged), and the new test pins the 5-flush shape for one mad.
Verdict: OK to merge. git diff --check exit 0.
|
Apple M4 run of
AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
|
Tested e3934c0 on Intel UHD Graphics 630 (CFL GT2): test_flush_on_bits, test_valu_f32_min3_max3_mad and test_valu_mul_legacy_denorm pass (29 tests), tests/test_translate.py passes (596), and run_gpu_tests.py with LEONIDA_VK_DEVICE=Intel gives 154/217 passed, 61 skipped, with FAIL cs_fmt_int_narrow and FAIL cs_signed_zero_nan. Running test_flush_on_bits with the translator tools from the base commit 3faac55 gives failures=1: test_integer_ops_only fails at assertNotIn(" FAbs ", spv). AI-assisted. |
|
@gertify thanks. The two GPU FAILs aren't from this PR: AI-assisted (Claude Code). |
|
Tested e3934c0 on AMD RADV RAPHAEL_MENDOCINO (Ryzen 9 9950X3D iGPU), subgroup 32..64: run_gpu_tests.py with LEONIDA_VK_DEVICE=RADV gives 202/217 passed, 15 skipped, 0 FAIL. test_flush_on_bits (3 tests), test_valu_f32_min3_max3_mad (22) and test_valu_mul_legacy_denorm (4) pass. Running test_flush_on_bits with the translator tools from the parent commit 3faac55 gives failures=1: test_integer_ops_only fails at assertNotIn(" FAbs ", spv). The shader corpus from the description was not run. AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
New SHADER item. Claim: #5256 (comment)
Gen.flush_f32is the f32 denormal flush ofv_mad_f32/v_mac_f32, the legacy multiplies, the f32 operands ofv_fma_mix_*and the accumulator ofv_dot2_f32_f16(SHADER-118, SHADER-298). Each operand, rounded product and sum gets it. It tested|x| < FLT_MINon the float:FAbs;OpFOrdLessThanagainst FLT_MIN, which onmainis itself anOpBitcastat each use;OpBitcastto uint for the sign;OpBitcastback;OpSelect.That is about seven instructions per flush, and the flush is the largest single cost in translated modules: 772,627
FAbson my 663-shader sample, nearly all of them flushes.Change
Gen.flush_u(u)flushes the bits of an f32 with four integer ops:(u & 0x7F800000) == 0 ? u & 0x80000000 : u.This is the same result as before for every input. The float test sent zeros and subnormals to the signed zero (
copysign(0, x)leaves a zero as it is), and inf and NaN compared false.flush_f32(f)is nowtof(flush_u(tou(f))), so no call site changes. Since nothing in the test is floating point, the driver's own f32 denormal handling inFAbs/compare, which Vulkan leaves open, no longer matters either.Tests
tests/semantic/test_flush_on_bits.py(translator +spirv_mini_interp). It runsx * 1.0 + -0.0throughv_mad_f32on the edges: FLT_MIN and −FLT_MIN stay, the largest subnormal of each sign becomes +0 / −0, 2^-149 becomes +0, ±0 and ±inf pass, and NaN stays a NaN. It also checks that the module has noFAbsorOpFOrdLessThanand has exactly five flushes (three operands, product, sum). Withmain's translator the structural check fails.test_valu_mul_legacy_denorm's flush count now counts exponent masks.test_valu_f32_min3_max3_mad's sabotage check now turns exactly the flush selects (those whose condition is the exponent test) into pass-throughs, and still sees the subnormal cases change.pytest tests/semantic -n 10: 6,246 passed, 5 failed, the same 5test_loop_ballot_barriersubtests asmain3faac557.pytest tests --ignore=tests/semantic -n 10: the same failures asmain3faac557.scripts/run_gpu_tests.pyon Intel UHD Graphics 750 (Windows 11,LEONIDA_VK_DEVICE=Intel,LEONIDA_W64_EMULATE=1; the test programs are built from98fa503f, since this PR changes no C++): 180/217 passed, 37 skipped, every test with the same result asmain3faac557on the same setup.Measured on my own 1.0.2.1 corpus (shard 0/40, counts only)
main3faac557spirv-val.spvbytesOther PRs
54e5d2dc). With both,src_f_flushed's run-time path can callflush_uonsrc_u's bits directly and skip the float round trip; I'll do that as a follow-up once both land.test_valu_mul_legacy_denorm.py's count. I'll rebase whichever lands second. Itslegacy_zerocompares|x| < FLT_MINtoo and could use the same exponent test afterwards.main, rdna2spirv: f32 constants are module-scope OpConstants, not a bitcast at each use (-2.4% SPIR-V) #4391, rdna2spirv: a multi-dword MUBUF access builds each bounds check once #4477, rdna2spirv: a bitcast back to a value's original type is the original id (-1.4% SPIR-V) #4510, rdna2spirv: the heap base is built once in the entry block, not at every memory access (SHADER-822, -1.9% SPIR-V) #4633, rdna2spirv: v_madak_f32 and v_madmk_f32 flush f32 denormals like v_mad_f32 #4189 and rdna2spirv: hoist constant-index %vgpr/%sgpr OpAccessChain to %entry (SHADER-789) #4440.AI-assisted (Claude Code). No game files.
🤖 Generated with Claude Code