dubfi.mpi.parent_context ======================== .. py:module:: dubfi.mpi.parent_context .. autoapi-nested-parse:: Generic MPI helpers for MPI main/parent process. .. codeauthor:: Valentin Bruch, DWD .. versionadded:: 0.2.0 Classes ------- .. autoapisummary:: dubfi.mpi.parent_context.MpiContext dubfi.mpi.parent_context.MpiObj Functions --------- .. autoapisummary:: dubfi.mpi.parent_context.send_array Module Contents --------------- .. py:class:: MpiContext Singleton class keeping information about MPI setup. Return singleton when trying to create new instance. .. py:method:: setup(target_module: str = '', workers: int = -1) -> None Create MPI setup, create child process if necessary. .. py:method:: is_initialized() -> bool Check whether self has been initialized. .. py:method:: init(target_module: str, workers: int = -1) -> None Initialize self if it is not initialized yet. .. py:property:: workers :type: int Number of MPI workers. .. py:property:: root :type: int Number (id) of MPI root (or parent) process. .. py:property:: iter Iterator over ids of worker processes. .. py:property:: comm MPI communicator. .. py:method:: gen_name(prefix: str = '') -> str Generate a new, unique name. .. py:method:: send_cmd(command: str) -> None Send command to worker processes. .. py:method:: quit() -> None Send termination signal to MPI child processes. .. py:method:: __del__() -> None Destructor: quit child processes. .. py:method:: Reduce(recvbuf: numpy.ndarray, op: mpi4py.MPI.Op) -> None Wrap :meth:`mpi4py.MPI.Comm.Reduce` to receive data in root. .. py:function:: send_array(array: numpy.ndarray | float) -> None Broadcast array to all child processes. .. py:class:: MpiObj Base class for all MPI parent objects. Initialization generates self._name and destruction deletes the associated objects on worker processes. .. py:method:: __del__() Destructor: Delete associated objects on worker processes.