Skip to content

borealis/agx2: Enable deferred CDM cache flushes on G13X - #1233

Merged
RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
DanteCpp:agx2-g13x-cdm-defer-flush
Nov 27, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:aurora-wipfrom
DanteCpp:agx2-g13x-cdm-defer-flush

Conversation

@DanteCpp

@DanteCpp DanteCpp commented Nov 27, 2026 •

Copy link
Copy Markdown

Problem

PR #1219 added AGX_CAP_CDM_DEFER_FLUSH to omit redundant trailing 0x1ff CDM cache flushes after independent application compute launches, but enabled it on G13G only until G13X hardware qualification was completed.

Change

  • src/asahi/lib/agx_chip_caps.h: move AGX_CAP_CDM_DEFER_FLUSH into AGX_CAPS_G13 so G13X (M1 Pro/Max) shares the deferred CDM flush behavior with G13G.
  • src/asahi/lib/tests/test-chip-caps.c: update test_cdm_defer_flush() to expect AGX_CAP_CDM_DEFER_FLUSH on both G13G and G13X.
  • src/asahi/vulkan/tests/test-hk-cdm-barrier-stream.c: run the deferred-flush stream suite (test_defer_flush_g13()) on both G13G and G13X, and run the non-deferred 0x1ff/0x160 narrowing tests on G14X (which keeps non-deferred flushes).

Testing

Tested on a 16-inch MacBook Pro M1 Max (J316c, G13X), kernel 7.3.0-ds4-ARCH:

  • Driver identities:
    • Arm A (origin/aurora-wip 13400438325): libvulkan_asahi.so sha256 d39ac03363d8a344844f4a0741550018b4b1b94c4f8bb427840a6c75691f15f4
    • Arm B (agx2-g13x-cdm-defer-flush da260397f11): libvulkan_asahi.so sha256 279b2d2ef82180e1ca5a1d714210ea0ee96e898cc99b559a002fbd0c54b41c23
  • Unit tests: asahi-agx-chip-caps (OK), hk_cdm_barrier_stream (OK).
  • Vulkan CTS (deqp-vk, 0 regressions):
    • dEQP-VK.compute.pipeline.basic.*: 77 Pass, 0 Fail, 3 NotSupported
    • dEQP-VK.compute.pipeline.indirect_dispatch.*: 18 Pass, 0 Fail, 27 NotSupported
    • dEQP-VK.synchronization2.op.single_queue.barrier.*ssbo_compute*: 100 Pass, 0 Fail, 104 NotSupported
    • dEQP-VK.synchronization2.op.single_queue.barrier.*image_compute*: 412 Pass, 0 Fail, 225 NotSupported
    • dEQP-VK.synchronization2.op.single_queue.barrier.*indirect*: 369 Pass, 0 Fail, 262 NotSupported
    • dEQP-VK.synchronization2.op.single_queue.event.*ssbo_compute*: 150 Pass, 0 Fail, 194 NotSupported
    • dEQP-VK.synchronization.op.single_queue.barrier.*ssbo_compute*: 50 Pass, 0 Fail, 52 NotSupported
    • dEQP-VK.memory_model.message_passing.core11.u32.coherent.fence_fence.atomicwrite.device.*: 13 Pass, 0 Fail, 44 NotSupported
  • Kernel health: 0 GPU kernel errors during all runs.
gpubench-vk alternating A/B (depth 4, 3 pairs x 5 runs, M1 Max J316c)
Test Arm A GPU (µs) Arm B GPU (µs) Delta
compute.light 5.7 5.7 +0.02%
compute.heavy 250.0 250.0 +0.02%
compute.conv2d 421.9 423.0 +0.26%
compute.stereo 4781.2 4780.8 -0.01%
copy.bw 360.9 361.2 +0.09%
diag.fill 192.9 193.0 +0.07%

Move AGX_CAP_CDM_DEFER_FLUSH into AGX_CAPS_G13 so G13X (M1 Pro/Max) joins G13G in deferring trailing 0x1ff CDM cache flushes on independent application compute dispatches until a declared barrier, non-deferred/meta launch, or stream close.

Update test-chip-caps.c to expect AGX_CAP_CDM_DEFER_FLUSH on both G13G and G13X, and update test-hk-cdm-barrier-stream.c to exercise deferred flushes on both G13G and G13X while keeping non-deferred narrowing coverage on G14X.

Signed-off-by: Dante Loi <danteloi1993@gmail.com>
@DanteCpp
DanteCpp requested review from a team and DjDeveloperr as code owners November 27, 2026 15:01
@RyanTheTide

Copy link
Copy Markdown

da260397f11c J316s (M1 Pro / T6000 / G13S C0, 7.3.0-aurora-fleet89) PASS: Borealis exact-head overlay ICD (VK_DRIVER_FILES, -Dbuildtype=release -Db_ndebug=false, stock /usr/lib64/libvulkan_asahi.so verified byte-identical before/after); meson test --suite asahi 215/215 PASS; deqp-vk 462 PASS / 0 FAIL (api.smoke.* 8/8, compute.pipeline.basic.* 78/81, compute.* 1,10 328/5485, synchronization.basic.* 21/29, synchronization.op.single_queue.barrier.*compute* 1,5 27/55); 0 GPU faults/recoveries, Enforcing, 0 failed units.

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

Blockers: none

Checked:

  • The cap moves into AGX_CAPS_G13, so G13X gets it via the chip-caps table, not a chip check (NO-GATES fine). AGX_CHIP_G13X covers the S/C/D variants (agx_chip.h:669-671): M1 Pro/Max/Ultra. No other chip's caps change.
  • The #1219 fix still holds at this head: hk_dispatch_precomp() passes allow_defer = false (hk_cmd_buffer.c:5592), and hk_dispatch_with_usc() allows deferral only for MESA_SHADER_COMPUTE (hk_cmd_dispatch.c:1022-1023). The GS/tess pre-pass launches in hk_cmd_draw.c are not COMPUTE stage, and in_meta launches still drain. Cases 5-7 of the stream test (precomp never defers; a deferred app launch drains before precomp; an SSBO barrier before precomp is upgraded to 0x1ff) now run on G13X as well as G13G.
  • The narrowing-only tests moved from G13X to G14X, so they still cover a non-deferring chip. G14X keeps the 0x1ff default word (agx2_cdm_barrier_default_word), so the expected words are unchanged.
  • Head merged into aurora-wip 743fa0d3 (clean; none of the touched files changed since your base 13400438): local drm-shim gate 338 Ok / 0 Fail.
  • Negative check: with agx_chip_caps.h reverted to aurora-wip and the tests kept, asahi-agx-chip-caps fails and hk_cdm_barrier_stream aborts (336/2).
  • Rows at this head: present: J316c M1 Max G13X (yours) and J316s M1 Pro G13S (comment above; also AGX_CHIP_G13X, sync barrier compute shard 27/27). That covers both dies of the only chip entry that changes. A regression row on another generation is not needed: on every other chip AGX_CAP_CDM_DEFER_FLUSH is unchanged, so cdm_flush_pending is never set and the command stream is the same by construction.
Evidence
  • Gate (head merged into aurora-wip 743fa0d, tree 1cf25468): Ok: 338 Fail: 0
  • Mutation (agx_chip_caps.h reverted, tests kept): Ok: 336 Fail: 2 (asahi-agx-chip-caps exit 1, hk_cdm_barrier_stream SIGABRT)
  • git diff --stat 13400438..743fa0d3 -- (the 3 touched files): empty

@RyanTheTide
RyanTheTide merged commit 6fb394d into aurora-silicon:aurora-wip Nov 27, 2026
joshuaswarren pushed a commit that referenced this pull request Nov 27, 2026
…ait slots on G14X

Add two AGX2 compute-shader scheduling passes gated via agx_chip_caps on G14X (Apple M2 Pro/Max/Ultra), with no new runtime switches:

1. AGX_CAP_COMPUTE_HOIST_LOAD_ADDRS (1u << 28; agx_hoist_loads in agx_pressure_schedule.c, run after agx_ilp_schedule on AGX2 compute): hoists non-coherent device_loads together with up to 3 pure SSA address-producing predecessors (depth <= 4) up to 64 instructions earlier while maintaining a strictly-earlier SSA dominance invariant.

2. AGX_CAP_COMPUTE_SMART_WAITS (1u << 27; agx_insert_waits_local in agx_insert_waits.c): precomputes per-block first-use positions in a single O(N) backward pass (respecting #1232 reorderable loads across threadgroup barriers) and partitions the two hardware scoreboard slots by first-use distance to eliminate mid-burst AGX_MAX_PENDING=8 slot-0 overflow stalls.

Rebased cleanly onto aurora-wip 7617c83 (preserving #1232 drain_on_tg_barrier and #1233 G13X CDM defer flush).

Author-Model: google/gemini-4-neon
joshuaswarren added a commit that referenced this pull request Nov 27, 2026
…ait slots on G14X

Add two AGX2 compute-shader scheduling passes gated via agx_chip_caps on G14X (Apple M2 Pro/Max/Ultra), with no new runtime switches:

1. AGX_CAP_COMPUTE_HOIST_LOAD_ADDRS (1u << 28; agx_hoist_loads in agx_pressure_schedule.c, run after agx_ilp_schedule on AGX2 compute): hoists non-coherent device_loads together with up to 3 pure SSA address-producing predecessors (depth <= 4) up to 64 instructions earlier while maintaining a strictly-earlier SSA dominance invariant.

2. AGX_CAP_COMPUTE_SMART_WAITS (1u << 27; agx_insert_waits_local in agx_insert_waits.c): precomputes per-block first-use positions in a single O(N) backward pass (respecting #1232 reorderable loads across threadgroup barriers) and partitions the two hardware scoreboard slots by first-use distance to eliminate mid-burst AGX_MAX_PENDING=8 slot-0 overflow stalls.

Rebased cleanly onto aurora-wip 7617c83 (preserving #1232 drain_on_tg_barrier and #1233 G13X CDM defer flush).

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
RyanTheTide pushed a commit that referenced this pull request Nov 28, 2026
Document and assert in hk_dispatch_with_usc_launch() that draw-feeding
GS/tess compute helpers on current_cs.pre_gfx never defer their trailing
CDM cache flush, and update the stale AGX2 flush comment on the G17P
compute launch path after AGX_CAP_CDM_DEFER_FLUSH landed in #1219/#1233.

Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
@DanteCpp
DanteCpp deleted the agx2-g13x-cdm-defer-flush branch December 1, 2026 09:14
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.

2 participants