Skip to content

borealis/tests: give the GS fence-strip loop a run-time trip count - #738

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
fix/borealis-gs-fence-strip-runtime-trips
Nov 22, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
fix/borealis-gs-fence-strip-runtime-trips

Conversation

@RyanTheTide

Copy link
Copy Markdown

Problem. hk_gs_ray_query fails at test-hk-gs-ray-query.c:643 once #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):

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):

merged, old test:   main fences=64 main atomics=64 main has_loop=0 rast fences=0 rast has_loop=0
merged, this fix:   main fences=1  main atomics=1  main has_loop=1 rast fences=0 rast has_loop=0
merged, fix + mutant (strip never removes the fence):
                    main fences=1  main atomics=0  main has_loop=1 rast fences=1 rast has_loop=1  -> FAIL :651

Root cause in code: in #704, agx_preprocess_nir_internal() calls agx_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)

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>
@RyanTheTide

Copy link
Copy Markdown
Author

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 DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and fence_mem_to_tex_agx stay intact for hk_nir_lower_gs() to inspect.
  • In the raster variant (rast), nir_load_global is side-effect-free, so stripping the atomic and fence still allows dead-loop/DCE to eliminate the loop (!has_loop(rast)), while mutating strip_fence_mem_to_tex() to retain the fence still fails the test.
  • The other constant-bound loops in test-hk-gs-ray-query.c use 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>, human Signed-off-by:, no AI trailers in commit; Assisted-by: present in PR body).
  • §5 Evidence: Pass (local meson test --suite asahi --suite poly runs pass on aurora-wip 235/235 and aurora-wip + #735 236/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; existing hk_/asahi identifiers are pre-existing under aurora-silicon/mesa#591).

Assisted-by: LLM (Gemini 4 Neon)

@DjDeveloperr
DjDeveloperr merged commit b219ee2 into aurora-wip Nov 22, 2026
@RyanTheTide
RyanTheTide deleted the fix/borealis-gs-fence-strip-runtime-trips branch November 27, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants