concurrent.py

concurrent.py#

Utilities for submitting function evaluations under MPI.

openmdao.utils.concurrent.concurrent_eval(func, cases, comm, allgather=False, model_mpi=None)[source]

Run the given function concurrently on all procs in the communicator.

NOTE : This function should NOT be used if the concurrent function makes any internal collective MPI calls.

Parameters:
funcfunction

The function to execute in workers.

casesiter of function args

Entries are assumed to be of the form (args, kwargs) where kwargs are allowed to be None and args should be a list or tuple.

commMPI communicator or None

The MPI communicator that is shared between the master and workers. If None, the function will be executed serially.

allgatherbool(False)

If True, the results will be allgathered to all procs in the comm. Otherwise, results will be gathered to rank 0 only.

model_mpiNone or tuple

If the function in func runs in parallel, then this will be a tuple containing the total number of cases to evaluate concurrently, and the color of the cases to evaluate on this rank.

Returns:
object

Return from function.

openmdao.utils.concurrent.concurrent_eval_lb(func, cases, comm, broadcast=False)[source]

Evaluate function on multiple processors with load balancing.

Runs a load balanced version of the given function, with the master rank (0) sending a new case to each worker rank as soon as it has finished its last case.

Parameters:
funcfunction

The function to execute in workers.

casescollection of function args

Entries are assumed to be of the form (args, kwargs) where kwargs are allowed to be None and args should be a list or tuple.

commMPI communicator or None

The MPI communicator that is shared between the master and workers. If None, the function will be executed serially.

broadcastbool(False)

If True, the results will be broadcast out to the worker procs so that the return value of concurrent_eval_lb will be the full result list in every process.

Returns:
object

Return from function.