Repository navigation
agx: fold shared offsets and pack preamble bases low on G14X - #1242
Conversation
Enable constant shared-memory offset folding (AGX_CAP_FOLD_SHARED_OFFSETS) on Apple M2 Max (G14X), matching G13G and G13X. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 8d4c393659e6
Blockers: The AGX2 low-preamble-base call has no stage check. form_preamble checks only the secondary and no-preamble flags, so a G14X fragment shader with ordinary preamble exports can also run the new layout pass. This conflicts with the stated unchanged fragment behavior and the compute-only qualification. Scope the call to compute or explicitly qualify the affected graphics stages. Add a negative graphics-stage case at the entry point, since the current compute fixture tests the repacking helper directly.
Checked: The source uses the shared capability table, and the posted compute A/B and isolated results cover G14X. Checked the call-site predicate and the uniform-file limit.
Evidence
See agx_compile.c at the new AGX2 branch. The predicate checks encoding, the chip capability and push count. It does not check the shader stage.
Add AGX_CAP_PREAMBLE_BASES_LOW (1u << 26, G14X only), agx_should_place_preamble_bases_low(), and agx_nir_place_preamble_bases_low() to pack 64-bit load_agx/load_constant_agx/store_agx/global_atomic_agx compute preamble base pointers into low uniform slots (< 256 halfwords), prioritizing loop-nested bases first and sorting non-base exports by descending alignment to prevent padding growth on uniform-full shaders. Scoped strictly to MESA_SHADER_COMPUTE at both the agx_compile.c entry-point gate and agx_nir_place_preamble_bases_low(), with negative graphics-stage unit test coverage. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
|
Addressed the stage-scoping blocker at
|
8d4c393 to
b8428c8
Compare
There was a problem hiding this comment.
Verdict: HOLD at b8428c8fb8ec
Blockers: Landing-owner confirmation of current-head compiler evidence and the reported compute equivalence to the hardware-tested binary. No hosted checks are listed.
Checked: Code approved. Both the compiler predicate and the repacking helper restrict the new layout to compute. The new unit test covers vertex and fragment refusals, the intended compute case and other chip/encoding paths.
Evidence
Compiled the exact entry predicate with a stub chip-capability lookup and passed seven checks for stage, encoding, capability, preamble presence and push-count boundary. The author reports 1,703 compiler passes, one pre-existing skip, 745 chip-capability passes and both preamble fixtures passing at this head.
|
|
|
GREEN on b8428c8 GREEN on b8428c8 [test] Evidence at head: RyanTheTide exact-head PASS comment on b8428c8 (Borealis overlay ICD build+load). Documented suite (test-chip-caps 745/745, test-preamble-bases 1/1, CTS 440 diffs=0) was recorded at prior tree 56d4d35f; the head delta since is the requested stage-scoping extraction (agx_should_place_preamble_bases_low) - a caller-side gate tightening, verified below. Mesa was not rebuilt locally; receipt attests the documented runs + maintainer head PASS. Full-suite receipt: /tmp/receipt-1242.json |
|
Forward-merged |
There was a problem hiding this comment.
Verdict: MERGE at 7a122be after the current-head hardware rows.
Checked: The preamble capability is unique at bit 30, with bits 26/27 preserved and 28/29 available to #1224. The chip tests preserve the G13 schedule scope and assert the intended fold and preamble scopes. The reported host suite passed Vulkan and chip-table tests. The prior hardware rows cover the previous head. Recheck the G14X row and the shared capability table in the combined merge.
|
@DjDeveloperr, code-owner heads-up: App approval at |
…ble-bases-low # Conflicts: # src/asahi/lib/agx_chip_caps.h # src/asahi/lib/tests/test-chip-caps.c
|
Forward-merged There was one conflict, in two files, because both PRs add G14X capability bits. #1224 took bits 28/29 (
Host This still needs an App re-approval at |
There was a problem hiding this comment.
Verdict: MERGE at 157aac4 after the merge train's combined checks.
Checked: Inspected both conflict resolutions. G14X keeps the shared-offset and low-preamble flags plus both #1224 flags. The flags use distinct bits, and the test retains the preamble check and the positive and negative chip checks for #1224. Merge train reports 318/344 matching the base suite. Integrated G14X hardware still gates landing.
|
Merge-train landing at
Revert: |
What
Two small
G14X(Apple M2 Max) AGX2 compute compiler improvements onaurora-wipgrouped into a single two-commit PR:649759df13c8):agx: enable AGX_CAP_FOLD_SHARED_OFFSETS on G14X(2files,+9/-7:src/asahi/lib/agx_chip_caps.h,src/asahi/lib/tests/test-chip-caps.c). AddsAGX_CAP_FOLD_SHARED_OFFSETS(1u << 24) to theG14Xrow inAGX_CHIP_CAPSso constant deltas between a block's shared-memory accesses fold intolload/lstoreindex immediates, matchingG13GandG13X.8d4c393659e6):agx: pack 64-bit AGX2 preamble memory bases low on G14X(7files,+391/-2:src/asahi/compiler/agx_compile.c,src/asahi/compiler/agx_compiler.h,src/asahi/compiler/agx_nir_opt_preamble.c,src/asahi/compiler/meson.build,src/asahi/compiler/test/test-preamble-bases.cpp,src/asahi/lib/agx_chip_caps.h,src/asahi/lib/tests/test-chip-caps.c). AddsAGX_CAP_PREAMBLE_BASES_LOW(1u << 26, clear of merged#12191u << 25and rebased#12241u << 27/1u << 28) andagx_nir_place_preamble_bases_low(), packing 64-bitload_agx/load_constant_agx/store_agx/global_atomic_agxpreamble base pointers into low uniform slots (< 256halfwords), prioritizing loop-nested bases first and sorting non-base exports by descending alignment to prevent padding growth on uniform-full shaders.aurora-silicon/mesaaurora-wip):a15657a362b7(verified conflict-free against latestaurora-wip7617c835cd8b)agx/g14x-fold-shared-offsets-and-preamble-bases-low(8d4c393659e6935f64e8f4420e1916ba8cde0226, 2 commits atopa15657a362b7, tree hash56d4d35f23adidentical to the benchmarked tip2b81527cce1b)G14X(Apple M2 Max) with no new runtime env switches;G13G,G13X,G14G, fragment shaders, and AGX3/Gen 15+ are unchanged.Table 1A: Direct Combined PR Head (
8d4c393659e6, tree56d4d35f) vsaurora-wip@a15657a362b7(Apple M2 Max, G14C B1)Matched interleaved ABBA directly comparing exact
aurora-wip@a15657a362b7against this 2-commit PR head (tree56d4d35f,8d4c393659e6/2b81527cce1b;MESA_SHADER_CACHE_DISABLE=1,MLX_OMARCHY_DEFER_TOKENS=0,omarchy-mlxea110593a, zero driver env flags,/proc/self/maps+ SHA-256 verified, 100% bit-identical greedy token digests). Every row in Tables 1A and 1B reports both the pooled median-of-arms throughput delta ((B_tok - A_tok) / A_tok) and the interleaved median pair ratio (median((A_i - B_i) / A_i)):aurora-wip@a15657a3Base8d4c3936)4784df039da04560c5fb4074d0b56223cedd5549b251572aThe combined 2-commit PR won 12 of 13 matched pairs across all 3 cells (
4/5at2B@512,5/5unanimous at2B@2048,3/3unanimous at9B@512), positive on both metrics in every cell, 100% bit-exact.Table 1B: Per-Commit Isolation on
aurora-wip@fffdc5c7(Apple M2 Max, G14C B1)Matched interleaved ABBA isolating each commit individually (
aurora-wip@fffdc5c7vsaurora-wip@fffdc5c7plus each patch;omarchy-mlxb8204376c3cd, zero driver env flags, 100% bit-exact). Both the pooled median-of-arms throughput delta and the median pair ratio are reported for every cell, including neutral/non-winning individual cells:Commit 1 alone:
AGX_CAP_FOLD_SHARED_OFFSETS(fffdc5c7vsfffdc5c7 + fold)aurora-wip@fffdc5c7Basefffdc5c7 + foldCommit 2 alone:
AGX_CAP_PREAMBLE_BASES_LOW(fffdc5c7vsfffdc5c7 + preamble_bases_low)aurora-wip@fffdc5c7Basefffdc5c7 + preamble_bases_lowTable 2: Reference Measurements on Shipped Mesa Vulkan Driver Line (non-
aurora-wip)On our shipped Mesa Vulkan driver line (
MESA_SHADER_CACHE_DISABLE=1,MLX_OMARCHY_DEFER_TOKENS=0, zero driver env flags, 100% bit-exact):agx_fold_shared_offsetson Apple M2 Max:2B@512210.36 -> 211.52 tok/s(+0.39%pair ratio,5/5unanimous),2B@2048206.72 -> 206.69(-0.04%pair ratio,1/5neutral),9B@51265.06 -> 65.07(+0.02%pair ratio,2/3),9B@204863.92 -> 63.99(+0.07%pair ratio,3/3).agx_nir_place_preamble_bases_lowon Apple M2 Max:2B@512+0.12%pair ratio (4/5,211.18 tok/s),2B@2048+0.48%pair ratio (4/5,207.66 tok/s).Conformance & Unit Tests
test-chip-caps):745/745checks PASSED on the 2-commit tip8d4c393659e6(tree56d4d35f, verifyingAGX_CAP_FOLD_SHARED_OFFSETSonG13G/G13X/G14XandAGX_CAP_PREAMBLE_BASES_LOW = 1u << 26strictly onG14X; zero cap-bit collision with merged#12191u << 25or rebased#12241u << 27/1u << 28).test-preamble-bases.cpp):1/1PreambleBasesLow.PrioritizesLoopBasePointerUnder256HalfwordsPASSED (verifying loop-nested 64-bit base pointer is placed atreservedahead of outer base pointer atreserved + 4, both< 256halfwords, withallocated <= offsetandnir_validate_shaderclean). On basea15657a362b7,agx_nir_place_preamble_bases_lowis absent.deqp-vkon Apple M2 Max G14C,MESA_SHADER_CACHE_DISABLE=true,cases-8bit.txt440 cases):aurora-wip@a15657a3base vs combined 2-commit PR head (8d4c3936, tree56d4d35f):440total (111 Pass,329 NotSupported,0 Fail) vs440(111 Pass,329 NotSupported,0 Fail),diffs=0.fffdc5c7(foldandpreamble_bases_low):440vs440,diffs=0on both.Risk
Two-way ·
G14X(Apple M2 Max) shared-memory offset folding and AGX2 preamble uniform placement only;G13G,G13X,G14G, fragment shaders, and AGX3/Gen 15+ are unchanged.