Skip to content

Commit

Permalink
api: cleanup subdimension and subdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Sep 28, 2023
1 parent a7d9c49 commit 7ed87f2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
22 changes: 14 additions & 8 deletions devito/passes/clusters/implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -145,6 +150,7 @@ def callback(self, clusters, prefix):

ispace = IterationSpace.union(c.ispace, ispaceN)
processed.append(c.rebuild(ispace=ispace))
seen.add(d)

return processed

Expand Down
3 changes: 2 additions & 1 deletion devito/types/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 12 additions & 11 deletions tests/test_subdomains.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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):

Expand All @@ -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):

Expand All @@ -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):
"""
Expand Down

0 comments on commit 7ed87f2

Please sign in to comment.