Repository navigation
agx: rematerialize uniform moves when spilling on AGX3C - #458
Conversation
|
Thanks for extending rematerialization. We select behaviour by a hardware property, here the ISA encoding, rather than by the chip it was tested on. The change adds a chip id next to an encoding test:
G17G, G17S and G18G use the same AGX3C encoding as G17C, so they would keep reading the move back from scratch for no stated reason. Could the test be If you make it the default more widely, we can supply rows on our M1 Pro, M2, M4 Pro and A18 Pro. |
Merge train: independent review (code only, Opus 5.5 xhigh)Verdict: CLEAN WITH NITS. No blocker or major (G17P already had the same rematerialization). NIT: no new test covers the G17C path. Reach: gated on |
A spilled copy of a 32-bit uniform word can be made again at its use instead of being read back from scratch. AGX3B already does this; the AGX3C copy form reads any even uniform pair into any 32-bit register the same way, so G17G, G17S and G17C take it too. This covers the AGX3 word copy; AGX2 reads uniforms with its own bitop and keeps its spill behaviour. G18G, which compiles as AGX3C and re-encodes as agx3d, is left out: a rematerialized copy is placed under register pressure, where its destination is often at or above half 128, and agx3d copies into those destinations have not been verified to execute correctly. The uniform rematerialization tests now cover every AGX3C part, check that after spilling there at least sixteen uniform moves remain with no memory operands, and that G18G keeps the copies in memory. Signed-off-by: Erik Bourget <erik@ebourget.net>
210b063 to
b5a86e1
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of erikwb Thanks. Changes in this revision:
Shader statistics, aurora-wip vs this change (host compiles under the noop drm-shim). "No change" means the tracked statistics (instructions, registers, threads, spills, fills, scratch, code size) match for the shaders that compiled on both trees:
On the M5 Max (G17C), the CTS sets in the description match aurora-wip case for case, including the cases where this change compiles differently. Rows on your M1 Pro, M2, M4 Pro and A18 Pro should show no change, since nothing outside AGX3C changes. A G17G or G17S row would cover the newly enabled parts. |
|
No blockers. Re-read b5a86e1 against the reviewed 210b063.
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Review of b5a86e1c551d547d85fb0dbc516484c261cf9266
0 code/policy/attribution blockers. Holding APPROVE only for §5 hardware verification on newly enabled AGX3C parts.
Checklist summary
- §1 No model gating: Pass.
agx_can_rematerialize_uniform()(src/asahi/compiler/agx_spill.c:307-321) keys onencoding == AGX_ISA_ENCODING_AGX3B || (encoding == AGX_ISA_ENCODING_AGX3C && !agx_is_g18g(&ctx->key->dev)).agx_is_g18g()checks theemit_agx3dISA property rather than a chip ID, and the G18G exclusion is backed byagx3_copy_encode_uniform_to_reg32()rejectingAGX3Ddestinations>= 128(src/asahi/compiler/agx3_copy_core.c:286-288) until high-destinationagx3dcopies are hardware-verified. - §2 Hygiene & §3 Correctness: Pass. Reuses the existing AGX3B eligibility invariants (non-preamble,
!uniforms_written, scalar 32-bit normal non-memory dest, aligned even 32-bit uniform< 512, no modifiers), whichagx3_copy_encode_uniform_to_reg32()encodes across the full 0..254 half-register destination range on AGX3C. Unit tests intest-uniform-remat.cppcover all 6 targets (G13G,G17P,G17G,G17S,G17C,G18G), verify zero spill memory traffic on AGX3C, and pin G18G's spill behavior. - §4 Attribution & clean-room: Pass. Single commit carries human author/committer and
Signed-off-byonly; PR body includesAssisted-by:. - §6 Naming: Pass. Compiler-only (
agx), no Honeykrisp/hk_naming issues. - CI / Mergeability:
MERGEABLE/CLEANagainstaurora-wip; no CI checks configured on this branch. Hostmeson test --suite asahi(166/166) andagx_tests(1218 pass, 1 skip) pass onb5a86e1c, and precompiledlibagxarrays are unchanged across all targets.
Remaining items (§5 evidence)
- Newly enabled AGX3C hardware (
G17GM5 /G17SM5 Pro): at least one hardware run covering the cooperative-matrix CTS subset (matchingaurora-wipcase-for-case) with regression checks (0 SELinux/AVC denials, 0 failed units, 0 new kernel errors). - Rebased-head regression row on
b5a86e1c: the M5 Max (G17C) CTS sets were run on identical code prior to rebase (7ba29572); please include the regression row (0 AVC / 0 failed units / 0 new kernel errors) on the rebased head when running hardware checks. (AGX2, AGX3B, and G18G codegen andlibagxare unchanged, so no rows are needed there.)
Assisted-by: LLM (Gemini 4 Neon)
|
Note 🤖 Gemini 4 Hydrogen responding on behalf of erikwb Returning this PR to draft pending On
Still unrun (PR moving back to draft until covered): |
satchlj
left a comment
There was a problem hiding this comment.
Verdict at b5a86e1c551d
Approved.
Blockers
None.
Checked
- Audited
src/asahi/compiler/agx_spill.candsrc/asahi/compiler/test/test-uniform-remat.cpp, plus callers insrc/asahi/compiler/agx_register_allocate.c. - Verified
agx_can_rematerialize_uniform()uses ISA encoding / backend capability gating (AGX_ISA_ENCODING_AGX3BorAGX_ISA_ENCODING_AGX3Cexcluding G18G pending verified high-destination>= 128uniform copy encoding) and preserves the immutability, alignment, range (< 512), and non-modifier preconditions across both spilling and RA cost estimation. - Verified build,
206/206non-layoutasahitests (including5/5UniformRemat.*unit tests covering AGX3B, AGX3C, and G18G spill retention), and live GLES3 CTS on Apple M5 Max (G17C B1), Linux 7.3 (MESA_SHADER_CACHE_DISABLE=1) with0GPU faults indmesg. - Untested scope: Live execution on other AGX3C variants (
G17G,G17S) andG18G.
Evidence
meson test --suite asahi(non-layout):206/206OK (agx_testsOK)agx_tests --gtest_filter='*UniformRemat*':5/5passed (ImmutableWordCopiesOnly,SpillerRecreatesUniformsWithoutMemoryTraffic,SpillerRecreatesUniformsWithoutMemoryTrafficOnAGX3C,G18GSpillsUniformCopies,UniformWritesKeepCapturedValuesInMemory)- Live Apple M5 Max (
G17C B1), Linux 7.3,MESA_LOADER_DRIVER_OVERRIDE=asahi MESA_SHADER_CACHE_DISABLE=1:dEQP-GLES3.functional.shaders.loops.for_constant_iterations.*:64/64passed (0failed)dmesgGPU fault delta:0
|
J714s (Apple M5 Pro / T6050 / G17S B1) exact-head PASS at
|
What: Enable 32-bit uniform word rematerialization in
agx_can_rematerialize_uniform()(src/asahi/compiler/agx_spill.c) onAGX_ISA_ENCODING_AGX3Cwhile excludingG18Gvia!agx_is_g18g(&ctx->key->dev), so spilled uniform copies onG17G,G17S, andG17Care recreated at use instead of spilling to scratch.Tested: M5 Max (
J716c,G17C) atb5a86e1c551d: VK-GL-CTS cooperative-matrix mustpass subsets matchaurora-wip(fa9a6766c01) with 0 diffs (200 Pass / 1800 NotSupported and 150 Pass / 1350 NotSupported) and 0 new kernel/GPU errors, 0 journal errors, 0 new failed units; reviewer-verified GLES3 CTS (dEQP-GLES3.functional.shaders.loops.for_constant_iterations.*: 64/64 passed, 0 GPU faults); hostmeson test --suite asahi166/166 passed (agx_tests1218 passed, 1 skipped).Risk: two-way door · M5 family (
G17G,G17S,G17C;AGX3CexcludingG18G);AGX2,AGX3B,G18G, and precompiledlibagxkernels are unchanged.Not yet: Live hardware runs on
G17G(M5) andG17S(M5 Pro) (noG17G/G17Shardware available locally;G18Gis intentionally excluded by!agx_is_g18g()).Details
agx_can_rematerialize_uniform()(src/asahi/compiler/agx_spill.c) previously gated onctx->key->dev.encoding == AGX_ISA_ENCODING_AGX3B. It now enablesAGX_ISA_ENCODING_AGX3B || (AGX_ISA_ENCODING_AGX3C && !agx_is_g18g(&ctx->key->dev)).AGX3C, the uniform-to-GPR word copy encodes any even 32-bit uniform word (< 512) into any 32-bit GPR (0..254halves), reusing the existing invariants (non-preamble,!uniforms_written, scalar 32-bit normal non-memory destination, noabs/negmodifiers).AGX2reads uniforms with its own bitop and keeps its existing spill behaviour.G18G(compiled asAGX3C, re-encoded asagx3dwhenemit_agx3dis set) stays excluded with a code comment: rematerialized copies are placed under register pressure where destinations are often at or above half 128 (AGX3_COPY_REG16_DEST_HALVES), andagx3dcopies into those destinations have not been verified to execute correctly onG18Ghardware (agx3_copy_encode_uniform_to_reg32()rejectsAGX_ISA_ENCODING_AGX3Ddestinations>= 128).src/asahi/compiler/test/test-uniform-remat.cppcover all six representative targets (G13G,G17P,G17G,G17S,G17C,G18G), verify zero spill memory traffic onG17G/G17S/G17C, and pinG18Gspill retention.Evidence
Host compiler and Borealis unit tests on
aurora-wip(fa9a6766c01) plusb5a86e1c551d(-Doptimization=2 -Ddebug=false -Db_ndebug=false -Dbuild-tests=true -Dtools=drm-shim -Dvulkan-drivers=asahi):meson test --suite asahi:166/166passed (and in reviewersatchlj's non-layoutasahisuite run atb5a86e1c551d:206/206passed).agx_tests:1218passed,1skipped (NativeFMA.ExactDyadicOracle, which skips withoutAGX_FMA_RTE_CASESonaurora-wipas well).agx_tests --gtest_filter='*UniformRemat*':5/5passed (ImmutableWordCopiesOnly,SpillerRecreatesUniformsWithoutMemoryTraffic,SpillerRecreatesUniformsWithoutMemoryTrafficOnAGX3C,G18GSpillsUniformCopies,UniformWritesKeepCapturedValuesInMemory).libagxkernels (src/asahi/lib/libagx_shaders.c): byte-for-byte identical betweenfa9a6766c01andb5a86e1c551d(sha256: cf7112a67527e000f35c24ce133e349741c391fd43808898d47b219399dab84d).M5 Max (
J716c,G17C) VK-GL-CTS mustpass A/B atb5a86e1c551dvs basefa9a6766c01(Linux 7.3.0, release builds;libvulkan_asahi.sosha256d6f38d655757a6676365d0f031722a90a505edbd8524cf4413ba1200842abcd2vs6b871cdb18f7251e659caac9496a4590b13d867257bb9eecf40caa4edad634f0):fa9a6766c01)b5a86e1c551d)compute.pipeline.cooperative_matrix.*physical_buffer*(2000 evenly spaced)compute.pipeline.cooperative_matrix.*(1500 evenly spaced)System health over the M5 Max (
G17C) CTS run:0new kernel/GPU dmesg errors,0new journal errors,0new failed systemd units (aurora-peripherals.servicewas already failed at boot before the run; SELinux/AVC is N/A on this Arch ARM host withCONFIG_SECURITY_SELINUXunset).Reviewer (
satchlj) live GLES3 CTS on M5 Max (G17C B1) atb5a86e1c551d(Linux 7.3,MESA_LOADER_DRIVER_OVERRIDE=asahi MESA_SHADER_CACHE_DISABLE=1):dEQP-GLES3.functional.shaders.loops.for_constant_iterations.*:64/64passed (0failed),dmesgGPU fault delta0.Shader statistics (
AGX_MESA_DEBUG=shaderdbunderlibasahi_noop_drm_shim.so),aurora-wip7ba29572vs identical code before rebase (ASAHI_SHIM_CHIPprofilesg17s,g17g-compile-only,g18g,g17p,g16g,g14g,g13g, plus a local compile-onlyg17cprofile on7ba29572withgpu_generation=17,gpu_variant='C',gpu_revision=0,chip_id=0x6050,num_dies=1,num_clusters_total=4,num_cores_per_cluster=10,core_masks={0x3ff, 0x3ff, 0x3ff, 0x3ff},usc_generation=3,gpu_hal_generation=DRM_ASAHI_GPU_HAL_300,features=SOFT_FAULTS|RENDER_RESOURCES|RENDER_RESOURCES_V2):G17CandG17S, 56 change (45 use fewer registers, 44 gain occupancy e.g. 111 -> 103 registers and 896 -> 1024 threads; total instructions 716,277 -> 717,806 onG17C, spills 2,054 -> 2,041, fills 2,047 -> 2,036 across 3 shaders). OnG17G, 5 change (3 with fewer registers and more threads). No change onG18G(347 of 617 compile),G17P, orG13G.G17C,G17S,G17G; 41 onG18G,G17P,G16G; 25 onG13G,G14G): no change on any chip.Prior to rebase (on
aurora-wip7ba29572with identical code), 12 of the 200 supported cases in thephysical_bufferset compiled differently and passed on both; across 20,000 evenly spaced cases over the Vulkan mustpass, no case outside cooperative matrices compiled differently. Earlier on M5 Max (57df4db849awith#450,#451,#452), a 22-frame Cyberpunk 2077 2.5 capture (3840x2160 High, FSR2 Balanced, GFXReconstruct replay, median of 3 alternating runs) measured 12.207 -> 12.274 FPS (+0.55%, within the 11.99-12.43 FPS run spread; stage times changed by < 0.2%).