Repository navigation
borealis/tests: give the GS fence-strip loop a run-time trip count - #738
Conversation
check_main_side_effects_fence_strip() builds a geometry shader whose loop runs exactly 64 times and expects the main kernel to keep that loop with one atomic and one fence_mem_to_tex_agx. The loop's only job is to check that stripping the atomic in replay also strips the fence, so the raster variant does not keep a loop alive for the fence alone. With "agx: enable AGX3 compute unroll, shared-memory, and 32x32 GEMM passes on AGX3B" (in #704), agx_preprocess_nir_g17p() raises max_unroll_iterations to 64, as M5 already does. The 64-trip loop is then fully unrolled before hk_nir_lower_gs() sees it: the main kernel has 64 atomics, 64 fences and no loop, and the test fails at its first count check although the strip itself still works. Read the trip count from memory instead, so no unroll limit can remove the loop. The checks are unchanged and still fail if strip_fence_mem_to_tex() stops removing the fence. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Review at e99a60c. Right fix for the test, not the compiler: with the bound loaded from memory, no constant unroll limit can flatten the loop, and the checks still see the loop + atomic + fence shape the GS lowering is meant to handle. The runtime-bound specialization in #735 only takes pure read-only loop nests, and this one has an atomic and a fence, so it stays a loop there too. Test-only, human trailer only. Nit: a one-line note that the test no longer cares about the trip count (only that the loop survives) would stop someone from "restoring" the 64 later. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at e99a60c5ac6a0180b6ddb36c63c7ec91e15ce74c (base aurora-wip).
Summary
Sound unit-test fix. Replacing the constant 64-trip loop bound (nir_uge_imm(&b, i, 64)) in check_main_side_effects_fence_strip() with a loop-invariant global load (nir_load_global at distinct count_addr = 0x1000a000000ull, nir_uge(&b, i, trips)) prevents agx_preprocess_nir_g17p() from flattening the loop under #704/#735's 64-iteration unroll limit (or any future constant limit) without weakening what is tested:
- In the main kernel (
b.shader), the loop, atomic, andfence_mem_to_tex_agxstay intact forhk_nir_lower_gs()to inspect. - In the raster variant (
rast),nir_load_globalis side-effect-free, so stripping the atomic and fence still allows dead-loop/DCE to eliminate the loop (!has_loop(rast)), while mutatingstrip_fence_mem_to_tex()to retain the fence still fails the test. - The other constant-bound loops in
test-hk-gs-ray-query.cuse 1024 iterations and are unaffected by the 64-trip preprocess limit.
§1–§6 Checklist
- §1 No model gating: Pass (unit-test-only change).
- §2 Production-ready, no hacks: Pass (run-time trip count is the right fix instead of bumping the constant).
- §3 Safety: Pass (N/A, unit test only).
- §4 Clean-room & attribution: Pass (human author/committer
Ryan Murray <ryan@aurorasilicon.org>, humanSigned-off-by:, no AI trailers in commit;Assisted-by:present in PR body). - §5 Evidence: Pass (local
meson test --suite asahi --suite polyruns pass onaurora-wip235/235 andaurora-wip + #735236/236 vs 235/236 failing at:643, plus mutant kill check at:651; unit-test-only so no hardware run needed; repo has no GitHub Actions check runs). - §6 Naming: Pass (
borealis/tests:subject; existinghk_/asahiidentifiers are pre-existing underaurora-silicon/mesa#591).
Assisted-by: LLM (Gemini 4 Neon)
Problem.
hk_gs_ray_queryfails attest-hk-gs-ray-query.c:643once #704 (or #735 on top of it) is merged onto aurora-wip. #704's commit "agx: enable AGX3 compute unroll, shared-memory, and 32x32 GEMM passes on AGX3B" raises the preprocess unroll limit to 64 iterations on G17P, as M5 already does. The fence-strip test's geometry shader loop runs exactly 64 times, so it is now fully unrolled before the GS lowering runs: the main kernel ends up with 64 atomics, 64 fences and no loop. The strip itself still works. The test just no longer builds the shape it means to check.Change. The loop reads its trip count from memory instead of using the constant 64, so no unroll limit can remove it. The checks are the same.
Testing (x86 build, clang release with asserts,
meson test --suite asahi --suite poly):strip_fence_mem_to_tex()changed so it never removes the fence, the fixed test fails at :651 (raster variant keeps the fence). The test still catches the bug it was written for.Still to run. Nothing on hardware: this changes a unit test only.
Probe output and notes for reviewers
Probe printed just before the :643 check (main = main kernel after
agx_preprocess_nir_g17p+hk_nir_lower_gs, rast = raster variant):Root cause in code: in #704,
agx_preprocess_nir_internal()callsagx_optimize_loop_nir(nir, !g17p && native_fragment_depth, g17p, g17p || native_fragment_depth). On aurora-wip the 64-iteration limit applied only when the M5 argument was true (!g17p && native_fragment_depth). So on AGX3B, every stage now gets the 64-trip unroll at preprocess, not just compute.A question for the #704 author, not a blocker for this PR: the #704 commit title and comment talk about compute and the GEMM matcher. Is the 64-trip unroll at preprocess meant for graphics stages too, given that AGX3C already does it in all stages? If it should be compute-only, that change belongs in #704. This test fix is correct either way.
The merge of #735 onto aurora-wip has two conflicts with #728's move of the shared-phase CSE. These tests used REVIEW-WAVE-3's resolution. Logs and diffs: traces/ci/20261123-review-wave-4-mesa735-gs-unroll on the lab store.
Assisted-by: LLM (Claude:Opus 5.5)