9 #ifndef STK_UTIL_DIAG_Timer_hpp 10 #define STK_UTIL_DIAG_Timer_hpp 17 #include <stk_util/stk_config.h> 18 #if defined( STK_HAS_MPI ) 22 #include <stk_util/diag/TimerMetricTraits.hpp> 23 #include <stk_util/parallel/Parallel.hpp> 24 #include <stk_util/environment/FormatTime.hpp> 25 #include <stk_util/diag/Writer_fwd.hpp> 28 #include <stk_util/diag/WriterParser.hpp> 29 #include <stk_util/diag/Option.hpp> 44 typedef unsigned TimerMask;
52 MetricsMask getEnabledTimerMetricsMask();
62 void setEnabledTimerMetricsMask(MetricsMask timer_mask);
71 void updateRootTimer(Timer root_timer);
86 Timer createRootTimer(
const std::string &name,
const TimerSet &timer_set);
94 void deleteRootTimer(Timer timer);
110 std::vector<Timer> &findTimers(Timer root_timer,
const std::string &path_tail, std::vector<Timer> &found_timers);
120 explicit TimerSet(TimerMask enabled_timer_mask)
121 : m_enabledTimerMask(enabled_timer_mask)
126 : m_enabledTimerMask(timer_set.m_enabledTimerMask)
130 m_enabledTimerMask = timer_set.m_enabledTimerMask;
146 return m_enabledTimerMask;
158 m_enabledTimerMask = timer_mask;
170 return (timer_mask == 0 || (m_enabledTimerMask & timer_mask));
174 TimerMask m_enabledTimerMask;
178 typedef std::list<Timer> TimerList;
187 friend class TimerImpl;
193 friend std::vector<Timer> &
findTimers(
Timer,
const std::string &, std::vector<Timer> &);
204 template <
typename T>
227 typename MetricTraits<T>::Type
addLap() {
246 typename MetricTraits<T>::Type
getLap()
const {
264 typename MetricTraits<T>::Type
getStop()
const {
313 Timer(
const std::string &name,
const Timer parent);
340 Timer(
const std::string &name, TimerMask timer_mask,
const Timer parent);
356 Timer(
const std::string &name, TimerMask timer_mask,
const Timer parent,
const TimerSet &timer_set);
362 explicit Timer(TimerImpl &timer_impl)
363 : m_timerImpl(&timer_impl)
366 explicit Timer(TimerImpl *timer_impl)
367 : m_timerImpl(timer_impl)
371 : m_timerImpl(timer.m_timerImpl)
376 m_timerImpl = timer.m_timerImpl;
384 const TimerList &getTimerList()
const;
386 TimerList::iterator begin();
387 TimerList::const_iterator begin()
const;
388 TimerList::iterator end();
389 TimerList::const_iterator end()
const;
397 const std::string &
getName()
const;
414 bool shouldRecord()
const;
479 Writer &
dump(Writer& dout)
const;
482 TimerImpl * m_timerImpl;
513 m_started(start_timer)
638 inline Writer &operator<<(Writer &dout, const Timer::Metric<T> &timer) {
639 return timer.
dump(dout);
653 inline Writer &operator<<(Writer &dout,
const Timer &timer) {
654 return timer.
dump(dout);
666 typedef stk_classic::TimeFormat TimeFormat;
676 TIMER_DOMAIN = 0x00000001,
677 TIMER_REGION = 0x00000002,
678 TIMER_PROCEDURE = 0x00000004,
679 TIMER_MECHANICS = 0x00000008,
680 TIMER_ALGORITHM = 0x00000010,
681 TIMER_SOLVER = 0x00000020,
682 TIMER_CONTACT = 0x00000040,
683 TIMER_MATERIAL = 0x00000080,
684 TIMER_SEARCH = 0x00000100,
685 TIMER_TRANSFER = 0x00000200,
686 TIMER_ADAPTIVITY = 0x00000400,
687 TIMER_RECOVERY = 0x00000800,
688 TIMER_PROFILE_1 = 0x00001000,
689 TIMER_PROFILE_2 = 0x00002000,
690 TIMER_PROFILE_3 = 0x00004000,
691 TIMER_PROFILE_4 = 0x00008000,
692 TIMER_APP_1 = 0x00010000,
693 TIMER_APP_2 = 0x00020000,
694 TIMER_APP_3 = 0x00040000,
695 TIMER_APP_4 = 0x00080000,
696 TIMER_ALL = 0x000FFFFF,
697 TIMER_NONE = 0x00000000,
699 TIMER_FORCE = 0x00000000
703 TimerSet &sierraTimerSet();
705 Timer &sierraTimer();
707 void sierraTimerDestroy();
716 typedef sierra::OptionMask TimerMask;
724 DEFAULT_TIMER_NAME_MAX_WIDTH = 40
733 TimerParser &theTimerParser();
743 void setEnabledTimerMask(TimerMask timer_mask);
751 TimerMask getEnabledTimerMask();
753 void setTimeFormat(
int time_format);
755 void setTimeFormatMillis();
767 void setTimerNameMaxWidth(
size_t width);
776 size_t getTimerNameMaxWidth();
778 stk_classic::diag::MetricTraits<stk_classic::diag::CPUTime>::Type getCPULapTime(Timer timer);
780 stk_classic::diag::MetricTraits<stk_classic::diag::CPUTime>::Type getCPUAccumulatedLapTime(Timer timer);
782 stk_classic::diag::MetricTraits<stk_classic::diag::CPUTime>::Type getSierraCPUTime();
783 stk_classic::diag::MetricTraits<stk_classic::diag::CPUTime>::Type getSierraWallTime();
808 Mask parse(
const char *mask_string)
const;
819 virtual void parseArg(
const std::string &name,
const std::string &arg)
const;
821 mutable stk_classic::diag::MetricsMask m_metricsSetMask;
822 mutable stk_classic::diag::MetricsMask m_metricsMask;
826 class SierraRootTimer
830 virtual ~SierraRootTimer();
844 #endif // STK_UTIL_DIAG_Timer_hpp MetricTraits< T >::Type getStart() const
friend std::vector< Timer > & findTimers(Timer, const std::string &, std::vector< Timer > &)
Member function findTimer return a vector of timers whose tail of the dot separated name from root_ti...
TimerMask getEnabledTimerMask() const
friend void updateRootTimer(Timer)
Timer(const std::string &name, const Timer parent)
MetricTraits< T >::Type getAccumulatedLap(bool arg_checkpoint=false) const
Class TimerParser implements the bit mask parser for the timer's bit masks.
friend void deleteRootTimer(Timer)
MetricTraits< T >::Type m_checkpoint
Checkpointed time/count.
void setEnabledTimerMask(TimerMask timer_mask)
double getSubtimerLapCount() const
MetricTraits< T >::Type m_lapStart
Most recent start time/count.
bool shouldRecord(TimerMask timer_mask) const
Timer(TimerImpl &timer_impl)
MetricTraits< T >::Type m_lapStop
Most recent stop or lap time/count.
MetricTraits< T >::Type m_accumulatedLap
Accumulated time/count.
MetricTraits< T >::Type addLap()
TimerMask getTimerMask() const
Writer & dump(Writer &dout) const
Mask parse(const char *mask_string) const
Member function parse parses the mask string and generates the corresponding bit mask.
Class TimerSet implements a set of timer classifications. A time classification consists of a bit mas...
TimeBlockSynchronized(Timer &timer, ParallelMachine mpi_comm, bool start_timer=true)
const TimerSet & getTimerSet() const
Class Writer implements a runtime selectable diagnostic output writer to aid in the development and d...
TimeBlock(Timer &timer, bool start_timer=true)
virtual void parseArg(const std::string &name, const std::string &arg) const
OptionMask Mask
Mask for this option.
MetricTraits< T >::Type getStop() const
friend Timer createRootTimer(const std::string &, const TimerSet &)
double accumulateSubtimerLapCounts() const
const std::string & getName() const
const Metric< T > & getMetric() const
Writer & dump(Writer &dout) const
MetricTraits< T >::Type getLap() const
Class Timer implements a diagnostic timer and timer container for the collection and display of execu...