Skip to content

Commit

Permalink
mpi: fix mask ordering for sparse gather
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Feb 7, 2022
1 parent 2f039b9 commit 06f1da9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion devito/types/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def _dist_gather_mask(self, dmap=None):
ret = list(self._dist_scatter_mask(dmap=dmap))
mask = ret[self._sparse_position]
inds = np.unique(mask, return_index=True)[1]
inds.sort()
ret[self._sparse_position] = inds.tolist()

return tuple(ret)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,22 @@ def test_sparse_coords(self):
coords_loc += sf.coordinates.data[i, 0]
assert sf.data[i] == coords_loc

@pytest.mark.parallel(mode=4)
def test_sparse_coords_issue1823(self):
grid = Grid((101, 101, 101), extent=(1000, 1000, 1000))
coords = np.array([[1000., 0., 900.], [1000., 300., 700.],
[1000., 500., 500.], [1000., 700., 300.],
[1000., 900., 0.], [1000., 0., 850.]])
rec = SparseTimeFunction(name="s", grid=grid, coordinates=coords,
nt=10, npoint=6)
ref = SparseTimeFunction(name="s1", grid=grid, coordinates=coords,
nt=10, npoint=6)
u = TimeFunction(name="u", grid=grid, space_order=1)

Operator([Eq(u, u+1)]+rec.interpolate(u))()

assert np.allclose(rec.coordinates.data[:], ref.coordinates.data)


class TestOperatorSimple(object):

Expand Down

0 comments on commit 06f1da9

Please sign in to comment.