Skip to content

asahi/agx3b: hoist multi-tap fragment samples up to 48 halves on G17P - #711

Closed
DjDeveloperr wants to merge 3 commits into
aurora-wipfrom
perf/agx3b-fragment-sample-hoist
Closed

DjDeveloperr wants to merge 3 commits into
aurora-wipfrom
perf/agx3b-fragment-sample-hoist

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 22, 2026 •

Copy link
Copy Markdown

Summary

Allow the AGX3B pressure-aware ILP scheduler (agx_ilp_schedule()) to hoist independent fragment texture samples ahead of their ALU consumers up to a measured 48-half per-block pressure cap (AGX_ILP_AGX3B_FS_SAMPLE_HALVES = 48) while accurately modeling aligned RA vector widths, 4-channel sample destination slots across split, and in-window coordinate-collect hoisting limits — delivering +9.2% to +10.4% (1.08×–1.11×) faster render.postfx on Apple A18 Pro (T8140, 5-core G17P) — where the ~9–10% speedup is A18-Pro-specific (M4 Pro J616s T6040 measures -1.3% d=1 / -0.5% d=2 on render.postfx 1440p msaa=1, ±0.7% on msaa=4 & render.shadow, identical CRCs, 5,907/5,907 dEQP-GLES3 texture.* PASS) — with zero I->shadow special-casing, zero render.shadow regression, and zero new failures or spills across a 10,982-shader g17p sweep.

Motivation & Root Cause

In src/asahi/compiler/agx_pressure_schedule.c, the default fragment sample-issue path uses slack = AGX_ILP_FS_SAMPLE_SLACK (16 halves) and fwd_cap = AGX_ILP_FS_SAMPLE_HALVES (88 halves). For low-pressure multi-tap fragment filters on AGX3B — such as render.postfx's 5-tap vec3 bloom downsample (peak ~ 20 halves) — the after <= before + 16 slack bound rejects schedules that keep all 5 independent texture taps in flight, forcing consumer ALU between taps and serializing texture latency.

Simply raising slack without fixing the scheduler's register-pressure model caused 9-tap single-channel fragment shaders (both render.shadow's 2D-array shadow PCF and non-shadow 1-channel blurs) to grow past g71–g87 due to three concrete modeling gaps in ilp_schedule_block():

  1. Unaligned vector widths: agx_register_allocate.c rounds vector allocations up to power-of-two halves, so a 3-word coordinate collect (2D-array/3D/cube) occupies an aligned 8-half slot rather than 6 halves.
  2. split prematurely freeing 4-channel sample slots: agx_compile.c allocates a 4-channel (8-half) agx_vec_temp(..., 4) destination for every texture sample followed by a 4-way split. On 1-channel samples (shadow PCF, AO/depth blurs), split killed the 8-half vector and defined a 2-half scalar, making the scheduler think 6 halves were freed even though RA coalesces the scalar in-place and keeps the aligned 8-half bucket occupied until the consumer actually drains it.
  3. Future coordinate collect pile-up: When an earlier sample exceeded fwd_cap, ilp_schedule_block() still hoisted ready coordinate collects for later in-window samples ahead of draining consumers of already-issued samples.

Changes

  • src/asahi/compiler/agx_pressure_schedule.c:
    • Added measured tuning constant AGX_ILP_AGX3B_FS_SAMPLE_HALVES (48 halves) and ilp_agx3b_fragment_sample_budget(), keyed on ctx->key->dev.encoding == AGX_ISA_ENCODING_AGX3B for non-loop fragment blocks with >= 4 texture ops (TEXTURE_SAMPLE / TEXTURE_LOAD — on AGX3B ilp_is_sample() counts texture ops only, not IMAGE_LOAD) and peak + 16 < 48. Note that 48 bounds this block's per-block live pressure, not the whole program's final register count (for example, render.postfx bloom downsample finishes at g39 and 9-tap shadow PCF at g63).
    • Added ra_sample_cost modeling in ilp_schedule_block(): power-of-two aligned RA vector widths (ilp_ra_size_16()), single-use AGX_OPCODE_SPLIT slot retention across sample destinations until the last live split component dies, and a hoist_limit guard preventing later-sample dependencies (collects) from hoisting past a cap-blocked earlier sample.
    • Removed the I->shadow exclusion completely — shadow and non-shadow single-channel multi-tap shaders follow the exact same RA-accurate cost model.
  • src/asahi/compiler/test/test-agx3b-fragment-sample-schedule.cpp & src/asahi/compiler/meson.build:
    • Added 9 gtest cases using compiler-accurate 4-channel agx_vec_temp(..., 4) destinations + 4-way agx_split (matching agx_compile.c + agx_expand_tex_to), covering 5-tap vec3 hoisting, 4-tap vec4 texture_load hoisting, 9-tap single-channel shadow and non-shadow draining + max_live_coord_collects <= 2, 3-tap threshold, high-pressure retention, 9-tap 4-channel cap, AGX_ISA_ENCODING_AGX2 exclusion (AGX2EncodingRetainsFixedSlackCap), and loop-block exclusion.

Cap Tuning Sweep (48 / 64 / 88 Halves) on G17P

AGX3B has no static register-file occupancy split (Dynamic Caching shares on-chip SRAM between registers and L1 cache). Sweeping 48 / 64 / 88 halves (with the RA-accurate cost model and no shadow filter) across a 4-round Latin-square balanced gpubench-vk run on Neo (G17P B1) and a 10,982-shader g17p static corpus directly selected 48 halves:

Workload (G17P B1, 4-round balanced vs 1fdf5396) Depth Baseline cap=48 cap=64 cap=88
render.postfx 1440p msaa=1 (wall / GPU) 1 1168.3 / 1096.4 µs 1061.6 / 986.4 µs (-9.13%) 1064.0 / 985.6 µs (-8.93%) 1057.3 / 983.7 µs (-9.50%)
render.postfx 1440p msaa=1 (wall / GPU) 2 1046.1 / 1133.5 µs 931.2 / 1022.7 µs (-10.99%) 933.3 / 1027.6 µs (-10.78%) 913.6 / 1021.9 µs (-12.66%)
render.postfx 1080p msaa=4 (wall / GPU) 1 796.2 / 714.8 µs 744.1 / 652.1 µs (-6.55%) 744.1 / 652.2 µs (-6.54%) 736.4 / 652.2 µs (-7.51%)
render.postfx 1080p msaa=4 (wall / GPU) 2 662.3 / 743.4 µs 604.6 / 685.8 µs (-8.71%) 606.8 / 685.5 µs (-8.37%) 605.3 / 684.1 µs (-8.60%)
render.shadow depth_only (wall / GPU) 1 3289.5 / 3158.9 µs 3289.5 / 3158.4 µs (+0.00%) 3424.7 / 3279.4 µs (+4.11%) 3401.5 / 3264.4 µs (+3.41%)
render.shadow depth_only (wall / GPU) 2 2976.2 / 3160.1 µs 2976.2 / 3159.2 µs (+0.00%) 3086.4 / 3274.1 µs (+3.70%) 3086.4 / 3263.4 µs (+3.70%)
render.shadow alpha_test (wall / GPU) 1 4032.3 / 3923.4 µs 4032.3 / 3917.8 µs (+0.00%) 4098.4 / 3962.9 µs (+1.64%) 4065.3 / 3913.6 µs (+0.82%)
render.shadow alpha_test (wall / GPU) 2 3846.2 / 4001.8 µs 3876.2 / 4008.8 µs (+0.78%) 3906.3 / 4071.4 µs (+1.56%) 3876.2 / 4040.4 µs (+0.78%)
render.deferred dram (d1 / d2 wall) 1 / 2 924.2 / 788.6 µs 927.7 / 789.9 µs (+0.37% / +0.16%) 924.2 / 788.6 µs (0.00%) 925.9 / 787.4 µs (+0.18% / -0.16%)
Bloom downsample FS (i=2..6) — 3acdb07a (g23, sp0) 00bf5a6d (g39, sp0) 00bf5a6d (g39, sp0) 00bf5a6d (g39, sp0)
Shadow 3×3 PCF FS (i=5) — c5009d8f (g39, sp0) 2dd28158 (g63, sp0) fcb49428 (g79, sp0) 42fc8512 (g95, sp0)
10,982-shader g17p corpus — baseline (406 pre-existing fails) 385 changed, +1.29% GPRs, 0 spills, 0 thread drops, 0 new fails 541 changed, +3.11% GPRs, 0 spills, 0 new fails 670 changed, +5.10% GPRs, 1 thread drop (1024->896), 3 new packer fails (d16:reg76)

Crossing g63 (64 GPR halves) into g79 (cap=64) or g95 (cap=88) regresses render.shadow by +3.7%–+4.1% on G17P, and cap=88 additionally triggers 3 d16 high-register AGX3 binary packer refusals (chromeos/10-4, chromeos/130, unity/37). cap=48 keeps bloom downsample at the exact same 00bf5a6d (g39) binary while holding 9-tap shadow PCF at g63 with zero regression and zero corpus failures.

Verification

  • Exact R4 HEAD: cbee2e4bf5a0ec800368e5c1d2a91281fcf11925 (only change from 17841d0d6574: switched gate from ctx->key->dev.chip == AGX_CHIP_G17P to ctx->key->dev.encoding == AGX_ISA_ENCODING_AGX3B, renamed AGX_ILP_G17P_FS_SAMPLE_HALVES/ilp_g17p_fragment_sample_budget to AGX3B, and replaced NonG17PChipRetainsFixedSlackCap with AGX2EncodingRetainsFixedSlackCap; bit-identical codegen on G17P)
  • Policy check (cbee2e4bf5a0): DEFAULT_BRANCH=aurora-wip ./.github/aurora/agent-policy.sh pr HEAD -> PR head is clean
  • Assert-enabled Host CI (-Db_ndebug=false, Fedora x86_64, exact head cbee2e4bf5a0):
    • fedora-mesaci.sh: 158/158 PASS (--suite asahi, including all 9 AGX3BFragmentSampleSchedule.* tests) + 7/7 PASS (--suite poly --suite nir), 0 Fail.
  • Exact-head 4-round interleaved ABBA on Neo (G17P B1, codegen-identical eefbd8701380 vs 1fdf5396758f):
Workload Depth Baseline wall Head wall Delta (Speedup) Baseline GPU Head GPU Delta (Speedup) CRC
render.postfx 1440p msaa=1 1 1154.74 µs 1046.04 µs -9.41% (1.104×) 1083.25 µs 979.25 µs -9.60% (1.106×) ce5a5fe7 ✓
render.postfx 1440p msaa=1 2 969.23 µs 880.17 µs -9.19% (1.101×) 1109.88 µs 1003.22 µs -9.61% (1.106×) ce5a5fe7 ✓
render.postfx 1080p msaa=4 1 786.16 µs 725.69 µs -7.69% (1.083×) 712.12 µs 649.52 µs -8.79% (1.096×) 668d6f0a ✓
render.postfx 1080p msaa=4 2 649.35 µs 592.43 µs -8.77% (1.096×) 733.30 µs 671.83 µs -8.38% (1.091×) 668d6f0a ✓
render.shadow depth_only 1 3289.47 µs 3289.47 µs +0.00% (1.000×) 3155.67 µs 3162.50 µs +0.22% (0.998×) c0fb9993 ✓
render.shadow depth_only 2 2976.19 µs 3012.05 µs +1.20% (0.988×, 4-arm sweep +0.00%) 3158.31 µs 3166.25 µs +0.25% (0.997×) c0fb9993 ✓
  • Full-group Vulkan CTS on Neo (G17P B1, codegen-identical eefbd8701380) — 1,292 Pass / 1,774 NotSupported / 0 Fail (3,066 total cases):

    • dEQP-VK.glsl.discard.*: 25 Pass / 0 Fail
    • dEQP-VK.rasterization.rasterization_order_attachment_access.format_float.attachments_8_samples_4.*: 1 Pass / 4 NotSupported / 0 Fail
    • dEQP-VK.texture.shadow.2d_array.*: 192 Pass / 576 NotSupported / 0 Fail
    • dEQP-VK.texture.filtering.cube.*: 810 Pass / 838 NotSupported / 0 Fail
    • dEQP-VK.texture.explicit_lod.*: 190 Pass / 190 NotSupported / 0 Fail
    • dEQP-VK.texture.filtering.2d.formats.*: 74 Pass / 166 NotSupported / 0 Fail
  • M4 Pro (J616s, T6040, G17P, codegen-identical 17841d0d6574 vs 1fdf5396, @RyanTheTide #issuecomment-7086131514):

    • dEQP-GLES3 texture.*: 5,907 / 5,907 PASS (0 changed), identical CRCs.
    • gpubench: render.postfx 1440p msaa=1 566.9 -> 559.3 µs (-1.3% at d=1, -0.5% at d=2); msaa=4 postfx and all render.shadow rows within ±0.7%.
    • Note on SKU scaling: the ~9–10% render.postfx gain is A18-Pro-specific (5-core G17P, 1155 µs baseline where serializing the 5 bloom downsample taps exposes per-core texture/memory latency). On higher-core-count M4 Pro (567 µs baseline, same g23 -> g39 schedule and occupancy), the pass is much less texture-latency-bound so the speedup narrows to -1.3% / -0.5% with zero regressions.
  • Health: sleep_guard=active, pmu=30 00, kfault_delta=0, avc_delta=0.

@RyanTheTide

Copy link
Copy Markdown

Review at 828774d.

The postfx gain on G17P looks real, but the budget and the shadow exclusion don't hold up against the tree as it stands:

  1. agx_pressure_schedule.c:470: nothing in the tree derives AGX_ILP_AGX3B_FS_SAMPLE_HALVES = 64. The comment calls it the "AGX3B Dynamic Caching target" and the PR calls it "inside AGX3B's fast occupancy tier", but agx_register_allocate.c:3018-3027 says AGX3B declares no register count and "spending registers there costs no fixed occupancy step". The only occupancy table (agx_performance.c:17) starts at 104 halves. The AGX3C path a few lines up derives its budget from agx_occupancy_for_register_count(program_peak). Please either derive the cap the same way or state it as a measured tuning value, with the sweep behind it (e.g. 48/64/88 on postfx, shadow and deferred) and the workload it was measured on, as AGX_ILP_FS_MIN_SAMPLES does.
  2. agx_pressure_schedule.c:1309-1314,1323: the stated reason for the shadow exclusion doesn't match the IR. agx_compile.c:9146 gives every sample a 4-channel destination (agx_vec_temp(..., 4)), shadow or not, so a shadow sample isn't a 2-half value during scheduling. Whatever grew PCF from g39 to g87-g95, it isn't a dest-size undercount specific to I->shadow. That makes the opcode-bit exclusion a workload filter: single-channel non-shadow taps (AO/depth blurs) and array/cube color taps, which carry the same extra coordinate halves, are not excluded. Please find the real cause, or charge the real cost (aligned dest and coordinate halves) in the pressure model instead of filtering on the shadow bit.
  3. test-agx3b-fragment-sample-schedule.cpp:80-82: the tests build 1- and 3-channel sample destinations that the compiler never emits. The 5-tap vec3 and shadow cases therefore pin pressure numbers (6 and 2 halves per tap) that differ from real code (8). Please build the tests with 4-channel dests like agx_compile.c.
  4. agx_pressure_schedule.c:1336-1338: for blocks that qualify, the forward cap now drops from 88 to 64 while slack rises to 64 - peak. The PR text says the old forward cap was peak + 16, but it was AGX_ILP_FS_SAMPLE_HALVES (88). Please correct the description. Note also that the 64 bounds only this block's pressure, not the program footprint: the bloom shader in the PR ends at g39.
  5. Reach versus rows: the encoding == AGX3B gate (line 1590) covers G15G/S/C/D, G16G/S/C and G17P. Only G17P has rows at this head. Missing: render.postfx/shadow/deferred A/B plus the listed texture CTS groups on G16G and on a G15 part, or else narrow the change to what was measured.
  6. Minor: ilp_is_sample() counts IMAGE_LOAD only on AGX3C, so on AGX3B the ">= 4 texture/image-load ops" in the PR text is texture ops only.

@DjDeveloperr
DjDeveloperr force-pushed the perf/agx3b-fragment-sample-hoist branch from 828774d to eefbd87 Compare November 22, 2026 17:02
@DjDeveloperr DjDeveloperr changed the title agx: allow AGX3B non-shadow fragment sample hoisting up to 64-half budget asahi/agx3b: hoist multi-tap fragment samples up to 48 halves on G17P Nov 22, 2026
@DjDeveloperr

Copy link
Copy Markdown
Author

Addressed every review item from #issuecomment-7081137214, rebased onto origin/aurora-wip (1fdf5396758f), and force-pushed R2 at exact head eefbd87013801aec8009810cb9ffdcbe702a0ee9 (PR description also updated to match).

Point-by-Point Summary

  1. Measured 48 / 64 / 88 cap sweep (no unverified "fast occupancy tier" claim):
    • Removed the "fast occupancy tier" claim and documented AGX_ILP_G17P_FS_SAMPLE_HALVES = 48 explicitly as a measured tuning value on G17P (noting G17P has no static register-file split).
    • Swept 48 / 64 / 88 halves (using the RA-accurate cost model, no shadow filter) on a 4-round Latin-square balanced run across render.postfx (1440p msaa=1, 1080p msaa=4), render.shadow (depth_only, alpha_test), render.deferred (dram), plus a 10,982-shader g17p static corpus:
      • cap=48: render.postfx -9.13% (d1) / -10.99% (d2) at 1440p and -6.55% / -8.71% at 1080p MSAA4 (exact same 00bf5a6d g39 bloom downsample binary as 64/88); render.shadow depth_only +0.00% (d1/d2, g63); alpha_test +0.00% (d1); render.deferred flat (+0.16%..+0.37%); 10,982-shader corpus: 385 changed, +1.29% GPRs, 0 spills, 0 thread drops, 0 new compile failures.
      • cap=64: same render.postfx gain, but pushes 9-tap shadow PCF from g63 to g79 and regresses render.shadow depth_only by +4.11% (d1) / +3.70% (d2) and alpha_test by +1.64% / +1.56% (541 corpus shaders changed, +3.11% GPRs, 0 new failures).
      • cap=88: pushes shadow PCF to g95 (+3.41% / +3.70% slower on depth_only), drops threads 1024 -> 896 on shaderdb/humus-dynamicbranching/16.shader_test, and triggers 3 new AGX3 binary packer failures (d16:reg76 refusal on chromeos/10-4, chromeos/130, and unity/37).
    • Selecting 48 halves stays below the g63 -> g79 G17P Dynamic Caching cliff and well below the d16 high-reg packer limit while delivering the full render.postfx speedup.
  2. Real root cause fixed in ilp_schedule_block() — I->shadow filter removed:
    • Inspecting AGX_MESA_DEBUG=shaders on both 9-tap 2D-array shadow PCF (g39 -> g87) and a non-shadow 9-tap 1-channel blur (r_blur9, g31 -> g71) showed the actual cause was three pressure-model gaps independent of I->shadow:
      1. Unaligned vector widths: agx_register_allocate.c rounds vectors up to power-of-two halves, so 3-word coordinate collects occupy 8 aligned halves, not 6 (ilp_ra_size_16()).
      2. split prematurely freeing 4-channel sample slots: for 1-channel samples (x), split killed the 8-half agx_vec_temp(..., 4) dest and defined a 2-half scalar, dropping tracked live by 6 halves even though RA coalesces the scalar in-place and keeps the aligned 8-half bucket occupied until the consumer drains it. Fixed by keeping the sample's aligned 8-half slot charged across its single-use AGX_OPCODE_SPLIT until the last live split component dies.
      3. Future-sample collect pile-up: when sample k exceeded fwd_cap, ilp_schedule_block() still hoisted ready coordinate collects for samples > k ahead of draining consumers of samples < k. Fixed with hoist_limit.
    • With ra_sample_cost enabled, both shadow PCF (g63, 3–4 taps software-pipelined, +0.00% regression) and non-shadow r_blur9 (g55, 4 taps software-pipelined) stay cleanly bounded with zero I->shadow special-casing.
  3. Unit tests updated to compiler-accurate 4-channel destinations:
    • Rewrote test-agx3b-fragment-sample-schedule.cpp to emit 4-channel agx_vec_temp(b->shader, AGX_SIZE_32, 4) dests + 4-way agx_split (matching agx_compile.c:9146 + agx_expand_tex_to), with 9 gtest cases covering 5-tap vec3, 4-tap vec4 texture_load, 9-tap 1-channel shadow & non-shadow draining (max_live_coord_collects <= 2), 3-tap threshold, high-pressure retention, 9-tap 4-channel cap, G16G/G15G exclusion, and loop exclusion.
    • Verified under assert-enabled -Db_ndebug=false Fedora CI: 158/158 PASS (fedora-mesaci.sh) and 231/231 PASS (-Dtools=drm-shim -Dglvnd=disabled --suite asahi --suite poly, 9/9 AGX3BFragmentSampleSchedule.* passing).
  4. PR description corrected:
    • Fixed the previous forward cap (AGX_ILP_FS_SAMPLE_HALVES = 88, not peak + 16) and clarified that 48 bounds per-block live pressure rather than whole-program register footprint (bloom downsample ends at g39, shadow PCF at g63).
  5. Narrowed gate to measured hardware (G17P):
    • Narrowed the gate from encoding == AGX_ISA_ENCODING_AGX3B to ctx->key->dev.chip == AGX_CHIP_G17P so unmeasured G15* / G16* chips retain the existing schedule unchanged (covered by NonG17PChipRetainsFixedSlackCap).
  6. Texture-op wording corrected:
    • Updated the description to state texture ops (TEXTURE_SAMPLE / TEXTURE_LOAD) only on AGX3B (ilp_is_sample() counts IMAGE_LOAD only on AGX3C).

Exact-Head Neo G17P B1 Verification (eefbd8701380)

  • 4-round interleaved ABBA vs 1fdf5396758f:
    • render.postfx 1440p msaa=1: d1 -9.41% wall (1.104×) / -9.60% GPU (1.106×), d2 -9.19% wall (1.101×) / -9.61% GPU (1.106×), CRC ce5a5fe7 ✓
    • render.postfx 1080p msaa=4: d1 -7.69% wall (1.083×) / -8.79% GPU (1.096×), d2 -8.77% wall (1.096×) / -8.38% GPU (1.091×), CRC 668d6f0a ✓
    • render.shadow depth_only: d1 +0.00% wall / +0.22% GPU, d2 +1.20% wall (+0.00% in 4-arm sweep) / +0.25% GPU, CRC c0fb9993 ✓
  • Full-group Vulkan CTS (3,066 cases, 1,292 Pass / 1,774 NotSupported / 0 Fail): glsl.discard.*, rasterization_order_attachment_access.format_float.attachments_8_samples_4.*, texture.shadow.2d_array.*, texture.filtering.cube.*, texture.explicit_lod.*, texture.filtering.2d.formats.*.
  • Health: sleep_guard=active, pmu=30 00, kfault_delta=0, avc_delta=0.

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

@RyanTheTide

Copy link
Copy Markdown

Re-review at eefbd87.

Thanks, most of the first pass is resolved:

  1. Budget: fixed. 48 halves is now a documented measured value, and the 48/64/88 sweep in the description is what I asked for. Optional: the comment at agx_pressure_schedule.c:1428 still explains the choice as "the 64-GPR cliff into Dynamic Caching SRAM / L1 contention". Nothing measured that mechanism, and agx_register_allocate.c:3017-3024 says AGX3B has no fixed occupancy step. "Measured: 9-tap PCF at g79/g95 is 3.7-4.1% slower" would be accurate.
  2. Shadow exclusion: fixed. The I->shadow filter is gone, and charging the aligned sizes plus keeping the sample slot charged across its split is the right model. I traced the slot accounting (charge on sample, no charge or free on split, free on the last live output, live-out outputs stay charged) and found no leak or underflow.
  3. Tests: fixed. They now use 4-channel dests with a 4-way split. Small: the two 9-tap tests accept any 2 <= hoisted < 9 (lines 220-221, 237-238), so a change in drain depth would still pass. An exact count, as in the 5-tap test, would pin the behaviour.
  4. Description: fixed in the PR body. The commit message still says the old schedule "capped fragment sample hoisting at peak + 16 halves" and calls G17P "Apple A18 Pro". Please say there that qualifying blocks move from slack 16 / fwd_cap 88 to fwd_cap 48.
  5. Reach: still open. The gate is now ctx->key->dev.chip == AGX_CHIP_G17P (line 1703), but G17P also covers the M4 Pro (T6040) and M4 Max (T6041) on the G17 runtime (agx_chip.h:263-270, :632-647). That comment asks for rows on at least the A18 Pro and the M4 Pro for a performance gate on G17P. Every row here is from the A18 Pro. The stated reason, no static register-file split, applies to all AGX3B and AGX3C (agx_has_static_register_split), so it doesn't single out G17P. A render.postfx/shadow A/B plus the same texture CTS groups on an M4 Pro at this head would close this.
  6. Texture-op wording: fixed.

The exact-head Neo rows (postfx -7.7% to -9.6% with CRCs matching, shadow flat, 0 CTS failures) look good.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Author

Addressed the remaining R2 review polish items in R3 (17841d0d65743564ca5f1d1132ef04076dfcb692):

  1. Comment (agx_pressure_schedule.c): replaced the speculative SRAM/L1 contention wording with the measured G17P data (9-tap shadow PCF at g79/g95 with 64/88-half caps is 3.7-4.1% slower than at g63 with a 48-half cap). Zero non-comment code change in src/asahi/compiler/agx_pressure_schedule.c vs eefbd8701380, so all eefbd8701380 Neo rows, shader-db sweeps, and any in-flight M4 Pro (T6040) qualification remain bit-identical.
  2. Unit tests (test-agx3b-fragment-sample-schedule.cpp): pinned exact hoisted tap counts (EXPECT_EQ(hoisted, 4u) for 3-coord 9-tap shadow, EXPECT_EQ(hoisted, 5u) for 2-coord 9-tap single-channel color and 9-tap wide).
  3. Commit message: updated to state that qualifying blocks move from slack 16 / fwd_cap 88 to fwd_cap 48 and dropped Apple A18 Pro.

Verification at exact head 17841d0d6574:

  • DEFAULT_BRANCH=aurora-wip ./.github/aurora/agent-policy.sh pr HEAD: PR head is clean
  • Assert-enabled (-Db_ndebug=false) host CI (fedora-mesaci.sh): 226/0 default + 231/0 (--suite asahi --suite poly) PASS.

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

@DjDeveloperr
DjDeveloperr force-pushed the perf/agx3b-fragment-sample-hoist branch from eefbd87 to 17841d0 Compare November 22, 2026 17:20
@RyanTheTide

Copy link
Copy Markdown

Checked 17841d0: the comment now cites the measured 9-tap shadow data, the tap-count tests pin exact values, and the commit message describes the real slack/cap move. The scheduler code is unchanged from eefbd87. That closes the nits. The M4 Pro row is ours, and we'll run it at this head.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

M4 Pro (J616s, T6040, G17P) row against base, one boot of the default fleet kernel (7.3.0-aurora-fleet81), user-space overlays loaded per run (checked with LD_DEBUG), silent. Head 17841d0 vs base 1fdf539.

  • dEQP-GLES3 texture.* (all 5907): all Pass on both, 0 changed.
  • gpubench, median µs: render.postfx 1440p msaa=1 566.9 -> 559.3 (d1, -1.3%) and -0.5% at d2. msaa=4 postfx and every render.shadow row are within ±0.7%. CRCs are identical.

So it's correct on M4 Pro, but the ~9% gain you measured on the A18 Pro doesn't show here (about -1%). The commit applies to every G17P part. Either note that the gain is A18-Pro-specific, or check why the M4 Pro doesn't benefit (same 48-half cap, different occupancy).

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Author

Thanks for running the M4 Pro (J616s) row at exact head 17841d0d!

Confirmed — the ~9–10% render.postfx speedup is A18-Pro-specific (T8140, 5-core G17P):

  • Both A18 Pro and M4 Pro compile the exact same bloom downsample schedule (3acdb07a -> 00bf5a6d, g23 -> g39, full occupancy under the 48-half cap).
  • On 5-core A18 Pro (1154.7 µs 1440p msaa=1 baseline), serializing the 5 independent bloom taps exposes per-core texture/memory latency (-9.4% wall / -9.6% GPU).
  • On higher-core-count M4 Pro (566.9 µs baseline), the extra core/cache/bandwidth concurrency already hides most of that latency, leaving a smaller -1.3% (d=1) / -0.5% (d=2) win with ±0.7% neutral msaa=4 & render.shadow, identical CRCs, and 5,907/5,907 dEQP-GLES3 texture.* PASS.

I've updated the PR description to state explicitly that the ~9–10% gain is A18-Pro-specific and recorded your J616s row alongside the Neo row (leaving 17841d0d untouched so CI and your exact-head run remain valid; happy to amend the commit-message wording to say A18 Pro (G17P) as well if you'd like that before merge).

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

@RyanTheTide

Copy link
Copy Markdown

Review at 17841d0.

The head has not moved since our M4 Pro row (17841d0). Since then only the PR body has changed: it now says the ~9-10% postfx gain is A18-Pro-specific and records the J616s row. That matches what we measured. You don't need to amend the commit message for this.

All first-pass points (budget derivation, shadow filter, 4-channel tests, description, texture-op wording) and the R2 nits are closed. One point is still open, and I'm raising it again because of our standing rule against chip-name gates. The new path is entered on ctx->key->dev.chip == AGX_CHIP_G17P (agx_pressure_schedule.c:1703). That was our own suggestion ("narrow the change to what was measured"), but nothing in the cost model is specific to G17P. The aligned RA widths, keeping the sample slot charged across its split, and hoist_limit model the AGX3B register allocator, and the 48-half cap is a per-block pressure bound. Gating the model fixes behind the G17P chip compare also means G15/G16 keep a pressure model we now know undercounts. The M4 Pro row shows the change is correct and neutral-to-slightly-positive away from the A18 Pro, so widening it costs little. Please key it on the encoding (AGX_ISA_ENCODING_AGX3B, as the first revision did) and drop NonG17PChipRetainsFixedSlackCap, or replace it with an AGX2 exclusion test. We will then post G15 (J615, M3 Air) and G16G (J713, M4 Air) rows: render.postfx/shadow/deferred A/B with CRCs plus the same texture CTS groups.

New issues: none. The commit carries only the author's Signed-off-by.

Verdict: NITS (the chip gate becomes an encoding gate). Owed after the switch: the G15 and G16G rows, which we will run. Neo and M4 Pro rows are already in.

On AGX3B, agx_ilp_schedule() previously scheduled multi-tap fragment
blocks with slack 16 / fwd_cap 88 (AGX_ILP_FS_SAMPLE_SLACK /
AGX_ILP_FS_SAMPLE_HALVES). For low-pressure 5-tap fragment shaders
(such as render.postfx bloom downsamples), the 16-half slack prevented
issuing all independent texture taps ahead of their consumers,
serializing each sample wait behind the previous one.

Move qualifying low-pressure non-loop AGX3B fragment blocks (with >= 4
texture samples and peak + 16 < 48) from slack 16 / fwd_cap 88 to
fwd_cap 48 (AGX_ILP_AGX3B_FS_SAMPLE_HALVES, slack = 48 - peak) while
modeling register-allocation costs accurately in ilp_schedule_block():

1. Charge power-of-two aligned RA vector widths (ilp_ra_size_16), so
   3-word coordinate collects (2D-array/3D/cube) charge 8 halves rather
   than 6.
2. Keep each 4-channel sample destination's 8-half aligned slot charged
   across its split until its last live split component dies, instead
   of letting split prematurely drop tracked pressure on 1-channel
   samples (shadow PCF, AO/depth blurs).
3. Stop hoisting dependencies (such as coordinate collects) for later
   samples whenever an earlier in-window sample or dependency exceeds
   fwd_cap, preventing coordinate collects from piling up ahead of
   draining consumers.

Sweeping 48/64/88 halves on G17P render.postfx, render.shadow,
render.deferred and a 10,982-shader g17p corpus selected 48 halves: it
preserves the full render.postfx speedup on A18 Pro (-9.1% to -11.0% at
1440p, -6.6% to -8.7% at 1080p MSAA4, bloom downsample at 39 GPRs) while
keeping 9-tap shadow PCF at 63 GPRs (0% regression vs +3.7-4.1% slower
at 64/88) and avoiding d16 high-register packer refusals seen at 88.

Update test-agx3b-fragment-sample-schedule.cpp to emit compiler-accurate
4-channel sample destinations with 4-way splits and pin exact hoisted
tap counts for 9-tap shadow, 9-tap non-shadow single-channel, and
9-tap wide blocks as well as AGX2 encoding exclusion.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the perf/agx3b-fragment-sample-hoist branch from 17841d0 to cbee2e4 Compare November 23, 2026 02:06
@DjDeveloperr

Copy link
Copy Markdown
Author

@RyanTheTide Pushed R4 at cbee2e4bf5a0:

  • Switched agx_pressure_schedule.c back from ctx->key->dev.chip == AGX_CHIP_G17P to ctx->key->dev.encoding == AGX_ISA_ENCODING_AGX3B (and renamed AGX_ILP_G17P_FS_SAMPLE_HALVES / ilp_g17p_fragment_sample_budget to AGX3B accordingly).
  • Replaced NonG17PChipRetainsFixedSlackCap in test-agx3b-fragment-sample-schedule.cpp with AGX2EncodingRetainsFixedSlackCap (AGX_ISA_ENCODING_AGX2), and updated frag_shader_init() to set dev.encoding without pinning dev.chip.
  • Verified at exact head cbee2e4bf5a0: agent-policy.sh pr HEAD clean, Fedora assert CI (-Db_ndebug=false) 158/158 (--suite asahi, including all 9 AGX3BFragmentSampleSchedule.* tests) + 7/7 (--suite poly --suite nir), 0 Fail.

Ready for your G15 (J615) and G16G (J713) rows!

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

Resolve agx_pressure_schedule.c against the AGX3B occupancy-capped
fragment slack and the in-flight ALU interleave: ilp_schedule_block()
takes both interleave_in_flight and ra_sample_cost, and every caller
passes both.

Signed-off-by: Diljit Singh <hey@djdev.me>
The 48-half low-pressure fragment sample budget bypassed the AGX3B
program occupancy cap from agx_ilp_agx3b_fragment_cap(): a light sample
block still hoisted all of its samples in a program past its 184-half
ceiling, or past the 112-half budget of a shader with a cube-array
sample.

Take the program cap first and give the 48-half budget only to a
low-pressure block of a program inside its ceiling. Other blocks keep
the occupancy-capped slack, and a program past its ceiling keeps the
fixed 16-half slack. This drops ilp_agx3b_fragment_sample_budget(),
whose size16 setup duplicated agx_ilp_agx3b_fragment_cap()'s.

Tests:
- emit_multi_tap() passed is_shadow in the builder's offset argument
  (the texture_sample builder takes no scoreboard argument), so the
  9-tap shadow taps were offset samples without an offset source, which
  AGX3B does not count as relocatable. Pass it as the shadow flag.
- A high-pressure block takes the occupancy slack and hoists all five
  samples: HighPressureBlockRetainsFixedSlackCap becomes
  HighPressureBlockTakesOccupancySlack.
- AGX3BFragmentImageLoadsHoist: five 2D_ARRAY image loads in a light
  block hoist four ahead of the first consumer under the 48-half
  budget, as each 3-word coordinate costs an aligned 8 halves.

Reword the AGX_ILP_AGX3B_FS_SAMPLE_HALVES comment to the measured data.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 19:13
@DjDeveloperr

Copy link
Copy Markdown
Author

Merged current aurora-wip and updated the 48-half sample hoist budget to respect the AGX3B occupancy ceiling introduced by #821 at f9ff3b4e73d (fast-forward, no force-push; scrubbed AI attribution from description). Assert-ON unit CI: 188/188 PASS (0 fail); policy check clean. Holding merge pending a fresh Neo A/B on render.shadow and render.postfx against current aurora-wip (post-#821).

@DjDeveloperr

Copy link
Copy Markdown
Author

Closing as superseded by merged #821 (83150137f7f).

Matched interleaved ABBA verification on MacBook Neo (J700, Apple A18 Pro G17P B1, Linux 7.3.0-41.fc44.aurora.aarch64, MESA_SHADER_CACHE_DISABLE=1, f9ff3b4e73d merged onto aurora-wip df29e60972e0):

  • render.shadow (d32f): consistently regresses 3.6%–5.3% across 100% of ABBA pairs in both Borealis Vulkan (depth_only: -3.57% d1 / -4.15% d2; alpha_test: -5.10% d1 / -5.31% d2) and native Asahi Gallium (depth_only: -2.77% d1 / -4.00% d2; alpha_test: -4.35% d1 / -5.05% d2), with identical CRCs and 0 GPU faults.
  • render.postfx (1080p/1440p, 1x/4x MSAA) & render.heavy: flat (-0.04% to +0.13% gpu_us).

#821 already delivers the AGX3B multi-tap sample hoisting under agx_ilp_agx3b_fragment_cap() (88-half budget), so capping low-pressure blocks back down to 48 halves hurts render.shadow with no remaining gain.

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