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 the x inputs on procs processors.

Args:
f (function): function x (list or ndarray): input params (tuple): parameters to be passed to the function (pickable) procs (int): number of processors to be used obj (object): object where f
Returns:
(list [nprocs]) – (ordered) outputs from all the processes
mpi_map.mpi_map_method(fname, x, params, nprocs, obj, splitted=False)[source]

This function applies the method with name fname of object obj to the x inputs on nprocs processors.

Args:
fname (str): name of the function defined in obj x (list or ndarray): input params (tuple): parameters to be passed to the function (pickable) nprocs (int): number of processors to be used obj (object): object where f 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()
eval_method(fname, x, params, obj, splitted=False)[source]

Submit a job to the pool.

Execute function fname belonging to the object obj with scattered input x and additional parameters params

Args:
fname (str): name of the function in obj to be executed x (list or ndarray): input params (tuple): additional parameters obj (object): object where to find function fname splitted (bool): whether the input is already splitted
Returns:
(list [nprocs]) – (ordered) outputs from all the processes
start()[source]

Start the pool of processes

stop()[source]

Stop the pool of processes

Indices and tables