Skip to content

compiler: Don't collect aliases guarded by a Dimension they don't span - #3010

Open
mloubout wants to merge 1 commit into
mainfrom
cire-guarded-aliases
Open

compiler: Don't collect aliases guarded by a Dimension they don't span#3010
mloubout wants to merge 1 commit into
mainfrom
cire-guarded-aliases

Conversation

@mloubout

Copy link
Copy Markdown
Contributor

Prevent aliaseas out of it's guards

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.68%. Comparing base (436199c) to head (4440234).

Files with missing lines Patch % Lines
tests/test_dse.py 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3010      +/-   ##
==========================================
+ Coverage   83.67%   83.68%   +0.01%     
==========================================
  Files         257      257              
  Lines       54663    54686      +23     
  Branches     4683     4687       +4     
==========================================
+ Hits        45739    45766      +27     
+ Misses       8114     8111       -3     
+ Partials      810      809       -1     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.48% <84.61%> (+<0.01%) ⬆️
pytest-gpu-gcc- 78.31% <93.10%> (+<0.01%) ⬆️
pytest-gpu-icx- 78.23% <93.10%> (+<0.01%) ⬆️
pytest-gpu-nvc-nvidiaX 69.12% <84.61%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

An alias is scheduled over the Dimensions it spans, but the guard it
inherits from its Cluster is kept as it is.  When the guard reads a
Dimension the alias itself does not span, the temporary is computed in
a loop nest that does not define it, and the generated code does not
compile:

    for (int x = ...)
      if (sdf(x, y) >= 0)     /* y is not iterated here */
        r0[y] = ...

which is what an expression guarded by a ConditionalDimension over a
Function of all the Dimensions produces -- an immersed boundary
condition, say -- as soon as a sub-expression of it depends on fewer
Dimensions than the guard.  The added test is an MFE of exactly that,
and fails to compile with "'x' undeclared" without this change.

Discard those aliases in `collect`, as the pivot is formed and before
its distance vectors and cost are computed.  A SEQUENTIAL Dimension is
exempt: its loop encloses the alias' own, so the guard is evaluated
outside of them in any case, and requiring the alias to span it would
cost the hoisting of a time invariant guarded by a subsampled time
Dimension (`test_invariants_with_conditional`).

The Dimensions a guard reads are what `Guards` is asked for here, so
give it a `dimensions` property rather than walking its values from the
outside.  `Cluster.guards_dimensions` was already doing that walk by
hand and now defers to it.  The property returns the Dimensions as they
are, not their roots: `guards_dimensions` reaches `expose_tuning_knobs`
through `used_dimensions`, which tests them for `is_Block`, and a root
is never a BlockDimension.

Asking `Properties` whether a Dimension is SEQUENTIAL requires it to
still be one: `CireInvariants._lookup_key` was rebuilding it as a plain
`frozendict`, losing the class and its API, where the other
`_lookup_key` passes it through untouched -- so `collect` saw a
different type depending on which CIRE variant called it.  `Properties`
is a `frozendict` itself, so preserving it there costs nothing.
@mloubout
mloubout force-pushed the cire-guarded-aliases branch from a52424a to 4440234 Compare August 21, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant