MueLu
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
MueLu_Monitor.cpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// MueLu: A package for multigrid based preconditioning
4
//
5
// Copyright 2012 NTESS and the MueLu contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#include "
MueLu_Monitor.hpp
"
11
int
MueLu::FactoryMonitor::timerIdentifier_
= 0;
12
13
namespace
MueLu
{
14
PrintMonitor::PrintMonitor
(
const
BaseClass
&
object
,
const
std::string& msg,
MsgType
msgLevel)
15
:
object_
(object) {
16
tabbed
=
false
;
17
if
(
object_
.IsPrint(msgLevel)) {
18
// Print description and new indent
19
object_.GetOStream(msgLevel, 0) << msg << std::endl;
20
object_.getOStream()->pushTab();
21
tabbed = true;
22
}
23
}
24
25
PrintMonitor::~PrintMonitor
() {
26
if
(
tabbed
)
object_
.getOStream()->popTab();
27
}
28
29
Monitor::Monitor
(
const
BaseClass
&
object
,
const
std::string& msg,
MsgType
msgLevel,
MsgType
timerLevel)
30
:
printMonitor_
(object, msg +
" ("
+ object.
description
() +
")"
, msgLevel)
31
,
timerMonitor_
(object, object.
ShortClassName
() +
": "
+ msg +
" (total)"
, timerLevel) {}
32
33
Monitor::Monitor
(
const
BaseClass
&
object
,
const
std::string& msg,
const
std::string& label,
MsgType
msgLevel,
MsgType
timerLevel)
34
:
printMonitor_
(object, label + msg +
" ("
+ object.
description
() +
")"
, msgLevel)
35
,
timerMonitor_
(object, label + object.
ShortClassName
() +
": "
+ msg +
" (total)"
, timerLevel) {}
36
37
Monitor::~Monitor
() =
default
;
38
39
SubMonitor::SubMonitor
(
const
BaseClass
&
object
,
const
std::string& msg,
MsgType
msgLevel,
MsgType
timerLevel)
40
:
printMonitor_
(object, msg, msgLevel)
41
,
timerMonitor_
(object, object.
ShortClassName
() +
": "
+ msg +
" (sub, total)"
, timerLevel) {}
42
43
SubMonitor::SubMonitor
(
const
BaseClass
&
object
,
const
std::string& msg,
const
std::string& label,
MsgType
msgLevel,
MsgType
timerLevel)
44
:
printMonitor_
(object, label + msg, msgLevel)
45
,
timerMonitor_
(object, label + object.
ShortClassName
() +
": "
+ msg +
" (sub, total)"
, timerLevel) {}
46
47
SubMonitor::~SubMonitor
() =
default
;
48
49
FactoryMonitor::FactoryMonitor
(
const
BaseClass
&
object
,
const
std::string& msg,
int
levelID,
MsgType
msgLevel,
MsgType
timerLevel)
50
:
Monitor
(object, msg, msgLevel, timerLevel) {
51
if
(
object
.
IsPrint
(
TimingsByLevel
)) {
52
if
(Teuchos::TimeMonitor::stackedTimerNameIsDefault())
53
levelTimeMonitor_
= rcp(
new
TimeMonitor
(
object
,
object
.
ShortClassName
() +
": "
+ msg +
" (total, level="
+ Teuchos::Utils::toString(levelID) +
")"
, timerLevel));
54
}
55
}
56
57
FactoryMonitor::FactoryMonitor
(
const
BaseClass
&
object
,
const
std::string& msg,
const
Level
& level,
MsgType
msgLevel,
MsgType
timerLevel)
58
:
Monitor
(object, msg,
FormattingHelper
::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel) {
59
if
(
object
.
IsPrint
(
TimingsByLevel
)) {
60
std::string label =
FormattingHelper::getColonLabel
(level.getObjectLabel());
61
if
(Teuchos::TimeMonitor::stackedTimerNameIsDefault())
62
levelTimeMonitor_
= rcp(
new
TimeMonitor
(
object
, label +
object
.
ShortClassName
() +
": "
+ msg +
" (total, level="
+ Teuchos::Utils::toString(level.
GetLevelID
()) +
")"
, timerLevel));
63
}
64
}
65
66
FactoryMonitor::~FactoryMonitor
() =
default
;
67
68
SubFactoryMonitor::SubFactoryMonitor
(
const
BaseClass
&
object
,
const
std::string& msg,
int
levelID,
MsgType
msgLevel,
MsgType
timerLevel)
69
:
SubMonitor
(object, msg, msgLevel, timerLevel) {
70
if
(
object
.
IsPrint
(
TimingsByLevel
) && Teuchos::TimeMonitor::stackedTimerNameIsDefault())
71
levelTimeMonitor_
= rcp(
new
TimeMonitor
(
object
,
object
.
ShortClassName
() +
": "
+ msg +
" (sub, total, level="
+ Teuchos::Utils::toString(levelID) +
")"
, timerLevel));
72
}
73
74
SubFactoryMonitor::SubFactoryMonitor
(
const
BaseClass
&
object
,
const
std::string& msg,
const
Level
& level,
MsgType
msgLevel,
MsgType
timerLevel)
75
:
SubMonitor
(object, msg,
FormattingHelper
::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel) {
76
if
(
object
.
IsPrint
(
TimingsByLevel
) && Teuchos::TimeMonitor::stackedTimerNameIsDefault()) {
77
std::string label =
FormattingHelper::getColonLabel
(level.getObjectLabel());
78
levelTimeMonitor_
= rcp(
new
TimeMonitor
(
object
, label +
object
.
ShortClassName
() +
": "
+ msg +
" (sub, total, level="
+ Teuchos::Utils::toString(level.
GetLevelID
()) +
")"
, timerLevel));
79
}
80
}
81
82
SubFactoryMonitor::~SubFactoryMonitor
() =
default
;
83
84
}
// namespace MueLu
MueLu_Monitor.hpp
MueLu::BaseClass
Base class for MueLu classes.
Definition
MueLu_BaseClass.hpp:27
MueLu::Describable::ShortClassName
virtual std::string ShortClassName() const
Return the class name of the object, without template parameters and without namespace.
Definition
MueLu_Describable.cpp:38
MueLu::Describable::description
virtual std::string description() const
Return a simple one-line description of this object.
Definition
MueLu_Describable.cpp:25
MueLu::FactoryMonitor::FactoryMonitor
FactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=static_cast< MsgType >(Test|Runtime0), MsgType timerLevel=Timings0)
Constructor.
Definition
MueLu_Monitor.cpp:49
MueLu::FactoryMonitor::~FactoryMonitor
~FactoryMonitor()
MueLu::FactoryMonitor::timerIdentifier_
static int timerIdentifier_
Definition
MueLu_Monitor.hpp:167
MueLu::FactoryMonitor::levelTimeMonitor_
RCP< TimeMonitor > levelTimeMonitor_
Total time spent on this level in this object and all its children.
Definition
MueLu_Monitor.hpp:195
MueLu::Level
Class that holds all level-specific information.
Definition
MueLu_Level.hpp:63
MueLu::Level::GetLevelID
int GetLevelID() const
Return level number.
Definition
MueLu_Level.cpp:51
MueLu::Monitor::timerMonitor_
TimeMonitor timerMonitor_
Records total time spent in this object and all its children, over all levels.
Definition
MueLu_Monitor.hpp:95
MueLu::Monitor::~Monitor
virtual ~Monitor()
MueLu::Monitor::Monitor
Monitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime0, MsgType timerLevel=Timings0)
Constructor.
Definition
MueLu_Monitor.cpp:29
MueLu::Monitor::printMonitor_
PrintMonitor printMonitor_
Manages printing.
Definition
MueLu_Monitor.hpp:93
MueLu::PrintMonitor::PrintMonitor
PrintMonitor()
MueLu::PrintMonitor::tabbed
bool tabbed
Definition
MueLu_Monitor.hpp:50
MueLu::PrintMonitor::object_
const BaseClass & object_
Definition
MueLu_Monitor.hpp:51
MueLu::PrintMonitor::~PrintMonitor
~PrintMonitor()
Definition
MueLu_Monitor.cpp:25
MueLu::SubFactoryMonitor::levelTimeMonitor_
RCP< TimeMonitor > levelTimeMonitor_
Total time spent on this level in this object and all children.
Definition
MueLu_Monitor.hpp:240
MueLu::SubFactoryMonitor::~SubFactoryMonitor
~SubFactoryMonitor()
MueLu::SubFactoryMonitor::SubFactoryMonitor
SubFactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.
Definition
MueLu_Monitor.cpp:68
MueLu::SubMonitor::timerMonitor_
TimeMonitor timerMonitor_
Definition
MueLu_Monitor.hpp:141
MueLu::SubMonitor::printMonitor_
PrintMonitor printMonitor_
Definition
MueLu_Monitor.hpp:140
MueLu::SubMonitor::SubMonitor
SubMonitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.
Definition
MueLu_Monitor.cpp:39
MueLu::SubMonitor::~SubMonitor
~SubMonitor()
MueLu::TimeMonitor
Integrates Teuchos::TimeMonitor with MueLu verbosity system.
Definition
MueLu_TimeMonitor.hpp:31
MueLu::VerboseObject::IsPrint
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
Definition
MueLu_VerboseObject.cpp:68
MueLu
Namespace for MueLu classes and methods.
Definition
MueLu_BrickAggregationFactory_decl.hpp:42
MueLu::MsgType
MsgType
Definition
MueLu_VerbosityLevel.hpp:17
MueLu::TimingsByLevel
@ TimingsByLevel
Record timing information level by level. Must be used in combinaison with Timings0/Timings1.
Definition
MueLu_VerbosityLevel.hpp:39
MueLu::FormattingHelper
Definition
MueLu_Monitor.hpp:28
MueLu::FormattingHelper::getColonLabel
static std::string getColonLabel(const std::string &label)
Helper function for object label.
Definition
MueLu_Monitor.hpp:30
src
Utils
MueLu_Monitor.cpp
Generated by
1.17.0