class TestWinAllocateSharedWorld(BaseTestWinAllocateShared, unittest.TestCase): COMM = MPI.COMM_WORLD class TestWinCreateDynamicSelf(BaseTestWinCreateDynamic, unittest.TestCase): COMM = MPI.COMM_SELF class TestWinCreateDynamicWorld(BaseTestWinCreateDynamic, unittest.TestCase): COMM = MPI.COMM_WORLD SpectrumMPI = MPI.get_vendor()[0] == 'Spectrum MPI' try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinCreate, 'mpi-win-create') try: if SpectrumMPI: raise NotImplementedError MPI.Win.Allocate(1, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinAllocate, 'mpi-win-allocate') try: if SpectrumMPI: raise NotImplementedError MPI.Win.Allocate_shared(1, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinAllocateShared, 'mpi-win-shared') try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create_dynamic(MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinCreateDynamic, 'mpi-win-dynamic')
class TestCCOVecSelfDup(TestCCOVecSelf): def setUp(self): self.COMM = MPI.COMM_SELF.Dup() def tearDown(self): self.COMM.Free() class TestCCOVecWorldDup(TestCCOVecWorld): def setUp(self): self.COMM = MPI.COMM_WORLD.Dup() def tearDown(self): self.COMM.Free() name, version = MPI.get_vendor() if name == 'Open MPI': if version == (1, 10, 0): BaseTestCCOVec.skip += [(0, '*')] if version == (1, 8, 6): BaseTestCCOVec.skip += [(0, 'b')] try: MPI.COMM_SELF.Ibarrier().Wait() except NotImplementedError: unittest.disable(BaseTestCCOVec, 'mpi-nbc') if __name__ == '__main__': unittest.main()
intercomm = MPI.Comm.Join(fd) client.close() if intercomm != MPI.COMM_NULL: self.assertEqual(intercomm.remote_size, 1) self.assertEqual(intercomm.size, 1) self.assertEqual(intercomm.rank, 0) if rank == 0: message = TestDPM.message root = MPI.ROOT else: message = None root = 0 message = intercomm.bcast(message, root) if rank == 0: self.assertEqual(message, None) else: self.assertEqual(message, TestDPM.message) intercomm.Free() MPI.COMM_WORLD.Barrier() MVAPICH2 = MPI.get_vendor()[0] == 'MVAPICH2' try: if MVAPICH2: raise NotImplementedError except NotImplementedError: unittest.disable(TestDPM, 'mpi-dpm') if __name__ == '__main__': unittest.main()
assert v is win MPI.Win.Free(v) self.keyval = MPI.Win.Create_keyval(delete_fn=delete_fn) self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID) # win = MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF) self.obj.Set_attr(self.keyval, win) self.assertTrue(win != null) self.obj.Delete_attr(self.keyval) self.assertTrue(win == null) try: k = MPI.Datatype.Create_keyval() k = MPI.Datatype.Free_keyval(k) except NotImplementedError: unittest.disable(BaseTestDatatypeAttr, 'mpi-type-attr') SpectrumMPI = MPI.get_vendor()[0] == 'Spectrum MPI' try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() k = MPI.Win.Create_keyval() k = MPI.Win.Free_keyval(k) except (NotImplementedError, MPI.Exception): unittest.disable(TestWinAttr, 'mpi-win-attr') if __name__ == '__main__': unittest.main()
@unittest.skipMPI('LAM/MPI') class TestIOSelf(BaseTestIO, unittest.TestCase): COMM = MPI.COMM_SELF prefix = BaseTestIO.prefix + ('%d-' % MPI.COMM_WORLD.Get_rank()) @unittest.skipMPI('openmpi(<2.2.0)') @unittest.skipMPI('msmpi') @unittest.skipMPI('MPICH2') @unittest.skipMPI('MPICH1') @unittest.skipMPI('LAM/MPI') class TestIOWorld(BaseTestIO, unittest.TestCase): COMM = MPI.COMM_WORLD def have_feature(): case = BaseTestIO() case.COMM = TestIOSelf.COMM case.prefix = TestIOSelf.prefix case.setUp() case.tearDown() try: have_feature() except NotImplementedError: unittest.disable(BaseTestIO, 'mpi-io') if __name__ == '__main__': unittest.main()
class TestWinCreateDynamicSelf(BaseTestWinCreateDynamic, unittest.TestCase): COMM = MPI.COMM_SELF class TestWinCreateDynamicWorld(BaseTestWinCreateDynamic, unittest.TestCase): COMM = MPI.COMM_WORLD SpectrumMPI = MPI.get_vendor()[0] == 'Spectrum MPI' try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinCreate, 'mpi-win-create') try: if SpectrumMPI: raise NotImplementedError MPI.Win.Allocate(1, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinAllocate, 'mpi-win-allocate') try: if SpectrumMPI: raise NotImplementedError MPI.Win.Allocate_shared(1, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinAllocateShared, 'mpi-win-shared') try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create_dynamic(MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestWinCreateDynamic, 'mpi-win-dynamic')
assert isinstance(o, MPI.Win) assert k == self.keyval assert v is win MPI.Win.Free(v) self.keyval = MPI.Win.Create_keyval(delete_fn=delete_fn) self.assertNotEqual(self.keyval, MPI.KEYVAL_INVALID) # win = MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF) self.obj.Set_attr(self.keyval, win) self.assertTrue(win != null) self.obj.Delete_attr(self.keyval) self.assertTrue(win == null) try: k = MPI.Datatype.Create_keyval() k = MPI.Datatype.Free_keyval(k) except NotImplementedError: unittest.disable(BaseTestDatatypeAttr, 'mpi-type-attr') SpectrumMPI = MPI.get_vendor()[0] == 'Spectrum MPI' try: if SpectrumMPI: raise NotImplementedError k = MPI.Win.Create_keyval() k = MPI.Win.Free_keyval(k) except NotImplementedError: unittest.disable(TestWinAttr, 'mpi-win-attr') if __name__ == '__main__': unittest.main()
@unittest.skipMPI('openmpi(<3.0.0)') class TestPackExternal(BaseTestPackExternal, unittest.TestCase): pass name, version = MPI.get_vendor() if name == 'MPICH': if version < (4, 0, 0): BaseTestPackExternal.skipdtype += 'ldgFDG' elif name == 'Open MPI': BaseTestPackExternal.skipdtype += 'gG' # XXX TODO if version < (5, 0, 0): BaseTestPackExternal.skipdtype += 'gG' elif name == 'Intel MPI': BaseTestPackExternal.skipdtype += 'ldgFDG' elif name == 'Microsoft MPI': BaseTestPackExternal.skipdtype += 'gFDG' elif name == 'MVAPICH2': BaseTestPackExternal.skipdtype += 'ldgFDG' elif name == 'MPICH2': BaseTestPackExternal.skipdtype += 'ldgFDG' else: try: MPI.BYTE.Pack_external_size(EXT32, 0) except NotImplementedError: unittest.disable(BaseTestPackExternal, 'mpi-ext32') if __name__ == '__main__': unittest.main()
for i in range(n // 2, n): self.assertEqual(mem[i], 0) mem[:] = 0 mem[1:5] = b"abcd" mem[10:13] = b"xyz" self.assertEqual(mem[0], 0) for i, c in enumerate("abcd"): self.assertEqual(mem[1 + i], ord(c)) for i in range(5, 10): self.assertEqual(mem[i], 0) for i, c in enumerate("xyz"): self.assertEqual(mem[10 + i], ord(c)) for i in range(13, n): self.assertEqual(mem[i], 0) self.assertEqual(mem[1:5].tobytes(), b"abcd") self.assertEqual(mem[10:13].tobytes(), b"xyz") finally: MPI.Free_mem(mem) self.assertEqual(mem.address, 0) self.assertEqual(mem.nbytes, 0) self.assertFalse(mem.readonly) try: MPI.memory except AttributeError: unittest.disable(TestMemory, 'mpi4py-memory') if __name__ == '__main__': unittest.main()
COMM = MPI.COMM_SELF class TestCCOBufInplaceWorld(BaseTestCCOBufInplace, unittest.TestCase): COMM = MPI.COMM_WORLD @unittest.skipMPI('IntelMPI', MPI.COMM_WORLD.Get_size() > 1) def testReduceScatter(self): super(TestCCOBufInplaceWorld, self).testReduceScatter() class TestCCOBufSelfDup(TestCCOBufSelf): def setUp(self): self.COMM = MPI.COMM_SELF.Dup() def tearDown(self): self.COMM.Free() class TestCCOBufWorldDup(TestCCOBufWorld): def setUp(self): self.COMM = MPI.COMM_WORLD.Dup() def tearDown(self): self.COMM.Free() try: MPI.COMM_SELF.Ibarrier().Wait() except NotImplementedError: unittest.disable(BaseTestCCOBuf, 'mpi-nbc') unittest.disable(BaseTestCCOBufInplace, 'mpi-nbc') if __name__ == '__main__': unittest.main()
class TestCCOBufWorld(BaseTestCCOBuf, unittest.TestCase): COMM = MPI.COMM_WORLD class TestCCOBufInplaceSelf(BaseTestCCOBufInplace, unittest.TestCase): COMM = MPI.COMM_SELF class TestCCOBufInplaceWorld(BaseTestCCOBufInplace, unittest.TestCase): COMM = MPI.COMM_WORLD class TestCCOBufSelfDup(TestCCOBufSelf): def setUp(self): self.COMM = MPI.COMM_SELF.Dup() def tearDown(self): self.COMM.Free() class TestCCOBufWorldDup(TestCCOBufWorld): def setUp(self): self.COMM = MPI.COMM_WORLD.Dup() def tearDown(self): self.COMM.Free() try: StartWaitFree( MPI.COMM_SELF.Barrier_init() ) except NotImplementedError: unittest.disable(BaseTestCCOBuf, 'mpi-coll-persist') unittest.disable(BaseTestCCOBufInplace, 'mpi-coll-persist') if __name__ == '__main__': unittest.main()
client.close() if intercomm != MPI.COMM_NULL: self.assertEqual(intercomm.remote_size, 1) self.assertEqual(intercomm.size, 1) self.assertEqual(intercomm.rank, 0) if rank == 0: message = TestDPM.message root = MPI.ROOT else: message = None root = 0 message = intercomm.bcast(message, root) if rank == 0: self.assertEqual(message, None) else: self.assertEqual(message, TestDPM.message) intercomm.Free() MPI.COMM_WORLD.Barrier() MVAPICH2 = MPI.get_vendor()[0] == 'MVAPICH2' try: if MVAPICH2: raise NotImplementedError MPI.Close_port(MPI.Open_port()) except NotImplementedError: unittest.disable(TestDPM, 'mpi-dpm') if __name__ == '__main__': unittest.main()
win.Set_errhandler(MPI.ERRORS_RETURN) win.Call_errhandler(MPI.ERR_OTHER) win.Free() @unittest.skipMPI('MPI(<2.0)') @unittest.skipMPI('msmpi') def testFileCallErrhandler(self): import os, tempfile rank = MPI.COMM_WORLD.Get_rank() fd, filename = tempfile.mkstemp(prefix='mpi4py-', suffix="-%d" % rank) os.close(fd) amode = MPI.MODE_WRONLY | MPI.MODE_CREATE | MPI.MODE_DELETE_ON_CLOSE try: file = MPI.File.Open(MPI.COMM_SELF, filename, amode, MPI.INFO_NULL) except NotImplementedError: self.skipTest('mpi-file') file.Set_errhandler(MPI.ERRORS_RETURN) #file.Call_errhandler(MPI.ERR_OTHER) file.Call_errhandler(MPI.SUCCESS) file.Close() try: MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): TestErrhandler.testWinCallErrhandler = \ unittest.disable(TestErrhandler.testWinCallErrhandler, 'mpi-win') if __name__ == '__main__': unittest.main()
COMM = MPI.COMM_SELF class TestCCONghBufWorld(BaseTestCCONghBuf, unittest.TestCase): COMM = MPI.COMM_WORLD class TestCCONghBufSelfDup(TestCCONghBufSelf): def setUp(self): self.COMM = MPI.COMM_SELF.Dup() def tearDown(self): self.COMM.Free() class TestCCONghBufWorldDup(TestCCONghBufWorld): def setUp(self): self.COMM = MPI.COMM_WORLD.Dup() def tearDown(self): self.COMM.Free() try: StartWaitFree(MPI.COMM_SELF.Barrier_init()) except NotImplementedError: unittest.disable(BaseTestCCONghBuf, 'mpi-coll-persist') if __name__ == '__main__': unittest.main()
eh = MPI.FILE_NULL.Get_errhandler() self.assertEqual(eh, MPI.ERRORS_ARE_FATAL) eh.Free() MPI.FILE_NULL.Set_errhandler(MPI.ERRORS_RETURN) eh = MPI.FILE_NULL.Get_errhandler() self.assertEqual(eh, MPI.ERRORS_RETURN) eh.Free() class TestFileSelf(BaseTestFile, unittest.TestCase): COMM = MPI.COMM_SELF prefix = BaseTestFile.prefix + ('-%d' % MPI.COMM_WORLD.Get_rank()) def have_feature(): case = BaseTestFile() case.COMM = TestFileSelf.COMM case.prefix = TestFileSelf.prefix case.setUp() case.tearDown() try: have_feature() except NotImplementedError: unittest.disable(BaseTestFile, 'mpi-file') unittest.disable(TestFileNull, 'mpi-file') if __name__ == '__main__': unittest.main()
self.assertEqual(info.Get("mpi_size"), "1") info.Free() group = session.Create_group(name) self.assertEqual(group.Get_rank(), 0) self.assertEqual(group.Get_size(), 1) group.Free() session.Finalize() def testSessionWORLD(self): comm = MPI.COMM_WORLD session = MPI.Session.Init() name = "mpi://WORLD" info = session.Get_pset_info(name) size = comm.Get_size() self.assertEqual(info.Get("mpi_size"), str(size)) info.Free() group = session.Create_group(name) self.assertEqual(group.Get_size(), comm.Get_size()) self.assertEqual(group.Get_rank(), comm.Get_rank()) group.Free() session.Finalize() try: MPI.Session.Init().Finalize() except NotImplementedError: unittest.disable(TestSession, 'mpi-session') if __name__ == '__main__': unittest.main()
# for i in range(size): win.Lock(i) win.Flush_local(i) win.Unlock(i) comm.Barrier() for i in range(size): if i == rank: win.Lock_all() win.Flush_local_all() win.Unlock_all() comm.Barrier() class TestRMASelf(BaseTestRMA, unittest.TestCase): COMM = MPI.COMM_SELF class TestRMAWorld(BaseTestRMA, unittest.TestCase): COMM = MPI.COMM_WORLD SpectrumMPI = MPI.get_vendor()[0] == 'Spectrum MPI' try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create(None, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except NotImplementedError: unittest.disable(BaseTestRMA, 'mpi-rma') if __name__ == '__main__': unittest.main()
class TestCCOVecWorld(BaseTestCCOVec, unittest.TestCase): COMM = MPI.COMM_WORLD class TestCCOVecSelfDup(TestCCOVecSelf): def setUp(self): self.COMM = MPI.COMM_SELF.Dup() def tearDown(self): self.COMM.Free() class TestCCOVecWorldDup(TestCCOVecWorld): def setUp(self): self.COMM = MPI.COMM_WORLD.Dup() def tearDown(self): self.COMM.Free() name, version = MPI.get_vendor() if name == 'Open MPI': if version == (1,10,0): BaseTestCCOVec.skip += [(0, '*')] if version == (1,8,6): BaseTestCCOVec.skip += [(0, 'b')] try: MPI.COMM_SELF.Ibarrier().Wait() except NotImplementedError: unittest.disable(BaseTestCCOVec, 'mpi-nbc') if __name__ == '__main__': unittest.main()
self.assertEqual(INFO.get('key3', 'newval3'), 'newval3') INFO.update(dict(key1='val1', key2='val2', key3='val3')) self.assertEqual(len(INFO), 3) self.assertEqual(INFO['key1'], 'val1') self.assertEqual(INFO['key2'], 'val2') self.assertEqual(INFO['key3'], 'val3') dupe = INFO.copy() self.assertEqual(INFO.items(), dupe.items()) dupe.Free() INFO.clear() self.assertEqual(len(INFO), 0) self.assertEqual(INFO.get('key1'), None) self.assertEqual(INFO.get('key2'), None) self.assertEqual(INFO.get('key3'), None) self.assertEqual(INFO.get('key1', 'value1'), 'value1') self.assertEqual(INFO.get('key2', 'value2'), 'value2') self.assertEqual(INFO.get('key3', 'value3'), 'value3') try: MPI.Info.Create().Free() except NotImplementedError: unittest.disable(TestInfo, 'mpi-info') unittest.disable(TestInfoNull, 'mpi-info') if (MPI.VERSION < 3 and MPI.INFO_ENV == MPI.INFO_NULL): unittest.disable(TestInfoEnv, 'mpi-info-env') if __name__ == '__main__': unittest.main()
def tearDown(self): self.COMM.Free() def have_feature(): info = MPI.Get_library_version() if 'MPICH' in info and 'ch3:' in info: raise NotImplementedError sreq = MPI.COMM_SELF.Psend_init(bytearray(1), 1, 0, 0) rreq = MPI.COMM_SELF.Precv_init(bytearray(1), 1, 0, 0) sreq.Start() rreq.Start() sreq.Pready(0) rreq.Parrived(0) rreq.Wait() rreq.Free() del rreq sreq.Wait() sreq.Free() del sreq try: have_feature() except NotImplementedError: unittest.disable(BaseTestP2PBufPart, 'mpi-p2p-part') if __name__ == '__main__': unittest.main()
r = self.WIN.Raccumulate([zeros, MPI.INT], MPI.PROC_NULL, None, MPI.SUM) r.Wait() r = self.WIN.Raccumulate([None, MPI.INT], MPI.PROC_NULL, None, MPI.SUM) r.Wait() self.WIN.Unlock(rank) @unittest.skipMPI('MPI(<3.0)') @unittest.skipMPI('openmpi(<1.8.1)') @unittest.skipMPI('MPICH2(<1.5.0)') class TestRMASelf(BaseTestRMA, unittest.TestCase): COMM = MPI.COMM_SELF @unittest.skipMPI('MPI(<3.0)') @unittest.skipMPI('openmpi(<1.8.1)') @unittest.skipMPI('MPICH2(<1.5.0)') class TestRMAWorld(BaseTestRMA, unittest.TestCase): COMM = MPI.COMM_WORLD SpectrumMPI = MPI.get_vendor()[0] == 'Spectrum MPI' try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create(None, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestRMA, 'mpi-rma-nb') if __name__ == '__main__': unittest.main()
def testFree(self): self.assertTrue(self.win) self.win.free() self.assertFalse(self.win) class TestMyWin(BaseTestMyWin, unittest.TestCase): pass SpectrumMPI = MPI.get_vendor()[0] == 'Spectrum MPI' try: if SpectrumMPI: raise NotImplementedError MPI.Win.Create(MPI.BOTTOM).Free() except (NotImplementedError, MPI.Exception): unittest.disable(BaseTestMyWin, 'mpi-win') # --- import os, tempfile class MyFile(MPI.File): def __new__(cls, file=None): return MPI.File.__new__(cls, file) def close(self): if self != MPI.FILE_NULL: MPI.File.Close(self)
self.COMM = MPI.COMM_SELF.Dup() def tearDown(self): self.COMM.Free() class TestCCOVecWorldDup(TestCCOVecWorld): def setUp(self): self.COMM = MPI.COMM_WORLD.Dup() def tearDown(self): self.COMM.Free() class TestCCOVecInplaceSelf(BaseTestCCOVecInplace, unittest.TestCase): COMM = MPI.COMM_SELF class TestCCOVecInplaceWorld(BaseTestCCOVecInplace, unittest.TestCase): COMM = MPI.COMM_WORLD try: StartWaitFree(MPI.COMM_SELF.Barrier_init()) except NotImplementedError: unittest.disable(BaseTestCCOVec, 'mpi-coll-persist') unittest.disable(BaseTestCCOVecInplace, 'mpi-coll-persist') if __name__ == '__main__': unittest.main()
class TestPackSelf(BaseTestPack, unittest.TestCase): COMM = MPI.COMM_SELF class TestPackWorld(BaseTestPack, unittest.TestCase): COMM = MPI.COMM_SELF @unittest.skipMPI('openmpi(<3.0.0)') class TestPackExternal(BaseTestPackExternal, unittest.TestCase): pass name, version = MPI.get_vendor() if name =='MPICH' or name == 'MPICH2': BaseTestPackExternal.skipdtype += ['l'] BaseTestPackExternal.skipdtype += ['d'] elif name == 'Intel MPI': BaseTestPackExternal.skipdtype += ['l'] BaseTestPackExternal.skipdtype += ['d'] elif name == 'MVAPICH2': BaseTestPackExternal.skipdtype += ['l'] BaseTestPackExternal.skipdtype += ['d'] else: try: MPI.BYTE.Pack_external_size(EXT32, 0) except NotImplementedError: unittest.disable(BaseTestPackExternal, 'mpi-ext32') if __name__ == '__main__': unittest.main()
@unittest.skipMPI('MPICH1') @unittest.skipMPI('LAM/MPI') class TestIOSelf(BaseTestIO, unittest.TestCase): COMM = MPI.COMM_SELF prefix = BaseTestIO.prefix + ('%d-' % MPI.COMM_WORLD.Get_rank()) @unittest.skipMPI('openmpi(<2.2.0)') @unittest.skipMPI('msmpi') @unittest.skipMPI('MPICH2') @unittest.skipMPI('MPICH1') @unittest.skipMPI('LAM/MPI') class TestIOWorld(BaseTestIO, unittest.TestCase): COMM = MPI.COMM_WORLD def have_feature(): case = BaseTestIO() case.COMM = TestIOSelf.COMM case.prefix = TestIOSelf.prefix case.setUp() case.tearDown() try: have_feature() except NotImplementedError: unittest.disable(BaseTestIO, 'mpi-io') if __name__ == '__main__': unittest.main()
for i in range(n//2, n): self.assertEqual(mem[i], 0) mem[:] = 0 mem[1:5] = b"abcd" mem[10:13] = b"xyz" self.assertEqual(mem[0], 0) for i, c in enumerate("abcd"): self.assertEqual(mem[1+i], ord(c)) for i in range(5, 10): self.assertEqual(mem[i], 0) for i, c in enumerate("xyz"): self.assertEqual(mem[10+i], ord(c)) for i in range(13, n): self.assertEqual(mem[i], 0) self.assertEqual(mem[1:5].tobytes(), b"abcd") self.assertEqual(mem[10:13].tobytes(), b"xyz") finally: MPI.Free_mem(mem) self.assertEqual(mem.address, 0) self.assertEqual(mem.nbytes, 0) self.assertFalse(mem.readonly) try: MPI.memory except AttributeError: unittest.disable(TestMemory, 'mpi4py-memory') if __name__ == '__main__': unittest.main()
win.Call_errhandler(MPI.ERR_OTHER) win.Free() @unittest.skipMPI('MPI(<2.0)') @unittest.skipMPI('msmpi') def testFileCallErrhandler(self): import os, tempfile rank = MPI.COMM_WORLD.Get_rank() fd, filename = tempfile.mkstemp(prefix='mpi4py-', suffix="-%d"%rank) os.close(fd) amode = MPI.MODE_WRONLY | MPI.MODE_CREATE | MPI.MODE_DELETE_ON_CLOSE try: file = MPI.File.Open(MPI.COMM_SELF, filename, amode, MPI.INFO_NULL) except NotImplementedError: self.skipTest('mpi-file') file.Set_errhandler(MPI.ERRORS_RETURN) #file.Call_errhandler(MPI.ERR_OTHER) file.Call_errhandler(MPI.SUCCESS) file.Close() try: MPI.Win.Create(MPI.BOTTOM, 1, MPI.INFO_NULL, MPI.COMM_SELF).Free() except (NotImplementedError, MPI.Exception): TestErrhandler.testWinCallErrhandler = \ unittest.disable(TestErrhandler.testWinCallErrhandler, 'mpi-win') if __name__ == '__main__': unittest.main()
self.INFO.Free() self.INFO = None super(TestExcInfo, self).tearDown() def testDelete(self): self.assertRaisesMPI(MPI.ERR_INFO_NOKEY, self.INFO.Delete, 'key') def testGetNthKey(self): self.assertRaisesMPI([MPI.ERR_INFO_KEY, MPI.ERR_ARG], self.INFO.Get_nthkey, 0) try: MPI.Info.Create().Free() except NotImplementedError: unittest.disable(TestExcInfo, 'mpi-info') unittest.disable(TestExcInfoNull, 'mpi-info') # -------------------------------------------------------------------- class TestExcGroupNull(BaseTestCase): def testCompare(self): self.assertRaisesMPI(MPI.ERR_GROUP, MPI.Group.Compare, MPI.GROUP_NULL, MPI.GROUP_NULL) self.assertRaisesMPI(MPI.ERR_GROUP, MPI.Group.Compare, MPI.GROUP_NULL, MPI.GROUP_EMPTY) self.assertRaisesMPI(MPI.ERR_GROUP, MPI.Group.Compare, MPI.GROUP_EMPTY, MPI.GROUP_NULL) def testAccessors(self):