Repository navigation
agx: keep f16 GPR sources native in unmodified AGX3B F32 FFMA - #702
Conversation
|
Rebased onto
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
04fafc6 to
8c7b126
Compare
|
Thanks. The Neo oracle (hardware widened vs native, subnormals, NaN payloads and signed zeros in every slot) is the right kind of evidence. A few things before this goes in:
Hardware: all rows are from G17P (Neo). AGX3B also covers G15G (M3), G16G (M4) and G16S (M4 Pro). Could you add, at 8c7b126, the 1024-case widened-vs-native oracle plus Assisted-by: LLM (Claude:Opus 5.5) |
Allow unmodified all-scalar-register F32 FFMA instructions on AGX3B (non-G18G) to consume f16 GPR sources directly instead of emitting redundant f16->f32 widening moves, while leaving AGX3C untouched: - In agx_optimizer.c, allow folding unmodified scalar f16 GPR widenings into unmodified, non-saturated, all-scalar-register F32 FFMA on AGX3B (keeping FADD, FMUL, G18G, saturated, modified, immediate, and uniform cases on their existing paths). - In agx_compile.c:agx_lower_agx3_fma_sources(), preserve unmodified f16 GPR sources (matching both AGX_INDEX_NORMAL and AGX_INDEX_REGISTER and excluding saturate) on AGX3B only. - In agx3_pack_binary.c:agx3_try_float_modifier(), route unmodified mixed-width AGX3B F32 FFMA through agx3_falu_fma_mod_runtime(), which encodes per-operand width bits directly. - Add compiler regression tests in test-optimizer.cpp and test-native-form-regressions.cpp covering optimizer folding, lowering (normal, precoloured, modified, saturated, uniform, G18G, and AGX3C cases), and end-to-end AGX3B binary packing checked directly against the agx3b_tables.txt width-bit layout. Signed-off-by: Diljit Singh <hey@djdev.me>
|
Addressed all five R1 items in
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
8c7b126 to
d7a02f6
Compare
|
Thanks, re-checked at d7a02f6:
This touches the same Assisted-by: LLM (Claude:Opus 5.5) |
|
Exact-head M4 (
Assisted-by: LLM (Gemini:4 Neon) |
|
Thanks. The M4 row at the exact head closes the hardware question: the denorm/NaN/-0 oracle is 1024/1024 bit-exact against base, fp16 arithmetic/float_controls/fma CTS have 0 failures, and the disassembly shows native mixed-width ffma. The correctness side is done from my side. One note for the description: the M4 ABBA is neutral (0.997x wall), so the benefit here is the removed widening moves rather than measured time. If the 10,982-shader sweep has instruction-count totals (fmov removed, ALU delta), please add them to the description so the merge is justified by numbers. Approving. Assisted-by: LLM (Claude:Opus 5.5) |
|
Merged into All merge gates green on exact head
Assisted-by: LLM (Google:Gemini 4 Neon) |
Extend #702's agx_lower_agx3_fma_sources() native half-GPR path cleanly from AGX3B to all non-G18G AGX3 encodings (AGX3B and AGX3C): on AGX3C (non-G18G), unmodified all-scalar-register F32 FFMA natively encodes per-operand width bits (src0_16, src1_16, addend_16) via agx3_falu_fma_mod_runtime(). Skip the redundant f16->f32 widening move for both SSA and precoloured half GPR sources while keeping AGX3B native and preserving widening for modified sources, uniform-mixed forms, and G18G. Add exact-byte src0_16 encoding coverage in test-agx3-alu-core.c and update/extend test-native-form-regressions.cpp for AGX3C (including precoloured AGX_INDEX_REGISTER half sources and end-to-end AGX3C shader compilation). Signed-off-by: Diljit Singh <hey@djdev.me>
Extend mixed-width
F32 FFMAnativef16GPR source preservation (as in #683 for M5 /AGX3C) toAGX3B(non-G18G), removing redundantfmov f32, f16widening moves ahead of unmodified all-scalar-registerF32 FFMAinstructions.Changes
src/asahi/compiler/agx_optimizer.c: allow folding unmodified scalarf16GPRfmovsources into unmodified, non-saturated, all-scalar-registerF32 FFMAonAGX_ISA_ENCODING_AGX3B.FADD,FMUL,G18G, saturated, modified, immediate, and uniform-mixed forms keep their existing widening behavior.src/asahi/compiler/agx_compile.c: keyall_scalar_regsinagx_lower_agx3_fma_sources()strictly onAGX_ISA_ENCODING_AGX3B(leavingAGX3Cuntouched) to preserve unmodified scalarf16GPR sources (AGX_INDEX_NORMALandAGX_INDEX_REGISTER, single- or multi-use).src/asahi/compiler/agx3_pack_binary.c: route unmodified mixed-width scalarAGX3BF32 FFMAthroughagx3_falu_fma_mod_runtime()so per-operandf16/f32width bits and runtime lifetime/wait hints pack natively.Optimizer.Agx3bFoldsUnmodifiedHalfGprIntoFfma(test-optimizer.cpp): positive/negative folding cases (src0/src1/addend/dual, saturated, modified, FADD, G18G).NativeForms.Agx3bFfmaKeepsUnmodifiedHalfGprNative(test-native-form-regressions.cpp): lowering cases (normal + precoloured register indices, modified, uniform-mixed, G18G,agx3c_src0_widened) plus directagx3b_tables.txtphysical bit-field assertions across 6-byteform f32fma 2and 8-byteform f32fma 3(group 270) encodings.10,982-Shader AGX3B (
g17p) Corpus Sweep (c0b51ef2455vsd7a02f6dc20d)Across
gpubench-foz,mc-packs,mc-vanilla,shaderdb, andvk-synth(10,982 shaders):-2,403(-0.11%) (up to-101instructions onmc-packscomposite4)-13,312B-142GPRs,+320threads,-51fills,-44scratch-2350new failures,0newagx3_pack_binaryrefusals (406 -> 406pre-existing)Verification (Exact Head
d7a02f6dc20ddbc6b8e5494b60fc3d9f866c29d2)fedora-mesaci): 156/156 PASS (0fail,0timeout,0skipped).asahiCI (DjDeveloperr/mesa): GREEN (45019754703).DEFAULT_BRANCH=aurora-wip bash .github/aurora/agent-policy.sh pr HEADclean.G17P B1,kfault_delta=0,avc_delta=0):1,024/1,024bit-exact (0diffs) vs widened baseline.2,724supported Pass /0Fail (float_controls.fp16.*2,252/0,precision*.fma.*16/0,float16.arithmetic.*456/0).G16G B0,J773g,0faults):1,024/1,024bit-exact (0diffs) vs basec0b51ef24554; native mixed-widthffmaconfirmed in disassembly.2,799Pass /0Fail (vk-mustpass-short87/87,float16.arithmetic.*456/456,float_controls.fp16.*2,240/0,precision*.fma.*16/0).gpubench(8 rows):8/8bit-exact CRCs (0.9970×wall /0.9964×GPU geomean — neutral wall time; primary win is the-2,403removed widening instructions /-13,312 B/-142GPRs /+320threads across the 10,982-shader corpus).Assisted-by: LLM (Google:Gemini 4 Neon)