Skip to content

Commit

Permalink
compiler: Fix misc review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Dec 5, 2024
1 parent 4567885 commit 3c19ade
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 204 deletions.
12 changes: 6 additions & 6 deletions devito/mpi/halo_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class HaloSchemeEntry(Reconstructable):
def __init__(self, loc_indices, loc_dirs, halos, dims):
self.loc_indices = frozendict(loc_indices)
self.loc_dirs = frozendict(loc_dirs)
self.halos = halos
self.dims = dims
self.halos = frozenset(halos)
self.dims = frozenset(dims)

def __eq__(self, other):
if not isinstance(other, HaloSchemeEntry):
Expand All @@ -48,10 +48,10 @@ def __eq__(self, other):
self.dims == other.dims)

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

def __repr__(self):
return (f"HaloSchemeEntry(loc_indices={self.loc_indices}, "
Expand Down
30 changes: 18 additions & 12 deletions devito/passes/iet/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from devito.mpi.reduction_scheme import DistReduce
from devito.mpi.routines import HaloExchangeBuilder, ReductionBuilder
from devito.passes.iet.engine import iet_pass
from devito.tools import generator, frozendict
from devito.tools import generator

__all__ = ['mpiize']

Expand Down Expand Up @@ -94,7 +94,6 @@ def _hoist_invariant(iet):
continue

for f, v in hs1.fmapper.items():

if f not in hs0.functions:
continue

Expand All @@ -114,7 +113,7 @@ def _hoist_invariant(iet):
else:
raw_loc_indices[d] = v

hse = hse._rebuild(loc_indices=frozendict(raw_loc_indices))
hse = hse._rebuild(loc_indices=raw_loc_indices)
hs1.halo_scheme.fmapper[f] = hse

hsmapper[hs1] = hsmapper.get(hs1, hs1.halo_scheme).drop(f)
Expand Down Expand Up @@ -348,20 +347,27 @@ def _filter_iter_mapper(iet):
Given an IET, return a mapper from Iterations to the HaloSpots.
Additionally, filter out Iterations that are not of interest.
"""
iter_mapper = MapNodes(Iteration, HaloSpot, 'immediate').visit(iet)
iter_mapper = {k: [hs for hs in v if not hs.halo_scheme.is_void]
for k, v in iter_mapper.items()}
iter_mapper = {k: v for k, v in iter_mapper.items() if k is not None}
iter_mapper = {k: v for k, v in iter_mapper.items() if len(v) > 1}
iter_mapper = {}
for k, v in MapNodes(Iteration, HaloSpot, 'immediate').visit(iet).items():
filtered_hs = [hs for hs in v if not hs.halo_scheme.is_void]
if k is not None and len(filtered_hs) > 1:
iter_mapper[k] = filtered_hs

return iter_mapper


def _make_cond_mapper(iet):
cond_mapper = MapHaloSpots().visit(iet)
return {hs: {i for i in v if i.is_Conditional and
not isinstance(i.condition, GuardFactorEq)}
for hs, v in cond_mapper.items()}

cond_mapper = {}
for hs, v in MapHaloSpots().visit(iet).items():
conditionals = set()
for i in v:
if i.is_Conditional and not isinstance(i.condition, GuardFactorEq):
conditionals.add(i)

cond_mapper[hs] = conditionals

return cond_mapper


def _check_control_flow(hs0, hs1, cond_mapper):
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/tutorials/09_viscoelastic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@
"source": [
"# References\n",
"\n",
"[1] Johan O. A. Roberston, *et.al.* (1994). \"Viscoelatic finite-difference modeling\" GEOPHYSICS, 59(9), 1444-1456.\n",
"[1] Johan O. A. Roberston, *et.al.* (1994). \"Viscoelastic finite-difference modeling\" GEOPHYSICS, 59(9), 1444-1456.\n",
"\n",
"\n",
"[2] https://janth.home.xs4all.nl/Software/fdelmodcManual.pdf"
Expand Down
2 changes: 1 addition & 1 deletion examples/seismic/viscoelastic/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ def ForwardOperator(model, geometry, space_order=4, save=False, **kwargs):

# Substitute spacing terms to reduce flops
return Operator([u_v, u_r, u_t] + src_rec_expr, subs=model.spacing_map,
name='ViscoElForward', **kwargs)
name='ViscoIsoElForward', **kwargs)
Loading

0 comments on commit 3c19ade

Please sign in to comment.