46 #ifndef MUELU_TIMEMONITOR_HPP 47 #define MUELU_TIMEMONITOR_HPP 50 #include <Teuchos_DefaultComm.hpp> 51 #include <Teuchos_Time.hpp> 52 #include <Teuchos_TimeMonitor.hpp> 57 #ifdef HAVE_TEUCHOS_ADD_TIME_MONITOR_TO_STACKED_TIMER 58 #include "Teuchos_StackedTimer.hpp" 82 timer_ = Teuchos::TimeMonitor::getNewTimer(
"MueLu: " + msg);
84 timer_ = rcp(
new Teuchos::Time(
"MueLu: " + msg));
89 timer_->incrementNumCalls();
90 #ifdef HAVE_TEUCHOS_ADD_TIME_MONITOR_TO_STACKED_TIMER 91 const auto stackedTimer = Teuchos::TimeMonitor::getStackedTimer();
92 if (nonnull(stackedTimer))
93 stackedTimer->start(
timer_->name());
100 if (
timer_ != Teuchos::null) {
102 #ifdef HAVE_TEUCHOS_ADD_TIME_MONITOR_TO_STACKED_TIMER 104 const auto stackedTimer = Teuchos::TimeMonitor::getStackedTimer();
105 if (nonnull(stackedTimer))
106 stackedTimer->stop(
timer_->name());
108 catch (std::runtime_error) {
109 std::ostringstream warning;
111 "\n*********************************************************************\n" 112 "WARNING: Overlapping timers detected!\n" 113 "A TimeMonitor timer was stopped before a nested subtimer was\n" 114 "stopped. This is not allowed by the StackedTimer. This corner case\n" 115 "typically occurs if the TimeMonitor is stored in an RCP and the RCP is\n" 116 "assigned to a new timer. To disable this warning, either fix the\n" 117 "ordering of timer creation and destuction or disable the StackedTimer\n" 118 "support in the TimeMonitor by setting the StackedTimer to null\n" 120 "Teuchos::TimeMonitor::setStackedTimer(Teuchos::null)\n" 121 "*********************************************************************\n";
122 std::cout << warning.str() << std::endl;
123 Teuchos::TimeMonitor::setStackedTimer(Teuchos::null);
143 template <
class TagName>
169 timer_->incrementNumCalls();
175 if (
timer_ != Teuchos::null)
183 RCP<MutuallyExclusiveTime<TagName> >
timer_;
188 #endif // MUELU_TIMEMONITOR_HPP High level timing information (use Teuchos::TimeMonitor::summarize() to print)
void SetVerbLevel(const VerbLevel verbLevel)
Set the verbosity level of this object.
MutuallyExclusiveTimeMonitor()
RCP< Teuchos::Time > timer_
TimeMonitor(const BaseClass &object, const std::string &msg, MsgType timerLevel=Timings0)
static RCP< MutuallyExclusiveTime< TagName > > getNewTimer(const std::string &name)
Return a new MutuallyExclusiveTime that is registered with the Teuchos::TimeMonitor (for timer summar...
Namespace for MueLu classes and methods.
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
Integrates Teuchos::TimeMonitor with MueLu verbosity system.
int SetProcRankVerbose(int procRank) const
Set proc rank used for printing.
MutuallyExclusiveTimeMonitor(const BaseClass &object, const std::string &msg, MsgType timerLevel=Timings0)
Constructor.
int GetProcRankVerbose() const
Get proc rank used for printing. Do not use this information for any other purpose.
Similar to TimeMonitor, but uses MutuallyExclusiveTime objects.
By default, enabled timers appears in the teuchos time monitor summary. Use this option if you do not...
RCP< MutuallyExclusiveTime< TagName > > timer_
Timers that are enabled (using Timings0/Timings1) will be printed during the execution.
Base class for MueLu classes.
This class wraps a Teuchos::Time and maintains a mutually exclusive property between wrapped timers...
VerbLevel GetVerbLevel() const
Get the verbosity level.
~MutuallyExclusiveTimeMonitor()