dubfi.mpi.parent_context

Generic MPI helpers for MPI main/parent process.

Added in version 0.2.0.

Classes

MpiContext

Singleton class keeping information about MPI setup.

MpiObj

Base class for all MPI parent objects.

Functions

send_array(array) → None

Broadcast array to all child processes.

Module Contents

class dubfi.mpi.parent_context.MpiContext

Singleton class keeping information about MPI setup.

Return singleton when trying to create new instance.

setup(target_module: str = '', workers: int = -1) → None

Create MPI setup, create child process if necessary.

is_initialized() → bool

Check whether self has been initialized.

init(target_module: str, workers: int = -1) → None

Initialize self if it is not initialized yet.

property workers: int

Number of MPI workers.

property root: int

Number (id) of MPI root (or parent) process.

property iter

Iterator over ids of worker processes.

property comm

MPI communicator.

gen_name(prefix: str = '') → str

Generate a new, unique name.

send_cmd(command: str) → None

Send command to worker processes.

quit() → None

Send termination signal to MPI child processes.

__del__() → None

Destructor: quit child processes.

Reduce(recvbuf: numpy.ndarray, op: mpi4py.MPI.Op) → None

Wrap mpi4py.MPI.Comm.Reduce() to receive data in root.

dubfi.mpi.parent_context.send_array(array: numpy.ndarray | float) → None

Broadcast array to all child processes.

class dubfi.mpi.parent_context.MpiObj

Base class for all MPI parent objects.

Initialization generates self._name and destruction deletes the associated objects on worker processes.

__del__()

Destructor: Delete associated objects on worker processes.