Skip to content

agx: admit the full half-index namespace in the G17-class unary encoder - #629

Merged
DjDeveloperr merged 2 commits into
aurora-wipfrom
j716c/g18g-funop-regs
Dec 2, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-wipfrom
j716c/g18g-funop-regs

Conversation

@erikwb

@erikwb erikwb commented Nov 21, 2026 •

Copy link
Copy Markdown

What: Admit the full eight-bit half-index namespace (h0–h255, keeping 32-bit even-pair alignment) in agx3_funop_encode_runtime() and agx3_funop_encode_g17g(), unblocking G18G shaders whose allocation places f32log2, f32exp2, or saturated f32rsqrt operands above h127 (and raising the encoder-level f32sqrtstep limit to h255, though the G18G packer handles SRSQRT before funop dispatch and exits with continue).
Tested: Host x86_64 at ccad404e0b09 (agx3_funop_core 1,772/1,772 checks, agx_tests 1,227 passed / 1 skipped, asahi + poly 231/234 with 3 pre-existing headless EGL/GLVND failures). G18G drm-shim compile A/B (aurora-wip 293cc49fc266 vs c3573f560627 integrating ccad404e0b09): log2/exp2 fail VK_ERROR_UNKNOWN on trunk and compile on candidate (19 high-half ops >= h128, max h164); synthetic 64/64 saturated rsqrt (h128–h254) vs 0/64 trunk. Saved J700 (G17P) kits/test/20261130-mesa629-high-unary: each driver returned all 2,560 CPU-checked values for each of 3 workloads; max absolute errors matched; empty kernel journal window. Exact-head ccad404e0b09 vs aurora-wip 46f3a68e60d9 (unaffected non-G18G hardware): J716c M5 Max (dEQP_VK_glsl_builtin_precision 664-case selection, 0 diffs, boot/smoke clean, 0 GPU faults) and J713 M4 Air (dEQP-VK.glsl.builtin.precision.* all 1,800 cases, 0 diffs, default-boot baseline smoke clean, 0 new dmesg error lines); J313 M1 Air (G13G) with aurora-wip 8a40c215dec9, exact ccad404e0b09, and ccad404e0b09 merged onto 8a40c215dec9 (dEQP-VK.glsl.builtin.precision.*, 664-case selection, 544 Pass / 120 NotSupported on all three, 0 diffs; default-boot smoke clean, 0 new GPU error lines). Prior-head ed79255b51ed J716c checks are in Evidence.
Risk: two-way door · M6 (G18G) only at runtime (agx3_emit_funop() gates agx3_funop_encode_g17g() on agx_is_g18g(&ctx->key->dev)); M1–M5 and legacy agx3_funop_encode_source_lifetime() callers keep their existing paths.
Revert: git revert -m 1 <merge-sha> on aurora-wip (or git revert ccad404e0b09 ed79255b51ed) and rebuild/reinstall Mesa; no persistent on-disk, shader-cache (hk_cache_identity() hashes build_sha), UAPI, or firmware state is changed.
Not yet:

  • External M6 (G18G / J873g / AGX3D, not present in our lab; satchlj moved the native M6 run to a follow-up; DjDeveloperr's change request still asks for it): live native run of kits/test/20261130-mesa629-high-unary exercising >= h128 f32log2 and f32exp2 readback with 0 GPU faults and clean system health (and saturated f32rsqrt if an identified production shader emits the modifier; the optimizer currently keeps the clamp separate, so saturated f32rsqrt has synthetic encoder coverage). Saturated RSQRT is the only saturated form that reaches agx3_funop_encode_g17g(): saturated SRSQRT is refused (AGX3_REFUSE) at agx3_pack_binary.c:18431 and saturated SQRT_STEP is also refused at agx3_funop_core.c:158, so no form of SQRT_STEP reaches the encoder. Note that J716c (G17C), J713 (G16G), J313 (G13G), and J700 (G17P) exercise unaffected non-G18G hardware (agx_is_g18g() == false).
Details

On G18G, agx3_emit_funop() in src/asahi/compiler/agx3_pack_binary.c routes AGX3_FUNOP_LOG2, AGX3_FUNOP_EXP2, and saturated AGX3_FUNOP_RSQRT through agx3_funop_encode_g17g() -> agx3_funop_encode_runtime(), which previously refused any destination or source register above h127. Following #1021 (ed2351e4f06), all four rounding ops (AGX3_FUNOP_FLOOR, AGX3_FUNOP_CEIL, AGX3_FUNOP_TRUNC, AGX3_FUNOP_RINT) fall through to agx3_alu_unary_m5(), and the G18G packer handles AGX_OPCODE_SRSQRT (along with unsaturated AGX_OPCODE_RSQRT) earlier in agx3_pack_binary.c and exits with continue before funop dispatch—so f32sqrtstep coverage in agx3_funop_encode_g17g() is encoder-only, not production packer dispatch. Furthermore, the current clamped rsqrt high-register shader preserves the clamp as a separate instruction (saturate=false on the rsqrt), so saturated f32rsqrt high-register behavior is covered by the synthetic encoder test (64/64 for h128–h254). On G17C (agx_is_g18g(&ctx->key->dev) == false), agx3_emit_funop() never calls agx3_funop_encode_g17g().

  • Which saturated forms reach the encoder: saturated RSQRT is the only saturated form that reaches agx3_funop_encode_g17g(); saturated SRSQRT is refused (AGX3_REFUSE) at agx3_pack_binary.c:18431 and saturated SQRT_STEP is also refused at agx3_funop_core.c:158, so no form of SQRT_STEP reaches the encoder.
  • Encoder helper (agx3_funop_encode_runtime() / agx3_funop_encode_g17g()): sets nr_regs = runtime ? 256 : 128, admitting h0–h255 across all five G17-class scalar register unary forms (f32rint, f32log2, f32exp2, f32rsqrt, f32sqrtstep), each of which deposits its destination (f2) and source (f18) index bits identically in src/asahi/compiler/agx3_compose/agx3c_tables.txt and src/asahi/compiler/agx3_compose/agx3d_tables.txt.
  • 32-bit pair and RA contracts: 32-bit even-pair alignment is preserved (h254:h255 encodes, 32-bit h255 and any >= 256 are refused). RA still caps AGX3C and AGX3D at 252 halves (AGX3C_NUM_REGS, AGX3D_NUM_REGS in src/asahi/compiler/agx_compiler.h), so h252–h255 only appear in unit tests.
  • Legacy entry point: agx3_funop_encode_source_lifetime() keeps its 128-half limit for fixed AGX3B/AGX3C replay forms and remaining qualified production forms (texture_gpr in src/asahi/compiler/agx_register_allocate.c).
  • Tests (test-agx3-funop-core.c): This PR's generated encode/decode checks (1,772 checks across h0–h255) are independent of the pre-existing inherited byte-replay fixtures in test-agx3-funop-core.c.

Thanks to satchlj for the M5 Max (T6050) verification and to RyanTheTide for the G18G drm-shim comparison and J700 (G17P) verification.

Evidence
  • G18G drm-shim compile comparison & J700 (G17P) fixture at ccad404e0b09 (aurora-wip 293cc49fc266 vs c3573f560627, kits/test/20261130-mesa629-high-unary, 2026-11-29):

    • G18G drm-shim compile-only: log2 and exp2 pipelines failed with VK_ERROR_UNKNOWN on trunk and compiled on the candidate; each linked G18G binary contained 80 target unary instructions, including 19 with an operand >= h128 (max h164). Clamped rsqrt compiled on both with no saturation modifier (19 high-half rsqrt instructions; optimizer keeps the clamp separate); direct synthetic encoder test with even source halves h128–h254 verified the saturation bit and operands on 64/64 candidate instructions vs 0/64 on trunk.
    • Saved J700 (G17P): both drivers returned all 2,560 CPU-checked values for each of the three shader workloads with matching maximum absolute errors, boot unchanged, and an empty kernel journal window; candidate also passed the focused funop suite.
  • Exact-head J716c (M5 Max, T6050, 2026-11-28): libvulkan_asahi.so SHA-256 2430fa7d153836a8e5227ab21a10cfdb07d164e922c13704d88266dac524fa06 (head ccad404e0b09, built as an unmerged exact commit vs 46f3a68e60d9 in the same native release setup, sharing git-97742505d8 in driverInfo) vs 291c55d4954f28aa2fcfc362db21decf1aeb7d0a65ed154c9aba12b047dbe595 (aurora-wip 46f3a68e60d9); default kernel image SHA-256 bf2582ab357573db64031f39e7bc9d617eb574c6b221364ff417810bbddf4c87, default Stage 2 SHA-256 21edee972e1ff1718c6f41c32b91ee151afdc58cbb69f16f2f6a4d8d4c722170, AC power. CTS runs used tools/cts/aurora-cts-ab.py (6 workers, shader cache on, chunk 300, CTS 7ba03cdac7ae) with its case-list expansion patched locally to keep only TEST: lines (the repository copy mis-parses this CTS build's export); Borealis arms are native release builds on the Mac selected through VK_DRIVER_FILES.

    • dEQP-VK.glsl.builtin.precision.* (dEQP_VK_glsl_builtin_precision, 664-case J716c selection, chunks of 37): 544 Pass / 120 NotSupported on both arms, 0 diffs; 21 s wall (live non-regression row on unaffected G17C hardware; does not test G18G high-register encoding).
    • boot/smoke on the default boot: eDP-1 3456x2234@120 enabled; Apple MTP keyboard, trackpad and SMC lid devices enumerated (not exercised remotely); wlan0 connected, 0% loss over 3 pings; AppleJ716 card present with speakerguardd v2 active (no playback in this row); Borealis Apple M5 Max (G17C B1) with vkcube --c 240 --wsi wayland clean; 0 failed units (system and user); 0 LSM denials (no SELinux/AppArmor loaded); 0 GPU fault, MMU fault, SError or Oops lines. Redacted dmesg excerpt (default boot, unchanged by the runs): aurora 2302600000.gpu: GPU firmware: 27.2 (26B123), G17C; 0 GPU fault / MMU fault / DeviceLost lines after all runs; the err+ set is the boot's usual 55 lines (apple-dcp ... unable to match service ... and systemd-gpt-auto-generator), unchanged.
  • Exact-head J713 (M4 MacBook Air, T8132, G16G B0, AGX3B, 2026-11-28): libvulkan_asahi.so SHA-256 2430fa7d153836a8e5227ab21a10cfdb07d164e922c13704d88266dac524fa06 (head ccad404e0b09) vs 291c55d4954f28aa2fcfc362db21decf1aeb7d0a65ed154c9aba12b047dbe595 (base 46f3a68e60d9), built natively on the aarch64 lab sibling Mac (sharing git-97742505d8 in driverInfo) and selected via VK_DRIVER_FILES on battery; default Linux 7.3.0 (default J713 7.3.0 kernel) kernel image SHA-256 592f7bc8834d8796d5bdb086091e90ac96fc6a17a83769cbadc92b3268604c49, default Stage 2 SHA-256 3b2d2f059858d1891b225910864c02d68afb1b42893667e0afa8666491651071.

    • dEQP-VK.glsl.builtin.precision.* (CTS 7ba03cdac7ae, 3 workers, aurora-cts-ab 1.0, all 1,800 cases): 1,155 Pass / 645 NotSupported on both arms, 0 diffs (live non-regression row on unaffected G16G hardware; the change affects G18G code generation only and this supplies no proof of high-register encoding on G18G).
    • Default-boot baseline smoke (default J713 7.3.0 kernel): eDP-1 2560x1664@60 enabled, input enumerated, wlan0 3/3 gateway ping (0% loss), speakerguardd-v2 active with protected-sink sgv2.voicing tone rc 0, Borealis Apple M4 (G16G B0) Vulkan 1.4.363 (glmark2 5,047), 0 failed units (system and user), 0 AppArmor denials (no SELinux), 4 pre-existing baseline err+ boot lines (AFK[ep:20], unsupported DFB layout, apple_sep matching, brcmfmac ring 4). Per-arm Mesa vulkaninfo --summary / vkcube smoke passed with 0 new dmesg error lines during this PR's Mesa run window.
  • Exact-head J313 (M1 MacBook Air, T8103, G13G B1, 2026-12-01): Linux 7.3.0 default boot and command line, AC power, docked to a CalDigit TS5 with one external DisplayPort display; default kernel image SHA-256 a90adbbad29de949f0a338f6d0626d4dbc7de3d2437989b178de42f5209abb39, default Stage 2 SHA-256 1262bc5de585fc57e34c36f10560522d4b231be4f9ac7e45066bc4e364f95484. Cross-built aarch64 release Borealis builds selected per arm through VK_DRIVER_FILES: libvulkan_asahi.so SHA-256 3d2478066c51b9c5ba738cdab0f827c2184d5461acda09942e04981aaf503ac0 (aurora-wip 8a40c215dec9), 0a9730974c84a35a2428c24f2d7aa526db358b7e4cb091de5056e5d82b1c3ea8 (exact ccad404e0b09), 69ebd48ff0227449b92dcaf6a822ddcb716092f375d25a1e97189a559c3b44f0 (ccad404e0b09 merged onto 8a40c215dec9).

    • dEQP-VK.glsl.builtin.precision.* (CTS 7ba03cdac7ae, aurora-cts-ab 1.0, 2 workers, shader cache on, 664-case selection as on J716c, 2m29s wall for the three arms): 544 Pass / 120 NotSupported on all three arms, 0 diffs after retry, 0 retries needed, 0 new dmesg GPU error lines per arm (live non-regression row on unaffected G13G hardware; it supplies no proof of G18G high-register encoding).
    • Default-boot smoke after the run: eDP-1 2560x1600@60 and the dock display (DP-2, 3840x2160@120) enabled; Apple SPI keyboard and trackpads enumerated (not exercised remotely); wlan0 and Ethernet connected, gateway ping 3/3 (0% loss); Borealis Apple M1 (G13G B1) compute check 1,802 runs, 0 wrong and render check 0 wrong; no audio playback in this row; 0 failed units (system and user); 0 LSM denials (no SELinux/AppArmor loaded); 0 Oops/BUG/WARN/SError and 0 GPU fault, MMU fault or firmware-timeout lines; the err+ set is the boot's usual 5 lines (apple-dcp ... failed to extract init props, DCPDP2XService admission failed, and two of_irq_parse_pci lines), unchanged by the runs. Redacted dmesg excerpt: aurora 206400000.gpu: G13 firmware 27.2 running; DRM device registered.
  • Head & clean merge check: head ccad404e0b09 (comment-only update on ed79255b51ed, base 1fdf5396758f); git merge-tree --write-tree origin/aurora-wip ccad404e0b09 against aurora-wip 8a40c215dec9 is clean (d9506a38ae44).

  • Host checks at ccad404e0b09 (-Dgallium-drivers=asahi -Dvulkan-drivers=asahi -Dplatforms=wayland -Dglx=disabled -Dtools=drm-shim -Dbuild-tests=true -Doptimization=2 -Ddebug=false -Db_ndebug=false):

    • meson test -C _build -v agx3_funop_core: 1/1 OK (agx3_funop_core: 1772 checks passed): generated encode/decode checks (independent of the pre-existing inherited byte-replay fixtures in test-agx3-funop-core.c) encode even indices 0..254 for 32-bit forms (f32rint in floor, ceil, and trunc modes; f32log2; f32exp2; f32rsqrt; f32sqrtstep — encoder-only, as G18G packer handles SRSQRT before funop dispatch and exits with continue) and all indices 0..255 for 16-bit forms (f32log2, f32exp2, f32rsqrt), decode with agx3d_table, check fields[2] == dest && fields[18] == src, and verify h256 and 32-bit h255 refusal. (The current clamped rsqrt compiler test preserves the clamp separately with saturate=false.)
    • _build/src/asahi/compiler/agx_tests --gtest_brief=1: 1,227 passed, 1 skipped (NativeFMA.ExactDyadicOracle), 0 failed (1,228 tests from 93 suites).
    • meson test -C _build --suite asahi --suite poly: 231/234 passed (5/5 poly, 226/229 asahi; the 3 failures asahi-egl-priority-{deny,allow,once} are pre-existing EGL/GLVND initialization failures on the headless x86 build host).
  • Prior M5 Max (T6050) hardware check at ed79255b51ed (merged onto aurora-wip 00a73680e009, satchlj):

    • meson test --suite asahi --suite poly: 295/295 OK.
    • Live Borealis Vulkan CTS (MESA_SHADER_CACHE_DISABLE=true): dEQP-VK.glsl.builtin.precision.floor.* 8/10 Pass (2 NotSupported, 0 Fail), dEQP-VK.glsl.builtin.precision.log2.* 8/10 Pass (2 NotSupported, 0 Fail), 0 GPU faults in dmesg.
  • Prior pre-rebase verification (3605daca802 on b8762aab):

    • 507,000 sampled field vectors across agx3c_tables.txt and agx3d_tables.txt gave byte-identical words.
    • Cyberpunk 2077 pipeline cache drm-shim replay (11,388 graphics / 1,919 compute pipelines, with #630 applied): G18G failures dropped from 6,584 graphics / 800 compute to 6,579 / 512 (293 pipelines newly created, 0 regressions); G17C, G17P, and G14G created every pipeline with and without this change.

@RyanTheTide

Copy link
Copy Markdown

The change looks right to me. The runtime entry point is only admitted for G17-class encodings (agx3_funop_core.c:148), and in the packer it is only reached on the G18G route (agx3_pack_binary.c:956-981), so only G18G codegen moves. The pair check still refuses an odd 32-bit index, so h254:h255 encodes and a 32-bit h255 is refused.

  • Small wording point: the commit message and the comment at agx3_funop_core.c:161-179 list f32rint among the forms that now take high registers, but agx3_emit_funop() keeps AGX3_FUNOP_RINT off this route (agx3_pack_binary.c:957). The encoder change is fine for it, but it would help to say which forms production actually sends through here.
  • Hardware: agreed that it needs an M6 (G18G) shader with a rounding or log/exp operand above h127 before this leaves draft.

Assisted-by: LLM (Claude:Opus 5.5)

On G18G, floor/ceil/trunc and log2/exp2 are encoded through the funop
encoder's runtime entry point (agx3_funop_encode_g17g() ->
agx3_funop_encode_runtime()), which refused a destination or source
above h127. A G18G shader whose allocation put one of these operands
there failed to compile.

In production, agx3_emit_funop() routes only G18G AGX3_FUNOP_FLOOR,
AGX3_FUNOP_CEIL, AGX3_FUNOP_TRUNC, AGX3_FUNOP_LOG2, AGX3_FUNOP_EXP2,
AGX3_FUNOP_RSQRT and AGX3_FUNOP_SQRT_STEP through the runtime entry
point (agx3_pack_binary.c handles SRSQRT and unsaturated RSQRT earlier
via separate ALU helpers that already take high registers, and
agx3_emit_funop() keeps AGX3_FUNOP_RINT off this route so roundeven
falls through to agx3_alu_unary_m5()).

The runtime encoder helper itself supports all five G17-class scalar
register unary forms -- f32rint (including AGX3_FUNOP_RINT), f32log2,
f32exp2, f32rsqrt and f32sqrtstep -- each of which deposits every bit of
its destination and source index fields identically in the AGX3C and
AGX3D (G18G) tables. The runtime entry point now admits the full
eight-bit half-index namespace (h0-h255) that the AGX3C packers already
use. The pair rule for 32-bit operands stays: h254 encodes as h254:h255
and h255 is refused. Encodable is not allocatable: RA still caps AGX3C
and AGX3D at 252 halves, so h252-h255 only appear in the encoder tests.

The legacy entry point keeps its 128-half limit. It serves the fixed
AGX3B/AGX3C replay forms and the remaining qualified production forms,
whose SSA webs RA constrains to the low bank.

The unit test encodes every register for each of these instructions,
decodes the word with the G18G table and checks the registers it names,
and checks that h256 and a 32-bit h255 are refused.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb force-pushed the j716c/g18g-funop-regs branch from b5becb6 to ed79255 Compare November 22, 2026 17:06
@erikwb

erikwb commented Nov 22, 2026 •

Copy link
Copy Markdown
Author

Updated the comment in src/asahi/compiler/agx3_funop_core.c and the commit message, and rebased onto aurora-wip 1fdf5396758f as ed79255b51ed.

Both now distinguish what production actually routes through agx3_funop_encode_runtime() / agx3_funop_encode_g17g() from what the encoder helper supports: agx3_emit_funop() sends G18G AGX3_FUNOP_FLOOR, AGX3_FUNOP_CEIL, AGX3_FUNOP_TRUNC, f32log2, f32exp2, f32rsqrt, and f32sqrtstep here (keeping AGX3_FUNOP_RINT off this route so roundeven falls through to agx3_alu_unary_m5(), and catching AGX_OPCODE_SRSQRT and unsaturated AGX_OPCODE_RSQRT earlier in agx3_pack_binary.c via separate ALU helpers), while the runtime encoder helper itself supports all five G17-class scalar unary forms including f32rint (AGX3_FUNOP_RINT).

Host checks on ed79255b51ed (-Doptimization=2 -Ddebug=false -Db_ndebug=false -Dtools=drm-shim): meson test --suite asahi passed 226/226, agx3_funop_core passed 1,772/1,772 checks, and agx_tests passed 1,227 (1 skipped NativeFMA.ExactDyadicOracle, 0 failed). Keeping the PR a draft pending the M6 (G18G) hardware run.

@erikwb
erikwb marked this pull request as ready for review November 22, 2026 21:26

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Formal pre-PR checklist (§1–§6) review at ed79255b51ed251fd3ca04644dfc0c1764524a5f (base aurora-wip, live tip efabab38502d).

Code, Superseded & Policy Audit (§1–§4, §6) — PASS

  • Not superseded: aurora-wip (efabab38502d) still caps agx3_funop_encode_impl() at dest >= 128 || src >= 128 (src/asahi/compiler/agx3_funop_core.c:162); #768 (90f9e2ec0843) only touched agx3_funop_carries_wait().
  • Register/index encoding & cross-generation safety (agx3_funop_core.c, test-agx3-funop-core.c):
    • runtime is non-NULL only via agx3_funop_encode_runtime() / agx3_funop_encode_g17g() (which already require agx_encoding_is_g17_class(enc)), and in production agx3_emit_funop() (agx3_pack_binary.c:959-984) routes only G18G FLOOR/CEIL/TRUNC/LOG2/EXP2/RSQRT/SQRT_STEP here (keeping AGX3_FUNOP_RINT off this route and leaving AGX2, AGX3B, and G17G/S/C codegen untouched).
    • Verified directly in agx3c_tables.txt and agx3d_tables.txt that f32rint, f32log2, f32exp2, f32rsqrt, and f32sqrtstep all share identical 9-bit field-deposit layouts for f2 (dest) and f18 (src) across AGX3C and AGX3D.
    • 32-bit pair alignment is preserved ((!dest_16 && (dest & 1)) || (!src_16 && (src & 1))), so h254:h255 encodes while 32-bit h255 and any >= 256 are refused; the legacy entry point keeps its 128-half contract.
    • test-agx3-funop-core.c round-trips every register 0..255 through agx3_funop_encode_g17g() + agx3_decode(&agx3d_table, ...) and verifies fields[2] == dest && fields[18] == src plus h256 and 32-bit h255 refusal. Prior comment wording point on AGX3_FUNOP_RINT is resolved.
  • §1–§4, §6: Keyed on G17-class runtime encoder capability (not a model gate); production-ready; human author/committer + human Signed-off-by: only on ed79255b51ed (zero AI trailers); PR body ends with Assisted-by:; clean naming.

Actionable Blockers (§5 Hardware Evidence & PR Status)

  1. §5 M6 (G18G / AGX3D) live hardware verification missing: There are zero hardware runs on G18G — the only hardware target whose codegen this PR changes. Before merge, post a live M6 (G18G) hardware run executing high-register (>= h128) floor/ceil/trunc/log2/exp2/rsqrt/sqrtstep operands (e.g., targeted shader readback or Vulkan/GL CTS cases exercising high-bank RA allocation) with exact machine/kernel/build tuple, 0 GPU faults, and clean system health (0 SELinux denials / 0 new failed units / 0 new kernel errors).
  2. PR body out of sync: The PR is marked ready for review (isDraft: false), but Still to run still states "This PR stays a draft until then."

@erikwb

erikwb commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Updated ## Still to run in the PR body to drop the stale draft sentence so it matches the PR's open ready-for-review state and align the proposed G18G probe with agx3_pack_binary.c, and kept the commit head at ed79255b51ed (which still merges cleanly onto aurora-wip 9322511c94e0, where src/asahi/compiler/agx3_funop_core.c, src/asahi/compiler/test/test-agx3-funop-core.c, and the unary routing in src/asahi/compiler/agx3_pack_binary.c are unchanged between efabab38502d and base 9322511c94e0 before applying the PR).

On hardware verification: no M6 (G18G / AGX3D) machine is available in this lab, and agx3_emit_funop() only routes G18G (agx_is_g18g(&ctx->key->dev)) through agx3_funop_encode_g17g(), leaving G17C and AGX3B codegen untouched. The live M6 (G18G) run exercising >= h128 operands for floor/ceil/trunc/log2/exp2 (plus saturated rsqrt if lowered to AGX_OPCODE_RSQRT with saturate) with exact machine/kernel/build details, 0 GPU faults, and clean system health therefore remains open for an M6 tester before merge.

@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 at ed79255b51ed

REQUEST_CHANGES — code, comments, host encoder/decoder tests, clean merge onto aurora-wip (00a73680e009), and Apple M5 Max regression check are all clean (and the earlier stale draft sentence in Still to run is fixed); narrowed solely to the remaining M6 (G18G) live hardware verification gate.

Blockers

  1. Missing M6 (G18G / AGX3D) live hardware verification:
    • Because agx3_emit_funop() routes only G18G through agx3_funop_encode_g17g(), no live hardware run yet exercises the changed production codegen path. Before merge, post a live M6 (G18G) run exercising >= h128 operands for floor/ceil/trunc/log2/exp2 (and saturated rsqrt where applicable) with exact machine/kernel/build details, 0 GPU faults, and clean system health.

Checked

  • Audited all 2 changed files (src/asahi/compiler/agx3_funop_core.c, src/asahi/compiler/test/test-agx3-funop-core.c, 110 diff lines) and commit hygiene (ed79255b51ed, Signed-off-by: present).
  • Verified nr_regs = runtime ? 256 : 128 keeps the legacy entry point capped at 128 halves, preserves 32-bit even-pair alignment (admitting h254:h255, refusing 32-bit h255 and any >= 256), and matches agx3_emit_funop() production routing.
  • Merged cleanly onto aurora-wip (00a73680e009), built on Apple M5 Max (Linux 7.3) with -Dbuildtype=debugoptimized -Db_ndebug=false -Dvulkan-drivers=asahi -Dgallium-drivers=asahi -Dplatforms=wayland -Dglx=disabled -Dbuild-tests=true -Dtools=drm-shim:
    • meson test --suite asahi --suite poly: 295/295 OK (including asahi - mesa:agx3_funop_core OK).
    • Live Apple M5 Max Borealis Vulkan CTS (MESA_SHADER_CACHE_DISABLE=true): dEQP-VK.glsl.builtin.precision.floor.* 8/10 Pass, 2 NotSupported, 0 Fail; dEQP-VK.glsl.builtin.precision.log2.* 8/10 Pass, 2 NotSupported, 0 Fail; 0 GPU faults in dmesg.
  • Untested scope: M6 (G18G / AGX3D) live hardware execution (not available locally).
Evidence
  • git merge-tree --write-tree against aurora-wip 00a73680e009: clean.
  • meson test --suite asahi --suite poly: Ok: 295, Fail: 0 (30/295 asahi - mesa:agx3_funop_core OK).
  • Live Apple M5 Max deqp-vk (MESA_SHADER_CACHE_DISABLE=true):
    • dEQP-VK.glsl.builtin.precision.floor.*: Passed: 8/10, Failed: 0/10, Not supported: 2/10.
    • dEQP-VK.glsl.builtin.precision.log2.*: Passed: 8/10, Failed: 0/10, Not supported: 2/10.
    • New GPU dmesg faults: 0.

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>
@erikwb
erikwb requested a review from a team as a code owner November 26, 2026 02:17
@erikwb
erikwb requested a review from Acelogic November 26, 2026 02:17
@erikwb

erikwb commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

Updated the production-routing comment in src/asahi/compiler/agx3_funop_core.c (ccad404e0b0) to match aurora-wip (262403b7bce), and updated the PR description to the current **What:** / **Tested:** / **Risk:** / **Not yet:** format without AI-attribution trailers.

  • Routing update after asahi: route G18G rounding ops through shared AGX3c unary encoder for FP16 support #1021 (ed2351e4f06): agx3_emit_funop() in src/asahi/compiler/agx3_pack_binary.c now routes AGX3_FUNOP_FLOOR, AGX3_FUNOP_CEIL, and AGX3_FUNOP_TRUNC on G18G through agx3_alu_unary_m5() alongside AGX3_FUNOP_RINT, so only G18G AGX3_FUNOP_LOG2, AGX3_FUNOP_EXP2, saturated AGX3_FUNOP_RSQRT, and AGX3_FUNOP_SQRT_STEP use agx3_funop_encode_g17g() -> agx3_funop_encode_runtime() (AGX_OPCODE_SRSQRT and unsaturated AGX_OPCODE_RSQRT are handled earlier in agx3_pack_binary.c).
  • Verification: ccad404e0b0 is comment-only on top of ed79255b51ed (no built object changes relative to your M5 Max T6050 run at ed79255b51ed), git merge-tree --write-tree against aurora-wip 262403b7bce is clean (e54db59219ea), and on ccad404e0b0 agx3_funop_core passed 1,772/1,772 checks and agx_tests passed 1,227/1,228 (1 skipped NativeFMA.ExactDyadicOracle, 0 failed).
  • M6 (G18G) hardware status: our local lab only has M1, M4, and M5 Max Macs and no M6 (G18G) hardware, so the live M6 (G18G) run exercising >= h128 operands for log2 / exp2 (and saturated rsqrt / sqrt_step if lowered via agx3_emit_funop()) remains open for an M6 owner before merge.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at ccad404e

Blockers:

  1. Missing live M6 (G18G) hardware verification row exercising f32log2/f32exp2/saturated f32rsqrt/f32sqrtstep above h127 (the target path this PR unblocks).

Checked:

  • src/asahi/compiler/agx3_funop_core.c & tests: admits h0..h255 half-index namespace while keeping 32-bit even-pair alignment; ccad404e updates the routing comment to match aurora-wip; host encoder/decoder tests and M5 Max regression check are clean; MERGEABLE on aurora-wip.
  • Checked for Apple material, tool attribution, private serials, and Borealis naming: clean.
Evidence
  • Head: ccad404e0b0 (base: aurora-wip, mergeable: MERGEABLE, +78/-2 across 2 files).

@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Author

@satchlj Re-verified at head ccad404e0b09 (comment-only update on ed79255b51ed, matching aurora-wip routing after #1021).

  • Clean merge & host checks at ccad404e0b09: git merge-tree --write-tree origin/aurora-wip ccad404e0b09 against current aurora-wip (46f3a68e60d9) is clean (c91f6f8bbd36). Host agx3_funop_core passed 1,772/1,772 checks, agx_tests passed 1,227/1,228 (1 pre-existing skipped NativeFMA.ExactDyadicOracle, 0 failed), and meson test --suite asahi --suite poly passed 231/234 (3 pre-existing headless EGL/GLVND asahi-egl-priority-{deny,allow,once} failures).
  • PR body: updated **What:**, **Tested:**, **Not yet:**, **Revert:**, and Details/Evidence at ccad404e0b09 to clarify that the G18G packer handles SRSQRT before funop dispatch and exits with continue (so f32sqrtstep coverage is encoder-only, not production packer dispatch), note that the current high-register compiler test uses saturate=false, and note that this PR's 1,772 generated encode/decode checks are independent of the pre-existing inherited byte-replay fixtures in test-agx3-funop-core.c.
  • M6 (G18G) production-path run still open: our local lab only has M1, M4, and M5 Max Macs and no M6 (G18G / AGX3D) hardware. Because J716c (G17C) and J713 (G16G) exercise unaffected non-G18G hardware (agx_is_g18g() == false), they supply no proof of >= h128 high-register encoding on G18G; the live M6 (G18G) hardware run specifically exercising >= h128 operands on the production paths that actually change (f32log2, f32exp2, and saturated f32rsqrt) remains explicitly open under **Not yet:**.
  • Exact-head J716c & J713 (2026-11-28): ccad404e0b09 vs 46f3a68e60d9:
    • J716c (M5 Max / G17C B1): dEQP-VK.glsl.builtin.precision.* (dEQP_VK_glsl_builtin_precision, 664-case selection, 544 Pass / 120 NotSupported) 0 diffs, 0 GPU faults, boot/smoke clean.
    • J713 (M4 Air / G16G B0 / AGX3B): dEQP-VK.glsl.builtin.precision.* all 1,800 cases (1,155 Pass / 645 NotSupported) 0 diffs (live G16G non-regression row), 0 GPU faults, default-boot baseline smoke clean (0 new dmesg error lines during this PR's Mesa run window). J313 exact-head row remains pending, and the M6 (G18G) production-path run remains open under **Not yet:**.

@RyanTheTide

Copy link
Copy Markdown

A reusable high-register Vulkan workload is ready for ccad404. The isolated driver pair is aurora-wip 293cc49 and c3573f560627, which integrates the exact PR head.

  • In the G18G drm-shim compile-only comparison, trunk returned VK_ERROR_UNKNOWN at pipeline creation for both log2 and exp2. The candidate compiled both. Each linked G18G binary contained 80 target unary instructions, including 19 with an operand at or above h128 and a maximum of h164.
  • The clamped rsqrt shader compiled on both drivers. Its 19 high-half rsqrt instructions had no saturation modifier in either linked binary. The current optimizer preserves the clamp as a separate instruction. A direct synthetic encoder test with even source halves h128–h254 verified the saturation bit and operands on 64/64 candidate instructions, versus 0/64 on trunk. This is encoder coverage.
  • On saved J700 G17P, each driver returned all 2,560 CPU-checked values for each of the three shader workloads. Maximum absolute errors matched for all three, the boot was unchanged and the kernel journal window was empty. The exact candidate also passed the focused funop suite.

The checksummed AArch64 kit is kits/test/20261130-mesa629-high-unary. It captures the real GPU readback and the linked shader binaries for native J873g. The native G18G comparison is still due. The fixture now exercises high-half log2 and exp2 directly. For saturation, please use an identified production shader that actually emits the modifier if one is available.

@erikwb

erikwb commented Nov 30, 2026

Copy link
Copy Markdown
Author

Thanks for the kit. The drm-shim comparison covers what this PR unblocks: G18G log2/exp2 pipelines that failed with VK_ERROR_UNKNOWN on trunk now compile, with operands up to h164.

Saturated high-half rsqrt only has encoder-test coverage (64/64), because the optimizer keeps the clamp as a separate instruction. No production shader we know of reaches it.

Still open: a native G18G run of kits/test/20261130-mesa629-high-unary at ccad404e0b09. We have no M6, so this needs an M6 owner.

@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 ccad404e0b0979d8cd446efcea1d3d6a5f750839

Blockers: none

Checked:

  • The change does what it claims: in the G18G drm-shim comparison, log2 and exp2 pipelines that fail with VK_ERROR_UNKNOWN on trunk compile at this head with operands up to h164. M1-M5 paths are unchanged: J716c and J713 precision CTS show 0 diffs against base.
  • The native M6 run I asked for moves to a follow-up: run kits/test/20261130-mesa629-high-unary on an M6 when one is available.
  • CI: this repo runs no PR CI (waived); host funop suite 1,772/1,772 at this head.
Evidence

ccad404e is a comment-only change on top of ed79255b. Rows and the shim comparison are in the thread.

@github-actions github-actions Bot added area:compiler Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot) labels Dec 1, 2026
@DjDeveloperr

Copy link
Copy Markdown

At ccad404e0b09 the encoder uses the full h0–h255 namespace in src/asahi/compiler/agx3_funop_core.c:167. The shim compiled 19 high-half instructions per log2/exp2 shader and the J700 fixture passed. The remaining check is native J873g readback for the affected high-half instructions, including which saturated rsqrt/sqrtstep form is reached.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at ccad404e0b09

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: - src/asahi/compiler/agx3_funop_core.c & tests: admits h0..h255 half-index namespace while keeping 32-bit even-pair alignment; ccad404e updates the routing comment to match aurora-wip; host encoder/decoder tests and M5 Max regression check are clean; MERGEABLE on aurora-wip.

  • Checked for Apple material, tool attribution, private serials, and Borealis naming: clean.

Follow-ups (not blocking): live M6 G18G row for f32 unary ops above h127

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at ccad404e: not ready yet

Check Detail
CI at head ok 1 check passed
Review ok review verdict MERGE at ccad404e; no GitHub approval yet, so approve it or merge through the bypass (--admin)
Requested changes no requested by DjDeveloperr
Hardware row at head ok in the PR body at ccad404e
Conflicts ok none
PR text ok Risk: two-way · M6 (G18G) only at runtime (agx3emitfunop() gates agx3funopencodeg17g() on agxisg18g(&ctx->key->dev)); M1–M5 and legacy agx3funopencodesourcelifetime() callers keep their existing paths. Revert: git revert -m 1 <merge-sha> on aurora-wip (or git revert ccad404e0b09 ed79255b51ed) and rebuild/reinstall Mesa; no persistent on-disk, shader-cache (hk_cache_identity() hashes build_sha), UAPI, or firmware state is changed.

Areas: area:compiler

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@erikwb

erikwb commented Dec 1, 2026

Copy link
Copy Markdown
Author

ccad404e0b09 still merges cleanly onto origin/aurora-wip (8a40c215dec9, tree d9506a38ae44).

On which saturated rsqrt / sqrtstep forms are reached on aurora-wip (8a40c215dec9, src/asahi/compiler/agx3_pack_binary.c):

  • Saturated RSQRT is the only saturated form that reaches agx3_funop_encode_g17g(). Saturated SRSQRT is refused (AGX3_REFUSE) at agx3_pack_binary.c:18431 and saturated SQRT_STEP is also refused at agx3_funop_core.c:158, so no form of SQRT_STEP reaches the encoder.
  • AGX_OPCODE_SRSQRT (lines 18417–18458) and unsaturated AGX_OPCODE_RSQRT (lines 18487–18516) are handled earlier and exit with continue before agx3_emit_funop(), so f32sqrtstep (AGX3_FUNOP_SQRT_STEP) is encoder-only here (1,772/1,772 checks in agx3_funop_core).
  • Saturated AGX_OPCODE_RSQRT is routed via agx3_map_funop_g18g() to agx3_emit_funop(), and in @RyanTheTide's kits/test/20261130-mesa629-high-unary drm-shim test the optimizer preserved the clamp separately (0 saturated rsqrt emitted; 64/64 synthetic encoder coverage for h128–h254 vs 0/64 on trunk). Thus f32log2 and f32exp2 are the active production paths exercised above h127.

The PR body has the G18G drm-shim comparison and the J700 (G17P) results at ccad404e0b09, plus exact-head J716c, J713 and J313 (M1 Air) rows on unaffected non-G18G hardware. On J313, dEQP-VK.glsl.builtin.precision.* (664 cases) gave 544 Pass / 120 NotSupported with 0 diffs across aurora-wip 8a40c215dec9, exact ccad404e0b09 and the two merged, with a clean default-boot smoke. Native J873g (G18G) readback of kits/test/20261130-mesa629-high-unary remains open for an M6 owner.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving at ccad404e0b09. This clears my earlier change request.

Checked: the encoder now admits h0-h255 only on the runtime entry point (agx3_funop_core.c:185), keeps 32-bit operands on even pairs, and leaves the legacy 128-half limit in place. The new test decodes every word with the G18G table. The rows on J716c, J713, J313 and J700 show no change on the chips that don't take this path, and the G18G drm-shim comparison shows the log2/exp2 pipelines that failed on trunk now compile.

No M6 is available in our lab, so the native J873g readback with kits/test/20261130-mesa629-high-unary is a post-merge peer request, not a merge hold.

@DjDeveloperr
DjDeveloperr merged commit 7fe256e into aurora-wip Dec 2, 2026
3 checks passed
@DjDeveloperr
DjDeveloperr deleted the j716c/g18g-funop-regs branch December 2, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:compiler Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants