Skip to content

Commit cfd4d78

Browse files
committed
mpi: Fixup halo exchange generation involving Bundles
1 parent 9937487 commit cfd4d78

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

devito/mpi/halo_scheme.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ def __hash__(self):
4343
self.halos,
4444
self.dims))
4545

46+
def union(self, other):
47+
"""
48+
Return a new HaloSchemeEntry that is the union of this and `other`.
49+
The `loc_indices` and `loc_dirs` must be the same, otherwise an
50+
exception is raised.
51+
"""
52+
if self.loc_indices != other.loc_indices or \
53+
self.loc_dirs != other.loc_dirs:
54+
raise HaloSchemeException(
55+
"Inconsistency found while building a HaloScheme"
56+
)
57+
58+
halos = self.halos | other.halos
59+
dims = self.dims | other.dims
60+
61+
return HaloSchemeEntry(self.loc_indices, self.loc_dirs, halos, dims,
62+
getters=self.getters)
63+
4664

4765
Halo = namedtuple('Halo', 'dim side')
4866

@@ -410,9 +428,11 @@ def add(self, f, hse):
410428
"""
411429
Create a new HaloScheme that contains all entries in `self` plus the one
412430
passed in input. If `f` already exists in `self`, the old value is
413-
overridden.
431+
augmented with `hse` (i.e., the halos are unioned).
414432
"""
415-
fmapper = dict(self.fmapper.items())
433+
fmapper = dict(self.fmapper)
434+
if f in fmapper:
435+
hse = fmapper[f].union(hse)
416436
fmapper[f] = hse
417437
return HaloScheme.build(fmapper, self.honored)
418438

0 commit comments

Comments
 (0)