Repository navigation
asahi/compiler: extend occupancy-capped fragment sample hoisting to AGX3B - #821
Conversation
RyanTheTide
left a comment
There was a problem hiding this comment.
Follow-Up at 68faddaf6383.
The scheduler mirrors the register allocator’s AGX3B and cube-specific ceilings in a separate helper. Please share the register-budget calculation or add a differential check that detects drift, including cube-array and bias-min forms. The Neo row verifies the new path; report M4 and M4 Pro/Max render rows for the other users of this encoding.
Source review. I used the test evidence attached to this PR.
…GX3B agx_ilp_schedule() runs fragment sample hoisting on all AGX3 encodings, but occupancy-capped slack was previously gated exclusively on AGX_ISA_ENCODING_AGX3C (m5_fragment). On AGX3B (192-half register file, used by M4 family and A18 Pro): - Fragment blocks with >=4 multi-channel samples fell back to the fixed 16-half AGX_ILP_FS_SAMPLE_SLACK. Hoisting 4-6 vec3/vec4 texture samples (post-processing downsamples, 2D-array texel-fetch passes, deferred DRAM lighting, shadow PCF) exceeds 16 halves of pressure growth even when the resulting peak stays well inside the 104-half (1024-thread) occupancy bucket, causing the scheduler to reject hoisting and serialize samples one at a time. - AGX_OPCODE_IMAGE_LOAD was only recognized as a native SMP sample on AGX3C, even though AGX3B encodes read-only image loads as native SMP with the same latency profile. - Not all AGX3B fragment samples can overlap in flight: in agx3_pack_binary.c, only staging-bank-relocatable samples (plain 2D and uniform/immediate-descriptor 2D_ARRAY samples with auto or immediate LOD, plus 2D/2D_ARRAY/3D immediate-LOD texel/image loads) allocate disjoint staging banks. Non-relocatable forms (including register-descriptor 2D_ARRAY samples when no preamble promotes the descriptors, 3D/cube samples, gradient/register-LOD/dynamic-offset samples, and multisample/register-LOD fetches) stay pinned to staging bank 0, where hoisting only inflates GPR pressure and forces serializing agx3_retire_result_wait barriers between consecutive samples. Extend occupancy-capped fragment sample hoisting and native SMP IMAGE_LOAD recognition to AGX3B while matching its hardware and binary packer constraints: - Restrict AGX3B fragment sample counting and hoisting in ilp_is_sample() to staging-bank-relocatable samples/fetches. - Cap AGX3B fragment occupancy slack at 184 halves (the highest occupancy step inside the 192-half register file, also matching RA's 2D_MS_ARRAY cap) and honor narrower AGX3B cube-sample register budgets (112/160 halves) so hoisting never pushes cube shaders into spilling. - Compute program peak lazily on AGX3B only when a fragment block has >= AGX_ILP_FS_MIN_SAMPLES relocatable samples. - Leave AGX3C (M5), AGX3D, AGX2, and compute scheduling untouched. Signed-off-by: Diljit Singh <hey@djdev.me>
68fadda to
1f90096
Compare
R2 (
|
| Case | Base wall (us) | R2 wall (us) | Wall speedup | Base GPU (us) | R2 GPU (us) | GPU speedup | CRC |
|---|---|---|---|---|---|---|---|
render.shadow (d32f, depth_only) |
1500.0 | 767.6 | 1.954× | 1664.5 | 929.0 | 1.792× | c0fb9993 OK |
render.shadow (d32f, alpha_test) |
3077.1 | 2483.8 | 1.239× | 3299.9 | 2566.0 | 1.286× | 7be9463a OK |
render.shadow (d16, depth_only) |
1065.1 | 833.3 | 1.278× | 1224.0 | 991.7 | 1.234× | OK |
render.postfx (1440p, msaa=1) |
1071.5 | 960.3 | 1.116× | 1147.6 | 1043.9 | 1.099× | ce5a5fe7 OK |
render.postfx (1440p, msaa=4) |
1087.6 | 978.7 | 1.111× | 1172.1 | 1074.4 | 1.091× | 4707efa8 OK |
render.postfx (1080p, msaa=4) |
639.4 | 578.9 | 1.105× | 746.5 | 687.4 | 1.086× | 668d6f0a OK |
compress.bw (array, 1440p) |
403.1 | 397.9 | 1.013× | 530.9 | 497.5 | 1.067× | valid:true |
render.deferred (dram, 1080p, m4) |
6428.6 | 6206.9 | 1.036× | 6630.9 | 6639.2 | 0.999× | OK |
render.deferred (tile, 1080p, m1) |
1585.9 | 1558.7 | 1.017× | 1619.0 | 1611.1 | 1.005× | OK |
render.heavy (texture, 1080p) |
1791.1 | 1791.1 | 1.000× | 1830.0 | 1830.2 | 1.000× | OK |
- MacBook Neo
ASAHI_MESA_DEBUG=verify+ Vulkan CTS 1.4.7.1: 8/8gpubench-vkverifysmoke runs PASS (valid:true), 1,200-case targeted VK CTSverifysweep (texture.filtering.{2d,2d_array,cube},texture.shadow,glsl.texture_functions.texture,image.load_store) = 545 Pass / 655 NotSupported / 0 Fail,kfaults_delta=0 avc_delta=0.
Ready for M4 (G16G) re-verification on 1f90096a2218.
Assisted-by: LLM (Antigravity:Gemini 4 Neon)
|
Exact-head
Assisted-by: LLM (Google:Gemini 4 Neon) |
Exact-head Apple M4 (
|
| Case | d |
Base sub (us) | #821 R2 sub (us) |
Δsub | Base GPU (us) | #821 R2 GPU (us) |
ΔGPU | CRC |
|---|---|---|---|---|---|---|---|---|
compress.bw(kind=array,res=1440p) |
4 | 772.8 | 763.4 | -1.2% (1.01x) | 802.9 | 765.4 | -4.7% (1.05x) | per-run OK |
render.deferred(mode=dram,msaa=1,res=1080p) |
2 | 969.0 | 978.5 | +1.0% (0.99x) | 972.8 | 975.9 | +0.3% (1.00x) | 2cfe9a54 OK |
render.postfx(msaa=1,res=1440p) |
2 | 1613.0 | 1623.4 | +0.6% (0.99x) | 1607.9 | 1612.3 | +0.3% (1.00x) | ce5a5fe7 OK |
render.shadow(fmt=d16,mode=depth_only,res=2048) |
2 | 996.0 | 1012.1 | +1.6% (0.98x) | 996.4 | 998.4 | +0.2% (1.00x) | c0fb9993 OK |
render.shadow(fmt=d32f,mode=alpha_test,res=2048) |
1 | 2272.7 | 2262.5 | -0.5% (1.00x) | 1865.0 | 1866.2 | +0.1% (1.00x) | 7be9463a OK |
render.shadow(fmt=d32f,mode=alpha_test,res=2048) |
2 | 1893.9 | 1894.0 | +0.0% (1.00x) | 1874.0 | 1875.9 | +0.1% (1.00x) | 7be9463a OK |
render.shadow(fmt=d32f,mode=depth_only,res=2048) |
1 | 2136.8 | 2127.7 | -0.4% (1.00x) | 1748.0 | 1746.2 | -0.1% (1.00x) | c0fb9993 OK |
render.shadow(fmt=d32f,mode=depth_only,res=2048) |
2 | 1760.6 | 1779.4 | +1.1% (0.99x) | 1756.7 | 1754.3 | -0.1% (1.00x) | c0fb9993 OK |
2. Targeted dEQP-VK CTS + ASAHI_MESA_DEBUG=verify (103 passed, 0 failed, 347 not supported, 450 total, verify_err=0, gpu_dmesg=+0, dmesg_delta=+0, nonzero_rc=0)
texture_shadow: 48/48 PASS (0fail,202NS,verify_err=0,gpu_dmesg=+0)verify_frag_ilp(ASAHI_MESA_DEBUG=verify): 19/19 PASS (0fail,81NS,verify_err=0,gpu_dmesg=+0)verify_tex_filt(ASAHI_MESA_DEBUG=verify): 36/36 PASS (0fail,64NS,verify_err=0,gpu_dmesg=+0)
3. Health & Verdict
GPU_DMESG_DELTA_ERRS=0,health: failed 0 errno 0 degraded 0,classes: render_failed 0 compute_failed 0,POST_IDLE=IDLE_CLEAN.- Verdict: PASS on Apple M4 (
G16G B0).
Assisted-by: LLM (Gemini:4 Neon)
joshuaswarren
left a comment
There was a problem hiding this comment.
APPROVED — hardware gate on M1 / M1 Max.
Reviewed 1f90096a22 (single commit on efabab3850) against aurora-wip tip c0c5738384. Our test chips are AGX2 (T8103/T6001), so the bar is "nothing changes for us" — verified both ways:
- Reachability: the occupancy-cap
else ifsits inside the existing fragment-hoist gate (FRAGMENTstage +>= AGX_ILP_FS_MIN_SAMPLESsamples);m5_fragment(AGX3C) keeps its own path, and AGX3B is the only encoding that reaches the new cap. AGX2, AGX3C, preambles, and non-fragment stages getAGX_ILP_FS_SAMPLE_SLACKexactly as before. ilp_is_samplewidening:is_agx3 && IMAGE_LOADcan only newly fire for AGX3B —key->dev.encodingis only ever AGX2/AGX3B/AGX3C (AGX3D is anemit_agx3dflag, not an encoding value), and everyilp_block_samplesconsumer outside the fragment gate ism5-gated (copy_mode/loop_sample_modeonly populate underm5_copy || m5_compute). On AGX3B fragment the early return restricts counting to staging-bank-relocatable samples, matching the packer constraints the commit documents.- Cap logic:
184halves cap with160/112cube reductions mirrorsagx3_cube_register_budgetin RA; program-peak is computed lazily once (agx3b_frag_cap_ready), and the alloc-failure/over-cap paths degrade toslack = 16— fail-closed, no hoist growth. - New
test-m5-copy-schedule.cppcases (274 lines) cover the AGX3B relocatable/non-relocatable split.
Hardware results (exact head build, aarch64 cross on mesa-xbuild):
- jwm1 (T8103/M1):
meson test --suite asahi --suite poly169/169; dEQP-VK.compute 13,781 cases vsaur-base-c0c57383: 0 diffs; vs merge-baseaur2-base-efabab38: 0 diffs - 16m1mbp (T6001/M1 Max): 13,781 cases vs
aur-base-c0c57383: 0 diffs; vs merge-baseaur2-base-efabab38: 0 diffs
|
Merged into
|
Resolve adjacent insertion conflicts in agx_pressure_schedule.c and test-m5-copy-schedule.cpp with #821 (AGX3B fragment sample hoisting), preserving both changes unchanged. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Summary
agx_ilp_schedule()runs fragment sample hoisting on all AGX3 encodings, but occupancy-capped slack was previously gated exclusively onAGX_ISA_ENCODING_AGX3C(m5_fragment).On
AGX_ISA_ENCODING_AGX3B(192-half register file: M4G16G, M4 ProT6040, M4 MaxT6041, A18 ProG17P):>= 4multi-channel samples fell back to the fixed 16-halfAGX_ILP_FS_SAMPLE_SLACK, rejecting sample hoisting for multi-tap shadow PCF, post-processing blur/downsample, and 2D-array texel-fetch passes even when the hoisted schedule stays well inside the 104-half (1024-thread) full-occupancy bucket.AGX_OPCODE_IMAGE_LOADwas only recognized as a nativeSMPsample onAGX3C, even thoughAGX3Bencodes read-only image loads as nativeSMPwith the same latency profile.This PR extends occupancy-capped fragment sample hoisting and native
SMPAGX_OPCODE_IMAGE_LOADrecognition toAGX_ISA_ENCODING_AGX3B:AGX3Bfragment occupancy slack at 184 halves (matching the highest occupancy bucket inside the 192-half register file and RA's2D_MS_ARRAYcap) and honors narrowerAGX3Bcube-sample register budgets (112halves forCUBE_ARRAY/AUTO_LOD_BIAS_MIN,160halves for plainCUBE) so hoisting never pushes cube shaders into spilling.AGX3Bonly when a fragment block has>= AGX_ILP_FS_MIN_SAMPLESsamples.AGX3C(M5 /G17S),AGX3D,AGX2, and compute scheduling untouched (zero overlap with computedevice_loadILP hoisting in agx: AGX3B direct byte u2f32 unpack, runtime-unroll binary tail peeling, and compute load ILP scheduling #743 / asahi/compiler: widen AGX3B compute device-load ILP window to {8, 6, 4, 2, 1} #817).src/asahi/compiler/test/test-m5-copy-schedule.cpp(AGX3BFragmentSamplesUseOccupancySlack,AGX3BFragmentImageLoadsHoist,AGX3BFragmentRespects184HalfCeiling,AGX3BFragmentCubeBudgetRespected).Verification (
68faddaf6383, ICDgit-68faddaf63)DEFAULT_BRANCH=aurora-wip bash .github/aurora/agent-policy.sh pr HEAD->PR is cleanasahiCI:FEDORA-CI 68faddaf6383dd246f08d47e7d005a172b3c0cc6 164/0(38s, 0 failures)AGX_ISA_ENCODING_AGX3B/agx_isa_is_agx3()(G16G/T6040/T6041/G17P); M4 (G16G) and M4 Pro/Max (T6040/T6041) hardware rows pending on-device validation.AGX3C(G17S/ M5) is unchanged bit-for-bit.MacBook Neo (
G17P, kernel6.19.0-rc8-asahi-00060-g2dfbc1f16dc4) — 4-round interleaved ABBA vsaurora-wip(efabab38502d)All runs with
MESA_SHADER_CACHE_DISABLE=true,kfaults_delta=0,avc_delta=0, all benchmark CRCs valid:us/submit)us/submit)gpu_usgpu_usrender.shadowdepth_onlyd32f20481500.0766.01.958×1664.2929.31.791×render.shadowdepth_onlyd1620481065.1833.31.278×1225.8990.31.238×render.shadowalpha_testd32f20483103.42466.21.258×3292.52585.51.273×render.postfx1440pmsaa=11071.4960.11.116×1144.71039.81.101×render.postfx1440pmsaa=41087.6981.01.109×1170.81066.81.097×render.postfx1080pmsaa=4638.3577.91.104×747.3688.21.086×compress.bwarray1440p405.0398.71.016×530.5500.41.060×compress.bwrgba32f/msaa4/mrt4412.4 / 307.4 / 861.3413.3 / 307.5 / 861.30.998–1.000×520.9 / 411.3 / 958.3521.8 / 410.3 / 958.60.998–1.002×render.deferreddram m4/tile m16428.6 / 1585.96317.7 / 1551.81.018–1.022×6626.3 / 1577.46630.4 / 1617.60.975–0.999×render.heavytexture1080p1782.21791.10.995×1829.91830.01.000×HK_FRAME_ANATOMY(Neo,basevs68faddaf6383)render.shadow d32fpass 4 (PCF lighting FS):fs=888ad48d:i80:g39:t1024:sp0(1464.8 us) ->fs=f587daff:i80:g87:t1024:sp0(722.5 us,2.03×, fullt1024occupancy preserved,0spills)render.shadow d16pass 4:1043.5 us -> 776.0 us(1.35×)render.shadow alpha_test d32fpass 4:2790.9 us -> 2054.2 us(1.36×)render.postfx 1440p msaa=1passes 1–5 (blur/downsample FS):fs=053684f9:i51:g23:t1024:sp0(571 us) ->fs=e1948ab7:i51:g39:t1024:sp0(408 us,1.40×, fullt1024occupancy preserved,0spills)render.deferred dram m1: identical shader hashes (5f1dd142,51703a29), zero codegen change.Correctness (
ASAHI_MESA_DEBUG=verify, MacBook Neo,kfaults_delta=0,avc_delta=0)gpubench-vkverifysmoke (8 cases acrosspostfx,compress.bw,shadow,deferred): 8/8 PASS, all CRCs valid.ASAHI_MESA_DEBUG=verify, 1,200 cases across 6 families): 1,200/1,200 (545 Pass,655 NotSupported,0 bad):dEQP-VK.texture.filtering.2d.*:200/200(47 Pass,153 NotSupported,0 bad)dEQP-VK.texture.filtering.2d_array.*:200/200(97 Pass,103 NotSupported,0 bad)dEQP-VK.texture.filtering.cube.*:200/200(104 Pass,96 NotSupported,0 bad)dEQP-VK.texture.shadow.*:200/200(53 Pass,147 NotSupported,0 bad)dEQP-VK.glsl.texture_functions.texture.*:200/200(142 Pass,58 NotSupported,0 bad)dEQP-VK.image.load_store.*:200/200(102 Pass,98 NotSupported,0 bad)Assisted-by: LLM (Antigravity:Gemini 4 Neon)