Skip to content

Commit

Permalink
CI: add single mpi sparse test
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jul 1, 2024
1 parent 1148087 commit fe2e65f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def parallel(item, m):
args = ["-n", "1", pyversion, "-m", "pytest", "-s", "--runxfail", "-qq", testname]
if nprocs > 1:
args.extend([":", "-n", "%d" % (nprocs - 1), pyversion, "-m", "pytest",
"-s", "--runxfail", "--tb=no", "-qq", "--no-summary", testname])
"-s", "--runxfail", "--tb=no", "-qq", testname])
# OpenMPI requires an explicit flag for oversubscription. We need it as some
# of the MPI tests will spawn lots of processes
if mpi_distro == 'OpenMPI':
Expand Down
6 changes: 4 additions & 2 deletions devito/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def __array_finalize__(self, obj):
decomposition.append(dec.reshape(i))
self._decomposition = tuple(decomposition)
self._allocator = obj._allocator
self._is_distributed = any(i is not None for i in self._decomposition)
decomp = any(i is not None for i in self._decomposition)
self._is_distributed = decomp and obj._is_distributed
else:
self._distributor = obj._distributor
self._allocator = obj._allocator
Expand All @@ -142,7 +143,8 @@ def __array_finalize__(self, obj):
# E.g., from a reduction operation such as `np.mean` or `np.all`
self._modulo = tuple(False for i in range(self.ndim))
self._decomposition = (None,)*self.ndim
self._is_distributed = any(i is not None for i in self._decomposition)
decomp = any(i is not None for i in self._decomposition)
self._is_distributed = decomp and obj._is_distributed

@property
def _local(self):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ def test_indexing_into_sparse(self):
sf.data[1:-1, 0] = np.arange(8)
assert np.all(sf.data[1:-1, 0] == np.arange(8))

@pytest.mark.parallel(mode=1)
def test_indexing_into_sparse_subfunc_singlempi(self, mode):
grid = Grid(shape=(4, 4))
s = SparseFunction(name='sf', grid=grid, npoint=1)
coords = np.random.rand(*s.coordinates.data.shape)
s.coordinates.data[:] = coords

s.coordinates.data[-1, :] = s.coordinates.data[-1, :] / 2

assert np.allclose(s.coordinates.data[-1, :], coords[-1, :] / 2)


class TestLocDataIDX:
"""
Expand Down

0 comments on commit fe2e65f

Please sign in to comment.