MLIR  19.0.0git
Public Types | Public Member Functions | Protected Member Functions | List of all members
mlir::DefaultTimingManager Class Reference

Facilities for time measurement and report printing to an output stream. More...

#include "mlir/Support/Timing.h"

+ Inheritance diagram for mlir::DefaultTimingManager:

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
 
DefaultTimingManageroperator= (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::TimingManagerImplimpl
 

Detailed Description

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.

Definition at line 388 of file Timing.h.

Member Enumeration Documentation

◆ DisplayMode

The different display modes for printing the timers.

Enumerator
List 

In this mode the results are displayed in a list sorted by total time, with timers aggregated into one unique result per timer name.

Tree 

In this mode the results are displayed in a tree view, with child timers nested under their parents.

Definition at line 391 of file Timing.h.

◆ OutputFormat

The different output formats for printing the timers.

Enumerator
Text 

In this format the results are displayed in text format.

Json 

In this format the results are displayed in JSON format.

Definition at line 402 of file Timing.h.

Constructor & Destructor Documentation

◆ DefaultTimingManager() [1/3]

DefaultTimingManager::DefaultTimingManager ( )

Definition at line 501 of file Timing.cpp.

References clear().

◆ DefaultTimingManager() [2/3]

mlir::DefaultTimingManager::DefaultTimingManager ( DefaultTimingManager &&  rhs)

◆ ~DefaultTimingManager()

DefaultTimingManager::~DefaultTimingManager ( )
override

Definition at line 507 of file Timing.cpp.

References print().

◆ DefaultTimingManager() [3/3]

mlir::DefaultTimingManager::DefaultTimingManager ( const DefaultTimingManager rhs)
delete

Member Function Documentation

◆ clear()

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().

◆ dumpAsList()

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.

◆ dumpAsTree()

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.

◆ dumpTimers()

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.

◆ getDisplayMode()

DefaultTimingManager::DisplayMode DefaultTimingManager::getDisplayMode ( ) const

Return the current display mode;.

Definition at line 521 of file Timing.cpp.

◆ hideTimer()

void DefaultTimingManager::hideTimer ( void *  handle)
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.

◆ isEnabled()

bool DefaultTimingManager::isEnabled ( ) const

Return whether execution time sampling is enabled.

Definition at line 513 of file Timing.cpp.

◆ nestTimer()

void * DefaultTimingManager::nestTimer ( void *  handle,
const void *  id,
function_ref< std::string()>  nameBuilder 
)
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.

◆ operator=()

DefaultTimingManager& mlir::DefaultTimingManager::operator= ( const DefaultTimingManager rhs)
delete

◆ print()

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().

◆ rootTimer()

std::optional< void * > DefaultTimingManager::rootTimer ( )
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.

◆ setDisplayMode()

void DefaultTimingManager::setDisplayMode ( DisplayMode  displayMode)

Change the display mode.

Definition at line 516 of file Timing.cpp.

Referenced by mlir::applyDefaultTimingManagerCLOptions().

◆ setEnabled()

void DefaultTimingManager::setEnabled ( bool  enabled)

Enable or disable execution time sampling.

Definition at line 510 of file Timing.cpp.

Referenced by mlir::applyDefaultTimingManagerCLOptions().

◆ setOutput()

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().

◆ startTimer()

void DefaultTimingManager::startTimer ( void *  handle)
overrideprotectedvirtual

Start the timer with the given handle.

Implements mlir::TimingManager.

Definition at line 568 of file Timing.cpp.

◆ stopTimer()

void DefaultTimingManager::stopTimer ( void *  handle)
overrideprotectedvirtual

Stop the timer with the given handle.

Implements mlir::TimingManager.

Definition at line 572 of file Timing.cpp.


The documentation for this class was generated from the following files: