MPI-tools#
This module contains a number of handy functions for MPI functionality.
Under normal circumstances you shouldn’t have to use any of the methods in here if you use
the run module to run GPry.
- mpi.get_random_generator(seed=None)[source]#
Generates seed sequences for processes running in parallel.
- Parameters:
seed (int or numpy seed, or numpy.random.Generator, optional (default=None)) – A random seed to initialise a Generator, or a Generator to be used directly. If none is provided a random one will be drawn.
- mpi.split_number_for_parallel_processes(n, n_proc=1)[source]#
Splits a number of atomic tasks n between the parallel processes.
If n is not divisible by the number of processes, processes with lower rank are preferred, e.g. 5 tasks for 3 processes are assigned as [2, 2, 1].
- mpi.step_split(values)[source]#
Broadcasts from rank=0 and splits array between MPI processes, using mpi.size as step.
If starting from sorted arrays, it preserves “computational scaling” among processes, but producing similar-in-content partial arrays.
- mpi.merge_step_split(values)[source]#
Gather step-split (with
::mpi.SIZE) arrays and returns the merged set for the rank=0 process (Nonefor the rest).
- mpi.multi_gather_array(arrs)[source]#
Gathers (possibly a list of) arrays from all processes into the main process.
NB: mpi-gather guarantees rank order is preserved.
- Parameters:
arrs (array-like) – The arrays to gather
- Return type:
The gathered array(s) from all processes
Broadcasts
attrofinstancefrom process of rankroot.