Welcome to mpi_map’s documentation!¶
Contents:
-
mpi_map.
mpi_map_code
(f, x, params, procs, obj_dill=None)[source]¶ This function applies the function in
func_code
to thex
inputs onprocs
processors.
-
mpi_map.
mpi_map_method
(fname, x, params, nprocs, obj, splitted=False)[source]¶ This function applies the method with name
fname
of objectobj
to thex
inputs onnprocs
processors.- Args:
- fname (str): name of the function defined in
obj
x (list
orndarray
): input params (tuple): parameters to be passed to the function (pickable) nprocs (int): number of processors to be used obj (object): object wheref
is defined splitted (bool): whether the input is already splitted - Returns:
- (
list
[nprocs
]) – (ordered) outputs from all the processes
-
mpi_map.
barrier
(comm, tag=0, sleep=0.01)[source]¶ Function used to avoid busy-waiting.
As suggested by Lisandro Dalcin at: * http://code.google.com/p/mpi4py/issues/detail?id=4 and * https://groups.google.com/forum/?fromgroups=#!topic/mpi4py/nArVuMXyyZI
-
class
mpi_map.
MPI_Pool
(nprocs)[source]¶ Returns (but not start) a pool of
nprocs
processes- Args:
- nprocs (int): number of processes
Usage example:
import numpy as np import numpy.random as npr from TransportMaps import get_mpi_pool, mpi_eval class Operator(object): def __init__(self, a): self.a = a def sum(self, x, n=1): out = x for i in range(n): out += self.a return out op = Operator(2.) x = npr.randn(100,5) n = 2 pool = get_mpi_pool(3) pool.start() try: xsum = mpi_eval("sum", op, x, (n,), mpi_pool=pool) finally: pool.stop()