from dosna.util import Timer log.getLogger().setLevel(log.INFO) DS = 256 CS = 50 if __name__ == '__main__': np.set_printoptions(formatter={'float': '{: 0.3f}'.format}) rdata = np.random.rand(DS, DS, DS).astype(np.float32) engines, backends = dn.engines.available, dn.backends.available for engine, backend in product(engines, backends): dn.use(engine=engine, backend=backend) engine, backend = dn.status(show=True) if not dn.compatible(engine, backend): log.warning('Skipping engine {} ({}) with {} backend'.format( engine.name.capitalize(), engine.params, backend.name.capitalize())) continue with Timer('DosNa (engine: %s, backend: %s)' % (engine.name, backend.name)): with dn.Cluster('/tmp/') as C: with C.create_pool('test_dosna') as P: data = P.create_dataset('test_data', data=rdata,
import dosna as dn from dosna.mpi_utils import pprint, mpi_comm, mpi_rank, \ mpi_size, mpi_root, MpiTimer import logging as log log.getLogger().setLevel(log.INFO) dn.use(engine='mpi', backend='hdf5') ############################################################################### DS = 256 CS = 50 engine, backend = dn.status() pprint('Loading data', rank=0) if mpi_root(): f = tempfile.NamedTemporaryFile() data = np.random.rand(DS, DS, DS).astype(np.float32) with h5.File(f.name, 'w') as g: g.create_dataset('data', data=data) fname = f.name else: fname = None fname = mpi_comm().bcast(fname, root=0) h5in = h5.File(fname, 'r') h5data = h5in['data']
def mpi_comm(): comm = status().engine.params.get('comm', None) if comm is None: comm = MPI.COMM_WORLD return comm