elephant.parallel.MPICommExecutor

class elephant.parallel.MPICommExecutor(comm=None, root=0)[source]

Legacy MPI-1 implementation for cluster nodes which do not support MPI-2 protocol.

Parameters:
commMPI.Intracomm or None

MPI (intra)communicator. If None, set to MPI.COMM_WORLD. Default: None

rootint

Designated master process. Default: 0

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__([comm, root]) 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).