Lines Matching full:action
1 # Action: Tracing and Debugging MLIR-based Compilers
11 `Action` are means to encapsulate any transformation of any granularity in a way
14 fuel" or "debug counters" in LLVM). As such, "executing a pass" is an Action, so
28 The `Action` framework doesn't make any assumptions about how the higher level
31 `Action` execution is shown below:
33 - Compiler developer defines an `Action` class, that is representing the
37 - An external entity registers an "action handler" with the action manager, and
43 ## Wrapping a Transformation in an Action
45 There are two parts for getting started with enabling tracing through Action in
46 existing or new code: 1) defining an actual `Action` class, and 2) encapsulating
49 There are no constraints on the granularity of an “action”, it can be as simple
50 as “perform this fold” and as complex as “run this pass pipeline”. An action is
54 /// A custom Action can be defined minimally by deriving from
63 /// This tag should uniquely identify this action, it can be matched for filtering
65 static constexpr StringLiteral tag = "unique-tag-for-my-action";
67 "This action will encapsulate a some very specific transformation";
71 Any transformation can then be dispatched with this `Action` through the
84 An action can also carry arbitrary payload, for example we can extend the
88 /// A custom Action can be defined minimally by deriving from
98 /// This tag should uniquely identify this action, it can be matched for filtering
100 static constexpr StringLiteral tag = "unique-tag-for-my-action";
102 "This action will encapsulate a some very specific transformation";
103 /// Extra members can be carried by the Action
109 These new members must then be passed as arguments when dispatching an `Action`:
125 When a transformation is executed through an `Action`, it can be directly
129 /// Signatures for the action handler that can be registered with the context.
131 std::function<void(function_ref<void()>, const tracing::Action &)>;
139 a callback, and the second is a reference to the associated action object. The
145 MLIR provides some predefined action handlers for immediate use that are
154 specific action and enabling/disabling execution of this action based on the
155 value of the counter. The counter controls the execution of the action with a
157 initial executions of a debug action. The "count" value is used to prevent a
158 debug action from executing after it has executed for a set number of times (not
160 negative, the action will always execute. If the "count" value is negative, the
161 action will always execute after the "skip" value has been reached. For example,
162 a counter for a debug action with `skip=47` and `count=2`, would skip the first
165 selected; allowing for finding the exact execution of a debug action that
168 Note: The DebugCounter action handler does not support multi-threaded execution,
176 `<count-name>=<counter-value>`. A `<counter-name>` is the debug action tag to
183 $ mlir-opt foo.mlir -mlir-debug-counter=unique-tag-for-my-action-skip=47,unique-tag-for-my-action-count=2
199 <action-tag> : {<current-count>,<skip>,<count>}
202 For example, using the options above we can see how many times an action is
206 $ mlir-opt foo.mlir -mlir-debug-counter=unique-tag-for-my-action-skip=-1 -mlir-print-debug-counter --pass-pipeline="builtin.module(func.func(my-pass))" --mlir-disable-threading
209 unique-tag-for-my-action : {370,-1,-1}
221 and tracks all executed actions, keeping a per-thread stack of action execution.
222 It acts as a middleware that handles the flow of action execution while allowing
226 action is dispatched for execution, it is passed to each of the `Observers`
229 When an action is dispatched for execution, it is passed to each of the
230 registered `BreakpointManager` until one matches the action and return a valid
237 hit by an `Action`. The returned value of type `Control` is an enum
241 /// action.
242 /// - Apply: The action is executed.
243 /// - Skip: The action is skipped.
244 /// - Step: The action is executed and the execution is paused before the next
245 /// action, including for nested actions encountered before the
246 /// current action finishes.
247 /// - Next: The action is executed and the execution is paused after the
248 /// current action finishes before the next action.
249 /// - Finish: The action is executed and the execution is paused only when we
266 - set breakpoints matching either action tags, or the `FileLineCol` locations of
267 the IR associated with the action.
270 IR context associated with the action.
277 One observer is provided that allows to log action execution on a provided