|
Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
|
Go to the documentation of this file.
4 #ifndef TEUCHOS_STACKED_TIMER_HPP
5 #define TEUCHOS_STACKED_TIMER_HPP
20 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE)
23 extern void pushRegion (
const std::string&);
24 extern void popRegion ();
33 void error_out(
const std::string& msg,
const bool fail_all =
false);
48 using Clock = std::chrono::high_resolution_clock;
55 error_out(
"Base_Timer:start Failed timer already running");
65 error_out(
"Base_Timer:stop Failed timer not running");
124 error_out(
"BaseTimer, cannot reset a running timer");
202 const char* name =
"RootTimer",
204 bool start_timer=
true) :
247 error_out(
"Stopping timer "+name+
" But top level running timer is "+
name_);
258 std::string parent_name(
"");
262 std::string my_name(
name_);
264 std::string full_name = parent_name + my_name;
293 if (locate_name ==
"")
296 std::string first_name,second_name;
298 size_t i = locate_name.find_first_of(
'@');
299 if ( i >= locate_name.size() ) {
300 first_name = locate_name;
303 first_name.assign(locate_name,0,i);
304 second_name.assign(locate_name,i+1,locate_name.size()-i-1);
308 return sub_timers_[j].accumulatedTime(second_name);
319 void splitString(
const std::string &locate_name, std::string &first_name, std::string &second_name) {
320 size_t i = locate_name.find_first_of(
'@');
321 if ( i >= locate_name.size() ) {
322 first_name = locate_name;
325 first_name.assign(locate_name,0,i);
326 second_name.assign(locate_name,i+1,locate_name.size()-i-1);
338 if (locate_name ==
"")
341 std::string first_name,second_name;
346 return sub_timers_[j].accumulatedTimePerUpdate(second_name);
357 if (locate_name ==
"")
360 std::string first_name,second_name;
365 return sub_timers_[j].accumulatedTimePerTimerCall(second_name);
385 void report(std::ostream &os);
414 timer_.BaseTimer::start();
415 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE)
416 ::Kokkos::Profiling::pushRegion(
"ANONYMOUS");
423 void start(
const std::string name) {
428 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE)
429 ::Kokkos::Profiling::pushRegion(name);
436 void stop(
const std::string &name =
"RootTimer") {
440 timer_.BaseTimer::stop( );
441 #if defined(HAVE_TEUCHOS_KOKKOS_PROFILING) && defined(HAVE_TEUCHOSCORE_KOKKOSCORE)
442 ::Kokkos::Profiling::popRegion();
495 bool foundTimer =
false;
498 "StackedTimer::findTimer() failed to find a timer named \"" << name <<
"\"!\n");
563 double printLevel(std::string prefix,
int level, std::ostream &os, std::vector<bool> &printed,
Reference-counted pointer class and non-member templated function implementations.
Timer info at a given level and all the children.
the basic timer used elsewhere, uses MPI_Wtime for time
LevelTimer * start(const char *sub_name)
LevelTimer * top_
Current level running.
LevelTimer * stop(const std::string &name="RootTimer")
void setAccumulatedTime(double accum=0)
Setter for accumulated time.
double difference(const BaseTimer &from) const
Return the difference between two timers in seconds,.
double printLevel(std::string prefix, int level, std::ostream &os, std::vector< bool > &printed, double parent_time, const OutputOptions &options)
void incrementCount(int i)
LevelTimer()
Default constructor, shouldn't be used but needed for std::vector.
bool output_total_updates
Templated array class derived from the STL std::vector.
double accumulatedTimePerUpdate(const std::string &locate_name="")
void merge(Teuchos::RCP< const Teuchos::Comm< int > > comm)
StackedTimer(const char *name)
double accumulatedTimePerUpdate(const std::string &name="")
void start(const std::string name)
unsigned long totalUpdates() const
Smart reference counting pointer class for automatic garbage collection.
void stop()
Stop a current running timer and accumulate time difference.
std::string get_full_name()
double accumulatedTimePerTimerCall() const
return the average time per timer start/stop
LevelTimer timer_
Base timer.
unsigned long long count_updates_
void reset()
Reset all the timer stats, throws if it is already running.
void error_out(const std::string &msg, const bool)
Error reporting function for stacked timer.
void stop(const std::string &name="RootTimer")
unsigned long incrementCount(unsigned long count=1)
Increment the total number of items updated between a start stop.
std::vector< LevelTimer > sub_timers_
void splitString(const std::string &locate_name, std::string &first_name, std::string &second_name)
split a string into two parts split by a '@' if no '@' first gets the full string
LevelTimer(int level, const char *name="RootTimer", LevelTimer *parent=NULL, bool start_timer=true)
double accumulatedTime(const std::string &name="")
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
double accumulatedTime() const
Get the total accumulated time since last reset or construction when the timer is running.
Array< Array< int > > hist_
void collectRemoteData(Teuchos::RCP< const Teuchos::Comm< int > > comm, const OutputOptions &options)
unsigned long count_started_
Struct for controlling output options like histograms.
Array< unsigned long > count_
This class allows one to push and pop timers on and off a stack.
std::chrono::high_resolution_clock Clock
Array< unsigned long long > updates_
Array< std::string > flat_names_
void report(std::ostream &os)
LevelTimer * unpack(unsigned from)
void report(std::ostream &os)
Abstract interface for distributed-memory communication.
void addTimerNames(Array< std::string > &names, unsigned &pos)
BaseTimer::TimeInfo findTimer(const std::string &name, bool &found)
unsigned long long updates
LevelTimer(const LevelTimer &src)
Copy constructor.
double accumulatedTime(const std::string &locate_name="")
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
void start()
Start a currently stopped timer.
Clock::time_point start_time_
double accumulatedTimePerTimerCall(const std::string &name="")
double accumulatedTimePerUpdate() const
return the average time per item updated
double accumulatedTimePerTimerCall(const std::string &locate_name="")
BaseTimer::TimeInfo findTimer(const std::string &name)