Repository navigation
agx: require tied min/max before decoding AGX3 FCMPSEL select immediates as minifloats - #677
Conversation
|
The fix for the reported 8x discard case is right, but the new predicate still works from raw immediates, so it narrows the ambiguity without removing it.
Assisted-by: LLM (Claude:Opus 5.5) |
|
Updated in
Assisted-by: LLM (Google:Gemini 4 Neon) |
933d7ea to
8d92763
Compare
|
Cross-chip verification on MacBook Neo (
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
8d92763 to
4e01913
Compare
|
Rebased cleanly onto
|
4e01913 to
856ddfb
Compare
|
Rebased cleanly onto |
Decoding AGX3 FCMPSEL select immediates as minifloats from raw immediate values is ambiguous even when both compare/select pairs appear tied (for example `(h < 0.5h) ? h : uint16(0x0020)` leaves imm 0x20 in both src1 and src3). Extract a shared agx_fcmpsel_is_tied_minmax() helper in agx_compiler.h used by both agx_g17p_tied_minmax() and agx_materialize_agx3_alu_constants(), record I->fcmpsel_minifloat_select = true at fold time when agx_optimizer_inline_imm() places a minifloat into a tied select slot, and decode select immediates as minifloats only when fcmpsel_minifloat_select is set. Update test-optimizer.cpp expectations and test materialized MOV_IMM values directly across G15G, G16G, and G17S for untied select (0x0020), adversarial `(h < 0.5h) ? h : 0x0020` (0x0020), and tied `max(h, 0.5h)` (0x3800). Signed-off-by: Diljit Singh <hey@djdev.me>
856ddfb to
3d1613b
Compare
|
Refreshed head pushed as
|
Signed-off-by: Diljit Singh <hey@djdev.me>
|
Merged current |
satchlj
left a comment
There was a problem hiding this comment.
Looks good! Audited all 5 changed files and cross-checked every fcmpsel_minifloat_select use across src/asahi/compiler/:
agx_fcmpsel_is_tied_minmax()cleanly centralizes the tied min/max predicate and gatesfcmpsel_minifloat_selectin bothagx_optimizer_inline_imm()andagx_compile.c(agx_nir_lower_minmax/ immediate lowering).- Untied AGX3 16-bit and AGX3C 32-bit
FCMPSELselect immediates are no longer decoded as minifloats, while tied constantfmin/fmaxfolding retains minifloat encoding. - The 3-case
NativeForms.Agx3HalfFcmpselUntiedImmediateNotDecodedAsMinifloatregression test covers the untied immediate shapes cleanly.
Verification
- Unmodified PR head
80e53866a120:agx_tests --gtest_filter="*Agx3HalfFcmpselUntiedImmediateNotDecodedAsMinifloat*:*G17PFoldsBothHalves*"3/3 PASS. - Cleanly test-merged onto
aurora-wip(a7920cea, which includes the#970hk_sync.crevert; excluding unrelatedasahi_layout_testsandhk-cpu-upload-bench): full non-layoutasahitest suite 283/283 PASS. - Live Apple M5 Max (
G17C B1,MESA_SHADER_CACHE_DISABLE=1):dEQP-VK.spirv_assembly.instruction.compute.float16.arithmetic.*76/76 PASS, 0 GPU faults indmesg.
Untested scope
- Live hardware execution on
G17P(AGX3B) was not run directly; AGX3B packing and optimizer behavior was verified via unit tests.
Verdict at
|
Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com>
Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com>
satchlj
left a comment
There was a problem hiding this comment.
Verdict at 0fda13d52c53
Approved.
Blockers
None.
Checked
- Audited all 5 changed files (
agx_compile.c,agx_compiler.h,agx_optimizer.c,test-native-form-regressions.cpp,test-optimizer.cpp) at exact head0fda13d52c53(+155/-35, clean merge ontoaurora-wipa65c0b99bb30with no functional delta vs80e53866a120). - Verified
agx_fcmpsel_is_tied_minmax()requires exact source equivalence including size,abs,neg, andmemoryflags,agx_optimizer_inline_imm()setsfcmpsel_minifloat_selectonly when folding a minifloat into a tied min/max select slot, andagx_materialize_agx3_alu_constants()gates minifloat decoding onfcmpsel_minifloat_selectbefore clearing it on both 32-bit and 16-bit paths. - Built isolated Borealis and compiler test targets cleanly (
b_ndebug=false) and ran the full non-layoutasahiunit suite (185/185 PASS, including the 3 new/updatedFCMPSELcases acrossAGX3BandAGX3C). - Verified on live Apple M5 Max (
G17C B1, Linux 7.3,MESA_SHADER_CACHE_DISABLE=1):dEQP-VK.spirv_assembly.instruction.compute.float16.arithmetic.*76/76 PASS,dEQP-VK.compute.pipeline.basic.*80/80 executed PASS (1 unsupported, 0 failed), 0 GPU faults. - Untested scope: Live hardware execution on
AGX3B(M3/M4) chips (covered only by compiler unit tests and IR/packing checks here) andasahi_layout_tests.
Evidence
- Exact head verified:
0fda13d52c5330a453931c2099d207b940f8c9da(OPEN, non-draft,MERGEABLE) agx_tests --gtest_filter="*Agx3HalfFcmpselUntiedImmediateNotDecodedAsMinifloat*:*G17PFoldsBothHalves*": 3/3 PASS- Full non-layout
asahisuite (meson test --suite asahi): 185/185 PASS, 0 FAIL - Live Apple M5 Max (
G17C B1,MESA_SHADER_CACHE_DISABLE=1):dEQP-VK.spirv_assembly.instruction.compute.float16.arithmetic.*: 76/76 PASSdEQP-VK.compute.pipeline.basic.*: 80/81 PASS (1 Not supported, 0 Failed)- GPU faults delta: 0
Summary
FCMPSELlegalization checked only whether a single compare/select immediate slot held the same raw value rather than verifying a full tiedLTN/GTNmin/max where both operand pairs match.0.5f(minifloat0x20) while selecting integer bitmask1 << 5 = 0x20caused0x20to be decoded as FP160x3800, leaving sample 5 undiscardable.NativeForms.Agx3HalfFcmpselUntiedImmediateNotDecodedAsMinifloat.Verification (Apple M5 Pro / G17S B1, Borealis+Zink,
MESA_SHADER_CACHE_DISABLE=1)dEQP-GL45-ES31.functional.sample_shading.min_sample_shading.multisample_*_samples_8_discard: 2/2 PassdEQP-GLES31.functional.sample_shading.min_sample_shading.multisample_*_samples_8_discard: 2/2 PassdEQP-{GL45-ES31,GLES31}.functional.sample_shading.*: 44/44 supported Pass (0 fails)agx_tests: 1222/1222 Pass (includingNativeForms.Agx3HalfFcmpselUntiedImmediateNotDecodedAsMinifloat)dmesg.