def test_get_mpi_type(self): if env.USE_MPI4PY: from mpi4py import MPI actual = OcgVM.get_mpi_type(int) self.assertEqual(actual, MPI.LONG_LONG) else: raise SkipTest('not env.USE_MPI4PY')
def test_init(self): for _ in range(50): vm = OcgVM() vm.finalize() self.assertTrue(vm.size_global >= 1) self.assertIsNotNone(vm.comm) vm.finalize() vm.__init__() vm.finalize()
def test_create_subcomm(self): vm = OcgVM() if vm.size != 2: raise SkipTest('vm.size != 2') self.assertFalse(vm._is_dummy) vm.create_subcomm('test', [], is_current=True) self.assertTrue(vm.is_null) vm.finalize() self.assertFalse(vm.is_null)
def test_scoped(self): if MPI_SIZE != 8: raise SkipTest('MPI_SIZE != 8') vm = OcgVM() self.assertEqual(vm.size, 8) with vm.scoped('test', [2, 3, 4]): if not vm.is_null: self.assertEqual(vm.size, 3) self.assertEqual(vm.ranks, range(3)) with vm.scoped('nested', [1]): if not vm.is_null: self.assertEqual(vm.size, 1) self.assertEqual(len(vm._subcomms), 2) self.assertEqual(vm.size, 8) self.assertEqual(len(vm._subcomms), 0) vm.finalize() vm = OcgVM() self.assertEqual(vm.size, 8) vm.finalize()
def test_get_live_ranks_from_object(self): if MPI_SIZE != 4: raise SkipTest('MPI_SIZE != 4') vm = OcgVM() if MPI_RANK == 1: dim = Dimension('woot', is_empty=True, dist=True) else: dim = Dimension('woot', dist=True, size=3) actual = vm.get_live_ranks_from_object(dim) self.assertEqual(actual, (0, 2, 3)) vm.finalize()
def test_barrier(self): if MPI_SIZE != 4: raise SkipTest('MPI_SIZE != 4') vm = OcgVM() live_ranks = [1, 3] vm.create_subcomm('for barrier', live_ranks, is_current=True) if not vm.is_null: self.assertEqual(vm.size, 2) else: self.assertNotIn(MPI_RANK, live_ranks) if MPI_RANK in live_ranks: vm.barrier() vm.finalize()
def test_gather(self): if MPI_SIZE != 8: raise SkipTest('MPI_SIZE != 8') vm = OcgVM() live_ranks = [1, 3, 7] # vm.set_live_ranks(live_ranks) vm.create_subcomm('tester', live_ranks, is_current=True) if MPI_RANK in live_ranks: value = MPI_RANK gathered_value = vm.gather(value) if MPI_RANK == 1: self.assertEqual(gathered_value, [1, 3, 7]) elif MPI_RANK in live_ranks: self.assertIsNone(gathered_value) vm.finalize()
def test_create_subcomm(self): vm = OcgVM() vm.create_subcomm('test', [], is_current=True) self.assertTrue(vm.is_null) vm.finalize() self.assertFalse(vm.is_null)