Repository navigation
agx: enable AGX_CAP_MOD3_REG_BANK_RA on M5 - #1111
Merged
Merged
Conversation
Add AGX_CAP_MOD3_REG_BANK_RA to AGX_CAPS_M5 (G17G, G17S, G17C) so the AGX register allocator tie-breaks co-read GPR pairs across the three 32-bit register banks ((reg / 2) % 3) and coalesces single-use loop RMW accumulator chains on non-preamble M5 shaders, matching G17P. Non-M5 chips (G15, G16, G18G, AGX2) remain unchanged. Update test-chip-caps.c and test-g17p-mod3-ra.cpp to cover M5 enablement while preserving negative gating checks for G16G, G18G, and preambles. Signed-off-by: Satya Benson <satya@benson.earth>
RyanTheTide
approved these changes
Nov 26, 2026
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at 0151657d: MERGE. Non-author review; no blockers.
Checked:
- This turns on one existing capability bit in
AGX_CAPS_M5, and the RA paths already key on that bit, not on chip IDs, so the change adds no gate. G13/G14/G15/G16/G18G/AGX2 stay off. The chip-caps test now asserts the exact set {G17P, G17G, G17S, G17C}. - The gating test still covers the off cases. G18G/AGX3D replaces the old G17G case, and a new G17C preamble case checks that preambles stay untouched on M5. The new
M5ResolvesMod3Conflictscase runs RA for all three M5 chips and checks 0 bank conflicts and 0 scratch. - J775c evidence: asahi suite 322/322, the CTS sample identical to baseline (0 fail), 0 GPU faults, and the Llama pp512/pp2048 gains of about 2% are outside the noise of a 3-round interleaved A/B.
- The parent is on
aurora-wip, and the PR is mergeable.
Non-blocking:
- No hosted checks ran on this branch. Please let CI run once before merge.
- G17G and G17S rows are still owed, as the PR lists. All three share the encoding and the capability set, so the J775c row is good evidence for them.
This was referenced Nov 26, 2026
oreater
added a commit
to oreater/mesa
that referenced
this pull request
Nov 26, 2026
…k runs in mod-3 RA Four issues in the mod-3 bank-conflict RA tie-breaking pass (aurora-silicon#997/aurora-silicon#1111) regressed inner-loop code generation on multi-block convolution and GEMM kernels on M5 (G17C): 1. loop_phi_targets was only populated inside block->loop_header, leaving it NULL in multi-block loop bodies. Bank-conflict detours stole enclosing loop-header phi targets and emitted multi-register cyclic mov1 copies on every iteration. Propagate each loop header's phi targets across the full loop range (header .. loop_last) and keep non-phi allocations off enclosing loop-header phi targets ahead of bank-conflict detours. 2. rmw_web only matched single-use loop-header phis globally (missing every loop accumulator also read after loop exit) and looked up phi_web[root].reg (which stays pinned to the pre-header source register when the pre-header stays live across the loop). It also kicked accumulators out whenever g17p_coread_bank_cost() was non-zero. Track the loop-header phi instruction directly (rmw_phi) for back-edge sources and RMW chains using in-loop use counts so loop-carried accumulators stay in place. 3. Mod-3 tie-breaking against a loop-invariant operand clustered consecutive independent 3-source FMA accumulators into back-to-back same-bank runs (e.g. bank 1,1,1 / 2,2,2 / 0,0,0), serializing pipelined bank ports on G17/M5. Add anti-bank edges between consecutive independent 3-source ALU destinations/accumulators (propagated to loop pre-header inits). 4. Keep low-weight outside-loop prologue conflicts (best_cost < 8) within the existing high-water mark so prologues do not inflate GPR footprint. Add GTest regression coverage in test-g17p-mod3-ra for multi-block loops, live-across pre-header phi sources, and adjacent 3-source FFMA accumulator streams. Signed-off-by: oreater <145754695+oreater@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Enable
AGX_CAP_MOD3_REG_BANK_RAinAGX_CAPS_M5(G17G,G17S,G17C) so the AGX register allocator tie-breaks co-read GPR pairs across the three 32-bit register banks ((reg / 2) % 3) and coalesces single-use loop RMW accumulator chains on non-preamble M5 shaders, matchingG17P.Tested: Mac Studio M5 Max (
J775c,G17C B1, 40-core GPU) at0151657d581b: native aarch64 GCC 16.1.1 (-Dbuildtype=release -Db_ndebug=false -Dbuild-tests=true -Dtools=drm-shim)MALLOC_PERTURB_=42 meson test -C build --suite asahi322/322pass (0fail); 3-round interleaved same-machine A/B vs8c74e92d5162improves Llama 2 7B Q4_0pp512by +2.08% (2,154.27->2,199.05t/s),pp2048by +2.03% (2,059.95->2,101.70t/s),vkpeakint32-vec4by +0.38% (8,240.81->8,272.06GIOPS), andfp16-vec4by +0.32% (32,039.81->32,142.77GFLOPS) with no regressions ongpubench-vk; live Vulkan CTS A/B (MESA_SHADER_CACHE_DISABLE=1)3,914/4,885pass (0fail,971NotSupported, identical to baseline),0GPU faults,0failed systemd units.Risk: two-way door · M5 Macs (
G17G,G17S,G17C) (a plain revert removes the capability bit fromAGX_CAPS_M5;G13,G14,G15,G16,G17P, andG18Gare unchanged).Not yet: Live M5 (
G17G) and M5 Pro (G17S) hardware A/B and CTS runs (all three M5 parts shareAGX_ISA_ENCODING_AGX3CandAGX_CAPS_M5).Details
src/asahi/lib/agx_chip_caps.h):AGX_CAP_MOD3_REG_BANK_RAtoAGX_CAPS_M5(G17G,G17S,G17C) and update the capability comment.G13,G14,G15,G16,G18G) stay off;G17Pis unchanged.src/asahi/lib/tests/test-chip-caps.c,src/asahi/compiler/test/test-g17p-mod3-ra.cpp):test_mod3_reg_bank_ra()to expectG17P,G17G,G17S, andG17C.G17PMod3RA.NonG17PAndPreambleGatingacrossG18G(AGX3D),G16G(AGX3B),G17Ppreambles, andG17Cpreambles, and addG17PMod3RA.M5ResolvesMod3Conflictsconfirming all three M5 chips resolve the loop to zero mod-3 conflicts without spilling.Evidence
Configuration and driver identities
J775c,G17C B1, 40-core GPU), Linux 7.3.0 aarch64-Dbuildtype=release -Db_ndebug=false -Dbuild-tests=true -Dtools=drm-shim -Dgallium-drivers=asahi -Dvulkan-drivers=asahi)aurora-wip):8c74e92d5162df704d1c79bef528806ef43923d7(libvulkan_asahi.soSHA-256673283188b5ea3fecec15f0b8b03a6c2f52e76e3275db28f5dc33055731fde7e)satchlj/m5-mod3-reg-bank-ra):0151657d581b12614b87119fd0d6157813f677bb(libvulkan_asahi.soSHA-256a5d37075ad583c3adb058c4b9495a407326409493e61b6f70fd01b7a3494c83d)0151657d581b:MALLOC_PERTURB_=42 meson test -C build --suite asahi-> 322/322 OK (0fail)Same-machine 3-round interleaved A/B (
MESA_SHADER_CACHE_DISABLE=1)llama.cppmaster8af68d48(Llama 2 7B Q4_0,llama-bench -ngl 99 -t 6 -b 2048 -ub 512 -ctk f16 -ctv f16 -fa 1 -r 3withDRIRC_CONFIGDIR=src/asahi/vulkan),vkpeak(vkpeak-20260527), andgpubench-vk(--depths 1,8 --warmup-ms 200 --runs 3 --run-ms 500 --timestamps on):8c74e92d5162(3 rounds; median)0151657d581b(3 rounds; median)llama-benchpp512(t/s)llama-benchpp2048(t/s)llama-benchpp512+tg128(t/s)llama-benchtg128(t/s)llama-benchtg128 @ d2048(t/s)vkpeakfp16-vec4(GFLOPS)vkpeakint32-vec4(GIOPS)vkpeakfp32-scalar(GFLOPS)vkpeakfp32-vec4(GFLOPS)vkpeakfp16-scalar(GFLOPS)vkpeakfp16-matrix(GFLOPS)gpubench-vkcompute.heavyd=8 (µs/submit)gpubench-vkrender.heavyd=8 (µs/submit)Live Vulkan CTS A/B (
vulkan-cts-1.4.7.1,MESA_SHADER_CACHE_DISABLE=1)