diff --git a/devito/passes/clusters/implicit.py b/devito/passes/clusters/implicit.py index 42e528d904..af02805102 100644 --- a/devito/passes/clusters/implicit.py +++ b/devito/passes/clusters/implicit.py @@ -7,6 +7,7 @@ from devito.ir import (Cluster, Interval, IntervalGroup, IterationSpace, Queue, FetchUpdate, PrefetchUpdate, SEQUENTIAL) +from devito.symbolics import retrieve_dimensions from devito.tools import as_tuple, timed_pass from devito.types import Eq from devito.types.grid import MultiSubDimension, SubDomainSet @@ -106,6 +107,13 @@ def callback(self, clusters, prefix): # The "implicit expressions" created for the MultiSubDomain exprs, dims, sub_iterators = make_implicit_exprs(d.msd, c) + # Make sure the "implicit expressions" aren't scheduled in + # an inner loop. E.g schedule both for `t, xi, yi` and `t, d, xi, yi` + edims = set(retrieve_dimensions(exprs, deep=True)) + if dim not in edims and any(d.dim in edims for d in prefix): + processed.append(c) + continue + # The IterationSpace induced by the MultiSubDomain if dims: intervals = [Interval(i) for i in dims]