parameter_sweep.parallel.mpi_parallel_manager

Module Contents

Classes

MPIParallelManager

Helper class that provides a standard way to create an ABC using

class parameter_sweep.parallel.mpi_parallel_manager.MPIParallelManager(MPI, **kwargs)

Helper class that provides a standard way to create an ABC using inheritance.

is_root_process()

Return whether the current process should be considered as the root of the parallel group it is a part of.

get_rank()

Get the process’s rank number in its parallel peer group.

number_of_worker_processes()

Return how many total processes are running local simulations.

sync_with_peers()

Implement a synchronization point with any peer processes.

sync_array_with_peers(data)

Broadcast the array to all processes. this call acts as a synchronization point when run by multiple peer mpi processes.

sync_pyobject_with_peers(obj)

Broadcast the object to all processes from the root. this call acts as a synchronization point when run by multiple peer mpi processes.

combine_data_with_peers(data)

Combine the data from each peer into a list. The return value will be a list of all the data elements provided by each process that calls this function.

With multiple processes, this must: - act as a synchronization point - return the list in the same order on each process

gather_arrays_to_root(sendbuf, recvbuf_spec)

Gather the data in the send buffer to the root process. Parameters are: - sendbuf: the data to be sent from this process - recvbuf_spec: a tuple of (receive buffer, list of sizes) where the list of sizes is how much data will come from each process. Ignored if not the root process.

sum_values_and_sync(sendbuf, recvbuf)

Sum a list of values from each process and sync the result to all processes. Parameters: - sendbuf: an array of values the local process is contributing to the sum - recvbuf: an array of a single value that will hold the summed result (same on each process) when the function returns.

Note: this is a specific case of a global reduce (with sum() as the reducing function). If more than sum() is needed in the future, this function should be extended to receive an Op argument.

scatter(do_build, do_build_kwargs, do_execute, all_parameters)

Scatter the specified execution out, as defined by the implementation’s parallelism, for a list of parameters. Args: - do_build: a function that builds the arguments necessary for the execution function. expected to return a list that will be exploded and passed into the do_execute function as arguments. - do_build_kwargs: a dictionary of keyword arguments for the do_build function - do_execute: the execution function. expected to take in the list of local parameters as its first argument. any arguments after that should match the list returned by the do_build function. - all_parameters: a list of all parameters to be run. included so that different implementations of the parallel manager can make decisions about splitting and parallelization.

gather()

Gather the results of the computation that was kicked off via a previous scatter. Returns: - a list of LocalResults, representing the results for each process. each result will be the return value of the do_execute function from scatter() for one process.

results_from_local_tree(results)

Given a list of LocalResults objects, return a sublist of the ones the current process is responsible for.