Skip to content

Commit

Permalink
compiler: class HaloSchemeEntry(EnrichedTuple)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Dec 16, 2024
1 parent 018ba54 commit 2e36b6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
3 changes: 3 additions & 0 deletions devito/ir/iet/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,8 @@ def DummyExpr(*args, init=False):


# Nodes required for distributed-memory halo exchange


class HaloSpot(Node):

"""
Expand Down Expand Up @@ -1498,6 +1500,7 @@ def body(self):
def functions(self):
return tuple(self.fmapper)


# Utility classes


Expand Down
22 changes: 5 additions & 17 deletions devito/mpi/halo_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from devito.ir.support import Forward, Scope
from devito.symbolics.manipulation import _uxreplace_registry
from devito.tools import (Reconstructable, Tag, as_tuple, filter_ordered, flatten,
frozendict, is_integer, filter_sorted)
frozendict, is_integer, filter_sorted, EnrichedTuple)
from devito.types import Grid

__all__ = ['HaloScheme', 'HaloSchemeEntry', 'HaloSchemeException', 'HaloTouch']
Expand All @@ -28,34 +28,22 @@ class HaloLabel(Tag):
STENCIL = HaloLabel('stencil')


class HaloSchemeEntry(Reconstructable):
class HaloSchemeEntry(EnrichedTuple):

__rargs__ = ('loc_indices', 'loc_dirs', 'halos', 'dims')

def __init__(self, loc_indices, loc_dirs, halos, dims):
def __init__(self, loc_indices, loc_dirs, halos, dims, getters=None):
self.loc_indices = frozendict(loc_indices)
self.loc_dirs = frozendict(loc_dirs)
self.halos = frozenset(halos)
self.dims = frozenset(dims)

def __eq__(self, other):
if not isinstance(other, HaloSchemeEntry):
return False
return (self.loc_indices == other.loc_indices and
self.loc_dirs == other.loc_dirs and
self.halos == other.halos and
self.dims == other.dims)

def __hash__(self):
return hash((tuple(self.loc_indices.items()),
tuple(self.loc_dirs.items()),
return hash((self.loc_indices,
self.loc_dirs,
self.halos,
self.dims))

def __repr__(self):
return (f"HaloSchemeEntry(loc_indices={self.loc_indices}, "
f"loc_dirs={self.loc_dirs}, halos={self.halos}, dims={self.dims})")


Halo = namedtuple('Halo', 'dim side')

Expand Down
4 changes: 3 additions & 1 deletion devito/passes/iet/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ def _filter_iter_mapper(iet):


def _make_cond_mapper(iet):
"Return a mapper from HaloSpots to the Conditionals that contain them."
"""
Return a mapper from HaloSpots to the Conditionals that contain them.
"""
cond_mapper = {}
for hs, v in MapHaloSpots().visit(iet).items():
conditionals = {i for i in v if i.is_Conditional and
Expand Down

0 comments on commit 2e36b6b

Please sign in to comment.