Repository navigation
agx: derive a register cap for sampled compute from occupancy - #461
Conversation
|
Thanks for this register-pressure experiment. We select behaviour by a hardware property rather than by the chip a tuning was measured on, and we ship tuning defaults only with a measured gain. Here the cap is tied to G17C:
The short replay in the description measured -4.2 % FPS with this change. Could you share the measurement that shows the occupancy gain? If it holds, the threshold should follow the hardware property that sets occupancy (register file size per core and the wave-occupancy steps), so G17G, G17S and the AGX3B parts get the same rule, with a code comment naming the reason for any generation left out. If you make it the default, we can supply rows on our M1 Pro, M2, M4 Pro and A18 Pro. |
|
Restoring the 160-half-register cap alone improved full-game T2 by +0.14 and +0.76 FPS in the two blocks. The direction repeated, but the size varied. One launch exited with a userspace allocator error before producing a score. Its replacement completed in the same position in the sequence. We used two blocks of full Cyberpunk T2 runs in opposite orders on the M5 Max, native 2560×1600 High, with the fans fixed. The control was Mesa For two hot 8×8 compute shaders the compiler’s maximum resident-thread estimate rose from 512 to 640. Each shader went from zero static spills/reloads to 29/33. That is the occupancy/spill trade-off behind the change. The 640 figure is a compiler estimate. Measuring achieved occupancy would require a runtime counter. A portable threshold would need the register-file and occupancy steps for each GPU. In a separate eight-run comparison, enabling #460, #461, #466 and #468 together raised native T2 from 29.99 to 31.33 FPS. All four adjacent pairs favored the bundle. That 1.35 FPS is the combined effect. |
|
Thanks for the isolated runs and the occupancy numbers. The direction is encouraging, though +0.14 vs +0.76 FPS is a wide spread, and the launch that exited with an allocator error is worth understanding before this becomes a default. On scope: the cap at |
Merge train: independent review (code only, Opus 5.5 xhigh)Verdict: CLEAN WITH NITS. No blocker or major. NITs: the 160-half cap is an unnamed constant, and it uses the shared G13-era occupancy table. The allocator error in one of your T2 runs is still unexplained, so worth understanding before this becomes a default. Reach: gated on |
14c2f5f to
e2dcb3c
Compare
|
The cap is now derived from the register file and the occupancy steps instead of keyed on G17C (e2dcb3c).
M4 (G16G), where the cap does not apply: the compute shaders from dEQP-VK texture and compute subsets (5,535) compile unchanged and give the same results. The PR body has the details. |
RyanTheTide
left a comment
There was a problem hiding this comment.
No blockers in the code. Re-review of e2dcb3c: the cap is now derived from the register file and the occupancy steps, which resolves our scope point, and the AGX3B exclusion has a measured reason. The capped * 2 < uncapped * 3 test gives 160 on AGX2/AGX3C and none on AGX3B, as described. Bit 31 of the compiler flags is free (debug bits stop at 25, FS structure is bit 30).
- Reach: AGX2 (M1/M2) Vulkan compute with 4 or more texture reads now gets the 160-half cap and its spills. There is no run on AGX2, and the one T2 launch that exited with an allocator error is still unexplained. That launch used the earlier G17C-only cap, so it is the same mechanism. Before this becomes a default on more chips, please either reproduce that error or rule it out, for example by running T2 or the replay repeatedly on the cap build.
- src/asahi/vulkan/hk_shader.c:5432
optional_spillsis set from chip checks (!= AGX_CHIP_G18G,agx_chip_g17_m5) that repeat which dispatch paths accept scratch. Ifhk_dispatch_m5_native()orhk_dispatch_g17g_native()changes, this goes stale and a capped shader with spills could be launched without scratch. Suggest one helper next to those dispatch paths (for examplehk_compute_launch_takes_scratch(dev)) that both use. - Naming: the PR body says "Honeykrisp sets it for compute" and "AArch64 release Honeykrisp". Please call the driver Borealis in new prose.
HW rows we can run: M1 Pro and M2: dEQP-VK.compute.* and dEQP-VK.texture.* subsets plus dEQP-VK.image.*, base vs head, no new failures; and a texture-heavy compute A/B (one of your sample workloads, if you can share it). Pass = no regressions and no slowdown. A18 Pro and J616s: no codegen change expected, so a shader-stats diff of the same set should show zero changes.
Assisted-by: LLM (Claude:Opus 5.5)
e2dcb3c to
8e4db9d
Compare
|
Thanks. All three points are addressed in ca677d2. 2. One helper for the scratch rule.
A change to which launches take scratch now moves the compiler bit, the cache key and the dispatch refusal together. 3. Naming. The body says Borealis. 1. The allocator error. It did not reproduce. I ran ten consecutive T2 launches of this head on the M5 Max (aurora-wip The earlier failure was a glibc heap-corruption abort, Tests: all Mesa tests pass in a debug-optimized build with assertions (192/192), including M1 Pro/M2 rows and the shader-stat diff on A18 Pro/J616s would still be welcome. |
|
Re-review of 8e4db9d: Blockers: 1. From our last comment:
New since our comment:
HW row: M1 Pro (G13S) and M2 (G14G), base against this head: Assisted-by: LLM (Claude:Opus 5.5) |
8e4db9d to
ca677d2
Compare
RyanTheTide
left a comment
There was a problem hiding this comment.
Re-review of ca677d2: Blockers: 1, unchanged from our last comment.
The only change from 8e4db9d is the commit message. "Developed with Claude Code." is gone, so that point is resolved, and the code is identical on the same base afcc08b. Still open: the AGX2 (M1 Pro / M2) A/B for the 160-half cap. The agx_performance.c:101 AGX3D exclusion is non-blocking, as before. The HW row in our last comment still applies.
Assisted-by: LLM (Claude:Opus 5.5)
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-review of ca677d21: 0 code, attribution, or policy blockers remain.
Verification
- Occupancy-derived cap (
src/asahi/compiler/agx_performance.c:43-122):agx_register_file_halves()andagx_sampled_compute_register_cap()derive the 160-half cap from the 5/8 resident-thread target and the>= 1.5xoccupancy gain check (160 on AGX2/AGX3C, 0 on AGX3B where 512 -> 640 regressed G16G by 7-10%). - Scratch contract & cache key (
hk_cmd_buffer.h:2885,hk_cmd_dispatch.c:1808,:2568,hk_shader.c:214,:5429):hk_compute_launch_takes_scratch()unifiesoptional_spills, the shader cache identity bit (bit 31, verified free on currentaurora-wipwhereAGX_DBG_*ends at bit 25 and FS structure uses bit 30), and the M5/G18G dispatch scratch refusals. - RA retry & tests (
agx_register_allocate.c:3123-3137,test-sampled-compute-register-cap.cpp):ra_failedretries withra_budget_cut = 16, droppingsampled_capto allocate from the full file; unit tests cover per-encoding caps, retry fallback, and!optional_spills(192/192 Mesa tests pass). - Attribution & naming: single human-signed commit (no AI trailers in commit), Borealis naming in PR body,
Assisted-by:at end of PR body. Earlier glibc heap abort is reasonably ruled out as cap-specific (present in control builds; 10 consecutive clean T2 launches onca677d21).
Non-blocking code observation
src/asahi/compiler/agx_performance.c:101:if (dev->emit_agx3d || dev->encoding == AGX_ISA_ENCODING_AGX3D) return 0;duplicates the G18G launch-scratch rule thatoptional_spillsnow conveys (echoing @RyanTheTide's note). Dropping it keeps the compiler helper purely file/occupancy-derived.
Remaining before APPROVE (§5 HW/runtime evidence on ca677d21)
- AGX2 (M1 Pro / M2) conformance + same-machine A/B performance run: the 160-half cap is live by default on AGX2 Vulkan compute shaders with >= 4 texture reads and currently has zero hardware runs. Given the 7-10% regression on G16G and -4.16% on the short M5 replay, §5 requires unchanged conformance (
dEQP-VK.compute.*,texture.*,image.*, 0 GPU faults) and a texture-heavy compute A/B on AGX2 before shipping it as a default. - (Also helpful on
ca677d21) A18 Pro / J616s zero-change shader-stats confirmation, and a fuller G17C compute/texture CTS run on this head (earlier head ran 54 focused cases).
Assisted-by: LLM (Gemini 4 Neon)
|
Returning this PR to draft pending the AGX2 (M1 Pro / M2) hardware conformance and same-machine texture-heavy compute A/B runs, while keeping
|
|
We have an M2 and an M1 Pro, so the AGX2 row is ours. Queued at ca677d2: dEQP-VK.compute.* plus a texture-heavy compute A/B, base vs head. We'll post it here. Assisted-by: LLM (Claude:Opus 5.5) |
|
Completed the fuller J716c (M5 Max,
The PR remains in draft on |
|
M2 (AGX2, G14) row at ca677d2. Base afcc08b vs head ca677d2, Borealis (the AGX2 A/B for the 160-half cap):
So no regression on AGX2. These kernels do not show a gain either. I did not check whether any of them crosses the cap, so this is a no-regression row, not a performance one. Environment: M2 (G14G), Fedora Aurora, kernel 7.3.0-aurora-fleet82, same boot for both arms, Mesa built from each sha and loaded per test command (nothing installed), dEQP 4 processes in 500-case chunks, GL surfaceless pbuffer 256x256 rgba8888d24s8ms0. Base and head order alternates between groups. No GPU firmware crash and no GPU fault or timeout in the kernel log during the dEQP rows. Trace: traces/gpu/20261123-r3-m2-batch2. Assisted-by: LLM (Claude:Opus 5.5) |
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at ca677d2. The cap comes from the encoding's register budget and occupancy. Please show that the AGX2 fallback declines the new target cleanly when it would introduce scratch, and attach the measured G14G performance pair. Separate the sampled compute workload from a pure image-store control.
Compute programs with four or more texture reads spend much of their time waiting on them, and more resident threads hide that wait. Cap their registers so a core keeps 5/8 of its maximum resident threads, trading scratch spills for occupancy. The cap is derived from the device's register file and the occupancy steps rather than keyed on one chip. agx_register_file_halves() gives the per-thread file for each encoding, and agx_sampled_compute_register_cap() takes the largest budget that still reaches the target step. The spills only pay for a large step in resident threads, so a device gets the cap only where it raises them by half again or more: 384 to 640 threads gained on G17C, while 512 to 640 lost 7-10% on G16G with the same sample workload. A device whose file is unknown gets no cap. With the current occupancy table the AGX2 and AGX3C encodings resolve to 160 halves (640 resident threads instead of 384); AGX3B, whose file already reaches 512, gets none. The cap only applies where the launch takes the scratch of its spills. The driver says so with the new optional_spills key bit, from hk_compute_launch_takes_scratch(), the same rule its compute dispatch paths accept scratch by: G18G launches take none, and M5 launches take it only with the kernel's compute resources. Gallium does not set the bit. G18G gets no cap from the derivation either. Borealis's shader cache identity includes that rule, so a binary cached with the cap is not reused on a kernel whose launch refuses its spills. Helpers, preambles, unspillable programs and ray-traversal programs keep their hardware budget. The cap is only an occupancy trade, so the retry after a failed allocation drops it and spills down from the whole file instead of refusing a program that fits there. A unit test pins the derived cap per encoding (160 on G17C and AGX2, none on AGX3B or G18G) and checks on both G17C and G14G (AGX2) that the first allocation spills to the cap, that the retry uses the whole file with zero scratch, and that a key without optional_spills or with fewer than four texture reads keeps the whole file. Signed-off-by: Erik Bourget <erik@ebourget.net>
ca677d2 to
0f3b08d
Compare
satchlj
left a comment
There was a problem hiding this comment.
Verdict at b2392e5ccd5f
APPROVE — b2392e5ccd5f cleanly resolves the RA_MEM exhaustion and AGX3 scratch-limit fallback gap, drops the redundant AGX3D/emit_agx3d early return in agx_sampled_compute_register_cap(), merges cleanly onto aurora-wip, and passes all asahi/poly/SampledComputeRegisterCap.* unit tests plus live Apple M5 Max compute and texture Vulkan CTS with 0 failures and 0 GPU faults.
Blockers
None in code, host tests, or Apple M5 Max verification. (Note: the external AGX2 sampled-compute A/B and texture.*/image.* hardware rows listed in the PR's Not yet section remain outside our test machine's hardware scope.)
Checked
- Changed files (10):
src/asahi/compiler/agx_compile.c,agx_compile.h,agx_compiler.h,agx_performance.c,agx_register_allocate.c,meson.build,test/test-sampled-compute-register-cap.cpp,src/asahi/vulkan/hk_cmd_buffer.h,hk_cmd_dispatch.c,hk_shader.c. - Code audit:
agx_ra_impl()setsctx->sampled_cap_appliedonly whenagx_sampled_compute_register_cap()actually lowersmax_possible_regs;agx_compile_function_nir_attempt()retries once from the full register file (disable_sampled_cap = true,ra_budget_cut = 0) on bothctx->ra_failed(includingra_mem_exhausted) andframe_B > limit_Bbefore anyra_budget_cutretry or refusal.agx_sampled_compute_register_cap()derives160purely fromagx_register_file_halves()and the occupancy table (capped * 2 >= uncapped * 3), whilehk_compute_launch_takes_scratch()unifiesoptional_spills, dispatch scratch refusals, and shader cache flag bit 31 (verified free on liveaurora-wip46b5217f8375, whereAGX_DBG_VERIFYis bit 25 and FS structure is bit 30).- Clean
Signed-off-by:on both commits (0f3b08dd0f90,b2392e5ccd5f) and cleangit merge-tree --write-treeagainst46b5217f8375.
- Host build & tests (
-Dbuildtype=debugoptimized -Db_ndebug=false, Linux 7.3 aarch64):meson test --suite asahi: 236/236 OK (0 fail).meson test --suite poly: 5/5 OK (0 fail).agx_tests --gtest_filter='SampledComputeRegisterCap.*': 5/5 PASSED (78 ms, includingRetryOnSpillExhaustionUsesWholeFileon both G14G/AGX2 and G17C/AGX3C).
- Live Apple M5 Max Vulkan CTS (
MESA_SHADER_CACHE_DISABLE=true, Linux 7.3):dEQP-VK.compute.pipeline.basic.*: 79 Pass, 1 NotSupported, 0 Fail (80 total).dEQP-VK.texture.filtering.2d.formats.*: 146 Pass, 94 NotSupported, 0 Fail (240 total).0GPU faults indmesg.
- Untested scope: Live AGX2 (M1/M2) sampled-compute A/B performance pair and
dEQP-VK.texture.*/dEQP-VK.image.*conformance; AGX3B (M4/A18 Pro) zero-change shader-stats confirmation.
Evidence
- Audited full 10-file diff (
707lines) and verifiedhk_physical_device_compiler_flags()bit 31 availability onaurora-wip(46b5217f8375). - Built
b2392e5ccd5fwith-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:236/236 OK;--suite poly:5/5 OK;agx_tests --gtest_filter='SampledComputeRegisterCap.*':5/5 PASSED.- Live Apple M5 Max CTS:
dEQP-VK.compute.pipeline.basic.*(79/80 Pass, 1 NotSupported, 0 Fail),dEQP-VK.texture.filtering.2d.formats.*(146/240 Pass, 94 NotSupported, 0 Fail),0GPU faults indmesg.
Resolve conflicts in src/asahi/compiler/agx_register_allocate.c (keep the sampled compute cap alongside agx3_register_budget()) and src/asahi/vulkan/hk_cmd_dispatch.c (keep G18G scratch support up to 64 KiB via g18_compute_resources). Drop the stale AGX_CHIP_G18G early return in hk_compute_launch_takes_scratch() now that G18G compute launches accept scratch frames. Signed-off-by: Erik Bourget <erik@ebourget.net>
hk_dispatch_g17g_native() is only called for AGX_CHIP_G18G, where hk_compute_launch_takes_scratch() unconditionally returns true and scratch_bytes > max_spill (64 KiB) is already checked directly. Drop the redundant !hk_compute_launch_takes_scratch() guard there and update the hk_compute_launch_takes_scratch() comment. Also drop bit 31 from hk_physical_device_compiler_flags(): its sole consumer, hk_cache_identity(), already hashes both dev->chip and all 64 kernel feature bits in dev->params.features, which completely determine hk_compute_launch_takes_scratch(). Signed-off-by: Erik Bourget <erik@ebourget.net>
… cap Hardware A/B testing of the 160-half sampled-compute register cap on G13G (AGX2) and G17C (AGX3C) exposed two separate spill-regression causes, plus a stage-scoping bug in hk_compile_nir(): 1. ISA spill backing (AGX2 vs AGX3 static TPS): AGX2 spills to a helper-backed device-memory stack (agx_scratch) with explicit 2-slot scoreboard waits after each reload, whereas AGX3 uses launch-allocated static thread-private storage (copy/rld with hardware scoreboarding). On G13G, capping sampled compute to 160 halves slowed ALU-heavy sampled compute by +16% to +259% (up to 3.6x) and yielded no meaningful gain on texture-bound workloads (-0.9% to +2.4%, vs -7.0% to -14.5% on G17C for the same shaders). Restrict agx_sampled_compute_register_cap() to encodings with static TPS (AGX3B/AGX3C/AGX3D; AGX3B still resolves to 0 from its 192-half register file). 2. Unbounded optional spills on AGX3C: applying the cap solely on samples >= 4 forced 82-290 spills/fills on ALU-heavy compute shaders with only 8 texture fetches, regressing G17C by +8.7% to +47.9%, and added 54-78 spills (216-312 B scratch) on heavy texture shaders for 0% gain. Add agx_sampled_cap_spills_excessive() and drop the optional cap via the existing whole-file retry in agx_compile_function_nir_attempt() when RA spills exceed 192 B, 48 scalar stores/loads, or 8 loop-weighted spill/fill ops per weighted texture op (counted per loop header). 3. Stage scoping in hk_compile_nir(): software vertex and tessellation-eval variants are retagged to MESA_SHADER_COMPUTE before backend key setup. Require sw_stage == MESA_SHADER_COMPUTE when setting optional_spills so only real Vulkan compute shaders opt into the cap. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Merged
|
Signed-off-by: Erik Bourget <erik@ebourget.net>
There was a problem hiding this comment.
Verdict: MERGE at c2984e1f
Blockers: none (ready for multi-family lab regression overlay and merge).
Checked:
c2984e1fcleanly mergesaurora-wipoveraca2656b, which resolved the earlierAGX2spill regression by requiring static-TPS ISA support (agx_performance.c) and bounding optional spills while dropping the redundant G18G scratch check and compiler flag bit (a064bf40).- Exact-head hardware verification on
G17C(J716c:88,139compute+texture CTS cases with 0 diffs,-7.0%to-14.5%sampled-compute wins,0.0%control delta, 0 GPU faults) andG16G(J713:88,139compute+texture CTS cases with 0 net diffs, byte-identical uncachedshaderdb, 0 GPU faults). - Checked for Apple material, tool attribution, private serials, and Borealis naming: clean; human
Signed-off-bypresent;MERGEABLEonaurora-wip.
Evidence
- Head:
c2984e1f(base: aurora-wip,mergeable: MERGEABLE,+858/-5).
|
Verified host build and unit tests at
|
The cap now requires static TPS support and bounds optional spills. This excludes the AGX2 path from the cap and addresses the allocation fallback finding. Exact-head host, G17C and G16G results are recorded in the PR. aca2656b
|
The newly merged #375 overlaps #461 in agx_compile_function_nir. I have a local forward-merge preview that keeps the sampled-cap retry and the shifted-half packer retry independent, and I’m running both test groups. Please forward-merge aurora-wip if you are already working on this. If the branch is still unchanged at 14:08 AEDT tomorrow, we will carry the tested resolution forward. The J873g direct and indirect spill readback is still queued. |
Resolve the agx_compile_function_nir() overlap with #375. The function now takes both disable_sampled_cap and the shifted-half select fold arguments. The three sampled-cap retries (RA failure, excessive spills, scratch frame over the target limit) and the spill-budget retry pass the fold arguments through unchanged, and the caller's retries without the fold start with the sampled cap allowed again, so the two retries stay independent. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Forward-merged
|
There was a problem hiding this comment.
Verdict: MERGE at 6f1bba6b4335
Blockers: None.
Checked:
- Forward merge
6f1bba6b4335ofaurora-wip(06e34ecacbf3, including#375) over previously approvedc2984e1f:src/asahi/compiler/agx_compile.c(agx_compile_function_nir()andagx_compile_shader_nir_internal()): cleanly keepsdisable_sampled_capand#375'sopt_select_shifted_half/did_select_shifted_halfindependent — all three sampled-cap retries (ra_failed, excessive spills, scratch frame over target limit) and the spill-budget retry preserve the fold arguments unchanged, while the caller's no-fold retries restart withdisable_sampled_cap = false.
- Exact-head host tests at
6f1bba6b4335:meson test --suite asahi --suite poly356/356,agx_tests1,828 pass / 1 skip,SampledComputeRegisterCap.*9/9,SelectShiftedHalf.*4/4. - Driver logic outside the merged signature is unchanged from
c2984e1f, so the prior G17C (J716c) and G16G hardware rows stand.
Evidence
- Verified all call sites of
agx_compile_function_nir()passdisable_sampled_cap,opt_select_shifted_half, anddid_select_shifted_halfin matching parameter order. MERGEABLEonaurora-wip; no code blockers found at6f1bba6b4335.
|
Thanks for carrying the forward merge through. I verified On J700 (G17P), the two Vulkan drivers matched all 51 compute, sampler and descriptor CTS results (43 Pass and 8 NotSupported per arm). One pinned case was absent in this CTS build. The saved boot and host health stayed unchanged, with no GPU faults in the run window. This row covers the unaffected path. The remaining target run is J873g on a compatible submit kernel. It will check whether cap-positive direct and indirect dispatches spill and return the expected data, with pure image-store as a control. The paired drivers are staged at this exact revision. GitHub rejected the build/test dispatch on this fork, so the exact-head CI run is being routed through an enabled runner. |
|
Thanks for the occupancy fix and for carrying the forward merge through. This landed at |
What: Cap register allocation at 160 half-registers for ordinary Vulkan compute shaders with four or more texture reads on encodings with launch-allocated static thread-private storage (
AGX3CandAGX3D, where the register file and occupancy table yield at least a 1.5x resident-thread gain: 640 vs 384 threads) when the launch accepts optional spills, retrying from the whole register file if allocation fails, spills exceed the target scratch limit, or optional spill cost exceeds a bounded per-shader and loop-weighted spill-to-texture budget.Tested: Host
x86_64atc2984e1f32a5(asahi+poly328/328,agx_tests1,640 passed / 1 skipped,SampledComputeRegisterCap.*9/9). Exact-headc2984e1f32a5vsbabd36d4d477: J716cM5 Max(88,139 compute + texture CTS cases 0 diffs, textureshaderdbidentical reported per-case stats and totals with 0 spills, boot/smoke clean, 0 GPU faults;sc_bench/m5probeand Cyberpunk 2077 T2 not run, see Not yet) and J713M4 Air(AGX3B,cap = 0, 88,139 compute + texture CTS cases 0 diffs, cache-offshaderdbbyte-identical across 45,341 shaders, default-boot baseline smoke clean, 0 newdmesgerror lines during this PR's Mesa run window); J313M1 Airexact-head row pending. Prior-merge-baseaca2656bc5b1hardware wins (tb_sampled_n24-11.1%,tb_sampled_n32-14.5%,samp_sampled-7.0%; regressions eliminated) andG13Gdrm-shim(13/13shaders identical) are in Evidence.Risk: two-way door · M5/M5 Pro/M5 Max (
AGX3C) and M6 (G18G,AGX3D) Vulkan compute shaders (sw_stage == MESA_SHADER_COMPUTE) with>= 4texture reads and> 160half-registers whose optional spills stay within the bounded cost guard (<= 192 B,<= 48scalar stores and<= 48scalar loads independently,<= 8loop-weighted spill/fill ops per weighted texture op); M1/M2 (AGX2, lacks static TPS), M4/M4 Pro/A18 Pro (AGX3B, 192-half file), software graphics variants lowered to compute, and Gallium unaffected.Revert:
git revert -m 1 <merge-sha>onaurora-wip; no persistent on-disk, pipeline/shader cache (hk_cache_identity()hashesbuild_sha, device generation contract, anddev->params.features), UAPI, or firmware state is changed.Not yet:
J716c(M5 Max/G17C B1) exact-head paired sampled-compute A/B (sc_bench/m5probeprobe source and binaries were unavailable on the Mac and build host) and Cyberpunk 2077 T2 A/B (did not fit the 2026-11-28 pass); exact-head hardware run atc2984e1f32a5onJ313(M1 Air/G13G B1: liveAGX2cap = 0confirmation and boot/smoke check); plus externalG18G(M6) spilling direct+indirect launch verification and externalM1 Pro/M2/M4 Pro/A18 Proruns (no external hardware in lab).Details
Problem
Compute programs with four or more texture reads spend much of their time waiting on texture fetches, and keeping more threads resident hides that wait. Without a register cap on targets with large per-thread register files (252 halves), these programs allocate near the full file and fall to 384 resident threads per core.
Hardware A/B testing of an unbounded 160-half cap across
G13G(AGX2) andG17C(AGX3C) exposed two separate spill-regression mechanisms:AGX2vsAGX3static TPS):AGX2spills to a helper-backed device-memory scratch BO (agx_scratch) with synchronous 2-slot scoreboardwaitstalls after every reload (agx_insert_waits), whereasAGX3lowers spills to launch-allocated static thread-private storage (copy/rldwith hardware scoreboarding and nowaitinstructions). OnG13G, capping to 160 halves slowed ALU-heavy sampled compute by+16%to+259%(up to3.6x, vs+8.7%to+47.9%onG17C) and yielded no meaningful gain on texture-bound workloads (-0.9%to+2.4%, vs-7.0%to-14.5%onG17Cfor the same shaders).AGX3C: Capping solely onsamples >= 4forced82–290scalar spills/fills on ALU-heavy compute shaders with only 8 texture reads (regressingG17Cby+8.7%to+47.9%) and added54–78spills (216–312 Bscratch) on heavy texture shaders for0%gain.Change
Cap register allocation for ordinary Vulkan compute programs with four or more
AGX_OPCODE_TEXTURE_SAMPLE/AGX_OPCODE_TEXTURE_LOADinstructions for an occupancy-model target of 640 resident threads (5/8 of 1024 maximum), trading bounded static TPS spills for occupancy:src/asahi/compiler/agx_performance.c):agx_isa_has_static_tps()checks whether the encoding uses launch-allocated static TPS (AGX3B,AGX3C,AGX3D),agx_register_file_halves()gives the per-thread file for each encoding, andagx_sampled_compute_register_cap()takes the largest budget reaching the640-thread step (occupancies[0].max_threads * 5 / 8). A target gets the cap only where it has static TPS and the occupancy model raises resident threads by at least 1.5x (capped * 2 >= uncapped * 3):AGX3CandAGX3D(252 halves,384 -> 640) resolve to160halves;AGX3B(192 halves,512 -> 640, which lost 7–10% onG16G),AGX2(helper-backed stack + explicit waits), and unknown encodings return0.src/asahi/vulkan/hk_cmd_buffer.h,hk_cmd_dispatch.c,hk_shader.c):optional_spillsinstruct agx_shader_keymarks shaders whose launch takes the scratch of optional spills. Borealis sets it only on non-internal real Vulkan compute shaders (!nir->info.internal && sw_stage == MESA_SHADER_COMPUTE && hk_compute_launch_takes_scratch(&dev->dev)), excluding software vertex/tessellation-evaluation variants thathk_compile_nir()lowers toMESA_SHADER_COMPUTE.hk_compute_launch_takes_scratch()matches the compute dispatch launch contract (hk_dispatch_m5_native()requiresDRM_ASAHI_FEATURE_COMPUTE_RESOURCES, whilehk_dispatch_g17g_native()acceptsG18Gscratch frames up to 64 KiB viag18_compute_resources). Gallium leavesoptional_spillsfalse (src/gallium/drivers/asahi/agx_state.c).hk_cache_identity()already hashes the device generation contract (hk_hash_device_generation_contract()) and all 64 bits ofdev->params.features(src/asahi/vulkan/hk_physical_device.c).src/asahi/compiler/agx_register_allocate.c,agx_compile.c,agx_compiler.h): Helpers, preambles, unspillable programs, and ray-traversal programs skip the cap. Whenagx_ra()tightensmax_possible_regs(sampled_cap < max_possible_regs), it setsctx->sampled_cap_applied. Inagx_compile_function_nir()(called byagx_compile_shader_nir_internal()), if a capped attempt fails register allocation (ctx->ra_failed, includingctx->ra_mem_exhausted), tripsagx_sampled_cap_spills_excessive(ctx)(RA spill frame> 192 B,> 48scalar RA stores or> 48scalar RA loads checked independently, or loop-weighted scalar RA spill+fill ops> 8 *loop-weighted texture ops, counting per loop header so multi-backedge loops are not double-counted and ignoring NIR scratch offsets< ctx->spill_base_B), or exceeds the AGX3 scratch-frame limit, it retries once withdisable_sampled_cap = trueandra_budget_cut = 0from the whole register file before falling back tora_budget_cutretries or refusal.origin/aurora-wip(262403b7bce1) intob2392e5ccd5fat22f040c4636d, dropped the redundantG18Gscratch guard and bit-31 compiler flag ina064bf402c15, added the static-TPS gate, post-spill cost guard, andsw_stage == MESA_SHADER_COMPUTEscoping inaca2656bc5b1, and mergedaurora-wip(babd36d4d477) atc2984e1f32a5(conflict-free against the PR's 10 touched files;git merge-tree --write-tree c2984e1f32a5 46f3a68e60d9also merges cleanly with identical+858/-5diff across those 10 files).Evidence
aurora-wip46f3a68e60d9incremental tree plus each arm's patch, sharinggit-97742505d8indriverInfoand identified by source SHA andlibvulkan_asahi.soSHA-256:7f6f76e89599829e6c8196abe24d3234243c47634cc0d619a9a18266bbf63522for headc2984e1f32a5vs51a29f064fd26295d4b67501501fd319337cba51f27fe87c803f1c7affe9c30dfor basebabd36d4d477); default kernel image SHA-256bf2582ab357573db64031f39e7bc9d617eb574c6b221364ff417810bbddf4c87, default Stage 2 SHA-25621edee972e1ff1718c6f41c32b91ee151afdc58cbb69f16f2f6a4d8d4c722170, AC power. CTS runs usedtools/cts/aurora-cts-ab.py(6 workers, shader cache on, chunk 300, CTS7ba03cdac7ae) with its case-list expansion patched locally to keep onlyTEST:lines (the repository copy mis-parses this CTS build's export); Borealis arms are selected throughVK_DRIVER_FILES.dEQP-VK.compute.*: 60,838 cases on both arms, 15,525 Pass / 45,313 NotSupported, 0 Fail / Crash / DeviceLost, 0 diffs after retry (base 2m22s, head 2m21s).dEQP-VK.texture.*: 27,301 cases on both arms, 19,440 Pass / 7,861 NotSupported, 0 diffs;--shaderdb(shader cache off) over the same cases reported identical per-case stats and totals (30,616shaders,instrs1,339,729,code_size11,516,120,uniforms2,446,326,0spills / fills / scratch on both arms,0of27,301cases changed).sc_bench/m5probesampled-compute A/B (tb_sampled_n24,tb_sampled_n32,samp_sampled) did not run because those probe sources/binaries were unavailable on the Mac and build host; Cyberpunk 2077 T2 A/B also did not run because it did not fit the pass. The prior-merge-base wins stay labeled as such below.eDP-13456x2234@120 enabled; Apple MTP keyboard, trackpad and SMC lid devices enumerated (not exercised remotely);wlan0connected, 0% loss over 3 pings;AppleJ716card present withspeakerguarddv2 active (no playback in this row); BorealisApple M5 Max (G17C B1)withvkcube --c 240 --wsi waylandclean; 0 failed units (system and user); 0 LSM denials (no SELinux/AppArmor loaded); 0 GPU fault, MMU fault, SError or Oops lines. Redacteddmesgexcerpt (default boot, unchanged by the runs):aurora 2302600000.gpu: GPU firmware: 27.2 (26B123), G17C; 0GPU fault/MMU fault/DeviceLostlines after all runs; theerr+set is the boot's usual 55 lines (apple-dcp ... unable to match service ...andsystemd-gpt-auto-generator), unchanged.M4 MacBook Air,T8132,G16G B0,AGX3B, 2026-11-28): native release base-plus-patch builds (aurora-wip46f3a68e60d9plus each arm's patch, built on the aarch64 lab sibling Mac, sharinggit-97742505d8indriverInfoand identified by source SHA andlibvulkan_asahi.soSHA-256:7f6f76e89599829e6c8196abe24d3234243c47634cc0d619a9a18266bbf63522for headc2984e1f32a5vs51a29f064fd26295d4b67501501fd319337cba51f27fe87c803f1c7affe9c30dfor basebabd36d4d477), selected viaVK_DRIVER_FILESon battery; default Linux 7.3.0 (default J713 7.3.0 kernel) kernel image SHA-256592f7bc8834d8796d5bdb086091e90ac96fc6a17a83769cbadc92b3268604c49, default Stage 2 SHA-2563b2d2f059858d1891b225910864c02d68afb1b42893667e0afa8666491651071; CTS7ba03cdac7ae, 3 workers (aurora-cts-ab1.0).dEQP-VK.compute.*+dEQP-VK.texture.*(all88,139cases):27,864 Pass / 60,275 NotSupportedon both arms, 0 diffs.--shaderdb(shader cache off) on the same88,139cases:45,341shaders on both arms,instrs 2846827,code_size 28265460,spills 2256,fills 2892,uniforms 2773256,scratch 9024(byte-identical,+0on every total,0of88,139cases changed), as expected onAGX3B(cap = 0).eDP-12560x1664@60 enabled, input enumerated,wlan03/3 gateway ping (0% loss),speakerguardd-v2active with protected-sinksgv2.voicingtone rc 0, BorealisApple M4 (G16G B0)Vulkan 1.4.363 (glmark25,047),0failed units (system and user),0AppArmor denials (no SELinux),4pre-existing baselineerr+boot lines (AFK[ep:20], unsupported DFB layout,apple_sepmatching,brcmfmacring 4). Per-arm Mesavulkaninfo --summary/vkcubesmoke passed with0newdmesgerror lines during this PR's Mesa run window.Host build and unit tests at head
c2984e1f32a5x86_64,-Dvulkan-drivers=asahi -Dgallium-drivers=asahi -Dplatforms=wayland -Dglx=disabled -Dbuild-tests=true -Dtools=drm-shim -Doptimization=2 -Ddebug=false -Db_ndebug=false.ninja -C _build && meson test -C _build --suite asahi --suite poly && _build/src/asahi/compiler/agx_tests --gtest_filter='SampledComputeRegisterCap.*'.asahi+poly), 0 failed;agx_tests1,640 passed, 1 pre-existing skipped (NativeFMA.ExactDyadicOracle), 0 failed;SampledComputeRegisterCap.*(src/asahi/compiler/test/test-sampled-compute-register-cap.cpp) 9/9 passed (DerivedFromFileAndOccupancy,RetryAfterFailedAllocationUsesWholeFile,NoCapOnAGX2WithoutStaticTPS,NoCapWithoutOptionalSpills,NoCapBelowTextureThresholdat 0 and 3 loads,RetryOnSpillExhaustionUsesWholeFile,ExcessiveSpillsRetryUsesWholeFile,ModerateSpillsKeepSampledCap,LoopSpillsWeightedAgainstLoopTexturescovering multi-backedge loops, nested loops, non-zerospill_base_B, and 64-bit scalar boundary).babd36d4d477..c2984e1f32a5PR diff (+858/-5across 10 files) matches262403b7bce1..aca2656bc5b1logic;babd36d4d477merged 77 commits intoaurora-wipincluding sharedsrc/asahi/compiler/andsrc/asahi/vulkan/files.Prior-head host build and unit tests at
aca2656bc5b1x86_64,-Dvulkan-drivers=asahi -Dgallium-drivers=asahi -Dplatforms=wayland -Dglx=disabled -Dbuild-tests=true -Dtools=drm-shim -Doptimization=2 -Ddebug=false -Db_ndebug=false.ninja -C _build && meson test -C _build --suite asahi --suite poly.asahi322/322,poly5/5), 0 failed;agx_tests1,621 passed, 1 pre-existing skipped (NativeFMA.ExactDyadicOracle), 0 failed;SampledComputeRegisterCap.*(src/asahi/compiler/test/test-sampled-compute-register-cap.cpp) 9/9 passed (DerivedFromFileAndOccupancy,RetryAfterFailedAllocationUsesWholeFile,NoCapOnAGX2WithoutStaticTPS,NoCapWithoutOptionalSpills,NoCapBelowTextureThresholdat 0 and 3 loads,RetryOnSpillExhaustionUsesWholeFile,ExcessiveSpillsRetryUsesWholeFile,ModerateSpillsKeepSampledCap,LoopSpillsWeightedAgainstLoopTexturescovering multi-backedge loops, nested loops, non-zerospill_base_B, and 64-bit scalar boundary).Prior-head hardware runs at
aca2656bc5b1vs262403b7bce1(pre-babd36d4d477merge)Both
aca2656bc5b1Mac runs used the same cross-compiled aarch64 Borealis release libraries (-Dvulkan-drivers=asahi -Dgallium-drivers=[] -Dplatforms=wayland -Dglx=disabled -Doptimization=2 -Ddebug=false -Db_ndebug=false):262403b7bce1): driver identity reported on deviceBorealis Mesa 26.3.0-devel (git-262403b7bc); stagedlibvulkan_asahi.sosha256da99d77ce72e606a18dbee76624c9503601282125e6909ba32a106bafe302c36(also device-verified viasha256sumon J713).aca2656bc5b1): driver identity reported on deviceBorealis Mesa 26.3.0-devel (git-aca2656bc5); stagedlibvulkan_asahi.sosha2563ee76d3a76ee20a0e6a8036593f2f70ccb8b88a4f24483cb406b3606a4cdb969(also device-verified viasha256sumon J713).VK-GL-CTScommit7ba03cdac7ae(vk-defaultmustpass,deqp-vk --deqp-surface-type=pbuffer --deqp-log-images=disable --deqp-log-shader-sources=disable --deqp-terminate-on-fail=disable, 6 parallel shards, fresh per-armMESA_SHADER_CACHE_DIR, diagnostics off).1. J716c (
M5 Max/G17C B1, Linux7.3.0, Arch ARM)base/fixalternating order across rounds r1–r6), 20 timed dispatches per round,MESA_SHADER_CACHE_DISABLE=true, diagnostics off (sc_bench <shader.spv> 20forsc_sampled_*/tb_sampled_*;m5probe --reps 20 samp <name>forsamp_sampled/samp_control). Output checksums were bit-identical across every arm and round.[min..max]across the 6 round medians):262403b7bce1) GPRs/spillsa064bf402c15delta (spills)aca2656bc5b1GPRs/spills[min..max](us)[min..max](us)aca2656bc5b1)sc_sampled_n20163 / 0:0-0.9%(22:22)159 / 22:22(32 B)256.4 [252.6..258.4]254.8 [252.6..259.4]-0.6%sc_sampled_n24195 / 0:0+8.7%(82:82)195 / 0:0(uncapped)250.1 [245.1..257.3]254.3 [247.4..258.1]+1.7%sc_sampled_n28227 / 0:0+18.1%(136:136)227 / 0:0(uncapped)263.9 [260.8..265.1]264.8 [263.0..270.4]+0.3%sc_sampled_n32247 / 29:29+20.2%(192:192)247 / 29:29(uncapped)300.6 [298.9..302.4]300.3 [298.3..303.8]-0.1%sc_sampled_n40247 / 125:125+47.9%(290:290)247 / 125:125(uncapped)395.6 [384.0..397.5]380.8 [376.0..391.0]-3.7%tb_sampled_n24207 / 0:0-11.2%(30:30)159 / 30:30(128 B)4106.2 [4099.1..4117.0]3649.1 [3647.6..3654.3]-11.1%tb_sampled_n32231 / 0:0-14.5%(30:30)159 / 30:30(120 B)5786.2 [5779.0..5792.6]4947.8 [4945.0..4956.4]-14.5%tb_sampled_n40247 / 10:10-0.1%(54:54, 216 B)247 / 10:10(uncapped)6125.5 [6108.0..6140.5]6120.1 [6108.6..6123.3]-0.1%tb_sampled_n48247 / 34:34-0.0%(78:78, 312 B)247 / 34:34(uncapped)7350.0 [7343.3..7374.6]7363.5 [7341.6..7402.4]+0.2%samp_sampled231 / 0:0-7.0%(29:29)159 / 29:29(116 B)4753.6 [4753.0..4755.1]4422.1 [4381.8..4425.0]-7.0%samp_control197 / 0:0+0.0%(0:0)197 / 0:0(uncapped)54.5 [54.5..54.6]54.5 [54.5..54.5]-0.0%tb_sampled_n24: base4099.6, 4099.1, 4100.4, 4117.0, 4112.0, 4112.6vs head3647.6, 3654.0, 3648.9, 3654.3, 3648.2, 3649.2(checksumc7ccd04d10a4a7a3)tb_sampled_n32: base5792.6, 5789.5, 5785.3, 5779.0, 5787.2, 5781.3vs head4945.6, 4946.2, 4945.0, 4949.4, 4950.0, 4956.4(checksumf1d270bf0f1bb6e3)samp_sampled: base4755.12, 4753.39, 4753.82, 4753.14, 4753.01, 4753.74vs head4420.67, 4423.54, 4424.97, 4381.76, 4424.38, 4420.53(fnv02691a7b)VK-GL-CTS 7ba03cdac7ae, 6 shards, per-arm cold cache):dEQP-VK.compute.*(60,838cases):15,525 Pass / 45,313 NotSupported / 0 Fail / 0 Crash / 0 Timeouton both arms (0diffs; 163 s vs 164 s).dEQP-VK.texture.*(27,301cases):19,440 Pass / 7,861 NotSupported / 0 Fail / 0 Crash / 0 Timeouton both arms (0diffs; 46 s vs 45 s).88,139cases ran,0diffs.0GPU error lines indmesg(dmesg_delta_lines=4,non_audit_lines=1),0AVC lines (SELinux not built on Arch ARM),0new failed units (2 pre-existing host units already failed before the run and unchanged afterward:aurora-peripherals.service,systemd-networkd-wait-online.service).2. J713 (
M4 Air/G16G B0,AGX3B,cap = 0, Linux7.3.0, Arch ARM)git-262403b7bc(sha256sumda99d77ce72e606a18dbee76624c9503601282125e6909ba32a106bafe302c36) vsgit-aca2656bc5(sha256sum3ee76d3a76ee20a0e6a8036593f2f70ccb8b88a4f24483cb406b3606a4cdb969).AGX_MESA_DEBUG=shaderdb(MESA_SHADER_CACHE_DISABLE=true):sc_sampled_n20..40,tb_sampled_n24..48):9/9shaders byte-identical (0diffs), bit-identical output checksums (4b404aa0a9cf4383).dEQP-VK.compute.pipeline.basic.*(80cases,85shader lines):85/85byte-identical (0diffs).VK-GL-CTS 7ba03cdac7ae, 6 shards, per-arm cold cache, diagnostics off):dEQP-VK.compute.*(60,838cases):13,140 Pass / 47,698 NotSupported / 0 Fail / 0 Crash / 0 Timeouton both arms (0diffs; 11 s vs 11 s).dEQP-VK.texture.*(27,301cases): 6-shard pass reported14,718 Pass / 12,577 NotSupported / 6 Failon both arms (6symmetric parallel-shard flakes indEQP-VK.texture.explicit_lod.2d.formats.*: 3 Fail->Pass, 3 Pass->Fail); isolated cold-cache rerun of all 6 cases returned6/6 Pass / 0 Failon both arms (14,724 Pass / 12,577 NotSupported / 0 Fail,0net diffs).88,139cases ran,0net diffs.0GPU error lines injournalctl -kover the run window,0AVC lines (SELinux not built on Arch ARM),0failed units before and after (systemctl --failedempty).3. Offline
drm-shimG13G(AGX2,cap = 0) zero-change check ataca2656bc5b1vs262403b7bce1ASAHI_SHIM_CHIP=g13g,MESA_SHADER_CACHE_DISABLE=true,AGX_MESA_DEBUG=shaderdb: all13/13shaders (sc_sampled_n18..40,tb_sampled_n16..48,samp_sampled,samp_control) produce byte-identicalshaderdboutput (0diffs;agx_sampled_compute_register_cap() == 0onAGX2).Earlier-head hardware runs (superseded by
aca2656bc5b1andc2984e1f32a5)M1 Air/G13G B1,a064bf402c15vs262403b7bce1):dEQP-VK.compute.*+texture.*(88,139cases,0diffs) +image.*(135,825cases,0diffs, pre-existing6,640 DeviceLost / 36 Failidentical on both arms); generated ALU-heavy sampled compute regressed+16% to +259%(up to3.6x) and texture-bound ran-0.9% to +2.4%whenAGX2had the 160-half cap enabled — motivating theAGX2static-TPS gate and spill-cost guard inaca2656bc5b1.ca677d21601bonafcc08b71067+#450, predating the spill-cost guard): 10 consecutive T2 launches (2560x1600 High) completed at 28.49–28.97 FPS vs 27.77/28.50 FPS control, with the two hot 8x8 compute shaders at 29 and 33 spills (an exact-head AC re-run atc2984e1f32a5is listed underNot yet).