Repository navigation
Conversation
added 2 commits
October 29, 2026 22:30
`_merge_halospots` and `_hoist_invariant` derived a Scope, i.e. a full `FindWithin` visit of the enclosing Iteration, for every HaloSpot pair before checking whether the pair could merge or hoist at all. Since 0038c8c, an Operator with many Eqs over distinct SubDomains carries one HaloSpot per Eq, so the number of pairs, and Scope derivations, grows quadratically. Derive the Scope only when a pair passes the cheap compatibility checks; all merge and hoist decisions are unchanged. Claude-Session: https://claude.ai/code/session_01TT4Kt2oZNzhQrSw8SfVoaw
Add Eqs whose HaloSpots exchange distinct Functions, so that a Scope derived eagerly in `_hoist_invariant` alone also breaks the bound. Claude-Session: https://claude.ai/code/session_01TT4Kt2oZNzhQrSw8SfVoaw
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3098 +/- ##
==========================================
+ Coverage 84.43% 84.46% +0.02%
==========================================
Files 260 260
Lines 58262 58293 +31
Branches 4956 4955 -1
==========================================
+ Hits 49194 49236 +42
+ Misses 8237 8228 -9
+ Partials 831 829 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mloubout
requested changes
Oct 29, 2026
mloubout
left a comment
Contributor
There was a problem hiding this comment.
This didn't follow devito style. Caching should go through memoized_func for example. Peter patch also doesn't make sense
Contributor
Author
|
Thanks @mloubout, this was the right question. We went back and measured whether the change matters for real programs.
Closing. We'll reopen the question only if a realistic program hits it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs devitocodespro/devitopro#1051
What
_merge_halospotsand_hoist_invariant(devito/passes/iet/mpi.py) built aScopefor every HaloSpot pair.Building one means a
FindWithinvisit of the enclosing Iteration, and it happened before the cheap checksthat reject most pairs. Since #3013 (0038c8c), an Operator with many Eqs over distinct SubDomains carries one
HaloSpot per Eq, so this became quadratic in the number of Eqs.
This PR derives the Scope lazily (
_lazy_scope, afunctools.cacheoverpartial(_derive_scope, ...)):_merge_halospotsderives it only once a pair passes_is_compatible. That check is the void,dimension and shared-function test, split out of
_is_mergeable, which keeps its contract for_hoist_redundant_from_conditionals._hoist_invariantderives it only oncehsf1.issubset(hsf0)holds.The Scope is built from the same
(it, hs0, hs1)as before, so every merge and hoist decision is unchanged.#3013's HaloSpot placement is untouched.
Effect
_derive_scopecallsTests
tests/test_mpi.py::TestCodeGeneration::test_merge_many_subdomains_linear. It builds 2n Eqs overn row SubDomains: n of them share one Function, so they merge, and n exchange distinct Functions, so they
can only hoist. It spies on
_derive_scopewithmock.patch(wraps=...). A spy is needed because thepair count is a compile-time cost that the Operator does not expose. The test asserts fewer than
2*ncalls.op.ccodeundermpirun -n 2:basic,diag2andoverlap2;advancedandnoop, and the per-row leapfrog.tests/test_cpml.py: codegen-only, with the CUDA target and identifiers normalized. All 185generated kernels are identical, including the MPI ones.
-m "not parallel"on test_mpi, test_subdomains, test_dle, test_operator and test_ir:887 passed, 1 xfailed.
-m parallelon test_mpi, test_subdomains, test_operator and test_dle: 580 passed.https://claude.ai/code/session_01TT4Kt2oZNzhQrSw8SfVoaw