Skip to content

Commit

Permalink
compiler: Refactor stree.preprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioLuporini committed Nov 21, 2023
1 parent 22ab915 commit bfa0fec
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions devito/ir/stree/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,19 @@ def preprocess(clusters, options=None, **kwargs):
# 99% of the cases we end up here
hs = HaloScheme.union([c1.halo_scheme for c1 in found])
processed.append(c.rebuild(halo_scheme=hs))
else:
elif options['mpi']:
# We end up here with e.g. `t,x,y,z,f` where `f` is a sequential
# dimension requiring a loc-index in the HaloScheme. The compiler
# will generate the non-perfect loop nest `t,f ; t,x,y,z,f`, with
# the first nest triggering all necessary halo exchanges along `f`
if not options['mpi']:
# Avoid ugly empty loops
processed.append(c)
else:
mapper = as_mapper(found, lambda c1: c1.ispace)
for ispace, v in mapper.items():
hs = HaloScheme.union([c1.halo_scheme for c1 in v])
processed.append(
c.rebuild(exprs=[], ispace=ispace, halo_scheme=hs)
)

processed.append(c)
mapper = as_mapper(found, lambda c1: c1.ispace)
for k, v in mapper.items():
hs = HaloScheme.union([c1.halo_scheme for c1 in v])
processed.append(c.rebuild(exprs=[], ispace=k, halo_scheme=hs))
processed.append(c)
else:
# Avoid ugly empty loops
processed.append(c)

# Sanity check!
try:
Expand Down

0 comments on commit bfa0fec

Please sign in to comment.