Skip to content

compiler: fix halo placement for non out dim exchange#2892

Merged
mloubout merged 4 commits intomainfrom
halo-comm-order
Apr 23, 2026
Merged

compiler: fix halo placement for non out dim exchange#2892
mloubout merged 4 commits intomainfrom
halo-comm-order

Conversation

@mloubout
Copy link
Copy Markdown
Contributor

No description provided.

@mloubout mloubout added MPI mpi-related compiler labels Apr 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.46%. Comparing base (d9dd186) to head (076af37).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
tests/test_mpi.py 11.76% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2892      +/-   ##
==========================================
- Coverage   83.48%   83.46%   -0.02%     
==========================================
  Files         248      248              
  Lines       51551    51570      +19     
  Branches     4437     4441       +4     
==========================================
+ Hits        43038    43045       +7     
- Misses       7761     7774      +13     
+ Partials      752      751       -1     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.77% <92.30%> (+0.01%) ⬆️
pytest-gpu-gcc- 78.06% <50.00%> (-0.04%) ⬇️
pytest-gpu-icx- 77.69% <50.00%> (-0.03%) ⬇️
pytest-gpu-nvc-nvidiaX 69.32% <92.30%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@mloubout mloubout changed the title compiler: fix halo placement for non out dimm exchange compiler: fix halo placement for non out dim exchange Apr 22, 2026
@mloubout mloubout force-pushed the halo-comm-order branch 4 times, most recently from b802a82 to b4d0594 Compare April 22, 2026 04:04
Comment thread tests/test_mpi.py
np.random.seed(0)
v = TimeFunction(name="v", grid=grid, space_order=4,
time_order=1, save=Buffer(1))
v.data[:] = np.random.randn(*grid.shape)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be worth using a sinusoidal function here and comparing to the analytical solution? Would need a bigger grid however, and the existing check is already pretty strong

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not a big fan of randn either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's random with a seed. I tend to prefer random values for tests, forces things to be more stable but can change it if makes people uncomfortable

@mloubout mloubout force-pushed the halo-comm-order branch 6 times, most recently from 3a8c97a to ca423ac Compare April 23, 2026 02:25
Comment thread devito/mpi/halo_scheme.py Outdated
Comment thread devito/mpi/halo_scheme.py Outdated
dims.add(ai.parent)
else:
dims.add(ai)
elif ai is not None and not ai._defines & set(f.dimensions):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

most importantly, I don't understand why the prior if wouldn't catch this? if ai is rrecx and it's being used to index into say x, then d should be x and f.grid.is_distributed(d) in the condition above should have returned True already... no? what am I missing here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's from when i tried to fix is_distributed to actually check if it's decomposed but it broke a lot of stuff so had to revert it. But right now is_distributed is meaningless since it always returns true.

Comment thread devito/mpi/halo_scheme.py Outdated
fmapper[f] = fmapper.get(f, hse).merge(hse)
return HaloScheme.build(fmapper, self.honored)

def _is_iter_carried(self, scope):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why did you hoist this? it doesn't feel right that data dependence analysis belong to HaloScheme, but again, I may be missing something

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved it here because I was checking it it would be enough to use in the communication pass. There is no strong reason to but it makes it potentially esier to use if needed in a different cluster pass instead of having to improt it form iet

Comment thread devito/ir/clusters/algorithms.py Outdated
for f in hs.fmapper:
for a in c.scope.getwrites(f):
is_write = set(a.access.indices) & loc_vals
is_dist = any(c.grid.distributor.topology.get(d, 1) > 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

any(f.grid.is_distributed(d) for d in hs.dimensions)

NOTE: f. and not c. is slightly more robust because not all Clusters may have an underlying Grid

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No that the main issue is_distributed is useless as it always returns true for a grid dimension irrespective of it it's decomposed or not

Comment thread devito/ir/clusters/algorithms.py Outdated
Comment thread devito/ir/clusters/algorithms.py Outdated
Comment thread devito/ir/clusters/algorithms.py Outdated
for f in hs.fmapper:
for a in c.scope.getwrites(f):
is_write = set(a.access.indices) & loc_vals
is_dist = any(c.grid.distributor.topology.get(d, 1) > 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can hoist this condition within the f loop and return False immediately if it doesn't hold;

then you can turn the current is_write condition into a one-liner if any(set(...) for a in ...)

Comment thread devito/ir/clusters/algorithms.py Outdated
Comment thread tests/test_mpi.py
@pytest.mark.skipif(TestTTI is None, reason="Requires installing the tests")
@pytest.mark.parallel(mode=1)
def test_halo_structure(self, mode):
from test_dse import TestTTI
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

from .test_dse import TestTTI

or it doesn't matter? I will never remember...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think both work? THis is just moved from a top import becuase somehow importing it at the top runs all the tests in TestTTI at import

Comment thread tests/test_mpi.py
np.random.seed(0)
v = TimeFunction(name="v", grid=grid, space_order=4,
time_order=1, save=Buffer(1))
v.data[:] = np.random.randn(*grid.shape)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not a big fan of randn either

Copy link
Copy Markdown
Contributor

@FabioLuporini FabioLuporini left a comment

Choose a reason for hiding this comment

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

LGTM

@mloubout mloubout merged commit 8d1995d into main Apr 23, 2026
42 checks passed
@mloubout mloubout deleted the halo-comm-order branch April 23, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler MPI mpi-related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants