Repository navigation
asahi/agx3b: hoist multi-tap fragment samples up to 48 halves on G17P - #711
DjDeveloperr wants to merge 3 commits into
Conversation
|
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:
|
828774d to
eefbd87
Compare
|
Addressed every review item from Point-by-Point Summary
Exact-Head Neo
|
|
Re-review at eefbd87. Thanks, most of the first pass is resolved:
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) |
|
Addressed the remaining R2 review polish items in R3 (
Verification at exact head
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
eefbd87 to
17841d0
Compare
|
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) |
|
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.
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) |
|
Thanks for running the M4 Pro ( Confirmed — the
I've updated the PR description to state explicitly that the Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
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 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>
17841d0 to
cbee2e4
Compare
|
@RyanTheTide Pushed R4 at
Ready for your G15 ( 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>
|
Merged current |
|
Closing as superseded by merged #821 ( Matched interleaved ABBA verification on MacBook Neo (
#821 already delivers the AGX3B multi-tap sample hoisting under |
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 acrosssplit, and in-window coordinate-collect hoisting limits — delivering+9.2%to+10.4%(1.08×–1.11×) fasterrender.postfxon Apple A18 Pro (T8140, 5-coreG17P) — where the~9–10%speedup is A18-Pro-specific (M4 ProJ616sT6040measures-1.3%d=1/-0.5%d=2onrender.postfx 1440p msaa=1,±0.7%onmsaa=4&render.shadow, identical CRCs,5,907/5,907dEQP-GLES3 texture.*PASS) — with zeroI->shadowspecial-casing, zerorender.shadowregression, and zero new failures or spills across a 10,982-shaderg17psweep.Motivation & Root Cause
In
src/asahi/compiler/agx_pressure_schedule.c, the default fragment sample-issue path usesslack = AGX_ILP_FS_SAMPLE_SLACK(16halves) andfwd_cap = AGX_ILP_FS_SAMPLE_HALVES(88halves). For low-pressure multi-tap fragment filters onAGX3B— such asrender.postfx's 5-tap vec3 bloom downsample (peak ~ 20halves) — theafter <= before + 16slack 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 pastg71–g87due to three concrete modeling gaps inilp_schedule_block():agx_register_allocate.crounds vector allocations up to power-of-two halves, so a 3-word coordinatecollect(2D-array/3D/cube) occupies an aligned 8-half slot rather than 6 halves.splitprematurely freeing 4-channel sample slots:agx_compile.callocates a 4-channel (8-half)agx_vec_temp(..., 4)destination for every texture sample followed by a 4-waysplit. On 1-channel samples (shadow PCF, AO/depth blurs),splitkilled 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.collectpile-up: When an earlier sample exceededfwd_cap,ilp_schedule_block()still hoisted ready coordinatecollects for later in-window samples ahead of draining consumers of already-issued samples.Changes
src/asahi/compiler/agx_pressure_schedule.c:AGX_ILP_AGX3B_FS_SAMPLE_HALVES(48halves) andilp_agx3b_fragment_sample_budget(), keyed onctx->key->dev.encoding == AGX_ISA_ENCODING_AGX3Bfor non-loop fragment blocks with>= 4texture ops (TEXTURE_SAMPLE/TEXTURE_LOAD— on AGX3Bilp_is_sample()counts texture ops only, notIMAGE_LOAD) andpeak + 16 < 48. Note that48bounds this block's per-block live pressure, not the whole program's final register count (for example,render.postfxbloom downsample finishes atg39and 9-tap shadow PCF atg63).ra_sample_costmodeling inilp_schedule_block(): power-of-two aligned RA vector widths (ilp_ra_size_16()), single-useAGX_OPCODE_SPLITslot retention across sample destinations until the last live split component dies, and ahoist_limitguard preventing later-sample dependencies (collects) from hoisting past a cap-blocked earlier sample.I->shadowexclusion 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:agx_vec_temp(..., 4)destinations + 4-wayagx_split(matchingagx_compile.c+agx_expand_tex_to), covering 5-tap vec3 hoisting, 4-tap vec4texture_loadhoisting, 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_AGX2exclusion (AGX2EncodingRetainsFixedSlackCap), and loop-block exclusion.Cap Tuning Sweep (
48 / 64 / 88Halves) onG17PAGX3Bhas no static register-file occupancy split (Dynamic Caching shares on-chip SRAM between registers and L1 cache). Sweeping48 / 64 / 88halves (with the RA-accurate cost model and no shadow filter) across a 4-round Latin-square balancedgpubench-vkrun on Neo (G17P B1) and a 10,982-shaderg17pstatic corpus directly selected48halves:G17P B1, 4-round balanced vs1fdf5396)cap=48cap=64cap=88render.postfx1440p msaa=1(wall / GPU)1168.3 / 1096.4 µs1061.6 / 986.4 µs(-9.13%)1064.0 / 985.6 µs(-8.93%)1057.3 / 983.7 µs(-9.50%)render.postfx1440p msaa=1(wall / GPU)1046.1 / 1133.5 µs931.2 / 1022.7 µs(-10.99%)933.3 / 1027.6 µs(-10.78%)913.6 / 1021.9 µs(-12.66%)render.postfx1080p msaa=4(wall / GPU)796.2 / 714.8 µs744.1 / 652.1 µs(-6.55%)744.1 / 652.2 µs(-6.54%)736.4 / 652.2 µs(-7.51%)render.postfx1080p msaa=4(wall / GPU)662.3 / 743.4 µs604.6 / 685.8 µs(-8.71%)606.8 / 685.5 µs(-8.37%)605.3 / 684.1 µs(-8.60%)render.shadowdepth_only(wall / GPU)3289.5 / 3158.9 µs3289.5 / 3158.4 µs(+0.00%)3424.7 / 3279.4 µs(+4.11%)3401.5 / 3264.4 µs(+3.41%)render.shadowdepth_only(wall / GPU)2976.2 / 3160.1 µs2976.2 / 3159.2 µs(+0.00%)3086.4 / 3274.1 µs(+3.70%)3086.4 / 3263.4 µs(+3.70%)render.shadowalpha_test(wall / GPU)4032.3 / 3923.4 µs4032.3 / 3917.8 µs(+0.00%)4098.4 / 3962.9 µs(+1.64%)4065.3 / 3913.6 µs(+0.82%)render.shadowalpha_test(wall / GPU)3846.2 / 4001.8 µs3876.2 / 4008.8 µs(+0.78%)3906.3 / 4071.4 µs(+1.56%)3876.2 / 4040.4 µs(+0.78%)render.deferreddram(d1 / d2 wall)924.2 / 788.6 µs927.7 / 789.9 µs(+0.37% / +0.16%)924.2 / 788.6 µs(0.00%)925.9 / 787.4 µs(+0.18% / -0.16%)i=2..6)3acdb07a(g23,sp0)00bf5a6d(g39,sp0)00bf5a6d(g39,sp0)00bf5a6d(g39,sp0)i=5)c5009d8f(g39,sp0)2dd28158(g63,sp0)fcb49428(g79,sp0)42fc8512(g95,sp0)g17pcorpus406pre-existing fails)385changed,+1.29%GPRs,0spills,0thread drops,0new fails541changed,+3.11%GPRs,0spills,0new fails670changed,+5.10%GPRs,1thread drop (1024->896),3new packer fails (d16:reg76)Crossing
g63(64GPR halves) intog79(cap=64) org95(cap=88) regressesrender.shadowby+3.7%–+4.1%onG17P, andcap=88additionally triggers 3d16high-register AGX3 binary packer refusals (chromeos/10-4,chromeos/130,unity/37).cap=48keeps bloom downsample at the exact same00bf5a6d(g39) binary while holding 9-tap shadow PCF atg63with zero regression and zero corpus failures.Verification
cbee2e4bf5a0ec800368e5c1d2a91281fcf11925(only change from17841d0d6574: switched gate fromctx->key->dev.chip == AGX_CHIP_G17Ptoctx->key->dev.encoding == AGX_ISA_ENCODING_AGX3B, renamedAGX_ILP_G17P_FS_SAMPLE_HALVES/ilp_g17p_fragment_sample_budgettoAGX3B, and replacedNonG17PChipRetainsFixedSlackCapwithAGX2EncodingRetainsFixedSlackCap; bit-identical codegen onG17P)cbee2e4bf5a0):DEFAULT_BRANCH=aurora-wip ./.github/aurora/agent-policy.sh pr HEAD->PR head is clean-Db_ndebug=false, Fedora x86_64, exact headcbee2e4bf5a0):fedora-mesaci.sh:158/158 PASS(--suite asahi, including all 9AGX3BFragmentSampleSchedule.*tests) +7/7 PASS(--suite poly --suite nir),0Fail.G17P B1, codegen-identicaleefbd8701380vs1fdf5396758f):render.postfx1440p msaa=11154.74 µs1046.04 µs-9.41%(1.104×)1083.25 µs979.25 µs-9.60%(1.106×)ce5a5fe7✓render.postfx1440p msaa=1969.23 µs880.17 µs-9.19%(1.101×)1109.88 µs1003.22 µs-9.61%(1.106×)ce5a5fe7✓render.postfx1080p msaa=4786.16 µs725.69 µs-7.69%(1.083×)712.12 µs649.52 µs-8.79%(1.096×)668d6f0a✓render.postfx1080p msaa=4649.35 µs592.43 µs-8.77%(1.096×)733.30 µs671.83 µs-8.38%(1.091×)668d6f0a✓render.shadowdepth_only3289.47 µs3289.47 µs+0.00%(1.000×)3155.67 µs3162.50 µs+0.22%(0.998×)c0fb9993✓render.shadowdepth_only2976.19 µs3012.05 µs+1.20%(0.988×, 4-arm sweep+0.00%)3158.31 µs3166.25 µs+0.25%(0.997×)c0fb9993✓Full-group Vulkan CTS on Neo (
G17P B1, codegen-identicaleefbd8701380) —1,292 Pass / 1,774 NotSupported / 0 Fail(3,066total cases):dEQP-VK.glsl.discard.*:25 Pass / 0 FaildEQP-VK.rasterization.rasterization_order_attachment_access.format_float.attachments_8_samples_4.*:1 Pass / 4 NotSupported / 0 FaildEQP-VK.texture.shadow.2d_array.*:192 Pass / 576 NotSupported / 0 FaildEQP-VK.texture.filtering.cube.*:810 Pass / 838 NotSupported / 0 FaildEQP-VK.texture.explicit_lod.*:190 Pass / 190 NotSupported / 0 FaildEQP-VK.texture.filtering.2d.formats.*:74 Pass / 166 NotSupported / 0 FailM4 Pro (
J616s,T6040,G17P, codegen-identical17841d0d6574vs1fdf5396,@RyanTheTide#issuecomment-7086131514):dEQP-GLES3 texture.*:5,907 / 5,907PASS (0changed), identical CRCs.gpubench:render.postfx 1440p msaa=1566.9 -> 559.3 µs(-1.3%atd=1,-0.5%atd=2);msaa=4postfx and allrender.shadowrows within±0.7%.~9–10%render.postfxgain is A18-Pro-specific (5-coreG17P,1155 µsbaseline where serializing the 5 bloom downsample taps exposes per-core texture/memory latency). On higher-core-count M4 Pro (567 µsbaseline, sameg23 -> g39schedule 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.