Skip to content

compiler: Minor tweaks for improved MPI modes - #3123

Merged
FabioLuporini merged 32 commits into
mainfrom
moar-mpi-fixes
Nov 30, 2026
Merged

FabioLuporini merged 32 commits into
mainfrom
moar-mpi-fixes

Conversation

@FabioLuporini

Copy link
Copy Markdown
Contributor

... Exploited in PRO

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.00000% with 148 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.99%. Comparing base (e9591ce) to head (d80e2ab).

Files with missing lines Patch % Lines
tests/test_mpi.py 14.86% 63 Missing ⚠️
devito/mpi/routines.py 11.90% 37 Missing ⚠️
tests/test_benchmark.py 80.48% 16 Missing ⚠️
tests/test_subdomains.py 10.00% 9 Missing ⚠️
devito/passes/iet/mpi.py 0.00% 4 Missing ⚠️
devito/mpi/halo_scheme.py 57.14% 3 Missing ⚠️
devito/core/autotuning.py 50.00% 1 Missing and 1 partial ⚠️
devito/mpi/distributed.py 60.00% 2 Missing ⚠️
devito/operator/operator.py 75.00% 2 Missing ⚠️
devito/operator/profiling.py 88.88% 1 Missing and 1 partial ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3123      +/-   ##
==========================================
+ Coverage   83.40%   83.99%   +0.58%     
==========================================
  Files         260      261       +1     
  Lines       59671    60001     +330     
  Branches     5036     5064      +28     
==========================================
+ Hits        49769    50397     +628     
+ Misses       9022     8760     -262     
+ Partials      880      844      -36     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.26% <65.56%> (+0.01%) ⬆️
pytest-gpu-gcc- 78.79% <61.75%> (-0.09%) ⬇️
pytest-gpu-icx- 78.72% <61.75%> (-0.10%) ⬇️
pytest-gpu-nvc-nvidiaX 69.07% <66.51%> (?)

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.

Comment thread devito/mpi/halo_scheme.py
is_integer = True
is_nonnegative = True


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.

Shouldn't this just be extracted from MPINeighbourhood?

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 simplified everything now, take a new look, but short answer yes

Comment thread devito/mpi/halo_scheme.py

aligned_m = IntDiv(m, self._alignment) * self._alignment
# Preserve empty regions when rounding down a start index
aligned_m = sympy.Piecewise(

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 is Piecewise needed 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 a bug fix: empty regions have inverted bounds. For example, rounding the start of [2, 1] down to a multiple of four would turn it into [0, 1], causing two iterations. Piecewise preserves the inverted bounds in that case.

Comment thread devito/mpi/routines.py Resolved
Comment thread devito/mpi/routines.py Outdated
Comment on lines +1398 to +1403
grid = getattr(args, 'grid', None)
neighborhood = {}
if grid is not None:
distributor = grid.distributor
shifts = distributor._obj_neighborhood.neighborhood
neighborhood = {d.root.name: shifts[d] for d in distributor.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.

Check this behaves with functions on subdomains

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.

will do, but practically speaking, when can we have written (Time)Functions-on-subdomain ? water-rock coupling, then?

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.

done

Comment thread devito/mpi/routines.py Outdated
row[name] = value
records.append(row)

# Keep CORE in slot zero and move empty OWNED records to the end.

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?

Comment thread devito/types/grid.py Resolved
Rounding down an inclusive lower bound can turn an empty CORE or OWNED region into executable points. Keep the original lower bound when it already exceeds the upper bound.
Bracket the time-stepping region with a native timer and reduce its elapsed time once across MPI ranks. Keep the section-based measurement for Operators without a time loop.
Allow a halo builder to place lifetime hooks and declare backend aggregates in the generated Operator.
@FabioLuporini

Copy link
Copy Markdown
Contributor Author

@EdCaunt @mloubout can take another look now, much simpler now

Comment thread devito/mpi/routines.py Resolved
nbytes = i.nbytes if i.is_regular else i.nbytes_max
v = subs_op_args(nbytes, self)
try:
nbytes = i.nbytes if i.is_regular else i.nbytes_max

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.

this is a critical bug fix @EdCaunt

Add a guarded example of LocalScatter lowering.
Comment thread devito/mpi/distributed.py
"""
Face ranks indexed by root dimension name and side.
"""
return {d.root.name: ranks for d, ranks in self.neighborhood.items()

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.

Frozendict?

@FabioLuporini
FabioLuporini merged commit afa5529 into main Nov 30, 2026
42 checks passed
@FabioLuporini
FabioLuporini deleted the moar-mpi-fixes branch November 30, 2026 15:47
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.

3 participants