parallel_map#
- caput.util.mpitools.parallel_map(func: collections.abc.Callable, glist: list, root: int | None = None, method: str = 'con', comm: mpi4py.MPI.Comm | None = _comm) list | None[source]#
Apply a parallel map using MPI.
Should be called collectively on the same list. All ranks return the full set of results.
- Parameters:
- func
callable() Function to apply.
- glist
list List of map over. Must be globally defined.
- root
int|None, optional Which process should gather the results, all processes will gather the results if None.
- method{“con”, “alt”, “rand”}, optional
How to split glist to each process, can be ‘con’: continuously, ‘alt’: alternatively, ‘rand’: randomly. Default is ‘con’.
- comm
MPI.Comm|None, optional MPI communicator that array is distributed over. Default is the gobal _comm.
- func
- Returns: