Skip to content

Commit 03ff042

Browse files
committed
mpi: fix typo in comm size
1 parent ba00b18 commit 03ff042

3 files changed

Lines changed: 61 additions & 65 deletions

File tree

devito/data/data.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,10 @@ def _check_idx(func):
176176
@wraps(func)
177177
def wrapper(data, *args, **kwargs):
178178
glb_idx = args[0]
179-
is_gather = isinstance(kwargs.get('gather_rank', None), int)
179+
is_gather = isinstance(kwargs.get('gather_rank'), int)
180180
if is_gather and all(i == slice(None, None, 1) for i in glb_idx):
181181
comm_type = gather
182-
elif len(args) > 1 and isinstance(args[1], Data) \
183-
and args[1]._is_decomposed:
182+
elif len(args) > 1 and isinstance(args[1], Data) and args[1]._is_decomposed:
184183
comm_type = index_by_index
185184
elif data._is_decomposed:
186185
for i in as_tuple(glb_idx):
@@ -197,10 +196,8 @@ def wrapper(data, *args, **kwargs):
197196

198197
@property
199198
def _is_decomposed(self):
200-
is_mpi = self._is_distributed and configuration['mpi']
201-
if is_mpi:
202-
is_mpi = is_mpi and self._distributor.comm.size > 2
203-
return is_mpi
199+
return self._is_distributed and configuration['mpi'] and \
200+
self._distributor.comm.size > 1
204201

205202
def __repr__(self):
206203
return super(Data, self._local).__repr__()

examples/seismic/self_adjoint/sa_03_iso_correctness.ipynb

Lines changed: 49 additions & 50 deletions
Large diffs are not rendered by default.

examples/seismic/self_adjoint/test_wavesolver_iso.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ def test_linearization_F(self, shape, dtype, so):
128128
ns = 2 * size + 1
129129
if len(shape) == 2:
130130
nx2, nz2 = shape[0]//2, shape[1]//2
131-
dm.data[nx2-size:nx2+size, nz2-size:nz2+size] = \
131+
dm.data[nx2-size:nx2+size+1, nz2-size:nz2+size+1] = \
132132
-1 + 2 * np.random.rand(ns, ns)
133133
else:
134134
nx2, ny2, nz2 = shape[0]//2, shape[1]//2, shape[2]//2
135135
nx, ny, nz = shape
136-
dm.data[nx2-size:nx2+size, ny2-size:ny2+size, nz2-size:nz2+size] = \
136+
dm.data[nx2-size:nx2+size+1, ny2-size:ny2+size+1, nz2-size:nz2+size+1] = \
137137
-1 + 2 * np.random.rand(ns, ns, ns)
138138

139139
# Compute F(m + dm)
@@ -194,12 +194,12 @@ def test_linearity_forward_J(self, shape, dtype, so):
194194
ns = 2 * size + 1
195195
if len(shape) == 2:
196196
nx2, nz2 = shape[0]//2, shape[1]//2
197-
m1.data[nx2-size:nx2+size, nz2-size:nz2+size] = \
197+
m1.data[nx2-size:nx2+size+1, nz2-size:nz2+size+1] = \
198198
-1 + 2 * np.random.rand(ns, ns)
199199
else:
200200
nx2, ny2, nz2 = shape[0]//2, shape[1]//2, shape[2]//2
201201
nx, ny, nz = shape
202-
m1.data[nx2-size:nx2+size, ny2-size:ny2+size, nz2-size:nz2+size] = \
202+
m1.data[nx2-size:nx2+size+1, ny2-size:ny2+size+1, nz2-size:nz2+size+1] = \
203203
-1 + 2 * np.random.rand(ns, ns, ns)
204204

205205
a = np.random.rand()
@@ -242,12 +242,12 @@ def test_linearity_adjoint_J(self, shape, dtype, so):
242242
ns = 2 * size + 1
243243
if len(shape) == 2:
244244
nx2, nz2 = shape[0]//2, shape[1]//2
245-
m1.data[nx2-size:nx2+size, nz2-size:nz2+size] = \
245+
m1.data[nx2-size:nx2+size+1, nz2-size:nz2+size+1] = \
246246
-1 + 2 * np.random.rand(ns, ns)
247247
else:
248248
nx2, ny2, nz2 = shape[0]//2, shape[1]//2, shape[2]//2
249249
nx, ny, nz = shape
250-
m1.data[nx2-size:nx2+size, ny2-size:ny2+size, nz2-size:nz2+size] = \
250+
m1.data[nx2-size:nx2+size+1, ny2-size:ny2+size+1, nz2-size:nz2+size+1] = \
251251
-1 + 2 * np.random.rand(ns, ns, ns)
252252

253253
a = np.random.rand()
@@ -289,12 +289,12 @@ def test_adjoint_J(self, shape, dtype, so):
289289
ns = 2 * size + 1
290290
if len(shape) == 2:
291291
nx2, nz2 = shape[0]//2, shape[1]//2
292-
dm1.data[nx2-size:nx2+size, nz2-size:nz2+size] = \
292+
dm1.data[nx2-size:nx2+size+1, nz2-size:nz2+size+1] = \
293293
-1 + 2 * np.random.rand(ns, ns)
294294
else:
295295
nx2, ny2, nz2 = shape[0]//2, shape[1]//2, shape[2]//2
296296
nx, ny, nz = shape
297-
dm1.data[nx2-size:nx2+size, ny2-size:ny2+size, nz2-size:nz2+size] = \
297+
dm1.data[nx2-size:nx2+size+1, ny2-size:ny2+size+1, nz2-size:nz2+size+1] = \
298298
-1 + 2 * np.random.rand(ns, ns, ns)
299299

300300
# Data perturbation

0 commit comments

Comments
 (0)