Muscat.Helpers.MPIInterface module¶
- class MPIInterface[source]¶
Bases:
object
Class to test if the mpi interface is available This class work even if the module mpi4py is not available
more information on https://mpi4py.readthedocs.io/
Note
from (https://mpi4py.readthedocs.io/en/stable/overview.html) MPI_Init() or MPI_Init_thread() is actually called when you import the MPI module from the mpi4py package (this is done internally if mpi4py is installed), but only if MPI is not already initialized. In such case, calling Init or Init_thread from Python is expected to generate an MPI error, and in turn an exception will be raised.
MPI_Finalize() is registered (by using Python C/API function Py_AtExit()) for being automatically called when Python processes exit, but only if mpi4py (or the Muscat MPIInterface) actually initialized MPI. Therefore, there is no need to call Finalize from Python to ensure MPI finalization.
- classmethod IsParallel() bool [source]¶
return True if the main program was launched in a mpi environment (mpirun with more than 1 core)
- Returns:
True there is more than one instance running this code (I.e. mpi with more than 1 core). False otherwise
- Return type:
bool