:py:mod:`parameter_sweep.parallel.parallel_manager` =================================================== .. py:module:: parameter_sweep.parallel.parallel_manager Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: parameter_sweep.parallel.parallel_manager.ParallelManager parameter_sweep.parallel.parallel_manager.parallelActor Functions ~~~~~~~~~ .. autoapisummary:: parameter_sweep.parallel.parallel_manager.build_and_execute .. py:class:: ParallelManager Abstract Base Class for Parallel Manager implementations. .. py:attribute:: ROOT_PROCESS_RANK :value: 0 .. py:method:: is_root_process() :abstractmethod: Return whether the current process should be considered as the root of the parallel group it is a part of. .. py:method:: get_rank() :abstractmethod: Get the process's rank number in its parallel peer group. .. py:method:: number_of_worker_processes() :abstractmethod: Return how many total processes are running local simulations. .. py:method:: sync_with_peers() :abstractmethod: Implement a synchronization point with any peer processes. .. py:method:: sync_array_with_peers(data) :abstractmethod: Synchronize an array with all peers processes. The data parameter is either: - (if root) the source of truth that will be broadcast to all processes - (if not root) an empty buffer that will hold the data sent from root once the function returns .. py:method:: sync_pyobject_with_peers(obj) :abstractmethod: Synchronize a python object with all peer processes. The obj parameter is either: - (if root) the source of truth that will be broadcast to all processes - (if not root) ignored Different from sync_array_with_peers in that it returns the synced object rather than using an existing buffer. .. py:method:: combine_data_with_peers(data) :abstractmethod: 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 .. py:method:: gather_arrays_to_root(sendbuf, recvbuf_spec) :abstractmethod: 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. .. py:method:: sum_values_and_sync(sendbuf, recvbuf) :abstractmethod: 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. .. py:method:: scatter(do_build, do_build_kwargs, do_execute, all_parameters) :abstractmethod: 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. .. py:method:: gather() :abstractmethod: 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. .. py:method:: results_from_local_tree(results) :abstractmethod: Given a list of LocalResults objects, return a sublist of the ones the current process is responsible for. .. py:function:: build_and_execute(do_build, do_build_kwargs, do_execute, local_parameters) Entrypoint for implementations of the parallel manager to use for running the build and execute functions. Defined at the top level so that it's picklable. For a description of the first three arguments, see the scatter() function above. The fourth argument is the list of local parameters that should be run by this process. .. py:class:: parallelActor(do_build, do_build_kwargs, do_execute, local_parameters) .. py:method:: build_model() .. py:method:: execute(local_parameters)