Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
|
Common capabilities for collecting and reporting performance data across processors. More...
#include <Teuchos_PerformanceMonitorBase.hpp>
Public Member Functions | |
PerformanceMonitorBase (T &counter_in, bool reset=false) | |
Construct with a counter. More... | |
PerformanceMonitorBase ()=delete | |
Default constructor is deleted, since it would be unsafe. More... | |
virtual | ~PerformanceMonitorBase ()=default |
Destructor. More... | |
Static Public Member Functions | |
static RCP< T > | getNewCounter (const std::string &name) |
Create a new counter with the specified name and add it to a global set of counters of this type. More... | |
static TableFormat & | format () |
Table format that will be used to print a summary of timer results. More... | |
static RCP< T > | lookupCounter (const std::string &name) |
Return the first counter with the given name, or null if none. More... | |
static void | clearCounters () |
"Forget" about all counters created with getNewCounter(). More... | |
static void | clearCounter (const std::string &name) |
"Forget" about any counters with the given name. More... | |
Protected Member Functions | |
const T & | counter () const |
Constant access to the instance's counter reference. More... | |
T & | counter () |
Nonconstant access to the instance's counter reference. More... | |
bool | isRecursiveCall () const |
Whether we are currently in a recursive call of the counter. More... | |
Static Protected Member Functions | |
static std::map< std::string, RCP< T > > & | counters () |
Array of all counters that were created with getNewCounter() on the calling (MPI) process. More... | |
Static Private Member Functions | |
static void | freeTableFormat () |
Free the singleton returned by format(). More... | |
static void | freeCounters () |
Free the singleton returned by counters(). More... | |
Private Attributes | |
T & | counter_ |
Reference to the counter being wrapped. More... | |
bool | isRecursiveCall_ |
Whether we are currently in a recursive call of the counter. More... | |
Static Private Attributes | |
static TableFormat * | format_ = nullptr |
Singleton object returned by format(). More... | |
static std::map< std::string, RCP< T > > * | counters_ = nullptr |
Singleton object returned by counters(). More... | |
Common capabilities for collecting and reporting performance data across processors.
PerformanceMonitorBase is templated on a counter type T (which might be a timer or a flop counter). The common capability of the counter type is a counter for the number of calls. Derived counter types may supply additional features.
PerformanceMonitorBase's constructor increments its counter's call count. Subclasses of PerformanceMonitorBase may do more upon construction or destruction; for example, TimeMonitor starts its timer on construction and stops it on destruction.
This class keeps a static list of all counters created using the getNewCounter() method during the course of a run. Counts from this list can then be printed out at the end of the run. Subclasses of PerformanceMonitorBase, such as TimeMonitor, may use this list to do things like compute global timer statistics over all the MPI processes.
PerformanceMonitorBase requires that the counter type T provide at least the following interface:
Definition at line 124 of file Teuchos_PerformanceMonitorBase.hpp.
|
inline |
Construct with a counter.
Definition at line 128 of file Teuchos_PerformanceMonitorBase.hpp.
|
delete |
Default constructor is deleted, since it would be unsafe.
|
virtualdefault |
Destructor.
The destructor for the base class does nothing. We provide a virtual destructor for memory safety of derived classes.
|
static |
Create a new counter with the specified name and add it to a global set of counters of this type.
If the counter already exists, just return the existing counter. If the counter doesn't already exist, create a new counter with that name and return it.
New counters should usually be created in this way rather than through a direct constructor call. This lets PerformanceMonitorBase keep track of them, so that methods like summarize() and report() know about them. Timers created in other ways are not included in the reports printed by these methods.
Definition at line 303 of file Teuchos_PerformanceMonitorBase.hpp.
|
inlinestaticprivate |
Free the singleton returned by format().
Definition at line 170 of file Teuchos_PerformanceMonitorBase.hpp.
|
inlinestaticprivate |
Free the singleton returned by counters().
Definition at line 186 of file Teuchos_PerformanceMonitorBase.hpp.
|
inlinestatic |
Table format that will be used to print a summary of timer results.
Definition at line 202 of file Teuchos_PerformanceMonitorBase.hpp.
|
static |
Return the first counter with the given name, or null if none.
It is currently possible to create multiple counters with the same name using getNewCounter()
. If multiple counters with the given name exist, this method simply returns the first in the list. Do not rely on the ability to create multiple counters with the same name; this may go away in the future.
Definition at line 353 of file Teuchos_PerformanceMonitorBase.hpp.
|
static |
"Forget" about all counters created with getNewCounter().
This removes all counters from the current set of counters (as would be returned by counters()).
Definition at line 376 of file Teuchos_PerformanceMonitorBase.hpp.
|
static |
"Forget" about any counters with the given name.
If one or more counters with the given name was created using getNewCounter(), calling this method with that name will remove them from the global list of counters.
Definition at line 369 of file Teuchos_PerformanceMonitorBase.hpp.
|
inlineprotected |
Constant access to the instance's counter reference.
Definition at line 245 of file Teuchos_PerformanceMonitorBase.hpp.
|
inlineprotected |
Nonconstant access to the instance's counter reference.
Definition at line 248 of file Teuchos_PerformanceMonitorBase.hpp.
|
inlineprotected |
Whether we are currently in a recursive call of the counter.
Subclasses of PerformanceMonitorBase may use this information to control whether to start or stop the given counter. This matters in cases such as timing, where we don't want to start and stop timers multiple times within a single call stack.
Definition at line 256 of file Teuchos_PerformanceMonitorBase.hpp.
|
inlinestaticprotected |
Array of all counters that were created with getNewCounter() on the calling (MPI) process.
Definition at line 262 of file Teuchos_PerformanceMonitorBase.hpp.
|
staticprivate |
Singleton object returned by format().
Definition at line 281 of file Teuchos_PerformanceMonitorBase.hpp.
|
staticprivate |
Singleton object returned by counters().
Definition at line 284 of file Teuchos_PerformanceMonitorBase.hpp.
|
private |
Reference to the counter being wrapped.
Definition at line 287 of file Teuchos_PerformanceMonitorBase.hpp.
|
private |
Whether we are currently in a recursive call of the counter.
Definition at line 290 of file Teuchos_PerformanceMonitorBase.hpp.