Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] compiler: Add new HaloSpot optimization #2475

Closed
wants to merge 4 commits into from

Conversation

georgebisbas
Copy link
Contributor

@georgebisbas georgebisbas commented Oct 29, 2024

[Requesting comments]
Fix for issue #2448, supplemented with some code edits

@georgebisbas georgebisbas added MPI mpi-related compiler labels Oct 29, 2024
@georgebisbas georgebisbas self-assigned this Oct 29, 2024
@georgebisbas georgebisbas changed the title compiler: Add new HaloSpot optimization Closes #2448 [RFC] compiler: Add new HaloSpot optimization Closes #2448 Oct 29, 2024
@georgebisbas georgebisbas linked an issue Oct 29, 2024 that may be closed by this pull request
@georgebisbas georgebisbas changed the title [RFC] compiler: Add new HaloSpot optimization Closes #2448 [RFC] compiler: Add new HaloSpot optimization Oct 29, 2024
@@ -1457,8 +1457,20 @@ def __init__(self, body, halo_scheme):
self._halo_scheme = halo_scheme

def __repr__(self):
functions = "(%s)" % ",".join(i.name for i in self.functions)
return "<%s%s>" % (self.__class__.__name__, functions)
fstrings = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we also print the slice for each halospot

i.e. v[t0] instead of just v.

What do you think?

self.halos == other.halos and
self.dims == other.dims)

def __hash__(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was autocompleted by copilot.
Are people happy to have class instead of namedtuple?

@@ -95,8 +127,20 @@ def __init__(self, exprs, ispace):
self._honored = frozendict(self._honored)

def __repr__(self):
fnames = ",".join(i.name for i in set(self._mapper))
return "HaloScheme<%s>" % fnames
fstrings = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same w above

@@ -366,6 +410,10 @@ def distributed_aindices(self):
def loc_indices(self):
return set().union(*[i.loc_indices.keys() for i in self.fmapper.values()])

@cached_property
def loc_values(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way to get the values of loc_indices?
If so happy to drop this


return iet


def _merge_halospots(iet):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was moved down, the diff is not "represetnative"


raw_loc_indices = {}
# Since lifted, we need to update the loc_indices with known values
# TODO: Can I get this in a more elegant way?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

About getting w.g. (time%2)

def denest_halospots(iet):
"""
Denest nested HaloSpots.
# TOFIX: This also merges HaloSpots that have different loc_indices
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a problem anymore, but I could not find some solution/custom idea that can trigger that even after the new pass

@@ -1005,6 +1008,93 @@ def test_avoid_haloupdate_if_distr_but_sequential(self, mode):
calls = FindNodes(Call).visit(op)
assert len(calls) == 0

@pytest.mark.parallel(mode=1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can further parametrize those, lots of code dupliucation

@@ -1357,7 +1446,7 @@ def test_merge_haloupdate_if_diff_locindices_v1(self, mode):
op = Operator(eqns)

calls = FindNodes(Call).visit(op)
assert len(calls) == 1
assert len(calls) == 2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
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.

My main concern is that we're adding a lot new complexity but I don't have an alternative at the moment


return iet


def _merge_halospots(iet):
def _hoist_and_drop(iet):
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks really complex, I hoped we could get away with something easier. It's a pity we have to add this much complexity and so much overlap with either hoist_halospot and merge_halospot

@FabioLuporini
Copy link
Contributor

as in, there are hoist and merge already, we're adding something "in between" these two, which so much repetition, to me it looks weird, as if we're still failing to capture the right logic

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 92.59259% with 12 lines in your changes missing coverage. Please review.

Project coverage is 87.22%. Comparing base (f95007d) to head (96eaa17).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
devito/passes/iet/mpi.py 87.95% 9 Missing and 1 partial ⚠️
devito/mpi/halo_scheme.py 90.90% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2475      +/-   ##
==========================================
+ Coverage   87.19%   87.22%   +0.03%     
==========================================
  Files         238      238              
  Lines       45201    45332     +131     
  Branches     4012     4029      +17     
==========================================
+ Hits        39415    39543     +128     
- Misses       5104     5108       +4     
+ Partials      682      681       -1     

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

@georgebisbas
Copy link
Contributor Author

Closing as superseded by #2477

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.

compiler: Redundant haloupdate
2 participants