MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_Monitor.cpp
Go to the documentation of this file.
1#include "MueLu_Monitor.hpp"
3
4namespace MueLu {
5 PrintMonitor::PrintMonitor(const BaseClass& object, const std::string& msg, MsgType msgLevel) : object_(object) {
6 tabbed = false;
7 if (object_.IsPrint(msgLevel)) {
8 // Print description and new indent
9 object_.GetOStream(msgLevel, 0) << msg << std::endl;
10 object_.getOStream()->pushTab();
11 tabbed = true;
12 }
13 }
14
15 PrintMonitor::~PrintMonitor() { if (tabbed) object_.getOStream()->popTab(); }
16
17 Monitor::Monitor(const BaseClass& object, const std::string & msg, MsgType msgLevel, MsgType timerLevel)
18 : printMonitor_(object, msg + " (" + object.description() + ")", msgLevel),
19 timerMonitor_(object, object.ShortClassName() + ": " + msg + " (total)", timerLevel)
20 { }
21
22 Monitor::Monitor(const BaseClass& object, const std::string & msg, const std::string & label, MsgType msgLevel, MsgType timerLevel)
23 : printMonitor_(object, label + msg + " (" + object.description() + ")", msgLevel),
24 timerMonitor_(object, label + object.ShortClassName() + ": " + msg + " (total)", timerLevel)
25 { }
26
27 SubMonitor::SubMonitor(const BaseClass& object, const std::string & msg, MsgType msgLevel, MsgType timerLevel)
28 : printMonitor_(object, msg, msgLevel),
29 timerMonitor_(object, object.ShortClassName() + ": " + msg + " (sub, total)", timerLevel)
30 { }
31
32 SubMonitor::SubMonitor(const BaseClass& object, const std::string & msg, const std::string & label, MsgType msgLevel, MsgType timerLevel)
33 : printMonitor_(object, label + msg, msgLevel),
34 timerMonitor_(object, label + object.ShortClassName() + ": " + msg + " (sub, total)", timerLevel)
35 { }
36
37 FactoryMonitor::FactoryMonitor(const BaseClass& object, const std::string & msg, int levelID, MsgType msgLevel, MsgType timerLevel)
38 : Monitor(object, msg, msgLevel, timerLevel),
39 timerMonitorExclusive_(object, object.ShortClassName() + ": " + msg, timerLevel)
40 {
41 if (object.IsPrint(TimingsByLevel)) {
42 if (Teuchos::TimeMonitor::getStackedTimer().is_null())
43 levelTimeMonitor_ = rcp(new TimeMonitor(object, object.ShortClassName() + ": " + msg +
44 " (total, level=" + Teuchos::Utils::toString(levelID) + ")", timerLevel));
46 MUELU_TIMER_AS_STRING + ": " + msg + " (level=" + Teuchos::Utils::toString(levelID) + ")", timerLevel));
47 }
48 }
49
50 FactoryMonitor::FactoryMonitor(const BaseClass& object, const std::string & msg, const Level & level, MsgType msgLevel, MsgType timerLevel)
51 : Monitor(object, msg, FormattingHelper::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel),
52 timerMonitorExclusive_(object, FormattingHelper::getColonLabel(level.getObjectLabel()) + object.ShortClassName() + ": " + msg, timerLevel)
53 {
54 if (object.IsPrint(TimingsByLevel)) {
55 std::string label = FormattingHelper::getColonLabel(level.getObjectLabel());
56 if (Teuchos::TimeMonitor::getStackedTimer().is_null())
57 levelTimeMonitor_ = rcp(new TimeMonitor(object, label+object.ShortClassName() + ": " + msg +
58 " (total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
60 MUELU_TIMER_AS_STRING + ": " + msg + " (level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
61 }
62 }
63
64 SubFactoryMonitor::SubFactoryMonitor(const BaseClass& object, const std::string & msg, int levelID, MsgType msgLevel, MsgType timerLevel)
65 : SubMonitor(object, msg, msgLevel, timerLevel)
66 {
67 if (object.IsPrint(TimingsByLevel) && Teuchos::TimeMonitor::getStackedTimer().is_null())
68 levelTimeMonitor_ = rcp(new TimeMonitor(object, object.ShortClassName() + ": " + msg +
69 " (sub, total, level=" + Teuchos::Utils::toString(levelID) + ")", timerLevel));
70 }
71
72 SubFactoryMonitor::SubFactoryMonitor(const BaseClass& object, const std::string & msg, const Level & level, MsgType msgLevel, MsgType timerLevel)
73 : SubMonitor(object, msg, FormattingHelper::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel)
74 {
75 if (object.IsPrint(TimingsByLevel) && Teuchos::TimeMonitor::getStackedTimer().is_null()) {
76 std::string label = FormattingHelper::getColonLabel(level.getObjectLabel());
77 levelTimeMonitor_ = rcp(new TimeMonitor(object, label+object.ShortClassName() + ": " + msg +
78 " (sub, total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
79 }
80 }
81
82} //namespace MueLu
#define MUELU_TIMER_AS_STRING
Base class for MueLu classes.
virtual std::string ShortClassName() const
Return the class name of the object, without template parameters and without namespace.
FactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=static_cast< MsgType >(Test|Runtime0), MsgType timerLevel=Timings0)
Constructor.
RCP< TimeMonitor > levelTimeMonitor_
Total time spent on this level in this object and all its children.
RCP< MutuallyExclusiveTimeMonitor< Level > > levelTimeMonitorExclusive_
Total time spent on this level in this object only, excluding all children.
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
int GetLevelID() const
Return level number.
Definition: MueLu_Level.cpp:76
Timer to be used in non-factories.
Monitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime0, MsgType timerLevel=Timings0)
Constructor.
Similar to TimeMonitor, but uses MutuallyExclusiveTime objects.
const BaseClass & object_
RCP< TimeMonitor > levelTimeMonitor_
Total time spent on this level in this object and all children.
SubFactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.
Timer to be used in non-factories. Similar to Monitor, but doesn't print object description.
SubMonitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.
Integrates Teuchos::TimeMonitor with MueLu verbosity system.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
Namespace for MueLu classes and methods.
@ TimingsByLevel
Record timing information level by level. Must be used in combinaison with Timings0/Timings1.
static std::string getColonLabel(const std::string &label)
Helper function for object label.