Skip to content

Commit b3a3e00

Browse files
FabioLuporinimloubout
authored andcommitted
compiler: Use more property caching and generators
1 parent 82fa9e6 commit b3a3e00

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

devito/ir/support/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def distance(self, other):
385385
# Compute the distance along the current IterationInterval
386386
if self.function._mem_shared:
387387
# Special case: the distance between two regular, thread-shared
388-
# objects fallbacks to zero, as any other value would be
388+
# objects falls back to zero, as any other value would be
389389
# nonsensical
390390
ret.append(S.Zero)
391391
elif degenerating_dimensions(sai, oai):

devito/mpi/halo_scheme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __hash__(self):
4343
return hash((self.loc_indices, self.loc_dirs, self.halos, self.dims,
4444
self.bundle))
4545

46-
@property
46+
@cached_property
4747
def loc_values(self):
4848
return frozenset(self.loc_indices.values())
4949

devito/passes/iet/mpi.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _drop_reduction_halospots(iet):
4141

4242
# If all HaloSpot reads pertain to reductions, then the HaloSpot is useless
4343
for hs, expressions in MapNodes(HaloSpot, Expression).visit(iet).items():
44-
scope = Scope([i.expr for i in expressions])
44+
scope = Scope(i.expr for i in expressions)
4545
for f, v in scope.reads.items():
4646
if f in hs.fmapper and all(i.is_reduction for i in v):
4747
mapper[hs].add(f)
@@ -79,7 +79,7 @@ def _hoist_redundant_from_conditionals(iet):
7979

8080
mapper = HaloSpotMapper()
8181
for it, halo_spots in iter_mapper.items():
82-
scope = Scope([e.expr for e in FindNodes(Expression).visit(it)])
82+
scope = Scope(e.expr for e in FindNodes(Expression).visit(it))
8383

8484
for hs0 in halo_spots:
8585
conditions = cond_mapper[hs0]
@@ -156,6 +156,7 @@ def _merge_halospots(iet):
156156
# `hsf1` out of `it`, otherwise we just drop it
157157
if hsf0.loc_values != hsf1.loc_values:
158158
continue
159+
159160
mapper.drop(hs1, f)
160161

161162
iet = mapper.apply(iet)
@@ -278,7 +279,7 @@ def _mark_overlappable(iet):
278279
if not expressions:
279280
continue
280281

281-
scope = Scope([i.expr for i in expressions])
282+
scope = Scope(i.expr for i in expressions)
282283

283284
# Comp/comm overlaps is legal only if the OWNED regions can grow
284285
# arbitrarly, which means all of the dependences must be carried
@@ -448,8 +449,8 @@ def _make_cond_mapper(iet):
448449
"""
449450
Return a mapper from HaloSpots to the Conditionals that contain them.
450451
"""
451-
return {hs: tuple(i for i in v if i.is_Conditional)
452-
for hs, v in MapHaloSpots().visit(iet).items()}
452+
mapper = MapHaloSpots().visit(iet)
453+
return {hs: tuple(i for i in v if i.is_Conditional) for hs, v in mapper.items()}
453454

454455

455456
def _derive_scope(it, hs0, hs1):
@@ -458,7 +459,7 @@ def _derive_scope(it, hs0, hs1):
458459
and ends at the HaloSpot `hs1`.
459460
"""
460461
expressions = FindWithin(Expression, hs0, stop=hs1).visit(it)
461-
return Scope([e.expr for e in expressions])
462+
return Scope(e.expr for e in expressions)
462463

463464

464465
def _check_control_flow(hs0, hs1, cond_mapper):

0 commit comments

Comments
 (0)