def test_invalid_ranks(self): """ Test that a comm from list with invalid ranks will fail. """ max_size = self.max_size # Nodes should be 0..max_size - 1, so create invalid values. nodes = range(10, max_size + 10) with self.assertRaises(InvalidRankError): create_comm_with_list(nodes)
def test_create_comm_with_list(self): """ Test that create_comm_with_list() works correctly. """ nodes = list(range(self.max_size)) comm = create_comm_with_list(nodes) if comm == MPI.COMM_NULL: # Only proceed when not COMM_NULL. return # Run a simple test to confirm this comm works. size = len(nodes) nrows = size * 3 d = Distribution.from_shape(comm=comm, shape=(nrows, 20)) a = zeros(d) expected = numpy.zeros((nrows // size, 20)) assert_array_equal(a.ndarray, expected) # Cleanup. comm.Free()
def _make_new_comm(rank_list): import distarray.localapi.mpiutils as mpiutils new_comm = mpiutils.create_comm_with_list(rank_list) if not mpiutils.get_base_comm(): mpiutils.set_base_comm(new_comm) return proxyize(new_comm) # noqa
def _make_new_comm(rank_list, base_comm): import distarray.localapi.mpiutils as mpiutils res = mpiutils.create_comm_with_list(rank_list, base_comm) return proxyize(res) # noqa
def test_list_too_big(self): """ Test that a comm from list with too many nodes will fail. """ too_many = 2 * self.max_size nodes = range(too_many) with self.assertRaises(InvalidCommSizeError): create_comm_with_list(nodes)