Bamboost
bamboostmpi

bamboost.mpi

This module handles the detection and selection of the appropriate MPI implementation for Bamboost, either using mpi4py for real MPI environments or falling back to a mock MPI implementation for non-MPI environments.

The detection logic considers user configuration options, environment variables, and the presence of common MPI-related environment variables.

If mpi4py is unavailable in an MPI environment, a fallback to the mock implementation is also provided.

Usage

Instead of importing mpi4py.MPI directly, import MPI to use the appropriate MPI module based on the current environment.

>>> from bamboost.mpi import MPI

Attributes

  • Comm:typing_extensions.TypeAlias=typing.Union[mpi4py.MPI.Comm, bamboost.mpi.serial.SerialComm]
  • log:Logger=BAMBOOST_LOGGER.getChild(__name__.split('.')[-1])

    Logger instance for this module.

  • MPI:=_MPIProxy()

    The selected MPI module (mpi4py.MPI or ).

Functions

Classes

_MPIProxy

Proxy class to delay the import of the MPI module until it's actually needed.

Attributes:
  • _mpi_module:typing.Any=None
  • enabled:bool=False
_MPIProxy.__getattr__(self, name) -> Any
Arguments:
  • name:str
Arguments:
  • cls

ReuseComm

ReuseComm(self, parent_obj)

Marker class to indicate that a communicator should be reused from a parent object.

This is used in the Communicator descriptor to allow child objects to automatically reuse the same communicator as their parent without needing to explicitly pass it around.

Arguments:
  • parent_obj:typing.Any
Attributes:
  • parent_obj=bamboost.mpi.ReuseComm(parent_obj)

_WeakKeyDict

_WeakKeyDict(self) -> None

A dictionary that stores keys as weak references, but supports unhashable keys by using the key's object identity id() for underlying storage.

Attributes:
  • _data:dict[int, tuple[weakref.weakref.ReferenceType, typing.Any]]={}
_WeakKeyDict.__contains__(self, key) -> bool
Arguments:
  • key:typing.Any
_WeakKeyDict.__getitem__(self, key) -> Any
Arguments:
  • key:typing.Any
_WeakKeyDict.__setitem__(self, key, value) -> None
Arguments:
  • key:typing.Any
  • value:typing.Any
_WeakKeyDict.get(self, key, default=None) -> Any
Arguments:
  • key:typing.Any
  • default:typing.Any=None
_WeakKeyDict.pop(self, key, default=None) -> Any
Arguments:
  • key:typing.Any
  • default:typing.Any=None

Communicator

Attributes:
Communicator.__delete__(self, instance)
Arguments:
  • instance
Communicator.__get__(self, instance, owner) -> Comm
Arguments:
  • instance
  • owner
Communicator.__set__(self, instance, value) -> None
Arguments:
  • instance
  • value

On this page