MPI communication (relentless.mpi)#

Parallel execution using the Message Passing Interface (MPI) is supported. Typically, the calculations required to steer an optimization are simple, so the primary reason to support MPI is for Simulation engines that will run on multiple processes. In Python, the MPI interface is accessed using the mpi4py package.

MPI processes run within a Communicator. The default communicator is the MPI “world,” which is all running processes. You can create your own Communicator using subsets of these processes if you do not want to use all of them.

All commands in your script are intended to be collective within a communicator, meaning that they should be executed by all processes. Behind the scenes, the appropriate MPI collectives will be invoked to keep things synchronized. Then, running the script under MPI can be as simple as invoking it with the MPI launcher on your system:

mpirun python3 script.py

Some caution must be taken with opening file handles when running under MPI. If you do not take special steps, each process will acquire a handle to the same resource. This can quickly overwhelm the operating-system limit. Best practice for small files is to allow one rank to load the file, then broadcast it to the other ranks. A convenience wrapper is given in Communicator.loadtxt(); see its documentation for more details.

Communicator

MPI communicator.