Skip to content

asahi/compiler: widen AGX3B compute device-load ILP window to {8, 6, 4, 2, 1} - #817

Closed
DjDeveloperr wants to merge 1 commit into
perf/agx3b-wave8-loop-rotate-unswitchfrom
perf/agx3b-wave9-load-ilp-window
Closed

DjDeveloperr wants to merge 1 commit into
perf/agx3b-wave8-loop-rotate-unswitchfrom
perf/agx3b-wave9-load-ilp-window

Conversation

@DjDeveloperr

Copy link
Copy Markdown

Stacked on #805 (perf/agx3b-wave8-loop-rotate-unswitch).

Summary

  • src/asahi/compiler/agx_pressure_schedule.c: Widen the AGX3B compute device-load ILP hoist window from {4, 2, 1} to {8, 6, 4, 2, 1} while keeping M5 (AGX3C) on {4, 2, 1}.
    • Unrolled 8-tap vertical filters, depthwise convolutions, and FAST feature extractors on AGX3B sit inside the 1024-thread occupancy tier with 21–63 halves of register headroom, yet {4, 2, 1} left the second half of loads interleaved behind the first consumers.
    • Candidate hoisting remains strictly bounded by the existing occupancy-step register cap and scoreboard waits, falling back cleanly (8 -> 6 -> 4 -> 2 -> 1) on high-pressure blocks.
  • src/asahi/compiler/test/test-agx3-vision-opts.cpp: Add AGX3VisionOpts.Agx3bComputeDeviceLoadIlpWideWindow verifying 8-load hoisting with headroom on AGX3B, high-pressure fallback (extra_live_32 = 45 -> 1 hoisted load), and unchanged {4, 2, 1} behavior on AGX3C (M5).

4-Chip Offline Shader-DB (80-SPV Compute Corpus, e5f03d1f7f44 vs #805 4afdcb486266)

Chip Changed Instrs GPRs Threads Spills
G15G (M3) 13 / 80 0 +94 0 (all 1024 -> 1024) 0
G16G (M4) 13 / 80 0 +94 0 (all 1024 -> 1024) 0
G17P (A18 Pro) 13 / 80 0 +90 0 (all 1024 -> 1024) 0
G17S (M5) 0 / 80 0 0 0 0

Selected G17P GPR changes (all staying at 1024 threads, 0 spills): 1cf53d30 (55 -> 63), gauss-v / 22a1d0a2 (55 -> 61), face-depthwise / 720b8163 (33 -> 41), e8b3e690 (67 -> 71), 323926dd (49 -> 59).

Verification

  • Assert CI (fedora-mesaci, exact head e5f03d1f7f44d30b5e10e76781625b955fa3e83a): 146/0 PASS (0 failures, 0 skipped).
  • Local -Db_ndebug=false unit tests (meson test --suite asahi --suite poly): 170/170 PASS.
  • Hardware ABBA on MacBook Neo (G17P, e5f03d1f7f44 vs agx: rotate binary-tail unrolled loops, elide dominated guards, and unswitch single-arm loop ifs #805 4afdcb486266, w2 -> v1 -> v1 -> w2, FAULTS_DELTA=0, AVC_DELTA=0):
    • Geekbench 6.7.1 Vulkan (busy/iter median):
      • Feature Matching: 33.94 -> 33.63 ms (+0.9%, 73.5% -> 74.2% Metal; passes 33.98 / 33.54 / 33.73 / 33.89 ms; vertical filter 1cf53d30 9.18 -> 8.79 ms, -4.2%)
      • Stereo Matching: 11.77 -> 11.71 ms (+0.5%, 118.4% -> 118.9% Metal; passes 11.77 / 11.70 / 11.73 / 11.77 ms)
      • Background Blur: 23.45 -> 23.38 ms (+0.3%, 71.3% -> 71.5% Metal; passes 23.44 / 23.39 / 23.38 / 23.45 ms; face-depthwise 1.605 -> 1.586 ms, -1.2%)
      • Gaussian Blur: 36.10 -> 36.01 ms (+0.2%, 46.1% -> 46.2% Metal)
      • Horizon Detection: 26.43 -> 26.39 ms (+0.2%, 94.0% -> 94.2% Metal)
      • Edge Detection: 20.07 -> 20.05 ms (+0.1%, 104.2% -> 104.3% Metal)
      • Face Detection: 36.19 -> 36.17 ms (+0.1%)
    • gpubench-vk ABBA (16/16 CRC_OK):
      • compute.uber d1 (kind=ilp): 583.26 -> 494.61 us (+17.9%; passes 583.35 / 494.71 / 494.52 / 583.17 us)
      • compute.uber d4 (kind=ilp): 581.44 -> 494.56 us (+17.6%; passes 581.38 / 494.29 / 494.83 / 581.50 us)
      • Remaining gpubench-vk compute kernels (conv2d, edge, stereo, uber_div, uber_uni) have <= 1 device_load per block (unchanged ISA; identical warm-pass gpu_us).
    • Vulkan CTS (G17P, exact head e5f03d1f7f44): integer_builtins, subgroups_compute, glsl_loops (624/624), ssbo_std430 (4/4), compute_basic (79/79, 2 NS), robustness2 (12 NS) — 0 failures.

Assisted-by: LLM (Antigravity:Gemini 4 Neon)

…4, 2, 1}

AGX3B compute kernels such as unrolled 8-tap vertical filters and FAST
feature extractors have 21-63 halves of register headroom inside the
1024-thread occupancy tier, yet the shared {4, 2, 1} load-hoist window
left their second half of loads interleaved behind the first consumers.

Try {8, 6, 4, 2, 1} on AGX3B compute while keeping M5 (AGX3C) on
{4, 2, 1}, still bounded strictly by the existing occupancy-step
register cap and falling back cleanly on high-pressure shaders.

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

Copy link
Copy Markdown
Author

G17S B1 (Apple M5 Pro / m5-ssd) Exact-Head Cross-Verification

  • Hardware / Kernel: Apple M5 Pro (G17S B1), Linux 7.3.0-m5-cdirect2 (+ 16-plane SLC)
  • Environment: MESA_SHADER_CACHE_DISABLE=1, no ASAHI_M5_BRINGUP
  • HEAD SHA: e5f03d1f7f44 (G17S no-op non-regression check)
  • ICD: Mesa 26.3.0-devel (git-e5f03d1f7f), Borealis, derived from Honeykrisp (prebuilt ARM64 tarball mesa-wave9a-e5f03d1f.tar.zst)
  • Targeted VK CTS (compute.pipeline.basic.*, ssbo.layout.single_basic_type.std430.*, image.load_store.with_format.*, subgroups.basic.compute.*, glsl.loops.generic.*): 314/365 passed (0 failed, 51 not supported)
  • Smoke (gpubench-vk compute.edge): PASS, CRC 27c79e6d valid (260.4 us d1 / 146.7 us d4)
  • Kernel GPU faults: 0 (dmesg delta 0)

@DjDeveloperr

Copy link
Copy Markdown
Author

M4 Hardware Verification (G16G B0) — Exact Head e5f03d1f7f44d30b5e10e76781625b955fa3e83a

  • Hardware / Env: Apple M4 Mac mini (J773g / T8132, Apple M4 (G16G B0)), kernel 7.3.0-ARCH-m4prod23.
  • Kit verified: Mesa 26.3.0-devel (git-e5f03d1f7f), Borealis, derived from Honeykrisp vs #805 base (4afdcb4862, Mesa 26.3.0-devel (git-4afdcb4862), Borealis, derived from Honeykrisp).

Targeted Single-Threaded dEQP-VK CTS (700/810 PASS, 110 NotSupported, 0 FAIL, dmesg_delta=+0)

  • glsl_loops: 250/250 PASS (0 NS, 0 FAIL)
  • ssbo_layout_store: 249/250 PASS (1 NS, 0 FAIL)
  • storage_8bit: 29/29 PASS (0 NS, 0 FAIL)
  • subgroups_compute: 93/200 PASS (107 NS, 0 FAIL)
  • compute_basic: 79/81 PASS (2 NS, 0 FAIL)

Symmetric ABBA gpubench-vk (#805 4afdcb4862 vs #817 e5f03d1f7f, 14 cases, 48/48 CRCs bit-exact)

  • compute.uber(kind=ilp):
    • d=1: 615.5 → 563.4 us sub (1.09×, -8.5%) / 384.1 → 327.1 us GPU (1.17×, -14.8%), CRC 19f35e30 OK
    • d=4: 390.6 → 333.6 us sub (1.17×, -14.6%) / 387.8 → 330.6 us GPU (1.17×, -14.7%), CRC 19f35e30 OK
  • Other compute benches (1.00–1.01× parity on clean legs):
    • compute.conv2d (d=1/4): GPU 908.4 → 906.9 us (1.00×), 910.2 → 910.8 us (1.00×), CRC 2d55a14d OK
    • compute.edge (d=1/4): GPU 512.9 → 511.9 us (1.00×), 518.2 → 517.0 us (1.00×), CRC 27c79e6d OK
    • compute.heavy (d=1/4): GPU 544.3 → 544.3 us (1.00×), 544.3 → 544.3 us (1.00×)
    • compute.stereo (d=1/4): sub 18181.8 → 18181.8 us (1.00×), GPU 18717.8 → 18810.4 us (1.00×) / 18722.0 → 18808.7 us (1.00×), CRC c62aadf9 OK
    • compute.cull_mdi d=1: sub 2484.6 → 2469.1 us (1.01×), GPU 1271.9 → 1268.3 us (1.00×), CRC 57276de2 OK
    • compute.uber d=4: sub 505.1 → 504.4 us (1.00×), GPU 502.2 → 502.2 us (1.00×), CRC 9963f56c OK
    • Thermal note: 4 transient M4 cooling: ENODATA -> S1..S10 backstop steps on m4prod23 (49 routine cooling lines in dmesg, 0 GPU/DRM errors) overlapped leg B2 of compute.uber d=1 (A1=724.6/500.2, B1=727.3/500.0, A2=727.3/500.0 exact 1.00× parity vs B2=1105.0/589.1, CRC 9963f56c OK) and compute.cull_mdi d=4 (A1=2247.2/1446.1, A2=2272.7/1445.5 vs B1=2439.0/1507.4, B2=2702.7/1510.5, CRC 57276de2 OK).

Health

  • FULL_BOOT_KERNEL_BUGS=0, 0 GPU/DRM errors (DMESG_DELTA_LINES=49, all routine M4 cooling ENODATA -> S1..S10 lines), POST_IDLE=IDLE_CLEAN.

Assisted-by: LLM (Gemini:4 Neon)

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

Follow-Up at e5f03d1f7f44.

The widened scheduling window is selected for AGX3B compute while the existing occupancy checks still admit each candidate. Please report candidate versus its actual parent as well as the comparison to #805. That isolates the effect of the window change, and a shader at the six/eight-load boundary would confirm the occupancy fallback after register allocation.

Source review. I used the test evidence attached to this PR.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE

Checked: Code review, -Db_ndebug=false build, meson test --suite asahi, and live Vulkan CTS on Mac Studio M5 Max (J775c, T6050) at e5f03d1f7f44.

Evidence
  • Verified agx_ilp_schedule() in src/asahi/compiler/agx_pressure_schedule.c widens the device-load ILP hoist window to {8, 6, 4, 2, 1} exclusively for agx3b_compute, keeping the {4, 2, 1} window unchanged on M5 (AGX3C), while preserving the existing occupancy-step register growth cap (load_growth) and scoreboard checks.
  • Verified AGX3VisionOpts.Agx3bComputeDeviceLoadIlpWideWindow covers all three cases: 8-load hoisting with headroom on AGX3B, high-pressure fallback (extra_live_32 = 45 -> 1), and unchanged {4, 2, 1} behavior on AGX3C.
  • Native -Db_ndebug=false build (clang 23.1.4) on Mac Studio M5 Max (J775c, T6050) passed meson test --suite asahi: 146/146 PASS (0 fail).
  • Live Vulkan CTS on Mac Studio M5 Max (J775c, T6050, G17C B1, LD_DEBUG=libs confirmed built libvulkan_asahi.so at git-e5f03d1f7f): dEQP-VK.compute.pipeline.basic.* 80/80 PASS (1 NotSupported, 0 fail), kernel GPU fault delta 0 (complements exact-head G17P, G16G, and G17S verification rows in the PR).

@DjDeveloperr

Copy link
Copy Markdown
Author

Superseded by standalone PR #1075 (bb38d56f2c75), which decouples this change cleanly onto aurora-wip (post-#1066/#1070/#1071) while preserving this PR's reviewed history untouched, and directly provides the requested exact-parent comparison + post-RA 38 -> 8 / 39 -> 6 load boundary test.

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