Repository navigation
agx: omit unreachable wrap fallback on exact-tail binary peels - #758
DjDeveloperr wants to merge 1 commit into
Conversation
|
Verdict: changes (points 1 and 2 are correctness; the rest are evidence and cleanup). Non-author review of a464d75 (5 commits on top of #743 Checked and holding
Points
|
|
Review at a464d75. Five commits in three independent groups. Please split them: (1) exact-tail wrap omission, (2)+(3) flatten-loads changes, (4)+(5) interior unswitch and rotated peel. Then each group can be reviewed and bisected on its own. I found no problems in 1: on a bottom-tested step +-1 REL_LT/REL_GT loop only iteration 0 can wrap, and only at the extreme.
|
For bottom-tested exact_tail loops peeled with a 4/2/1 binary tail, wrap on iteration 0 is only possible when iv0 is non-constant or equals the step-direction extreme (INT32_MAX/UINT32_MAX for +1, INT32_MIN/0 for -1). When iv0 is a compile-time non-extreme constant and the bound cannot wrap, rewrite latch and header live-outs from the lowered registers and remove the dead scalar fallback loop. Shared across AGX3B and AGX3C (M5); removes the unreachable tail loop from bottom-tested 1D convolution loops while preserving wrap semantics for runtime or extreme initial values. Signed-off-by: DjDeveloperr <hey@djdev.me>
a464d75 to
01a39fa
Compare
|
Review at 01a39fa. What changed: the PR was split as asked. It now holds only the exact-tail wrap-fallback commit, on top of #743 ( Status of our points:
I re-read the remaining commit. When Verdict: APPROVE (code). Owed: Dj's exact-head fedora-mesaci run and the 4-chip shader-db numbers (G15G/G16G/G17P/G17S) promised in the body. It lands after #743. |
|
@RyanTheTide Thanks for the thorough review and catching both real bugs in
Assisted-by: LLM (Antigravity:Gemini 4 Neon) |
|
Exact-head verification for #758 R2 ( 1. Exact-head
|
| Chip | Compiled | Spills | Changed | Total Instrs | Total Code Size | Thread Occupancy Drops |
|---|---|---|---|---|---|---|
g15g (AGX3B) |
80/80 OK | 0 | 9/80 | 16602 -> 16458 (-0.87%) |
159250 -> 157874 B (-0.86%) |
0 |
g16g (AGX3B) |
80/80 OK | 0 | 9/80 | 16602 -> 16458 (-0.87%) |
159250 -> 157874 B (-0.86%) |
0 |
g17p (AGX3B) |
80/80 OK | 0 | 9/80 | 17397 -> 17249 (-0.85%) |
176328 -> 174888 B (-0.82%) |
0 |
g17s-kernel (AGX3C) |
80/80 OK | 0 | 9/80 | 13887 -> 13760 (-0.91%) |
130250 -> 128990 B (-0.97%) |
0 |
All 9 matched shaders drop 1 dead scalar wrap-fallback loop across every chip (loops 2->1 or 4->3, saving 10–22 instrs / 90–200 B per shader on G15G/G16G/G17P, and up to -4 GPRs on fdb07155 on G17S; ca29e97d on G17S is +2 instrs / +6B with loops 2->1, 39->39 GPRs).
#758 R2 is now fully verified and ready to merge behind #743.
Assisted-by: LLM (Antigravity:Gemini 4 Neon)
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE
Checked: Full diff in src/asahi/compiler/agx_nir_unroll_runtime_loops.c and src/asahi/compiler/test/test-agx3-vision-opts.cpp, native assert-enabled build (-Db_ndebug=false), meson test --suite asahi, and live Vulkan CTS on Mac Studio M5 Max (J775c, T6050).
Notes:
exact_tailrestricts the wrap-fallback omission to rotated bottom-tested loops withcl->offset == cl->step, valid preheaderinitand latchiv_back, andback_edge_live_outs, whilebinary_tailguaranteesfactor == 8and|cl->step| == 1. OnREL_LT/REL_GT, wheniv_nextwraps past the type extremum before the first iteration's post-body test (iv_next < boundoriv_next > boundis true only if the wrapped value does not satisfy the exit bound, and the main loop'sguard_boundprevents overshoot), omitting the unreachable scalar fallback loop while retainingREL_LE/REL_GEextreme-bound wrap handling is sound.- Both unit tests (
ExactTailBinaryPeelOmitsUnreachableWrapFallbackandExactTailRelLeKeepsWrapFallback) cover the omitted vs retained fallback paths.
Evidence
- Head audited:
01a39fa4f91fd416fe12ff381889db3e2f4ba0f2(aurora-silicon/mesa#758) - Host build & unit tests on Mac Studio M5 Max (J775c, T6050):
clang 23.1.4,-Db_ndebug=false,meson test --suite asahi:146/146 PASS(0 fail). - Live Borealis Vulkan CTS on Mac Studio M5 Max (J775c, T6050),
LD_DEBUG=libsconfirmedlibvulkan_asahi.so(git-01a39fa4f9):dEQP-VK.compute.pipeline.basic.*:80/80 PASS(1 NotSupported,0 fail),GPU_FAULT_DELTA=0.
|
@DjDeveloperr thanks for the 4/2/1 tail and the wrap proof. #1353 carries those pieces into the current counted-loop unroller and preserves the scalar path where wrap is possible. J615 and J700 readbacks match and show faster integer convolution with larger shaders. The benchmark source and full results are linked there. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Split from the original 5-commit PR #758 per review (
#issuecomment-7088946412): this PR keeps only Commit 1 (exact-tail wrap fallback omission); the remaining two independent groups are being split into separate follow-up PRs (PR B: load flattening on AGX3B +store_sharedsink / tile-load burst flattening; PR C: affine interior-bounds unswitching + rotated 2D stencil peeling, with both review correctness fixes).Summary
agx_nir_unroll_runtime_loops.c(unroll_loop): For bottom-testedexact_tailloops peeled with a 4/2/1 binary tail (REL_LT/REL_GT, step±1), wrap on iteration 0 is only possible wheniv0is non-constant or equals the step-direction extreme (INT32_MAX/UINT32_MAXfor+1,INT32_MIN/0for-1). Wheniv0is a compile-time non-extreme constant and the bound cannot wrap, rewrite latch and header live-outs from the lowered registers and remove the dead scalar fallback loop.agx_nir_unroll_runtime_loops.c:1039-1057noted in review.agx3_unroll((AGX3B || AGX3C) && !emit_agx3d), reaching all shader stages on AGX3B (G15/G16/G17P/G17A) and AGX3C withoutemit_agx3d(G17G/G17S/ M5). AGX2 and G18G (emit_agx3d) are unchanged.Verification
-Db_ndebug=falsemeson test --suite asahi --suite poly: 170/170 OK (includingExactTailWrapFallbackOmitted,ExactTailWrapFallbackKeptAtExtreme, andExactTailWrapFallbackKeptRuntimeInitintest-agx3-vision-opts.cpp).DEFAULT_BRANCH=aurora-wip bash .github/aurora/agent-policy.sh pr HEAD: clean.fedora-mesaci+ 4-chip (G15G/G16G/G17P/G17S) shader-db verification in progress (will post in comment).