gemseo.core.chains.parallel_chain module#
A parallel discipline chain.
- class MDOParallelChain(disciplines, name='', use_threading=True, n_processes=None, use_deep_copy=False)[source]#
Bases:
ProcessDiscipline
Chain of processes that executes disciplines in parallel.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
disciplines (Sequence[Discipline]) -- The disciplines.
name (str) --
The name of the discipline. If
None
, use the class name.By default it is set to "".
use_threading (bool) --
Whether to use threads instead of processes to parallelize the execution; multiprocessing will copy (serialize) all the disciplines, while threading will share all the memory. This is important to note if you want to execute the same discipline multiple times, you shall use multiprocessing.
By default it is set to True.
n_processes (int | None) -- The maximum simultaneous number of threads, if
use_threading
is True, or processes otherwise, used to parallelize the execution. IfNone
, uses the number of disciplines.use_deep_copy (bool) --
Whether to deepcopy the discipline input data.
By default it is set to False.
Notes
The actual number of processes could be lower than
n_processes
if there are less thann_processes
disciplines.n_processes
can be lower than the total number of CPUs on the machine. Each discipline may itself run on several CPUs.- add_differentiated_inputs(input_names=())[source]#
Add the inputs with respect to which to differentiate the outputs.
The inputs that do not represent continuous numbers are filtered out.
- Parameters:
input_names (Iterable[str]) --
The input variables with respect to which to differentiate the outputs. If empty, use all the inputs.
By default it is set to ().
- Raises:
ValueError -- When an input name is not the name of a discipline input.
- Return type:
None
- add_differentiated_outputs(output_names=())[source]#
Add the outputs to be differentiated.
The outputs that do not represent continuous numbers are filtered out.
- Parameters:
output_names (Iterable[str]) --
The outputs to be differentiated. If empty, use all the outputs.
By default it is set to ().
- Raises:
ValueError -- When an output name is not the name of a discipline output.
- Return type:
None