Skip to content

agx: interleave provably disjoint shared-memory stores before workgroup barriers - #1560

Open
IronsideXXVI wants to merge 6 commits into
aurora-silicon:aurora-wipfrom
IronsideXXVI:j604-agx-interleave-disjoint-shared-stores
Open

IronsideXXVI wants to merge 6 commits into
aurora-silicon:aurora-wipfrom
IronsideXXVI:j604-agx-interleave-disjoint-shared-stores

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Dec 2, 2026 •

Copy link
Copy Markdown

What: Add agx_nir_interleave_disjoint_shared_stores(), gated to AGX3B compute shaders with shared_size > 0, to interleave provably disjoint suffix store_shared operations (and their bounded read-only global/constant-load closures) earlier ahead of workgroup barriers inside loop blocks. Uses conservative unsigned [lo, hi] interval analysis (u32_interval()) to bound each non-volatile, non-negative-base store_shared byte range strictly within [0, shared_size), bails if any side-effecting, shared-read/atomic, global-store/atomic, or volatile op precedes the workgroup barrier, stops immediately if any suffix store cannot be moved so later suffix stores never overtake an earlier suffix store, and maintains nir_metadata_instr_index validity cleanly.

Tested:

  • Offline build & Asahi suite atop origin/aurora-wip (cb983a61cb1, head 5517fb46fea, gcc 16.1.1, aarch64, -Dbuildtype=release -Db_ndebug=false): libvulkan_asahi.so built with 0 warnings in touched files; meson test -t 4 --suite asahi 398 Ok / 0 Fail / 1 Skipped; agx_tests 1972 passed / 0 failed / 1 skipped (17/17 *Interleave*, including SharedByteOffsets.InterleaveDisjointSharedStores, InterleaveSharedStoresVolatileAndNegativeBase, and InterleaveSharedStoresLoadAgxAndBounds).
  • Offline G16G compile diff across llama-bench pipelines showed [3] q6_K B0/B1 tile loads/stores interleaved 101-134 instructions earlier before the workgroup barrier (0:0 spills across all 16 pipelines). (Earlier J604 llama-bench numbers came from a combined build and are not standalone proof for this pass.)

Risk: two-way door · AGX3B compute compiler only (M3, M4 family, and A18 Pro) — strictly gated to is_agx3b && mesa_shader_stage_is_compute && shared_size > 0. AGX3C (M5) is intentionally left out because it uses a separate backend/scheduling profile and has not been benchmarked with this pass. Only moves non-volatile store_shared ops with non-negative base whose [byte_lo, byte_hi] intervals stay inside shared_size and are provably disjoint from all prefix store_shared ops, only moves read-only non-volatile load closures inside the same basic block before a workgroup barrier, bails on any side-effecting op before the barrier, and preserves relative suffix store ordering.

Not yet:

  • Standalone exact-head aurora-wip (5517fb46fea) hardware A/B on J604 / M4 (llama-bench Q4_K_M and Q6_K pp512/tg32 base vs head ABBA on one boot, 0 faults, gpubench compute.* CRC match, dEQP-VK.compute.*shared*, dEQP-VK.memory_model.*workgroup*).
  • Second-generation AGX3B regression check on A18 Pro (J700) (gpubench compute.* and the same CTS subset).
Offline & unit test details
  • Base: origin/aurora-wip (cb983a61cb1, standalone, zero stacking dependencies)
  • Head: 5517fb46fea29f9ba544b53bf5836705fe5afd45 (includes dd59e17ad0d2)
  • Files: src/asahi/compiler/agx_nir.h, src/asahi/compiler/agx_compile.c, src/asahi/compiler/agx_nir_lower_shared_bitsize.c, src/asahi/compiler/test/test-shared-byte-offsets.cpp
  • Unit tests:
    • SharedByteOffsets.InterleaveDisjointSharedStores: disjoint B-store interleaving ahead of the last A-store, rejection on overlapping shared ranges, non-overtaking guard, and metadata preservation on no-progress.
    • SharedByteOffsets.InterleaveSharedStoresVolatileAndNegativeBase: rejects volatile store_shared and negative base offsets.
    • SharedByteOffsets.InterleaveSharedStoresLoadAgxAndBounds: covers real post-agx_nir_lower_address read-only load_agx (ACCESS_NON_WRITEABLE) and load_constant_agx, rejects writable load_agx, and rejects unbounded indices whose byte_hi >= shared_size.

…up barriers

In tiled compute loops (such as quantized GEMM) that stage an A tile and a
B tile into disjoint regions of threadgroup shared memory before a workgroup
barrier, the B tile global loads and store_shared ops sit at the end of a
long basic block behind the A tile unpack chain.

Add agx_nir_interleave_disjoint_shared_stores(), gated to AGX3B compute
shaders with shared_size > 0, to:
- Scan loop basic blocks up to a workgroup barrier and bail if any
  side-effecting, shared-read/atomic, global-store/atomic, or volatile op
  appears before the barrier.
- Bound each store_shared byte range via conservative unsigned [lo, hi]
  interval analysis (u32_interval) and identify a suffix of B-stores whose
  byte ranges are provably disjoint from all prefix A-stores.
- Move each suffix store and its bounded, movable read-only global-load
  closure (up to 24 instructions) earlier after prefix store anchors, stopping
  immediately on any unmovable suffix store so later suffix stores never
  overtake an earlier suffix store.

Add unit test SharedByteOffsets.InterleaveDisjointSharedStores covering
disjoint interleaving, overlapping shared ranges, and the non-overtaking
guard.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI
IronsideXXVI requested review from a team and DjDeveloperr as code owners December 2, 2026 20:58
Three small fixes to agx_nir_interleave_disjoint_shared_stores():

- store_shared_byte_range() ignored ACCESS_VOLATILE, so a volatile store
  could move past others. Refuse it, as for every other volatile access.
- A negative base wraps byte_lo above byte_hi when the index may be 0,
  and the overlapping range then passes the disjointness test. Refuse it.
- The pass overwrote instr->index with block-local numbers and then
  reported no progress with all metadata preserved, so a valid
  instr_index became wrong (nir_validate asserts). Require the metadata
  instead and invalidate it when instructions move.

Add tests for the three cases.

Signed-off-by: DjDeveloperr <hey@djdev.me>

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

HOLD at dd59e17ad0d2: no hardware row or standalone A/B at the head. No blocking finding left in the code.

I pushed dd59e17ad0d2 on top of your 847e6c66305a (one added commit, nothing rewritten) with three small fixes and tests:

  • a volatile store_shared was still moved (store_shared_byte_range() never looked at ACCESS_VOLATILE);
  • a negative base wraps byte_lo above byte_hi, and the overlapping range then counts as disjoint;
  • the pass wrote block-local numbers into instr->index and then reported no progress with all metadata kept, so nir_validate aborts with instr->index > index when instr_index was valid. It now requires that metadata and drops it when something moves.

The new tests fail on 847e6c66305a and pass now.

Checked and fine

  • Disjointness is tested for every A/B pair at each split, suffix stores keep their order, and a suffix store that cannot move stops the rest. The intervals fall back to the full range on every possible wrap.
  • Reordering two disjoint plain stores of one invocation before the workgroup barrier is allowed; shared loads, shared atomics, memory-only barriers, global stores and textures before the barrier all make the block bail. The moved loads are non-writeable, non-volatile, stay in their block and cross no barrier.
  • The GEMM matcher and the shared vec2/phase passes that run later do not depend on the order of these stores.

Question (not blocking unless it can happen). The range uses base + index * size without a wrap. agx_nir_opt_shared_vec2.c proves its addresses stay inside shared_size before relying on that; here a B store with an unbounded index and a non-zero base still counts as "above" A. Refusing ranges with byte_hi >= shared_size would close it, if it does not stop the q6_K case from firing.

Not blocking

  • By this point agx_nir_lower_address has turned global loads into load_agx/load_constant_agx. load_constant_agx is movable but does not set saw_global_load, so tiles loaded from constant buffers never qualify. The tests use load_global_constant, which the pass will not see in a real compile; a load_agx case with ACCESS_NON_WRITEABLE would cover the real path.
  • AGX3B here is M3, the M4 family and A18 Pro, not only M4. Please widen the Risk line, and say why AGX3C is left out.
  • The limits (24 stores, 5 A stores, nb < na, 24 instructions) need one line each on why. The closure walk could stop at 24 instead of collecting everything first.
  • u32_interval() and u32_upper_bound() in #1559 are the same walk twice; one shared helper would do. The two PRs conflict at the end of test-shared-byte-offsets.cpp.

Performance claim. The tok/s figures are from a combined build, and instruction distance is not speed. This pass exists only for performance and the backend scheduler may reorder around it, so it needs its own base/head A/B on one boot (policy/mesa-performance-claims.md).

Local check. dd59e17ad0d2 merged into the current tip e4346bdb3a55 (tree 73c5a9cfa401), assert-enabled x86-64: asahi, poly and vulkan suites 464 ok, 0 failed, 1 skipped; agx_tests 1973 passed, 1 skipped. (Your head on 3146ce4726a1 gave 463 ok and one borealis-sync-runner failure; that is a host timing flake, three reruns alone passed.)

Rows owed at dd59e17ad0d2

  • J773g (M4, G16G B0) or your J604: llama-bench Q4_K_M and Q6_K pp512/tg32, base vs head ABBA, 0 faults, plus gpubench compute.* with CRC match and dEQP-VK.compute.*shared*, dEQP-VK.memory_model.*workgroup*, 0 regressions. Expect a measurable pp512 gain; at parity there is no reason to carry the pass.
  • J700 (A18 Pro, G17P, also AGX3B): the same CTS subset and gpubench compute.*, no regression. Required as the second generation.
  • M3 (J516s is down): same as J700 when available. Not required.

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

Checked: The exact-head pass remains limited to AGX3B compute. It moves only within the prefix of the first workgroup barrier. Every moved store's byte range is disjoint from the crossed stores, and a rejected suffix store stops later moves. I checked the unsigned interval multiplication and shift against NIR's opcode semantics. The follow-up commit rejects volatile stores and negative bases and preserves valid instruction-index metadata when there is no move. The maintainer reports the new focused cases pass at this head.

Follow-ups: If this grows further, please split the interval analysis from the instruction scheduling so each can be reviewed independently.

…ound closure walk

Follow-up polish on agx_nir_interleave_disjoint_shared_stores():

- Reject store_shared byte ranges with byte_hi >= shader->info.shared_size
  so an unbounded index with a non-zero base cannot wrap and falsely pass
  the disjointness test.
- Recognize nir_intrinsic_load_constant_agx as a global/constant tile load
  for saw_global_load after agx_nir_lower_address.
- Bail early from collect_shared_store_closure() once the 24-instruction
  cap is reached instead of traversing an unbounded dependency DAG first.
- Document the rationale for each heuristic cap (24 stores, split >= 5,
  nb < na, 24 closure instructions).
- Add SharedByteOffsets.InterleaveSharedStoresLoadAgxAndBounds covering
  read-only load_agx / load_constant_agx, writable load_agx rejection, and
  byte_hi >= shared_size rejection.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Author

Thanks for catching and fixing the volatile store, negative-base wrap, and instr_index metadata issues in dd59e17ad0d2!

Pushed forward commit 5517fb46fea on top of dd59e17ad0d2 covering the remaining non-blocking notes:

  • shared_size wrap guard: store_shared_byte_range() now rejects any range with byte_hi >= shader->info.shared_size, matching agx_nir_opt_shared_vec2.c so an unbounded index with a non-zero base cannot wrap and appear disjoint.
  • load_constant_agx + real lowered path test: collect_shared_store_closure() now also counts nir_intrinsic_load_constant_agx toward saw_global_load, and new test SharedByteOffsets.InterleaveSharedStoresLoadAgxAndBounds exercises post-agx_nir_lower_address read-only load_agx (ACCESS_NON_WRITEABLE) + load_constant_agx, writable load_agx rejection, and byte_hi >= shared_size rejection.
  • Closure cap & comments: collect_shared_store_closure() now stops early once 24 instructions have been visited rather than traversing an unbounded DAG first, and each limit (24 stores, split >= 5, nb < na, 24 closure instructions) has a brief rationale comment.
  • PR description: Widened Risk to list AGX3B (M3, M4 family, A18 Pro) and explain why AGX3C (M5) is excluded, removed the combined-build tok/s figure as standalone evidence, and listed the owed standalone J604 / M4 A/B + A18 Pro CTS/gpubench rows in Not yet.
  • Offline verification at 5517fb46fea: libvulkan_asahi.so built cleanly (0 warnings in touched files), agx_tests 1972 passed / 0 failed / 1 skipped (17/17 *Interleave*), meson test -t 4 --suite asahi 398 Ok / 0 Fail / 1 Skipped.
  • Shared helper / agx: fuse disjoint shifted ior and masked shifts into imadshl_agx #1559 conflict: Keeping agx: fuse disjoint shifted ior and masked shifts into imadshl_agx #1559 and agx: interleave provably disjoint shared-memory stores before workgroup barriers #1560 standalone on aurora-wip; whichever lands second will forward-merge to share one interval/upper-bound helper and resolve the test-file conflict cleanly.

@DjDeveloperr

DjDeveloperr commented Dec 3, 2026 •

Copy link
Copy Markdown

J700 (MacBook Neo, A18 Pro, G17P B1): INCOMPLETE. Tested head dd59e17ad0d2, which is no longer the PR head (5517fb46fea2)

The PR moved after this kit was sealed. The result below is for dd59e17ad0d2, so it isn't an exact-head row for the current head.

Stock Fedora 44 kernel 7.3.0-41 (feature word 0x0000007a2001fc06, soft faults off), one boot, userspace only. Base is the merge base with aurora-wip, cb983a61cb14. Nothing was installed.

  • CTS, serial, shader cache off: 9,311 cases, shared memory, memory-model and workgroup-memory groups. Base and head: 4,844 Pass and 4,467 NotSupported, 0 status changes.
  • GPUBench compute.*, 20 configurations in ABBA: base/head time per submit median 1.0000 (0.966 to 1.024), timing for information only. The fixed outputs are CRC-identical on base and head. 76 of 80 runs matched the suite's expected value exactly; the other four are compute.heavy alu runs (two on each build). For that case the suite itself accepts a small tolerance (valid: true), and the eight alu results match the exact value predicted from the shader's rounding on this GPU. Corrected: I first wrote that this case "fails its CRC check on the base", and treated the GPUBench part as incomplete. It doesn't fail: the mismatch is the suite's bit-exact expectation against its own tolerance. No difference between base and head was seen.
  • test-backend-ops MUL_MAT q4_K/q6_K against the CPU: 257 cases, 0 failures on base or head, in default mode and with HK_PERFTEST=norobust.
  • The pass itself isn't exercised in the default configuration here. No shader in these workloads compiles differently on the stock kernel. With HK_PERFTEST=norobust, 1 of 68 MUL_MAT shader parts differs, and the results still match the CPU. That's evidence against a regression, and not proof of the changed path.
  • Health: 0 GPU faults or recoveries, 0 kernel WARNINGs, SLC on, stock handback verified.

Not covered: the current head 5517fb46fea2, and the changed path on a configuration where it runs by default.

@DjDeveloperr DjDeveloperr 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 5517fb46fea2 once the rows below pass. No blocking finding in the new commit.

Checked (what changed since dd59e17ad0d2)

  • byte_hi >= shared_size: shared_size is in bytes and so is the range (base + index * element size). Zero-init, the mesh lowerings and the index-sort pass change it earlier, and they only grow it. The only pass that shrinks it is the GEMM matcher, which runs after this one. Variable workgroup memory lies past shared_size, so it is refused, and with a variable workgroup size the invocation ids have no bound, so those blocks bail. The check can only refuse more than before.
  • Early bail at 24: same limit as before (the 25th instruction refuses). Nothing is moved until the whole closure is collected, so no half-moved closure is possible. Stores moved by earlier rounds stay valid and progress is still reported.
  • load_constant_agx / load_agx: load_constant_agx was already movable (reorderable in NIR) and now also counts as the tile load. load_agx still needs non-writeable and non-volatile. Loads only move up inside one block before the barrier, and any global store, atomic, shared load or other barrier there makes the block bail, so no aliasing write is crossed.
  • Tests: the new test fails with the bound removed and with the load_constant_agx line removed. The cap changes no result, so it has no test.

Local check: merge with aurora-wip e4346bdb3a55 (tree 7e3543b88540), asserts on, x86-64: asahi, poly and vulkan suites 463 ok, 0 failed, 1 skipped, 1 timeout (borealis-sync-runner on a loaded host; 3 of 3 alone passed). agx_tests 1974 passed, 1 skipped; *Interleave* 17/17, with *SharedByteOffsets* 58/58. It also merges cleanly with 4f2853ac8250.

Generated code, dd59e17ad0d2 against 5517fb46fea2: identical, every packed compute part, offline on the drm-shim (nothing executes there).

Set G16G G17P G15S
llama.cpp MUL_MAT q4_K/q6_K, soft faults on 70 70 35
same, soft faults off 70 70
same, off and norobust 68
llama-bench, TinyLlama Q4_K_M 40 40
GTA V compute pipelines 481 481 242

The exact head also gives the same MUL_MAT code as the J700 kit's own dd59e17ad0d2 dump, in all three modes. This is not an empty result: with the pass removed, 1 MUL_MAT part differs on G16G (both modes) and G17P (soft faults on, and norobust), and 2 llama-bench parts differ on both chips. GTA V and G15S MUL_MAT never use the pass.

So the J700 MUL_MAT result at dd59e17ad0d2, including the norobust runs of the changed shader, carries over to this head. CTS and gpubench shaders were not in this compare.

Rows left

  • J773g (or your J604) at 5517fb46fea2: llama-bench Q4_K_M and Q6_K pp512/tg32, base/head ABBA, 0 faults, and a measurable gain; gpubench compute.* with CRC match; dEQP-VK.compute.*shared* and dEQP-VK.memory_model.*workgroup*.
  • J700: only the code-hash step at 5517fb46fea2 over the same CTS and gpubench lists. If the hashes equal the recorded ones, the 9,311 CTS cases and the gpubench runs at dd59e17ad0d2 count. If not, rerun those lists.
  • M3: optional.

Nit: the > 24 test after the walk can no longer be true.

@DjDeveloperr

Copy link
Copy Markdown

J700 (MacBook Neo, A18 Pro, G17P B1): code-hash probe at 5517fb46fea2: IDENTICAL to the tested dd59e17ad0d2

The earlier J700 row ran at dd59e17ad0d2 (comment 7363281541). This checks whether the commit on top of it, 5517fb46fea2 (agx_nir_lower_shared_bitsize.c +19 −1, plus tests), changes any of the code that row compiled. Same stock kernel 7.3.0-41, zero reboot, shader disk cache off. Both ICDs are cross-builds with identical options, and dd59e17ad0d2 was rebuilt byte-identical to the one in the row.

Final packed code was read from Mesa's own dump (AGX_MESA_DEBUG=binaries) and compared for every shader part:

Set dd59e17ad0d2 5517fb46fea2 Differences
CTS list of the earlier row (9,311 cases; 4,844 compile at least one shader) 18,930 parts, 1,624 distinct 18,930 parts, 1,624 distinct 0
GPUBench, 20 configurations 58 parts 58 parts 0

0 GPU faults or recoveries, 0 kernel WARNINGs, SLC on, stock handback verified.

So the earlier J700 CTS (9,311 cases, 0 status changes) and GPUBench results apply to 5517fb46fea2, on the same configuration and case lists. That matches the review's check on the shaders it looked at.

Not covered: the run-time internal shaders the driver builds itself aren't in that dump, so they aren't compared. On this stock kernel the pass isn't exercised by default (see the earlier comment), so this is a no-regression result and not proof of the changed path.

@DjDeveloperr

Copy link
Copy Markdown

J773g (Apple M4, T8132, G16G B0 / AGX3B, stock 7.3.0-ARCH-m4main-6c83a2a6, boot_id=bc9fa24e-37f4-4fa0-b91d-31ed138b3356, zero-reboot userspace ICD swap, MESA_SHADER_CACHE_DISABLE=true) exact-head A/B at 5517fb46fea29f9ba544b53bf5836705fe5afd45 (libvulkan_honeykrisp.so SHA-256 48ccba36e50b...) vs base e4346bdb3a55 (9f4bf4859ffb...):

Verdict: correctness PASS, standalone perf gate NOT MET (no measurable gain).

  • Loader verification (LD_DEBUG=libs vulkaninfo --summary): both arms verified calling init: on their respective libvulkan_honeykrisp.so, Apple M4 (G16G B0), Borealis.
  • Correctness:
    • test-backend-ops test -o MUL_MAT -p 'type_a=(q4_K|q6_K),' -b Vulkan0: 192/192 passed on both arms. AGX_MESA_DEBUG=shaderdb shows 1/35 shaders changed (11736 -> 11740 instrs, 191 gprs, 512 threads).
    • detlogits ABBA (NGEN=64, tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf): all 4 slots bit-exact identical (cmp 0 diffs, SHA-256 5e211a7ac5c34d9ac220db6cd4522441ab5092f008efa34077c6123fdea644cc).
    • Vulkan CTS (dEQP-VK.compute.*shared* + dEQP-VK.memory_model.*workgroup*, 9,311 cases): 4,844 Pass / 4,467 NotSupported / 0 Fail on both arms, 0 status diffs.
    • gpubench-vk (compute.*, 20 configs / 40 series, ABBA --warmup-ms 200 --runs 3 --run-ms 150 --timestamps off --verify): 40/40 valid: true, all 37 deterministic-CRC series identical across arms (compute.light submit-count-seeded CRCs match expected), median us_per_submit delta range -1.73% (edge_sobel d=4) to +2.14% (fp16_gemv d=4).
    • Kernel faults/warnings (dmesg delta): 0 (F0=2 -> F1=2).
  • Performance (ABBA, standalone):
    • llama-bench (tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf, -ngl 99 -p 512 -n 128 -r 10, base / head / head / base):
      • pp512: base 1229.70 ± 4.57 / 1231.39 ± 5.49 (mean 1230.55 t/s) vs head 1227.56 ± 6.16 / 1223.60 ± 5.66 (mean 1225.58 t/s, -0.40%)
      • tg128: base 113.92 ± 0.41 / 114.04 ± 0.36 (mean 113.98 t/s) vs head 114.08 ± 0.44 / 113.99 ± 0.54 (mean 114.04 t/s, +0.05%)
    • test-backend-ops perf -o MUL_MAT -p 'type_a=q6_K,' -b Vulkan0 (ABBA, 7 shapes m=4096, k=14336, n=1..8,512): median delta -0.11% (range -1.04% at n=1 442.2 -> 437.6 us to +0.13% at n=3 1601.0 -> 1603.1 us; n=512 -0.43% 25471.8 -> 25363.4 us).

Note: no standalone Q6_K GGUF was staged on J773g, so Q6_K was measured directly via test-backend-ops perf (q6_K shapes) alongside tinyllama Q4_K_M llama-bench; neither shows a measurable standalone gain.

@DjDeveloperr

Copy link
Copy Markdown

Where this stands at 5517fb46fea2: it is correct on both Macs (J773g: 192/192 MUL_MAT, bit-exact logits, CTS 0 diffs; J700: identical code, 0 diffs), but J773g shows no gain (pp512 -0.40 %, tg128 +0.05 %, direct q6_K MUL_MAT -0.11 %), and the J604 numbers came from a combined build. J604 is the same T8132, so I am not merging it on those numbers even though GitHub allows it.

To land it, please post a standalone J604 ABBA at this exact head (Q6_K pp512/tg32, base against head, one boot) that shows a gain outside noise, or show that it pays only together with #1559 or #1498 and fold it in there. Without either by 2026-12-05 I suggest closing it.

…-shared-stores

Resolve the adjacent end-of-file test addition in
src/asahi/compiler/test/test-shared-byte-offsets.cpp after PR #1559
merged into aurora-wip, keeping both test suites intact.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Author

Forward-merged aurora-wip (4238a66de55, including merged #1559) at 33be469f2dae (no force-push) to resolve the end-of-file test append conflict in src/asahi/compiler/test/test-shared-byte-offsets.cpp. The compiler diff (agx_compile.c, agx_nir.h, agx_nir_lower_shared_bitsize.c) is unchanged.

Verified offline at 33be469f2dae:

  • agx_tests --gtest_filter="SharedByteOffsets.*": 49/49 passed (0 failed).

Standalone J604 A/B numbers on top of current aurora-wip remain queued and will be posted once captured.

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

Reviewed 33be469f2dae. Its parents are the previously approved 5517fb46fea2 and 4238a66de5585. The same four files have identical added and removed lines against their respective bases. The base merge preserves the shared-store pass and tests.

The measured performance gate is still open. The standalone J773g run showed no gain. A J604 base/head ABBA showing a gain outside run-to-run variance, or evidence that the pass pays in a combined change, remains the next step.

@github-actions github-actions Bot added area:compiler Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) labels Dec 3, 2026
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at 6e2ed418: not ready yet

Check Detail
CI at head ok no CI for this change (the hardware row is the gate)
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head no no line with the head SHA 6e2ed418, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · AGX3B compute compiler only (M3, M4 family, and A18 Pro) — strictly gated to isagx3b && mesashaderstageiscompute && sharedsize > 0. AGX3C (M5) is intentionally left out because it uses a separate backend/scheduling profile and has not been benchmarked with this pass. Only moves non-volatile storeshared ops with non-negative base whose [bytelo, bytehi] intervals stay inside sharedsize and are provably disjoint from all prefix storeshared ops, only moves read-only non-volatile load closures inside the same basic block before a workgroup barrier, bails on any side-effecting op before the barrier, and preserves relative suffix store ordering.

Areas: area:compiler

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@DjDeveloperr

Copy link
Copy Markdown

J516s (MacBook Pro M3 Pro, G15S) CTS row at 33be469f2dae: PASS

Both arms ran on one boot, with no reboot and userspace only. Base = aurora-wip 482df38c3395. Head = a local merge 7c537c3fad28 of 33be469f2dae into that tip (tree f3215f5bc6f5, not pushed). Kernel 7.3.0-j516s-tip35ddf947 (has linux#4198), boot ae743f31, feature word 0x81026001dc07, 04:52-04:58Z.

  • 54,362 cases per arm, ABBA batches. That is the J516s wide, extra and sample lists, plus all 9,311 cases of this PR's own lists (compute.*shared*, memory_model.*workgroup*, memory_model.shared.*, workgroup_memory_explicit_layout, zero_initialize_workgroup_memory). Base and head: 27,437 Pass, 26,925 NotSupported, 0 Fail, 0 crash. 0 cases differ.
  • Refused or failed pipelines: 0 on base, 0 on head. GPU fault or reset lines: 0. Every process mapped only its own arm's library (base 75a36bcc…, head bf29a6c3…).

Offline checks (pc, x86-64, asserts on)

  • The PR merges cleanly into 482df38c3395 and into the current tip 5ea0fccfdcfc (agx_compile.c 3-way, no conflict). On both tips the asahi and vulkan suites give 468 ok, 0 failed, 1 skipped on base and merge. agx_tests: 2,019 passed, 1 skipped (base 2,016). *Interleave* 17/17, SharedByteOffsets.* 49/49.
  • drm-shim compile diff on G16G with J773g's feature word, on both tips: 24,190 cases (the 15,641-case wide slice plus the 9,311 above). 0 cases with changed code, 0 refusals, 0 failed compiles, 0 status changes. 13 glsl.conditionals.if cases can't run on the x86 CTS build.
  • GTA V Fossilize DB on G15S, G16G, G17P and G17S: same code for every executable. llama.cpp f0c9c91f ggml pipelines (1,110 executables) on G15S with J516s's word, and on G16G with and without soft faults: same code.
  • So this row shows no regression on J516s. It does not exercise the changed path: offline, the pass changed none of the shaders above. The changed path did run on J773g and J700 at 5517fb46fea2, which has the same compiler code as this head, and MUL_MAT and the logits were correct there.

The reordering. Each store's byte range comes from an unsigned interval that covers every invocation and every loop iteration. Unknown values give the full range, and a range that reaches shared_size is refused. So no byte can be written by both an A store and a B store, even from different invocations. Before the barrier the moved stores cross only plain shared stores, ALU ops and read-only loads. Any shared load, atomic, global store, volatile access or narrower barrier makes the block bail. I found no case where moved stores can alias.

This row does not measure performance.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Dec 4, 2026
…-shared-stores

Resolve the adjacent end-of-file test addition in
src/asahi/compiler/test/test-shared-byte-offsets.cpp after PR #1626
merged into aurora-wip, keeping both test suites intact. The compiler
diff against aurora-wip is unchanged.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Author

Forward-merged aurora-wip (9b13a91203e, including merged #1626) at a3a44c072319 (no force-push) to resolve the adjacent end-of-file test append conflict in src/asahi/compiler/test/test-shared-byte-offsets.cpp, keeping both #1626's hoisted-offset tests and this PR's shared-store interleave tests intact.

The 4-file diff against aurora-wip (agx_compile.c, agx_nir.h, agx_nir_lower_shared_bitsize.c, test-shared-byte-offsets.cpp, +782 lines) has identical added/removed lines to approved 33be469f2dae.

Verified offline at exact head a3a44c072319 (GCC 16.1.1 ARM64, asserts enabled, 0 compiler warnings in touched files):

  • agx_tests --gtest_filter="SharedByteOffsets.*": 51/51 passed (0 failed).
  • Full agx_tests: 2,021 passed, 1 skipped, 0 failed (2,022 total).

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 4, 2026
…-shared-stores

Resolve the adjacent end-of-file test addition in
src/asahi/compiler/test/test-shared-byte-offsets.cpp after PR #1629
merged into aurora-wip, keeping both test suites intact. The compiler
diff against aurora-wip is unchanged.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Author

Forward-merged aurora-wip (c3fd4e7df6c4, including merged #1629) at 6e2ed418a08a (no force-push) to resolve the adjacent end-of-file test append conflict in src/asahi/compiler/test/test-shared-byte-offsets.cpp, keeping both #1629's byte-to-float/normflt tests and this PR's shared-store interleave tests intact.

The 4-file diff against aurora-wip (agx_compile.c, agx_nir.h, agx_nir_lower_shared_bitsize.c, test-shared-byte-offsets.cpp, +782 lines) has identical added/removed lines to approved 33be469f2dae.

Verified offline at exact head 6e2ed418a08a (GCC 16.1.1 ARM64, asserts enabled, 0 compiler warnings in touched files):

  • agx_tests --gtest_filter="SharedByteOffsets.*": 53/53 passed (0 failed).
  • Full agx_tests: 2,023 passed, 1 skipped, 0 failed (2,024 total).

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Dec 4, 2026

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

The forward merge retains both sets of unit tests. The added and removed lines in all four files match the previously reviewed change. The pass keeps the relative order of potentially overlapping stores and stops at the barrier. On aurora-wip 0b69db0 plus this head, agx_tests passed 2,023 cases with one skip. The standalone J773g comparison showed no gain. Please post the J604 ABBA result against current aurora-wip, or a combined comparison that isolates this pass's contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:compiler Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants