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 MPIAttributes
- 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()
Functions
() -> bool() -> NoneClasses
_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
(self, name) -> AnyArguments:
- name:
str
Arguments:
- cls
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
(self) -> NoneA 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]]={}
(self, key) -> boolArguments:
- key:
typing.Any
(self, key) -> AnyArguments:
- key:
typing.Any
(self, key, value) -> NoneArguments:
- key:
typing.Any - value:
typing.Any
(self, key, default=None) -> AnyArguments:
- key:
typing.Any - default:
typing.Any=None
(self, key, default=None) -> AnyArguments:
- key:
typing.Any - default:
typing.Any=None
Communicator
Attributes:
(self, instance)Arguments:
- instance
(self, instance, owner) -> CommArguments:
- instance
- owner
(self, instance, value) -> NoneArguments:
- instance
- value
(self) -> Comm
Bamboost