Skip to content

borealis: enable ordered tile reduction pass on AGX3B - #1573

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/hk-agx3b-ordered-tile-reduction
Dec 3, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:aurora-wipfrom
AxxzyWasTaken:pr/hk-agx3b-ordered-tile-reduction

Conversation

@AxxzyWasTaken

Copy link
Copy Markdown

Summary

Extends the hk_nir_opt_ordered_tile_reduction() gate in hk_preprocess_nir_internal() from AGX_ISA_ENCODING_AGX3C to both AGX_ISA_ENCODING_AGX3B (M3 G15G/S/C, M4 G16G/S/C, M4 Max G17P) and AGX_ISA_ENCODING_AGX3C.

Every native AGX3B chip exposes 32-wide subgroups and encodes immediate-lane simdbfly shuffle_xor natively in compute shaders (agx_nir_lower_subgroups.c / agx_compile.c), and the pass only emits constant shuffle distances (16/8/4/2/1) with an explicit 16x16 → 32x8 workgroup remap.

Verification

  • Unit tests (host): hk_ordered_tile_reduction, hk_compute_pair, hk_pack, and agx_tests all PASS.
  • Multi-chip compile check (drm-shim, MESA_SHADER_CACHE_DISABLE=true):
    • g15g, g16g, g17p, g17s all lower the 16×16 ordered min/max/sum tile reduction cleanly (87–89 instrs, ~854 B, 1024 threads, 0 spills).
  • Apple M4 Max (G17P) hardware A/B (2048×2048 R32_UINT → 128×128 RGBA32F 16×16 ordered min/max/sum tile reduction, 40 batched dispatches × 7 runs):
    • Shader: 142 → 87 instrs (-38.7%), 166 → 97 native (-41.6%), 1764 → 850 code bytes (-51.8%), 1024 threads preserved, 0 spills
    • GPU dispatch median: 103.35 µs → 40.67 µs (2.54× faster, bit-exact readback hash ecf8005493440c25)
    • Note on test coverage: Hardware-executed on M4 Max (G17P); M3 (g15g) and M4 (g16g) compile-verified via drm-shim.

All native AGX3B chips (M3 G15G/S/C, M4 G16G/S/C, M4 Max G17P) expose
32-wide subgroups and encode immediate-lane simdbfly shuffle_xor natively
in compute shaders, just like AGX3C.

Extend the hk_nir_opt_ordered_tile_reduction() gate in
hk_preprocess_nir_internal() from AGX3C-only to both AGX3B and AGX3C,
allowing 16x16 shared-memory tile reductions (texelFetch -> 8-stage
ordered min/max/sum -> imageStore) to lower into 32x8 subgroup shuffles
with 1 barrier instead of 8 and 384 B of shared memory instead of 3072 B.

Measured on Apple M4 Max (G17P) with a 2048x2048 R32_UINT -> 128x128
RGBA32F 16x16 ordered tile reduction (40 batched dispatches, 7 runs):
- Shader: 142 -> 87 instrs, 166 -> 97 native, 1764 -> 850 code bytes,
  1024 threads preserved, 0 spills.
- GPU time: 103.35 us -> 40.67 us median (2.54x faster, bit-exact hash
  ecf8005493440c25).
- Compile smoke-checked via drm-shim on g15g, g16g, g17p, and g17s
  (88-89 instrs, ~854 B, 1024 threads).

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken
AxxzyWasTaken requested review from a team and DjDeveloperr as code owners December 3, 2026 06:46

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

The change enables the existing ordered reduction only for AGX3B chips that still pass all three 32-wide subgroup checks. The constant XOR shuffle form is available on these targets. The M4 Max row reports a bit-exact result and lower dispatch time, with M3 and M4 additionally covered by compile checks.

@DjDeveloperr

Copy link
Copy Markdown

We run the pass at 7990c2bb323c on J773g (M4, G16G), J516s (M3 Pro, G15S) and J700 (A18 Pro, G17P): every texel against a CPU reference, plus the subgroup shuffle and compute CTS lists against base. #1374 kept the pass off on these chips, so these are its first hardware runs on G15 and G16.

@DjDeveloperr

Copy link
Copy Markdown

J516s (Apple MacBook Pro 16-inch M3 Pro, T6030, G15S B1, os-fw 27.2, kernel 7.3.0-m3-s2r-gcff875630c61, boot 0aa5973b-fc6b-47d3-a892-885df32b9f02, headless) hardware row for 7990c2bb323c (merged onto b1f845424656, head commit 8de3ec80c7d4, tree 39d48c34d2b5 vs base b1f845424656, tree 3c8d5d76c284): VERDICT PASS.

Results

  • otr correctness (ABBA: base, head, head, base): 4/4 rc=0, CHECKED 3003372 texels, 0 bad | VERDICT PASS (180 combinations per run).
  • Pipeline statistics (VK_KHR_pipeline_executable_properties):
    • match: Instructions 148 -> 101, Code size 1798 -> 1072, Native instructions 173 -> 112, Threads 1024, Spills 0 (pass active: yes)
    • near_xor: unchanged (148 instructions, 1798 B, 173 native instructions on both arms)
    • near_rev: unchanged (148 instructions, 1798 B, 173 native instructions on both arms)
  • Dispatch timing (match, 3024x1964, 21 bursts × 40 dispatches):
    • base median: 368.91 us / 354.90 us
    • head median: 299.76 us / 300.07 us
    • head/base: 0.829 (-17.1%)
  • CTS (deqp-vk, caselist.txt):
    • base: 16875/16875 in 81 s (8590 Pass, 8285 NotSupported, 0 fail)
    • head: 16875/16875 in 79 s (8590 Pass, 8285 NotSupported, 0 fail)
    • cts differences: 0
  • Kernel log (kfaults): 0 new GPU-side lines, 0 driver warnings across the run (window 24 kernel lines; pattern A 0, driver warnings B 0; GPU-side 0).

@DjDeveloperr

Copy link
Copy Markdown

Hardware verification on J773g (Apple Mac mini M4, T8132, G16G B0, os-fw 27.2 / 26B123) using mesa1573-kit-20261203: VERDICT PASS.

Environment & Arms

  • Kernel: 7.3.0-j773g-s2r4007a+ (boot_id=0e47e587-c53c-4f3f-a7a7-8b41c667cc62; main cff875630c61 + non-GPU #4007/#4031, zero GPU diff from main)
  • base: b1f845424656 (tree 3c8d5d76c284015dbdc970061f675bf1000f1844, libvulkan_asahi.so sha256: 0f88b2f3c46f03786252fd813bc7d78d39a6048533eae059c4f523a5702dc295)
  • head: 8de3ec80c7d4 (clean merge of PR head 7990c2bb323c onto b1f845424656, tree 39d48c34d2b51ec0c8038e424be6a269f5a0880a, libvulkan_asahi.so sha256: 7997dc56fa8d941e4004e78cd462580b6d8dbaa70e7a2b969e3c1618bf6e94f4)

Key Results

  • Correctness (bin/otr ABBA: base, head, head, base): 4/4 runs rc=0, CHECKED 3003372 texels, 0 bad | VERDICT PASS (180 combinations each).
  • Pipeline stats (pass active: yes):
    • match: Instructions 148 -> 101, Native instructions 173 -> 112, Code size 1798 -> 1072, Threads 1024, Spills 0.
    • near_xor & near_rev: unchanged (148 instructions, 173 native, 1798 bytes).
  • Dispatch timing (match 3024×1964 median): base 477.52 / 476.85 µs → head 206.63 / 207.02 µs (head/base = 0.433, 2.31× faster / -56.7%).
  • Vulkan CTS (16,875 cases per arm): base 8,590 Pass / 8,285 NotSupported (74 s), head 8,590 Pass / 8,285 NotSupported (75 s), cts differences: 0.
  • Kernel faults (kfaults.sh): window 56 kernel lines; pattern A 0, driver warnings B 0; GPU-side 0, excluded 0, other 0.
Full out/summary.txt
kernel 7.3.0-j773g-s2r4007a+ boot 0e47e587-c53c-4f3f-a7a7-8b41c667cc62 model Apple Mac mini (M4, 2024)
base b1f845424656 tree 3c8d5d76c284; head 8de3ec80c7d4 tree 39d48c34d2b5
otr 1 base rc=0 CHECKED 3003372 texels, 0 bad | VERDICT PASS
  DEVICE Apple M4 (G16G B0) | Borealis | Mesa 26.3.0-devel (git-b1f8454246), Borealis, derived from Honeykrisp | subgroup 32
  match: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=477.52 min_us=477.33 max_us=478.05
  near_xor: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=477.47 min_us=477.20 max_us=477.93
  near_rev: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=473.61 min_us=473.49 max_us=473.91
otr 2 head rc=0 CHECKED 3003372 texels, 0 bad | VERDICT PASS
  match: Instructions = 101 Code size = 1072 Threads = 1024 Spills = 0 Native instructions = 112 | median_us=206.63 min_us=206.29 max_us=206.84
  near_xor: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=476.75 min_us=476.52 max_us=477.02
  near_rev: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=476.86 min_us=476.73 max_us=477.27
otr 3 head rc=0 CHECKED 3003372 texels, 0 bad | VERDICT PASS
  match: Instructions = 101 Code size = 1072 Threads = 1024 Spills = 0 Native instructions = 112 | median_us=207.02 min_us=206.66 max_us=207.48
  near_xor: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=476.82 min_us=476.48 max_us=477.07
  near_rev: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=476.86 min_us=476.77 max_us=477.17
otr 4 base rc=0 CHECKED 3003372 texels, 0 bad | VERDICT PASS
  match: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=476.85 min_us=476.71 max_us=477.38
  near_xor: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=476.82 min_us=476.69 max_us=477.43
  near_rev: Instructions = 148 Code size = 1798 Threads = 1024 Spills = 0 Native instructions = 173 | median_us=472.99 min_us=472.87 max_us=473.35
match instructions: base 148 head 101
pass active: yes
near_xor: unchanged
near_rev: unchanged
match 3024x1964 median us: base 477.52 / 476.85, head 206.63 / 207.02
match head/base time: 0.433
cts base: 16875 of 16875 in 74 s: 8285 NotSupported 8590 Pass
cts head: 16875 of 16875 in 75 s: 8285 NotSupported 8590 Pass
cts differences: 0
kfaults: window 56 kernel lines; pattern A 0, driver warnings B 0; GPU-side 0, excluded 0, other 0
VERDICT PASS

@DjDeveloperr

Copy link
Copy Markdown

J700 (MacBook Neo, A18 Pro, G17P B1) at PR head 7990c2bb323c: PASS

Stock 7.3.0-41.fc44.aurora, userspace only, zero reboot. Base = aurora-wip tip b1f845424656, head = a clean local merge of 7990c2bb323c into that tip (8de3ec80c7d4, tree 39d48c34d2b5). Drivers loaded per process; each run checked that it loaded its own.

Check Result
The program, base, head, head, base: 180 combinations each (5 sizes, 4 inputs, 3 shaders, 3 dispatch kinds), 3 times each, every texel against a CPU reference with a guard row and column PASS in all 4 runs, 3,003,372 texels checked per run, 0 bad
Pass active on G17P yes. The matching shader drops from 148 to 101 instructions (173 to 112 native), code size 1,798 to 1,072 bytes, threads and spills unchanged
The two near misses (near_xor, near_rev) unchanged between base and head
Time of the matching dispatch at 3024×1964, median 1,018.7 µs to 428.8 µs (0.421×, 2.4× faster), both head runs agree to 0.1 µs and both base runs to 0.1 µs
CTS, 16,875 cases (subgroups and compute), base and head 16,875 of 16,875 recorded on both, 11,054 Pass, 5,821 NotSupported on both, 0 differences
GPU lines in the kernel log during the run 0

Not covered: one J700, one boot, the CTS list is the kit's. The near misses differ between repeats by up to 0.8 % (near_rev 1,010.5 µs on the two base runs, 1,018.7 µs on the head runs), which is a timing spread, not a shader change.

@DjDeveloperr
DjDeveloperr merged commit f4a7491 into aurora-silicon:aurora-wip Dec 3, 2026
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.

3 participants