MLIR
20.0.0git
|
This class represents facilities to measure execution time. More...
#include "mlir/Support/Timing.h"
Public Member Functions | |
TimingManager () | |
virtual | ~TimingManager () |
Timer | getRootTimer () |
Get the root timer of this timing manager. More... | |
TimingScope | getRootScope () |
Get the root timer of this timing manager wrapped in a TimingScope for convenience. More... | |
Protected Member Functions | |
virtual std::optional< void * > | rootTimer ()=0 |
Return the root timer. More... | |
virtual void | startTimer (void *handle)=0 |
Start the timer with the given handle. More... | |
virtual void | stopTimer (void *handle)=0 |
Stop the timer with the given handle. More... | |
virtual void * | nestTimer (void *handle, const void *id, function_ref< std::string()> nameBuilder)=0 |
Create a child timer nested within the one with the given handle. More... | |
virtual void | hideTimer (void *handle) |
Hide the timer in timing reports and directly show its children. More... | |
Protected Attributes | |
const std::unique_ptr< detail::TimingManagerImpl > | impl |
Friends | |
class | Timer |
class | TimingIdentifier |
This class represents facilities to measure execution time.
Libraries and infrastructure code operate on opque Timer
handles returned by various functions of this manager. Timers are started and stopped to demarcate regions in the code where execution time is of interest, and they can be nested to provide more detailed timing resolution. Calls to the timer start, stop, and nesting functions must be balanced. To facilitate this, users are encouraged to leverage the TimingScope
RAII-style wrapper around Timer
s.
Users can provide their own implementation of TimingManager
, or use the default DefaultTimingManager
implementation in MLIR. Implementations override the various protected virtual functions to create, nest, start, and stop timers. A common pattern is for subclasses to provide a custom timer class and simply pass pointers to instances of this class around as the opaque timer handle. The manager itself can then forward callbacks to the this class. Alternatively, external timing libraries may return their own opaque handles for timing scopes.
For example:
|
explicit |
Definition at line 63 of file Timing.cpp.
|
virtualdefault |
TimingScope TimingManager::getRootScope | ( | ) |
Get the root timer of this timing manager wrapped in a TimingScope
for convenience.
Get the root timer of this timing manager wrapped in a TimingScope
.
Automatically starts the timer and stops it as soon as the TimingScope
is destroyed, e.g. when it goes out of scope.
Definition at line 74 of file Timing.cpp.
References getRootTimer().
Referenced by performActions().
Timer TimingManager::getRootTimer | ( | ) |
Get the root timer of this timing manager.
The returned timer must be started and stopped manually. Execution time can be measured by nesting timers within this root timer and starting/stopping them as appropriate. Use this function only if you need access to the timer itself. Otherwise consider the more convenient getRootScope()
which offers an RAII-style wrapper around the timer.
Definition at line 68 of file Timing.cpp.
References rootTimer(), and Timer.
Referenced by getRootScope().
|
inlineprotectedvirtual |
Hide the timer in timing reports and directly show its children.
This is merely a hint that implementations are free to ignore.
Reimplemented in mlir::DefaultTimingManager.
Definition at line 162 of file Timing.h.
Referenced by mlir::Timer::hide().
|
protectedpure virtual |
Create a child timer nested within the one with the given handle.
The id
parameter is used to uniquely identify the timer within its parent. Multiple calls to this function with the same handle
and id
should return the same timer, or at least cause the samples of the returned timers to be combined for the final timing results.
Implemented in mlir::DefaultTimingManager.
Referenced by mlir::Timer::nest().
|
protectedpure virtual |
Return the root timer.
Implementations should return std::nullopt
if the collection of timing samples is disabled. This will cause the timers constructed from the manager to be tombstones which can be skipped quickly.
Implemented in mlir::DefaultTimingManager.
Referenced by getRootTimer().
|
protectedpure virtual |
Start the timer with the given handle.
Implemented in mlir::DefaultTimingManager.
Referenced by mlir::Timer::start().
|
protectedpure virtual |
Stop the timer with the given handle.
Implemented in mlir::DefaultTimingManager.
Referenced by mlir::Timer::stop().
Definition at line 133 of file Timing.h.
Referenced by getRootTimer().
|
friend |
|
protected |
Definition at line 165 of file Timing.h.
Referenced by mlir::TimingIdentifier::get().