diff --git a/devito/passes/clusters/implicit.py b/devito/passes/clusters/implicit.py index 78454c1f1a..42e528d904 100644 --- a/devito/passes/clusters/implicit.py +++ b/devito/passes/clusters/implicit.py @@ -107,20 +107,25 @@ def callback(self, clusters, prefix): exprs, dims, sub_iterators = make_implicit_exprs(d.msd, c) # The IterationSpace induced by the MultiSubDomain - intervals = [Interval(i, 0, 0) for i in dims] - relations = (ispace0.itdimensions + dims, dims + ispace1.itdimensions) - ispaceN = IterationSpace( - IntervalGroup(intervals, relations=relations), sub_iterators - ) + if dims: + intervals = [Interval(i) for i in dims] + relations = (ispace0.itdimensions + dims, dims + ispace1.itdimensions) + ispaceN = IterationSpace( + IntervalGroup(intervals, relations=relations), sub_iterators + ) + ispace = IterationSpace.union(ispace0, ispaceN) + else: + ispaceN = None + ispace = ispace0 - ispace = IterationSpace.union(ispace0, ispaceN) properties = {i.dim: {SEQUENTIAL} for i in ispace} - if len(ispaceN) == 0: + + if not ispaceN: # Special case: we can factorize the thickness assignments # once and for all at the top of the current IterationInterval, # and reuse them for one or more (potentially non-consecutive) # `clusters` - if ispaceN not in seen: + if d not in seen: # Retain the guards and the syncs along the outer Dimensions retained = {None} | set(c.ispace[:n-1].dimensions) @@ -143,8 +148,12 @@ def callback(self, clusters, prefix): ) tip = nxt - ispace = IterationSpace.union(c.ispace, ispaceN) - processed.append(c.rebuild(ispace=ispace)) + if ispaceN: + ispace = IterationSpace.union(c.ispace, ispaceN) + processed.append(c.rebuild(ispace=ispace)) + else: + processed.append(c) + seen.add(d) return processed diff --git a/devito/types/grid.py b/devito/types/grid.py index faecb25236..de91284441 100644 --- a/devito/types/grid.py +++ b/devito/types/grid.py @@ -725,7 +725,8 @@ def __subdomain_finalize__(self, grid, counter=0, **kwargs): # Create the SubDomainSet SubDimensions self._dimensions = tuple( - MultiSubDimension('%si' % d.name, d, self) for d in grid.dimensions + MultiSubDimension('%si%d' % (d.name, counter), d, self) + for d in grid.dimensions ) # Compute the SubDomainSet shapes diff --git a/tests/test_subdomains.py b/tests/test_subdomains.py index f7a8c3df4d..984f2c29ef 100644 --- a/tests/test_subdomains.py +++ b/tests/test_subdomains.py @@ -447,7 +447,7 @@ class DummySubdomains(SubDomainSet): # Make sure it jit-compiles op.cfunction - assert_structure(op, ['x,y', 't,n0', 't,n0,xi,yi'], 'x,y,t,n0,xi,yi') + assert_structure(op, ['x,y', 't,n0', 't,n0,xi2,yi2'], 'x,y,t,n0,xi2,yi2') def test_issue_1761_b(self): """ @@ -486,8 +486,8 @@ class DummySubdomains2(SubDomainSet): op.cfunction assert_structure(op, - ['x,y', 't,n0', 't,n0,xi,yi', 't,n1', 't,n1,xi,yi'], - 'x,y,t,n0,xi,yi,n1,xi,yi') + ['x,y', 't,n0', 't,n0,xi2,yi2', 't,n1', 't,n1,xi3,yi3'], + 'x,y,t,n0,xi2,yi2,n1,xi3,yi3') def test_issue_1761_c(self): """ @@ -522,9 +522,9 @@ class DummySubdomains2(SubDomainSet): # Make sure it jit-compiles op.cfunction - assert_structure(op, ['x,y', 't,n0', 't,n0,xi,yi', - 't,n1', 't,n1,xi,yi', 't,n0', 't,n0,xi,yi'], - 'x,y,t,n0,xi,yi,n1,xi,yi,n0,xi,yi') + assert_structure(op, ['x,y', 't,n0', 't,n0,xi2,yi2', + 't,n1', 't,n1,xi3,yi3', 't,n0', 't,n0,xi2,yi2'], + 'x,y,t,n0,xi2,yi2,n1,xi3,yi3,n0,xi2,yi2') def test_issue_1761_d(self): """ @@ -549,7 +549,8 @@ class Dummy(SubDomainSet): # Make sure it jit-compiles op.cfunction - assert_structure(op, ['t,n0', 't,n0,xi,yi', 't,n0,xi,yi'], 't,n0,xi,yi,xi,yi') + assert_structure(op, ['t,n0', 't,n0,xi2,yi2', 't,n0,xi2,yi2'], + 't,n0,xi2,yi2,xi2,yi2') def test_guarding(self): @@ -576,8 +577,8 @@ class Dummy(SubDomainSet): # Make sure it jit-compiles op.cfunction - assert_structure(op, ['t', 't,n0', 't,n0,xi,yi', 't,n0', 't,n0,xi,yi'], - 't,n0,xi,yi,n0,xi,yi') + assert_structure(op, ['t', 't,n0', 't,n0,xi2,yi2', 't,n0', 't,n0,xi2,yi2'], + 't,n0,xi2,yi2,n0,xi2,yi2') def test_3D(self): @@ -597,8 +598,8 @@ class Dummy(SubDomainSet): # Make sure it jit-compiles op.cfunction - assert_structure(op, ['t,n0', 't,n0,xi0_blk0,yi0_blk0,xi,yi,zi'], - 't,n0,xi0_blk0,yi0_blk0,xi,yi,zi') + assert_structure(op, ['t,n0', 't,n0,xi20_blk0,yi20_blk0,xi2,yi2,zi2'], + 't,n0,xi20_blk0,yi20_blk0,xi2,yi2,zi2') def test_sequential_implicit(self): """