Skip to content

asahi: route G18G rounding ops through shared AGX3c unary encoder for FP16 support - #1021

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
fix/g18g-fp16-rounding
Nov 25, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
fix/g18g-fp16-rounding

Conversation

@sithglan

Copy link
Copy Markdown

Summary

  • Route AGX3_FUNOP_FLOOR, AGX3_FUNOP_CEIL, and AGX3_FUNOP_TRUNC on G18G through agx3_alu_unary_m5() in agx3_emit_funop() (src/asahi/compiler/agx3_pack_binary.c), matching AGX3_FUNOP_RINT.

Root Cause

agx3_emit_funop() sent G18G FLOOR, CEIL, and TRUNC to agx3_funop_encode_g17g(), which refuses 16-bit operands (dest_16 || src_16), while AGX3_FUNOP_RINT already fell through to agx3_alu_unary_m5() (which emits the same AGX3_MN_f32rint fields with 16-bit and 0..255 register support).

Verification

  • meson test -C /root/mesa/vkcts-b --suite asahi: 203/203 OK (-Db_ndebug=false).
  • Live verification on Apple M6 (G18G B1, mini6), 0 GPU faults in dmesg:
    • dEQP-VK.glsl.builtin.precision_fp16_storage16b.{ceil,floor,trunc,round,roundeven}.*: 20/20 Pass, 0 Fail.

… FP16 support

In agx3_emit_funop() (agx3_pack_binary.c), AGX3_FUNOP_RINT on G18G
already fell through to agx3_alu_unary_m5(), which emits the same
AGX3_MN_f32rint fields while supporting 16-bit half operands and high
registers (0..255). FLOOR, CEIL, and TRUNC on G18G were still routed to
agx3_funop_encode_g17g(), which refuses 16-bit rounding operands.

Route all four rounding operations (FLOOR, CEIL, TRUNC, RINT) on G18G
through agx3_alu_unary_m5() so FP16 ceil/floor/trunc/roundEven encode
cleanly and transcode to AGX3D.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan requested review from a team and DjDeveloperr as code owners November 25, 2026 08:42

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at ed2351e4f06d

Blockers: none

Checked: Full diff, enum agx3_funop ordering and agx3_alu_unary_m5() handling, debug-assert build, full Asahi unit test suite, and live Vulkan CTS on Mac Studio M5 Max (J775c, T6050).

Evidence
  • Audited src/asahi/compiler/agx3_pack_binary.c alongside agx3_funop_core.h and agx3_alu_core.c: AGX3_FUNOP_{FLOOR,CEIL,TRUNC,RINT} are contiguous <= AGX3_FUNOP_RINT, so tightening the G18G agx3_funop_encode_g17g() branch to (op > AGX3_FUNOP_RINT && op <= AGX3_FUNOP_EXP2) routes all four rounding ops to agx3_alu_unary_m5() (which handles op <= AGX3_FUNOP_RINT with 16-bit and 0..255 register support) while keeping LOG2, EXP2, RSQRT, and SQRT_STEP on their existing paths.
  • Built ed2351e4f06d with -Db_ndebug=false: meson test --suite asahi passed 203/203 (0 failures).
  • Verified live Borealis ICD (libvulkan_asahi.so, sha256:5ea4cdb733c1, confirmed loaded via LD_DEBUG=libs) on Mac Studio M5 Max (J775c, T6050): dEQP-VK.glsl.builtin.precision_fp16_storage16b.{ceil,floor,trunc,round}.* 16/20 PASS (4/5 each, 0 failures, 4 not supported), GPU_FAULT_DELTA=0.

@RyanTheTide
RyanTheTide merged commit 7fd0acb into aurora-wip Nov 25, 2026
erikwb added a commit that referenced this pull request Nov 26, 2026
PR #1021 moved G18G floor/ceil/trunc onto agx3_alu_unary_m5() alongside
roundeven, leaving only f32log2, f32exp2, f32rsqrt and f32sqrtstep on the
agx3_funop_encode_g17g() production route in agx3_emit_funop().

Update the comment in agx3_funop_encode_impl() to match aurora-wip.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@RyanTheTide
RyanTheTide deleted the fix/g18g-fp16-rounding branch November 27, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants