Skip to content

Commit

Permalink
Merge pull request #2408 from devitocodes/subdomainset_fix
Browse files Browse the repository at this point in the history
compiler: Patch bug in SubDomainSet lowering
  • Loading branch information
FabioLuporini committed Jul 16, 2024
2 parents 3024584 + d69cc43 commit 6e79f1c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions devito/passes/clusters/implicit.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def callback(self, clusters, prefix):
d = None
if d is None:
processed.append(c)
# If no MultiSubDomain present in this cluster, then tip should be reset
tip = None
continue

# Get all MultiSubDimensions in the cluster and get the dynamic thickness
Expand Down
30 changes: 30 additions & 0 deletions tests/test_subdomains.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,36 @@ class MySubdomains(SubDomainSet):
reads = set().union(*[e.reads for e in exprs])
assert len(reads) == 4 # f, g, h, mydomains

def test_multi_eq_split(self):
"""
Test cases where two loops over the same SubDomainSet will be
separated by another loop.
"""
# Note: a bug was found where this would cause SubDomainSet
# bounds expressions not to be generated in the second loop over
# the SubDomainSet
class MSD(SubDomainSet):
name = 'msd'

msd = MSD(N=1, bounds=(1, 1, 1, 1))

grid = Grid(shape=(11, 11), subdomains=(msd,))

f = Function(name='f', grid=grid)
g = Function(name='g', grid=grid)

eq0 = Eq(f, 1, subdomain=msd)
eq1 = Eq(f, g) # Dependency needed to fix equation order
eq2 = Eq(g, 1, subdomain=msd)

op = Operator([eq0, eq1, eq2])

# Ensure the loop structure is correct
# Note the two 'n0' correspond to the thickness definitions
assert_structure(op,
['n0', 'n0xy', 'xy', 'n0', 'n0xy'],
'n0xyxyn0xy')

def test_multi_sets(self):
"""
Check functionality for when multiple subdomain sets are present.
Expand Down

0 comments on commit 6e79f1c

Please sign in to comment.