From 06f1da901ea7aced903dd557b1aadab376fb116b Mon Sep 17 00:00:00 2001 From: Mathias Louboutin Date: Mon, 24 Jan 2022 13:14:18 -0500 Subject: [PATCH] mpi: fix mask ordering for sparse gather --- devito/types/sparse.py | 1 - tests/test_mpi.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/devito/types/sparse.py b/devito/types/sparse.py index c743364304..7144f74e6a 100644 --- a/devito/types/sparse.py +++ b/devito/types/sparse.py @@ -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) diff --git a/tests/test_mpi.py b/tests/test_mpi.py index 2cf6867df3..dbfe5338b4 100644 --- a/tests/test_mpi.py +++ b/tests/test_mpi.py @@ -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):