elephant.parallel.MPIPoolExecutor

class elephant.parallel.MPIPoolExecutor(max_workers=None)[source]

The MPIPoolExecutor class uses a pool of MPI processes to execute calls asynchronously.

MPIPoolExecutor is recommended to use on cluster nodes which support MPI-2 protocol.

Notes

-m mpi4py.futures command line option is needed to execute Python scripts with MPI:

mpiexec -n numprocs python -m mpi4py.futures pyfile [arg] ...

For more information of how to launch MPI processes in Python refer to https://mpi4py.readthedocs.io/en/stable/mpi4py.futures.html#command-line

Methods

__init__([max_workers]) Initialize self.
execute(handler, args_iterate, **kwargs) Executes the queue of [handler(arg, **kwargs) for arg in args_iterate] in multiple processes within one machine (ProcessPoolExecutor) or multiple nodes (MPIPoolExecutor and MPICommExecutor).
execute(handler, args_iterate, **kwargs)

Executes the queue of [handler(arg, **kwargs) for arg in args_iterate] in multiple processes within one machine (ProcessPoolExecutor) or multiple nodes (MPIPoolExecutor and MPICommExecutor).

Parameters:
handlercallable

A function to be executed for each argument in args_iterate.

args_iteratelist

A list of (different) values of the first argument of the handler function.

kwargs

Additional key arguments to handler.

Returns:
resultslist

The result of applying the handler for each arg in the args_iterate. The i-th item of the resulting list corresponds to args_iterate[i] (the order is preserved).