Repository navigation
agx,borealis: share SSBO vectorization, bounded CSE, loop spill room, and canonical minmax across chips - #941
Merged
Conversation
… and canonical minmax across chips Remove qualification-only chip and encoding gates on five pure NIR/AGX-IR optimization passes so M1/M2 (AGX2) and M3/M4 (G15/G16G) share the same compiler pipeline as G17P and M5: - Run pre-lowering SSBO CSE and nir_opt_load_store_vectorize on nir_var_mem_ssbo uniformly across all chips in hk_shader.c, keeping storage_result_select tied to the agx_has_soft_fault() hardware capability. - Enable loop live-through register reservation in agx_spill.c (compute_w_entry_loop_header) across all chips. - Enable agx_opt_cse_bounded across all AGX3B chips (G15/G16G/G17P) instead of falling back to agx_opt_cse_pressure on G15/G16G. - Run agx_nir_opt_canonical_minmax across all chips (AGX2, AGX3B, AGX3C) to elide redundant denorm-flush fadds after fmin_agx/fmax_agx. - Run agx3_remove_redundant_physical_copies across all AGX3 fragment shaders (AGX3B and AGX3C). Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH at 5fc6c67545a8
Blockers:
- Exact-head
asahiCI (build-teston5fc6c67545a8) is stillin_progress(run 45399412813); no code blockers. Ready to approve oncebuild-testfinishes green.
Checked:
- §1 No model gating / capability discipline: drops four qualification-only chip/encoding gates (
agx_chip_g17p_or_m5,AGX_CHIP_G17P,AGX_ISA_ENCODING_AGX3C) and tiesglobal_loads.storage_result_selecttoagx_has_soft_fault(&dev->dev)(DRM_ASAHI_FEATURE_SOFT_FAULTS); no new chip or firmware gates introduced. - §2 Code correctness across AGX2/AGX3B/AGX3C:
src/asahi/vulkan/hk_shader.c: pre-loweringnir_var_mem_ssboCSE + vectorization preservesrobust_modeswhen SSBO robustness is enabled and keepshk_ubo_loads_reorderableUBO-only;storage_result_select = agx_has_soft_fault(&dev->dev)usesnir_bounds_agx/nir_bcseland enablesm5_merge_buffer_wordsonly where soft faults are supported, matching existing UBO soft-fault lowering and element-alignment rules.src/asahi/compiler/agx_spill.c:compute_w_entry_loop_header()/loop_room_for_live_through()is pure SSA structured-CF live-through room calculation, guarded by!ctx->remat_onlywithassert(ctx->nW <= ctx->k)intact.src/asahi/compiler/agx_compile.c:agx_opt_cse_boundedpreserves global peak register pressure (pressure[p] + sizes[a] <= peak) and never eliminates block live-outs;agx_opt_cse_pressurestays covered bytest-pressure-cse.cpp.agx_nir_opt_canonical_minmaxbails on FP32 denorm-preserve mode, proves non-denormal/non-sNaN provenance (failing closed on buffers, unaligned shared accesses, atomics, and NaN constants), and only strips identityfadd(fmin_agx|fmax_agx, -0.0)flushes.src/asahi/compiler/agx_opt_register_cache.c:agx3_remove_redundant_physical_copies()clears tracking on every non-eliminable/non-reorderable/scheduled/destless instruction (including all exec-mask and CF ops), handles overlapping self-copies safely viaold_value[], matches AGX3BMOV_IMM/BITOP(UTIL_LUT2(a))lowering, and runs beforepostra_livenessrecomputes cache/discard hints.
- §3–§4 Safety, clean-room, authorship: pure NIR/AGX-IR passes, clean-room diff, human author/committer (
Ryan Murray) with matchingSigned-off-by:. - §5–§6 Evidence & naming: exact-head 4-generation CTS matrix (J316s G13X AGX2, J615 G15G, J713 G16G, Neo G17P regression; 0 Fail, 0 GPU faults, 0 new AVCs, 0 failed units) plus 258/258 host
asahisuite pass; Borealis naming followed.
Evidence
- PR state/head verified live:
OPEN,MERGEABLE,5fc6c67545a8a0c8a5497bf8217cee009f6b3087. - Exact-head mirror CI (
ci/train-pr941@5fc6c67545a8):policyPASS (run 45399413000),asahibuild-testin_progress(run 45399412813). - Non-blocking doc nits (no change required): stale chip-specific wording remains in comments at
src/asahi/compiler/agx_spill.c:1221(On G17P and M5...),src/asahi/compiler/agx_compile.c:13819-13820(AGX3B main programs additionally use the pressure-aware CSE...), andsrc/asahi/vulkan/hk_shader.c:1332(/* M5: ... */onm5_merge_buffer_words).
DjDeveloperr
approved these changes
Nov 24, 2026
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 5fc6c67545a8
Blockers: none
Checked:
- Exact-head
DjDeveloperr/mesamirror CI is now green on5fc6c67545a8:asahi(45399412813) PASS andaurora-agent-policy(45399413000) PASS. - Code, Hard Rule #8 capability gating, 4-generation CTS results (J316s, J615, J713, Neo), 258/258 host tests, and clean-room/attribution checks were verified in the prior review at this exact head.
Evidence
- Mirror
asahi: https://github.com/DjDeveloperr/mesa/actions/runs/45399412813 (PASS at5fc6c67545a8) - Mirror
aurora-agent-policy: https://github.com/DjDeveloperr/mesa/actions/runs/45399413000 (PASS at5fc6c67545a8) - Prior full audit at exact head: #941 (review)
|
Merged into |
satchlj
approved these changes
Nov 24, 2026
satchlj
left a comment
Member
There was a problem hiding this comment.
Verdict at 5fc6c67545a8
APPROVE
Blockers
None.
Checked
- Code audit (
5fc6c67545a8):- Removes qualification-only chip/encoding gates across five compiler/runtime passes without introducing any new model/chip gates:
src/asahi/vulkan/hk_shader.c: enables pre-lowering SSBO CSE/vectorization across all chips while keepingstorage_result_select = agx_has_soft_fault(&dev->dev)capability-driven.src/asahi/compiler/agx_spill.c: removesagx_chip_g17p_or_m5()incompute_w_entry_loop_header(), preserving!ctx->remat_only.src/asahi/compiler/agx_compile.c: enablesagx_opt_cse_boundedacross allAGX_ISA_ENCODING_AGX3Bnon-preamble non-vertex shaders, and runsagx_nir_opt_canonical_minmaxacross all encodings (verified encoding-agnostic insrc/asahi/compiler/agx_nir_lower_fminmax.c:366, bailing on FP32 denorm-preserve and failing closed on non-canonical sources).src/asahi/compiler/agx_opt_register_cache.c: widensagx3_remove_redundant_physical_copies()fromAGX_ISA_ENCODING_AGX3Ctoagx_isa_is_agx3()(verified post-RA single-block value-numbering clears on non-eliminable/non-reorderable/scheduled/destless instructions and runs prior topostra_livenessrecomputing cache/discard hints).
- Removes qualification-only chip/encoding gates across five compiler/runtime passes without introducing any new model/chip gates:
- Unit / drm-shim tests (
build-b19,-Dbuildtype=debugoptimized,MESA_SHADER_CACHE_DISABLE=1):- Full
meson test --suite asahi(excludingasahi_layout_tests): 260/260 PASS,0failures.
- Full
- Live hardware verification (Apple M5 Max
G17C B1, Linux 7.3, Borealis,MESA_SHADER_CACHE_DISABLE=1):- Targeted Vulkan CTS (
dEQP-VK.ssbo.layout.single_basic_type.std430.*): 303/303 PASS,0failures. - Kernel GPU faults:
0.
- Targeted Vulkan CTS (
- Untested scope:
- Live AGX2 (
G13/G14) and AGX3B (G15/G16G/G17P) hardware runs were not executed on this Apple M5 Max (G17C B1, AGX3C) host (covered by author 4-generation hardware receipts and host drm-shim tests). asahi_layout_testswas excluded from the localmeson test --suite asahirun.
- Live AGX2 (
Evidence
- Meson
asahisuite (non-layout):260/260OK (0fail). - Live Vulkan CTS on Apple M5 Max (
G17C B1, Linux 7.3,Mesa 26.3.0-devel (git-5fc6c67545), Borealis):dEQP-VK.ssbo.layout.single_basic_type.std430.*:303/303PASS (0fail)dmesgGPU fault check:0GPU faults.
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Remove qualification-only chip and encoding gates on five pure NIR/AGX-IR optimization passes so M1/M2 (AGX2) and M3/M4 (G15/G16G) share the same Borealis compiler pipeline as G17P and M5: pre-lowering SSBO CSE and vectorization (
hk_shader.c, keepingstorage_result_selecttied toagx_has_soft_fault()), loop live-through spill reservation (agx_spill.c), AGX3Bagx_opt_cse_bounded(agx_compile.c), all-chipagx_nir_opt_canonical_minmax(agx_compile.c), and AGX3agx3_remove_redundant_physical_copies(agx_opt_register_cache.c).Tested: At exact head
5fc6c67545a8(arm64libvulkan_asahi.sosha2567929e968dabc54c9fc173350557f03fc1ded37c5cc22fb46a577f8984ebeaf68), hostmeson test --suite asahipassed 258/258 (0 Fail) and exact-headdEQP-VKCTS (b5_compiler_ssbo, 270 cases covering SSBO layout/phys/robustness, FP32 min/max/clampdenorm_flush, loops, switch, selection, compute SSBO + control suite) passed with 0 failures, 0 GPU faults, and 0 new AVCs across J316s (G13X AGX2), J615 (G15G), J713 (G16G), and Neo (G17P regression).Risk: Two-way door. Scope is pure NIR/AGX-IR optimization passes in
src/asahi/vulkan/hk_shader.c,src/asahi/compiler/agx_spill.c,src/asahi/compiler/agx_compile.c, andsrc/asahi/compiler/agx_opt_register_cache.c; no ABI, UAPI, or hardware descriptor changes.Not yet: Exact-head mirror CI, independent review, and optional J413 (G14G) confirmation (AGX2 path already covered by J316s G13X; J413 was locked for a Stage 2 boot trial at submission time).
Implementation details and exact-head 4-generation CTS results
Change
src/asahi/vulkan/hk_shader.c: dropagx_chip_g17p_or_m5()around pre-lowering SSBO CSE andnir_opt_load_store_vectorizeonnir_var_mem_ssboso adjacent 32-bit SSBO loads/stores vectorize before 64-bit explicit-IO lowering on AGX2, G15, and G16G too. Tieglobal_loads.storage_result_selecttoagx_has_soft_fault(&dev->dev)so soft-fault zero-select remains strictly hardware-capability-driven.src/asahi/compiler/agx_spill.c: dropagx_chip_g17p_or_m5()incompute_w_entry_loop_header()so live-through loop register reservation runs across all chips when!ctx->remat_only.src/asahi/compiler/agx_compile.c:key->dev.chip == AGX_CHIP_G17Pin the AGX3B CSE branch so G15 and G16G useagx_opt_cse_boundedinstead of falling back toagx_opt_cse_pressure.key->dev.encoding == AGX_ISA_ENCODING_AGX3Caroundagx_nir_opt_canonical_minmaxso AGX2 and AGX3B also elide redundant denorm-flushfadd(..., -0.0)afterfmin_agx/fmax_agx.src/asahi/compiler/agx_opt_register_cache.c: widenagx3_remove_redundant_physical_copies()fromAGX_ISA_ENCODING_AGX3Ctoagx_isa_is_agx3()so AGX3B fragment shaders also eliminate redundant post-RA register copies.Testing
Base:
origin/aurora-wip6fa856f3ba3(ff972ec79174b291) vs Head:5fc6c67545a8(7929e968dabc54c9):meson test --suite asahi: 258/258 PASS (0 Fail).dEQP-VK(b5_compiler_ssbo, 270 cases:ssbo.layout.*85/85,ssbo.phys.layout.*20/20,robustness2.*storage_buffer*23/30,float_controls.fp32.*denorm_flush*35/35,glsl.loops.*35/35,glsl.switch.*20/20,glsl.operator.selection.*20/20,compute.*ssbo*20/25; plus 96-case control suite, 95 on J713fleet85):base3b5_compiler_ssbob5b5_compiler_ssbob5controlfleet87)fleet85)fleet85)fleet87, reg.)