pub fn use_mpi(trigger: bool) -> PyResult<()>
Expand description
Use the Message Passing Interface (MPI) to run on a distributed system
§Parameters
trigger: bool, default=True An optional parameter which allows MPI to only be used under some boolean condition.
§Notes
You must have MPI installed for this to work, and you must call the program with
mpirun <executable>
, or bad things will happen.
MPI runs an identical program on each process, but gives the program an ID called its
“rank”. Only the results of methods on the root process (rank 0) should be
considered valid, as other processes only contain portions of each dataset. To ensure
you don’t save or print data at other ranks, use the provided laddu.mpi.is_root()
method to check if the process is the root process.
Once MPI is enabled, it cannot be disabled. If MPI could be toggled (which it can’t), the other processes will still run, but they will be independent of the root process and will no longer communicate with it. The root process stores no data, so it would be difficult (and convoluted) to get the results which were already processed via MPI.
Additionally, MPI must be enabled at the beginning of a script, at least before any
other laddu
functions are called. For this reason, it is suggested that you use the
context manager laddu.mpi.MPI
to ensure the MPI backend is used properly.
If laddu.mpi.use_mpi()
is called multiple times, the subsequent calls will have no
effect.
You must call laddu.mpi.finalize_mpi()
before your program exits for MPI to terminate
smoothly.
§See Also
laddu.mpi.MPI laddu.mpi.using_mpi laddu.mpi.is_root laddu.mpi.get_rank laddu.mpi.get_size laddu.mpi.finalize_mpi