5from .ActionSet
import ActionSet
11 Marker which ends a group of action sets that run in parallel
13 The generated observer invokes the action sets of a step one by one.
14 Consecutive action sets with parallel=True form a task group instead:
15 Per event, their code is spawned as one task per action set, and the
16 observer waits for all of these tasks before it continues
17 (@ref peano4.api.solversteps.SynchroniseActionSets.get_task_groups()).
18 An action set with parallel=False ends a group, too, but it is then
21 This marker ends a group without invoking anything. Use it to separate
22 two task groups which follow each other directly. Without the marker,
23 they would merge into one group, i.e. action sets of the second group
24 might run concurrently to the ones of the first group although they
25 depend on them. @ref peano4.api.taskgraph.compiler.FuseSteps inserts
28 The marker is ignored when we generate the C++ code: It yields neither
29 an action set class nor any code in the observer. Append it directly to
30 a step's action_sets. Do not use
31 @ref peano4.api.solversteps.Step.Step.add_action_set(), as this routine
32 sorts the action sets according to their descend_invocation_order, i.e.
33 it might move the marker.
38 super().
__init__(descend_invocation_order=0, parallel=
False)
56 return "SynchroniseActionSets"
68def get_task_groups(action_sets: List[ActionSet]) -> List[List[ActionSet]]:
71 Split a sequence of action sets into groups which are invoked one after
74 We run through the action sets in their order. Consecutive action sets
75 with parallel=True form one group, i.e. they may run in parallel. An
76 action set with parallel=False forms a group of its own and ends the
78 @ref peano4.api.solversteps.SynchroniseActionSets.SynchroniseActionSets
79 ends the current group, too, but does not show up in any group.
81 For the sequence V1, V2, V3, V4, V5 with V1, V2, V4 and V5 being
82 parallel, we get the groups [V1, V2], [V3] and [V4, V5]: The observer
83 spawns V1 and V2 as tasks and waits for them, then invokes V3, and
84 finally spawns V4 and V5 and waits for them.
86 @param action_sets: [peano4.api.solversteps.ActionSet]
87 Action sets in the order in which they are invoked.
89 @return [[peano4.api.solversteps.ActionSet]]
90 Groups in invocation order. No group is empty.
95 for action_set
in action_sets:
96 if isinstance(action_set, SynchroniseActionSets):
98 elif action_set.parallel
and current_group
is not None:
99 current_group.append(action_set)
101 current_group = [action_set]
102 groups.append(current_group)
103 if not action_set.parallel:
Action set (reactions to events)
Marker which ends a group of action sets that run in parallel.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_constructor_body(self)
Define a tailored constructor body.
get_body_of_unprepareTraversal(self)
get_attributes(self)
Return attributes as copied and pasted into the generated class.
get_destructor_body(self)
get_body_of_prepareTraversal(self)
get_includes(self)
Return include statements that you need.
get_action_set_name(self)
Return unique action set name.
user_should_modify_template(self)
Is the user allowed to modify the output.