Bamboost
bamboost/mpi/utilities

bamboost.mpi.utilities

Functions

on_rank(func, comm, rank) -> Callable[_P, _T]

Decorator to run a function on a specific rank and broadcast the result.

Arguments:
  • func:typing.Callable[_P, bamboost._typing._T]

    The function to decorate.

  • comm:Comm

    The MPI communicator.

  • rank:int

    The rank to run the function on.

on_root(func, comm) -> Callable[_P, _T]

Decorator to run a function on the root rank and broadcast the result.

Arguments:
  • func:typing.Callable[_P, bamboost._typing._T]

    The function to decorate.

  • comm:Comm

    The MPI communicator.

Classes

HasComm

Attributes:

RootProcessMeta

A metaclass that makes classes MPI-safe by ensuring methods are only executed on the root process. The class implementing this metaclass must have a _comm attribute that is an MPI communicator.

This metaclass modifies class methods to either use broadcast communication (if decorated with @bcast) or to only execute on the root process (rank 0).

Attributes:
  • __exclude__={'__init__', '__new__'}
RootProcessMeta.__new__(mcs, name, bases, attrs)

Create a new class with MPI-safe methods.

Arguments:
  • mcs
  • name:str

    The name of the class being created.

  • bases:tuple

    The base classes of the class being created.

  • attrs:dict

    The attributes of the class being created.

Returns
The new class with MPI-safe methods.
RootProcessMeta.comm_self(instance) -> Generator[None, None, None]

Context manager to temporarily change the communicator to MPI.COMM_SELF.

Arguments:
Arguments:
  • func
Arguments:
  • func

Decorator that ensures a method is only executed on the root process (rank 0).

Arguments:
  • func:callable

    The method to be decorated.

Returns
The wrapped method that only executes on the root process.