Skip to content

Commit fe15a66

Browse files
committed
mpi: fix halo ispace with subdomains
1 parent 3539fd4 commit fe15a66

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

devito/ir/clusters/algorithms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def callback(self, clusters, prefix, seen=None):
472472
expr = Eq(self.B, HaloTouch(*points, halo_scheme=hs))
473473

474474
key0 = lambda i: i in prefix[:-1] or i in hs.loc_indices # noqa: B023
475-
key1 = lambda i: i not in hs.distributed_defined # noqa: B023
475+
key1 = lambda i: not i._defines & set(hs.distributed_defined) # noqa: B023
476476
key = lambda i: key0(i) and key1(i) # noqa: B023
477477
ispace = c.ispace.project(key)
478478

tests/test_subdomains.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from conftest import assert_structure, opts_tiling
88
from devito import (
9-
Border, ConditionalDimension, Constant, Eq, Function, Grid, Lt, Operator,
9+
Border, Buffer, ConditionalDimension, Constant, Eq, Function, Grid, Lt, Operator,
1010
SparseFunction, SparseTimeFunction, SubDomain, SubDomainSet, TensorFunction,
1111
TimeFunction, VectorFunction, solve
1212
)
@@ -228,6 +228,40 @@ def define(self, dimensions):
228228
sregistry=SymbolRegistry())[0]
229229
assert str(expr.rhs) == 'ix*f[ix + 1, iy + 1] + iy'
230230

231+
@pytest.mark.parallel(mode=2)
232+
def test_halo_subdomain(self, mode):
233+
"""
234+
Test halo lowering with temporary dimensions and shifted subdomain access.
235+
"""
236+
space_order = 8
237+
238+
class Interface(SubDomain):
239+
name = 'interface'
240+
241+
def define(self, dimensions):
242+
x, y, z = dimensions
243+
return {
244+
x: ('middle', 0, 0),
245+
y: ('middle', 0, 0),
246+
z: ('middle', space_order//2, 0)
247+
}
248+
249+
grid = Grid(shape=(9, 9, 9), subdomains=(Interface(),))
250+
x, y, z = grid.dimensions
251+
time = grid.stepping_dim
252+
u = TimeFunction(name='u', grid=grid, time_order=1,
253+
space_order=space_order, save=Buffer(1),
254+
is_transient=False)
255+
256+
equation = Eq(u[time + 1, x, y, z - space_order//2],
257+
u.dxdy + u.dydz +
258+
u[time + 1, x, y, z - space_order//2],
259+
subdomain=grid.subdomains['interface'])
260+
261+
op = Operator([equation])
262+
263+
assert_structure(op, ['t', 'txyz', 'txyz'], 'txyzyz')
264+
231265

232266
class TestMultiSubDomain:
233267

0 commit comments

Comments
 (0)