MLIR
20.0.0git
|
Facilities for time measurement and report printing to an output stream. More...
#include "mlir/Support/Timing.h"
Public Types | |
enum class | DisplayMode { List , Tree } |
The different display modes for printing the timers. More... | |
enum class | OutputFormat { Text , Json } |
The different output formats for printing the timers. More... | |
Public Member Functions | |
DefaultTimingManager () | |
DefaultTimingManager (DefaultTimingManager &&rhs) | |
~DefaultTimingManager () override | |
DefaultTimingManager (const DefaultTimingManager &rhs)=delete | |
DefaultTimingManager & | operator= (const DefaultTimingManager &rhs)=delete |
void | setEnabled (bool enabled) |
Enable or disable execution time sampling. More... | |
bool | isEnabled () const |
Return whether execution time sampling is enabled. More... | |
void | setDisplayMode (DisplayMode displayMode) |
Change the display mode. More... | |
DisplayMode | getDisplayMode () const |
Return the current display mode;. More... | |
void | setOutput (std::unique_ptr< OutputStrategy > output) |
Change the stream where the output will be printed to. More... | |
void | print () |
Print and clear the timing results. More... | |
void | clear () |
Clear the timing results. More... | |
void | dumpTimers (raw_ostream &os=llvm::errs()) |
Debug print the timer data structures to an output stream. More... | |
void | dumpAsList (raw_ostream &os=llvm::errs()) |
Debug print the timers as a list. More... | |
void | dumpAsTree (raw_ostream &os=llvm::errs()) |
Debug print the timers as a tree. More... | |
Public Member Functions inherited from mlir::TimingManager | |
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 | |
std::optional< void * > | rootTimer () override |
Return the root timer. More... | |
void | startTimer (void *handle) override |
Start the timer with the given handle. More... | |
void | stopTimer (void *handle) override |
Stop the timer with the given handle. More... | |
void * | nestTimer (void *handle, const void *id, function_ref< std::string()> nameBuilder) override |
Create a child timer nested within the one with the given handle. More... | |
void | hideTimer (void *handle) override |
Hide the timer in timing reports and directly show its children. More... | |
Additional Inherited Members | |
Protected Attributes inherited from mlir::TimingManager | |
const std::unique_ptr< detail::TimingManagerImpl > | impl |
Facilities for time measurement and report printing to an output stream.
This is MLIR's default implementation of a TimingManager
. Prints an execution time report upon destruction, or manually through print()
. By default the results are printed in DisplayMode::Tree
mode to stderr. Use setEnabled(true)
to enable collection of timing samples; it is disabled by default.
You should only instantiate a DefaultTimingManager
if you are writing a tool and want to pass a timing manager to the remaining infrastructure. If you are writing library or infrastructure code, you should rather accept the TimingManager
base class to allow for users of your code to substitute their own timing implementations. Also, if you only intend to collect time samples, consider accepting a Timer
or TimingScope
instead.
|
strong |
The different display modes for printing the timers.
|
strong |
DefaultTimingManager::DefaultTimingManager | ( | ) |
Definition at line 501 of file Timing.cpp.
References clear().
mlir::DefaultTimingManager::DefaultTimingManager | ( | DefaultTimingManager && | rhs | ) |
|
override |
Definition at line 507 of file Timing.cpp.
References print().
|
delete |
void DefaultTimingManager::clear | ( | ) |
Clear the timing results.
Only call this when there are no more references to nested timers around, as clearing invalidates them.
Definition at line 540 of file Timing.cpp.
Referenced by DefaultTimingManager(), and print().
void DefaultTimingManager::dumpAsList | ( | raw_ostream & | os = llvm::errs() | ) |
Debug print the timers as a list.
Only call this when there are no more references to nested timers around.
Definition at line 551 of file Timing.cpp.
References List.
void DefaultTimingManager::dumpAsTree | ( | raw_ostream & | os = llvm::errs() | ) |
Debug print the timers as a tree.
Only call this when there are no more references to nested timers around.
Definition at line 557 of file Timing.cpp.
References Tree.
void DefaultTimingManager::dumpTimers | ( | raw_ostream & | os = llvm::errs() | ) |
Debug print the timer data structures to an output stream.
Definition at line 546 of file Timing.cpp.
DefaultTimingManager::DisplayMode DefaultTimingManager::getDisplayMode | ( | ) | const |
Return the current display mode;.
Definition at line 521 of file Timing.cpp.
|
overrideprotectedvirtual |
Hide the timer in timing reports and directly show its children.
This is merely a hint that implementations are free to ignore.
Reimplemented from mlir::TimingManager.
Definition at line 581 of file Timing.cpp.
bool DefaultTimingManager::isEnabled | ( | ) | const |
Return whether execution time sampling is enabled.
Definition at line 513 of file Timing.cpp.
|
overrideprotectedvirtual |
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.
Implements mlir::TimingManager.
Definition at line 576 of file Timing.cpp.
|
delete |
void DefaultTimingManager::print | ( | ) |
Print and clear the timing results.
Only call this when there are no more references to nested timers around, as printing post-processes and clears the timers.
Definition at line 531 of file Timing.cpp.
References clear().
Referenced by ~DefaultTimingManager().
|
overrideprotectedvirtual |
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.
Implements mlir::TimingManager.
Definition at line 562 of file Timing.cpp.
void DefaultTimingManager::setDisplayMode | ( | DisplayMode | displayMode | ) |
Change the display mode.
Definition at line 516 of file Timing.cpp.
Referenced by mlir::applyDefaultTimingManagerCLOptions().
void DefaultTimingManager::setEnabled | ( | bool | enabled | ) |
Enable or disable execution time sampling.
Definition at line 510 of file Timing.cpp.
Referenced by mlir::applyDefaultTimingManagerCLOptions().
void DefaultTimingManager::setOutput | ( | std::unique_ptr< OutputStrategy > | output | ) |
Change the stream where the output will be printed to.
Definition at line 526 of file Timing.cpp.
Referenced by mlir::applyDefaultTimingManagerCLOptions().
|
overrideprotectedvirtual |
Start the timer with the given handle.
Implements mlir::TimingManager.
Definition at line 568 of file Timing.cpp.
|
overrideprotectedvirtual |
Stop the timer with the given handle.
Implements mlir::TimingManager.
Definition at line 572 of file Timing.cpp.