Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions devito/core/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _specialize_clusters(cls, clusters, **kwargs):
sregistry = kwargs['sregistry']

# Toposort+Fusion (the former to expose more fusion opportunities)
clusters = fuse(clusters, toposort=True)
clusters = fuse(clusters, toposort='topdown')

# Hoist and optimize Dimension-invariant sub-expressions
clusters = cire(clusters, 'invariants', sregistry, options, platform)
Expand Down Expand Up @@ -292,7 +292,7 @@ def callback(f, *args):
'cse': lambda i: cse(i, sregistry, options),
'opt-pows': optimize_pows,
'opt-hyperplanes': optimize_hyperplanes,
'topofuse': lambda i: fuse(i, toposort=True, options=options)
'topofuse': lambda i: fuse(i, toposort='topdown', options=options)
}

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions devito/core/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _specialize_clusters(cls, clusters, **kwargs):
sregistry = kwargs['sregistry']

# Toposort+Fusion (the former to expose more fusion opportunities)
clusters = fuse(clusters, toposort=True, options=options)
clusters = fuse(clusters, toposort='topdown', options=options)

# Fission to increase parallelism
clusters = fission(clusters)
Expand Down Expand Up @@ -321,7 +321,7 @@ def _make_clusters_passes_mapper(cls, **kwargs):
'cire-sops': lambda i: cire(i, 'sops', sregistry, options, platform),
'cse': lambda i: cse(i, sregistry, options),
'opt-pows': optimize_pows,
'topofuse': lambda i: fuse(i, toposort=True, options=options)
'topofuse': lambda i: fuse(i, toposort='topdown', options=options)
}

@classmethod
Expand Down
16 changes: 10 additions & 6 deletions devito/ir/clusters/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def clusterize(exprs, **kwargs):
clusters = normalize(clusters, **kwargs)

# Derive the necessary communications for distributed-memory parallelism
clusters = communications(clusters)
clusters = communications(clusters, **kwargs)

return ClusterGroup(clusters)

Expand Down Expand Up @@ -479,12 +479,12 @@ def rule(size, e):


@timed_pass(name='communications')
def communications(clusters):
def communications(clusters, **kwargs):
"""
Enrich a sequence of Clusters by adding special Clusters representing data
communications for distributed parallelism.
"""
clusters = HaloComms().process(clusters)
clusters = HaloComms(**kwargs).process(clusters)
clusters = reduction_comms(clusters)

check_halo_writes(clusters)
Expand All @@ -501,7 +501,8 @@ class HaloComms(Queue):
_q_guards_in_key = True
_q_properties_in_key = True

B = Symbol(name='⊥')
def __init__(self, sregistry, **kwargs):
self.sregistry = sregistry

def process(self, clusters):
return self._process_fatd(clusters, 1, seen=set())
Expand Down Expand Up @@ -539,8 +540,11 @@ def callback(self, clusters, prefix, seen=None):
# the args is important because that's what search functions honor!
points = sorted(points, key=str)

# Construct the HaloTouch Cluster
expr = Eq(self.B, HaloTouch(*points, halo_scheme=hs))
# Construct the HaloTouch Cluster. Each writes its own mock Symbol, as
# a shared one would totally order all HaloTouches via output
# dependences, preventing their reordering upon topological sorting
mock = Symbol(name=self.sregistry.make_name(prefix='⊥'))
expr = Eq(mock, HaloTouch(*points, halo_scheme=hs))

key0 = lambda i: i in prefix[:-1] or i in hs.loc_indices # noqa: B023
key1 = lambda i: not i._defines & set(hs.distributed_defined) # noqa: B023
Expand Down
4 changes: 4 additions & 0 deletions devito/ir/stree/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def stree_build(clusters, profiler=None, **kwargs):
break

d = it0.dim
# TODO: a Cluster whose `halo_scheme` absorbed a HaloTouch doesn't reuse
# the previous Cluster's loop, so loop sharing depends on Cluster order,
# e.g. `f1 = f0; f2 = f0.dx` shares no `x` loop, while `f2 = f0.dx;
# f1 = f0` does. Fusion can't fix this; it needs halo-aware reuse here
if needs_nodehalo(d, c.halo_scheme):
break

Expand Down
Loading
Loading