aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-08-07 18:33:48 -0400
committerErik Schnetter <schnetter@gmail.com>2013-08-07 18:57:56 -0400
commit77e61bb9a06ef271348c96d762935442c7439f0c (patch)
tree23a12a75ff19e45f65f71141efa2bf892e4773da /Carpet/Carpet
parent2dedcb0e7340b0682d530dc26e764408b301e3b8 (diff)
Timers: Move all timer-related code into a new thorn Timers
Diffstat (limited to 'Carpet/Carpet')
-rw-r--r--Carpet/Carpet/configuration.ccl2
-rw-r--r--Carpet/Carpet/interface.ccl6
-rw-r--r--Carpet/Carpet/param.ccl18
-rw-r--r--Carpet/Carpet/src/CactusTimer.cc253
-rw-r--r--Carpet/Carpet/src/CactusTimer.hh75
-rw-r--r--Carpet/Carpet/src/CallFunction.cc27
-rw-r--r--Carpet/Carpet/src/CarpetStartup.cc10
-rw-r--r--Carpet/Carpet/src/Checksum.cc5
-rw-r--r--Carpet/Carpet/src/Comm.cc27
-rw-r--r--Carpet/Carpet/src/Cycle.cc5
-rw-r--r--Carpet/Carpet/src/Evolve.cc38
-rw-r--r--Carpet/Carpet/src/Initialise.cc50
-rw-r--r--Carpet/Carpet/src/LoadBalanceReal/splitregions_recursively.cc3
-rw-r--r--Carpet/Carpet/src/OutputGH.cc9
-rw-r--r--Carpet/Carpet/src/Poison.cc7
-rw-r--r--Carpet/Carpet/src/Recompose.cc15
-rw-r--r--Carpet/Carpet/src/Restrict.cc17
-rw-r--r--Carpet/Carpet/src/SetupGH.cc18
-rw-r--r--Carpet/Carpet/src/Shutdown.cc25
-rw-r--r--Carpet/Carpet/src/TimerNode.cc373
-rw-r--r--Carpet/Carpet/src/TimerNode.hh119
-rw-r--r--Carpet/Carpet/src/TimerSet.cc190
-rw-r--r--Carpet/Carpet/src/TimerSet.hh69
-rw-r--r--Carpet/Carpet/src/Timers.cc90
-rw-r--r--Carpet/Carpet/src/Timers.hh84
-rw-r--r--Carpet/Carpet/src/make.code.defn6
-rw-r--r--Carpet/Carpet/src/modes.cc108
-rw-r--r--Carpet/Carpet/src/variables.cc3
-rw-r--r--Carpet/Carpet/src/variables.hh5
29 files changed, 176 insertions, 1481 deletions
diff --git a/Carpet/Carpet/configuration.ccl b/Carpet/Carpet/configuration.ccl
index d41eb1ae1..caae10cf3 100644
--- a/Carpet/Carpet/configuration.ccl
+++ b/Carpet/Carpet/configuration.ccl
@@ -4,7 +4,7 @@ PROVIDES Carpet
{
}
-REQUIRES IOUtil CarpetLib MPI
+REQUIRES CarpetLib IOUtil MPI Timers
OPTIONAL LoopControl
{
diff --git a/Carpet/Carpet/interface.ccl b/Carpet/Carpet/interface.ccl
index fe5c91d10..4a096666e 100644
--- a/Carpet/Carpet/interface.ccl
+++ b/Carpet/Carpet/interface.ccl
@@ -5,14 +5,16 @@ IMPLEMENTS: Driver
include header: carpet_public.hh in carpet.hh
include header: carpet_public.h in carpet.h
-include header: Timers.hh in CarpetTimers.hh
-
uses include header: Requirements.hh
uses include header: nompi.h
uses include header: loopcontrol.h
+uses include header: CactusTimerSet.hh
+uses include header: Timer.hh
+uses include header: TimerTree.hh
+
uses include header: mpi_string.hh
uses include header: cacheinfo.hh
diff --git a/Carpet/Carpet/param.ccl b/Carpet/Carpet/param.ccl
index 8db365016..90ad98b81 100644
--- a/Carpet/Carpet/param.ccl
+++ b/Carpet/Carpet/param.ccl
@@ -409,15 +409,6 @@ STRING timer_file "File name in which detailed timing statistics are collected"
"^.+$" :: "file name"
} "carpet-timing-statistics"
-BOOLEAN timers_verbose "Output (debug) messages when a timer is started or stopped" STEERABLE=always
-{
-} "no"
-
-STRING timer_xml_clock "Which clock to use in the XML timer output file" STEERABLE=always
-{
- ".*" :: "must be a legal clock name"
-} "gettimeofday"
-
BOOLEAN output_initialise_timer_tree "Output timing information in tree form to standard output for Initialise"
{
} "no"
@@ -440,15 +431,6 @@ BOOLEAN include_local_mode_in_mode_timer_tree "Include a node for the time spen
{
} "no"
-CCTK_REAL timer_tree_threshold_percentage "The percentage of the root timer below which timers are omitted" STEERABLE=always
-{
- 0:* :: ""
-} 1.0
-
-INT timer_tree_output_precision "Number of decimal places to use in standard output for timer tree" STEERABLE=always
-{
- 1:* :: "number of decimal places"
-} 1
BOOLEAN recompose_verbose "Output debug information during recomposing" STEERABLE=ALWAYS
diff --git a/Carpet/Carpet/src/CactusTimer.cc b/Carpet/Carpet/src/CactusTimer.cc
deleted file mode 100644
index a4250f6ee..000000000
--- a/Carpet/Carpet/src/CactusTimer.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-#include <cassert>
-#include <cstdio>
-#include <cstring>
-#include <iomanip>
-#include <list>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <cctk.h>
-#include <cctk_Parameters.h>
-#include <util_String.h>
-
-#if HAVE_UNISTD_H
-# include <fcntl.h>
-# include <unistd.h>
-#endif
-
-#include <defs.hh>
-
-#include "CactusTimer.hh"
-#include "TimerSet.hh"
-
-namespace Carpet
-{
- using namespace std;
-
- // Create a new Cactus timer with the given name
- CactusTimer::CactusTimer (const string &timername)
- : running (false)
- {
-// cout << "CactusTimer::CactusTimer(): name = " << timername << endl;
- handle = CCTK_TimerCreate (timername.c_str());
- assert (handle >= 0);
-
- timerSet.add (this);
- }
-
- // Destroy a timer
- CactusTimer::~CactusTimer ()
- {
- timerSet.remove (this);
- check (not CCTK_TimerDestroyI (handle));
- }
-
- // Start the timer
- void CactusTimer::start ()
- {
- msgStart ();
-// cout << "CactusTimer::start this = " << this << endl;
- running = true;
- CCTK_TimerStartI (handle);
- }
-
- // Stop the timer
- void CactusTimer::stop ()
- {
- CCTK_TimerStopI (handle);
- running = false;
- msgStop ();
- }
-
- // Reset the timer
- void CactusTimer::reset ()
- {
- CCTK_TimerResetI (handle);
- }
-
- // Timer name
- string CactusTimer::name () const
- {
- char const * const timername = CCTK_TimerName (handle);
- assert (timername);
- return string(timername);
- }
-
- double CactusTimer::getTime()
- {
- DECLARE_CCTK_PARAMETERS;
-
- static cTimerData * timer = 0;
- if (not timer) timer = CCTK_TimerCreateData ();
- assert (timer);
- CCTK_TimerI (handle, timer);
-
- bool const was_running = running;
- if (was_running) stop();
- const cTimerVal * tv = CCTK_GetClockValue(timer_xml_clock, timer);
- if (was_running) start();
-
- if (not tv) {
- CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Clock \"%s\" not found for timer #%d \"%s\"",
- timer_xml_clock, handle, CCTK_TimerName(handle));
- return -1.0;
- }
-
- return CCTK_TimerClockSeconds(tv);
- }
-
- void CactusTimer::getGlobalTime(double& avg, double& max)
- {
- const cGH *const cctkGH = 0;
-
- int ierr;
-
- static int op_sum = -1;
- static int op_max = -1;
- if (op_sum<0) op_sum = CCTK_ReductionArrayHandle("sum");
- if (op_max<0) op_max = CCTK_ReductionArrayHandle("maximum");
-
- const double val = getTime();
- const CCTK_REAL val1 = val;
-
- CCTK_REAL sum1;
- ierr = CCTK_ReduceLocScalar(cctkGH, -1, op_sum,
- &val1, &sum1, CCTK_VARIABLE_REAL);
- if (ierr) {
- CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Error in sum reduction");
- }
- avg = sum1 / CCTK_nProcs(cctkGH);
-
- CCTK_REAL max1;
- ierr = CCTK_ReduceLocScalar(cctkGH, -1, op_max,
- &val1, &max1, CCTK_VARIABLE_REAL);
- if (ierr) {
- CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Error in maximum reduction");
- }
- max = max1;
- }
-
- vector<pair<string,string> > CactusTimer::getAllTimerNames() const
- {
- DECLARE_CCTK_PARAMETERS;
-
- static cTimerData *timer = NULL;
- if (not timer) timer = CCTK_TimerCreateData();
- assert(timer);
-
- CCTK_TimerI(handle, timer);
-
- vector<pair<string,string> > names(timer->n_vals);
- for (int i=0; i<timer->n_vals; ++i) {
- names[i].first = timer->vals[i].heading;
- names[i].second = timer->vals[i].units;
- }
-
- return names;
- }
-
- vector<double> CactusTimer::getAllTimerValues()
- {
- DECLARE_CCTK_PARAMETERS;
-
- bool const was_running = running;
- if (was_running) stop();
-
- static cTimerData *timer = NULL;
- if (not timer) timer = CCTK_TimerCreateData();
- assert(timer);
-
- CCTK_TimerI(handle, timer);
-
- vector<double> vals(timer->n_vals);
- for (int i=0; i<timer->n_vals; ++i) {
- switch (timer->vals[i].type) {
- case val_int: vals[i] = timer->vals[i].val.i; break;
- case val_long: vals[i] = timer->vals[i].val.l; break;
- case val_double: vals[i] = timer->vals[i].val.d; break;
- default: CCTK_BUILTIN_UNREACHABLE();
- }
- }
-
- if (was_running) start();
-
- return vals;
- }
-
- // Print timer data
- void CactusTimer::printData ()
- {
- bool const was_running = running;
- if (was_running) stop();
-
-#if 0
- check (not CCTK_TimerPrintDataI (handle, -1)); // -1 means: all clocks
-#endif
-
- static cTimerData * timer = 0;
- if (not timer) timer = CCTK_TimerCreateData ();
- assert (timer);
- CCTK_TimerI (handle, timer);
-
- static bool firsttime = true;
- if (firsttime) {
- printf ("# 1: timer name");
- for (int i=0; i<timer->n_vals; ++i) {
- printf (" %d: %s [%s]",
- i+2, timer->vals[i].heading, timer->vals[i].units);
- }
- printf ("\n");
- firsttime = false;
- }
-
- printf ("%s:", name().c_str());
- for (int i=0; i<timer->n_vals; ++i) {
- switch (timer->vals[i].type) {
- case val_int:
- printf (" %d", timer->vals[i].val.i);
- break;
- case val_long:
- printf (" %ld", timer->vals[i].val.l);
- break;
- case val_double:
- printf (" %g", timer->vals[i].val.d);
- break;
- case val_none:
- break;
- default:
- assert (0);
- }
- }
- printf ("\n");
-
- if (was_running) start();
- }
-
- // Output (debug) messages that a timer is starting or stopping
- void CactusTimer::msgStart () const
- {
- DECLARE_CCTK_PARAMETERS;
- if (timers_verbose) {
- CCTK_VInfo (CCTK_THORNSTRING, "Timer \"%s\" starting", name().c_str());
- }
- }
-
- void CactusTimer::msgStop () const
- {
- DECLARE_CCTK_PARAMETERS;
- if (timers_verbose) {
- CCTK_VInfo (CCTK_THORNSTRING, "Timer \"%s\" stopping", name().c_str());
- }
- }
-
- ostream& CactusTimer::serialise(ostream &os)
- {
- os << scientific << setprecision(19) << getTime() << " " << name();
- return os;
- }
-
-} // namespace Carpet
diff --git a/Carpet/Carpet/src/CactusTimer.hh b/Carpet/Carpet/src/CactusTimer.hh
deleted file mode 100644
index cab4c592a..000000000
--- a/Carpet/Carpet/src/CactusTimer.hh
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef CACTUSTIMER_HH
-#define CACTUSTIMER_HH
-
-#include <cctk.h>
-
-#include <iostream>
-#include <list>
-#include <string>
-#include <utility>
-#include <vector>
-
-namespace Carpet {
-
- using namespace std;
-
-/** The CactusTimer class wraps the Cactus timer mechanism. All times
- are returned as doubles for now. */
-
- class CactusTimer
- {
- int handle;
- bool running;
-
- public:
-
- /// Create a new Cactus timer with the given name
- CactusTimer (const string &timername);
-
- /// Destroy a timer
- ~CactusTimer ();
-
- /// Start the timer
- void start ();
-
- /// Stop the timer
- void stop ();
-
- /// Reset the timer
- void reset ();
-
- /// Timer name
- string name () const;
-
- /// Return the current time of the timer in seconds as a double
- double getTime();
-
- /// Return the average and maximum current time over all MPI processes
- void getGlobalTime(double& avg, double& max);
-
- /// Return all clock names and their units
- vector<pair<string,string> > getAllTimerNames() const;
-
- /// Return all clock values of the timer as double
- vector<double> getAllTimerValues();
-
- /// Print timer data
- void printData ();
-
- ostream& serialise(ostream &os);
-
- private:
-
- // Output (debug) messages that a timer is starting or stopping
- void
- msgStart ()
- const;
-
- void
- msgStop ()
- const;
-
- };
-} // namespace Carpet
-
-#endif // CACTUSTIMER_HH
diff --git a/Carpet/Carpet/src/CallFunction.cc b/Carpet/Carpet/src/CallFunction.cc
index 5b209270b..935fe2e4d 100644
--- a/Carpet/Carpet/src/CallFunction.cc
+++ b/Carpet/Carpet/src/CallFunction.cc
@@ -12,10 +12,11 @@
#include <Requirements.hh>
+#include <Timer.hh>
+
#include <gh.hh>
#include <carpet.hh>
-#include <Timers.hh>
#include "adler32.hh"
@@ -32,12 +33,12 @@ namespace Carpet {
void * function,
cFunctionData * attribute,
void * data,
- Timer & user_timer);
+ Timers::Timer & user_timer);
static void
SyncGroupsInScheduleBlock (cFunctionData * attribute, cGH * cctkGH,
vector<int> const & sync_groups,
- Timer & sync_timer);
+ Timers::Timer & sync_timer);
/// Traverse one function on all components of one refinement level
/// of one multigrid level.
@@ -47,9 +48,9 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- static Timer total_timer ("CallFunction");
- static Timer user_timer ("thorns");
- static Timer sync_timer ("syncs");
+ static Timers::Timer total_timer ("CallFunction");
+ static Timers::Timer user_timer ("thorns");
+ static Timers::Timer sync_timer ("syncs");
total_timer.start();
@@ -322,7 +323,7 @@ namespace Carpet {
buf << attribute->routine << "\n";
string const str = buf.str();
int const id = adler32(str.c_str(), str.length());
- static Timer barrier_timer ("barrier");
+ static Timers::Timer barrier_timer ("barrier");
barrier_timer.start();
Carpet::NamedBarrier (NULL, id, "Carpet::CallFunction");
barrier_timer.stop();
@@ -344,7 +345,7 @@ namespace Carpet {
void * const function,
cFunctionData * const attribute,
void * const data,
- Timer & user_timer)
+ Timers::Timer & user_timer)
{
cGH const * const cctkGH = static_cast <cGH const *> (data);
Checkpoint ("%s call at %s to %s::%s",
@@ -353,7 +354,7 @@ namespace Carpet {
attribute->thorn, attribute->routine);
int const skip = CallBeforeRoutines (cctkGH, function, attribute, data);
if (not skip) {
- Timer timer(attribute->routine);
+ Timers::Timer timer(attribute->routine);
// Save the time step size
CCTK_REAL const saved_cctk_delta_time = cctkGH->cctk_delta_time;
@@ -366,7 +367,7 @@ namespace Carpet {
#endif
timer.start();
if (CCTK_IsFunctionAliased("Accelerator_PreCallFunction")) {
- Timer pre_timer("PreCall");
+ Timers::Timer pre_timer("PreCall");
pre_timer.start();
Accelerator_PreCallFunction(cctkGH, attribute);
pre_timer.stop();
@@ -374,7 +375,7 @@ namespace Carpet {
int const res = CCTK_CallFunction (function, attribute, data);
assert (res==0);
if (CCTK_IsFunctionAliased("Accelerator_PostCallFunction")) {
- Timer post_timer("PostCall");
+ Timers::Timer post_timer("PostCall");
post_timer.start();
Accelerator_PostCallFunction(cctkGH, attribute);
post_timer.stop();
@@ -430,7 +431,7 @@ namespace Carpet {
void SyncGroupsInScheduleBlock (cFunctionData* attribute, cGH* cctkGH,
vector<int> const & sync_groups,
- Timer & sync_timer)
+ Timers::Timer & sync_timer)
{
DECLARE_CCTK_PARAMETERS;
@@ -453,7 +454,7 @@ namespace Carpet {
buf << attribute->routine << " sync\n";
string const str = buf.str();
int const id = adler32(str.c_str(), str.length());
- static Timer barrier_timer ("sync_barrier");
+ static Timers::Timer barrier_timer ("sync_barrier");
barrier_timer.start();
Carpet::NamedBarrier (NULL, id, "Carpet::Sync");
barrier_timer.stop();
diff --git a/Carpet/Carpet/src/CarpetStartup.cc b/Carpet/Carpet/src/CarpetStartup.cc
index 96d061f50..7314cda43 100644
--- a/Carpet/Carpet/src/CarpetStartup.cc
+++ b/Carpet/Carpet/src/CarpetStartup.cc
@@ -9,7 +9,6 @@
#include <dist.hh>
#include <carpet.hh>
-#include <TimerNode.hh>
@@ -65,15 +64,6 @@ namespace Carpet {
CCTK_OverloadQueryGroupStorageB (QueryGroupStorageB);
CCTK_OverloadGroupDynamicData (GroupDynamicData);
- // This must happen before any Timer objects are created
- main_timer_tree.root = new TimerNode(&main_timer_tree,"main");
- main_timer_tree.current = 0; // No timer has been started yet
- main_timer_tree.root->start();
-
- mode_timer_tree.root = new TimerNode(&mode_timer_tree,"meta mode");
- mode_timer_tree.current = 0; // No timer has been started yet
- mode_timer_tree.root->start();
-
return 0;
}
diff --git a/Carpet/Carpet/src/Checksum.cc b/Carpet/Carpet/src/Checksum.cc
index 877b1d209..b96282f64 100644
--- a/Carpet/Carpet/src/Checksum.cc
+++ b/Carpet/Carpet/src/Checksum.cc
@@ -7,10 +7,11 @@
#include <util_ErrorCodes.h>
#include <util_Table.h>
+#include <Timer.hh>
+
#include <gh.hh>
#include <carpet.hh>
-#include "Timers.hh"
namespace Carpet {
@@ -68,7 +69,7 @@ namespace Carpet {
if (! checksum_timelevels) return;
- Timer timer("CalculateChecksums");
+ Timers::Timer timer("CalculateChecksums");
timer.start();
Checkpoint ("CalculateChecksums");
diff --git a/Carpet/Carpet/src/Comm.cc b/Carpet/Carpet/src/Comm.cc
index 040ed64fe..b1c5cf2ab 100644
--- a/Carpet/Carpet/src/Comm.cc
+++ b/Carpet/Carpet/src/Comm.cc
@@ -10,11 +10,12 @@
#include <Requirements.hh>
+#include <Timer.hh>
+
#include <ggf.hh>
#include <gh.hh>
#include <carpet.hh>
-#include <Timers.hh>
@@ -145,7 +146,7 @@ namespace Carpet {
// prolongate boundaries
bool const local_do_prolongate = do_prolongate and not do_taper;
if (local_do_prolongate) {
- static Timer timer ("Prolongate");
+ static Timers::Timer timer ("Prolongate");
timer.start();
ProlongateGroupBoundaries (cctkGH, goodgroups);
timer.stop();
@@ -165,7 +166,7 @@ namespace Carpet {
// synchronise ghostzones
if (sync_during_time_integration or local_do_prolongate) {
- static Timer timer ("Sync");
+ static Timers::Timer timer ("Sync");
timer.start();
SyncGroups (cctkGH, goodgroups);
timer.stop();
@@ -191,9 +192,9 @@ namespace Carpet {
// use the current time here (which may be modified by the user)
const CCTK_REAL time = cctkGH->cctk_time;
- static vector<Timer*> timers;
+ static vector<Timers::Timer*> timers;
if (timers.empty()) {
- timers.push_back(new Timer("comm_state[0].create"));
+ timers.push_back(new Timers::Timer("comm_state[0].create"));
for (astate state = static_cast<astate>(0);
state != state_done;
state = static_cast<astate>(static_cast<int>(state)+1))
@@ -201,15 +202,15 @@ namespace Carpet {
ostringstream name1;
name1 << "comm_state[" << timers.size() << "]"
<< "." << tostring(state) << ".user";
- timers.push_back(new Timer(name1.str()));
+ timers.push_back(new Timers::Timer(name1.str()));
ostringstream name2;
name2 << "comm_state[" << timers.size() << "]"
<< "." << tostring(state) << ".step";
- timers.push_back(new Timer(name2.str()));
+ timers.push_back(new Timers::Timer(name2.str()));
}
}
- vector<Timer*>::iterator ti = timers.begin();
+ vector<Timers::Timer*>::iterator ti = timers.begin();
(*ti)->start();
for (comm_state state; not state.done(); state.step()) {
(*ti)->stop(); ++ti; (*ti)->start();
@@ -253,9 +254,9 @@ namespace Carpet {
Accelerator_PreSync(cctkGH, &groups.front(), groups.size());
}
- static vector<Timer*> timers;
+ static vector<Timers::Timer*> timers;
if (timers.empty()) {
- timers.push_back(new Timer("comm_state[0].create"));
+ timers.push_back(new Timers::Timer("comm_state[0].create"));
for (astate state = static_cast<astate>(0);
state != state_done;
state = static_cast<astate>(static_cast<int>(state)+1))
@@ -263,15 +264,15 @@ namespace Carpet {
ostringstream name1;
name1 << "comm_state[" << timers.size() << "]"
<< "." << tostring(state) << ".user";
- timers.push_back(new Timer(name1.str()));
+ timers.push_back(new Timers::Timer(name1.str()));
ostringstream name2;
name2 << "comm_state[" << timers.size() << "]"
<< "." << tostring(state) << ".step";
- timers.push_back(new Timer(name2.str()));
+ timers.push_back(new Timers::Timer(name2.str()));
}
}
- vector<Timer*>::iterator ti = timers.begin();
+ vector<Timers::Timer*>::iterator ti = timers.begin();
(*ti)->start();
for (comm_state state; not state.done(); state.step()) {
(*ti)->stop(); ++ti; (*ti)->start();
diff --git a/Carpet/Carpet/src/Cycle.cc b/Carpet/Carpet/src/Cycle.cc
index 5210d7f48..cff3235de 100644
--- a/Carpet/Carpet/src/Cycle.cc
+++ b/Carpet/Carpet/src/Cycle.cc
@@ -6,11 +6,12 @@
#include <Requirements.hh>
+#include <Timer.hh>
+
#include <ggf.hh>
#include <gh.hh>
#include <carpet.hh>
-#include <Timers.hh>
@@ -24,7 +25,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- Timer timer("CycleTimeLevels");
+ Timers::Timer timer("CycleTimeLevels");
timer.start();
Checkpoint ("CycleTimeLevels");
diff --git a/Carpet/Carpet/src/Evolve.cc b/Carpet/Carpet/src/Evolve.cc
index 0a959b48c..24d4cbbb2 100644
--- a/Carpet/Carpet/src/Evolve.cc
+++ b/Carpet/Carpet/src/Evolve.cc
@@ -12,18 +12,17 @@
#include <cctk.h>
#include <cctk_Parameters.h>
#include <cctk_Termination.h>
+#include <util_String.h>
#include <Requirements.hh>
-#include <util_String.h>
+#include <CactusTimerSet.hh>
+#include <Timer.hh>
#include <dist.hh>
#include <th.hh>
#include <carpet.hh>
-#include <Timers.hh>
-#include <TimerSet.hh>
-#include <TimerNode.hh>
@@ -61,7 +60,7 @@ namespace Carpet {
// Main loop
BeginTimingEvolution (cctkGH);
- static Timer timer ("Evolve");
+ static Timers::Timer timer ("Evolve");
timer.start();
while (not do_terminate (cctkGH)) {
@@ -83,33 +82,28 @@ namespace Carpet {
// Print timer values
{
- Timer timer("PrintTimers");
+ Timers::Timer timer("PrintTimers");
timer.start();
int const do_every = maxtimereflevelfact / timereffacts.AT(reflevels-1);
if (output_timers_every > 0 and
cctkGH->cctk_iteration % output_timers_every == 0 and
cctkGH->cctk_iteration % do_every == 0)
{
- Carpet::TimerSet::writeData (cctkGH, timer_file);
+ Timers::CactusTimerSet::writeData (cctkGH, timer_file);
}
if (output_timer_tree_every > 0 and
cctkGH->cctk_iteration % output_timer_tree_every == 0 and
cctkGH->cctk_iteration % do_every == 0)
{
- TimerNode *et = main_timer_tree.root->getChildTimer("Evolve");
- double total_avg, total_max;
- et->getGlobalTime(total_avg, total_max);
- et->print(cout, total_max, 0, timer_tree_threshold_percentage, timer_tree_output_precision);
- mode_timer_tree.root->getGlobalTime(total_avg, total_max);
- mode_timer_tree.root->print(cout, total_max, 0, timer_tree_threshold_percentage, timer_tree_output_precision);
+ Timers::Timer::outputTree("Evolve");
}
timer.stop();
}
// Ensure that all levels have consistent times
{
- Timer timer("CheckLevelTimes");
+ Timers::Timer timer("CheckLevelTimes");
timer.start();
CCTK_REAL const eps =
pow(numeric_limits<CCTK_REAL>::epsilon(), CCTK_REAL(0.75));
@@ -144,7 +138,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- static Timer timer ("DoTerminate");
+ static Timers::Timer timer ("DoTerminate");
timer.start();
bool term;
@@ -228,7 +222,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- static Timer timer ("AdvanceTime");
+ static Timers::Timer timer ("AdvanceTime");
timer.start();
Checkpoint ("AdvanceTime");
@@ -264,7 +258,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallRegrid";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
assert (is_level_mode());
@@ -404,7 +398,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallEvol";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
for (int ml=mglevels-1; ml>=0; --ml) {
@@ -492,7 +486,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "Evolve::CallRestrict";
- static Timer timer ("CallRestrict");
+ static Timers::Timer timer ("CallRestrict");
timer.start();
for (int ml=mglevels-1; ml>=0; --ml) {
@@ -595,7 +589,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallAnalysis";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
for (int ml=mglevels-1; ml>=0; --ml) {
@@ -727,7 +721,7 @@ namespace Carpet {
void ScheduleTraverse (char const * const where, char const * const name,
cGH * const cctkGH)
{
- Timer timer(name);
+ Timers::Timer timer(name);
timer.start();
ostringstream infobuf;
infobuf << "Scheduling " << name;
@@ -739,7 +733,7 @@ namespace Carpet {
void OutputGH (char const * const where, cGH * const cctkGH)
{
- static Timer timer("OutputGH");
+ static Timers::Timer timer("OutputGH");
timer.start();
CCTK_OutputGH (cctkGH);
timer.stop();
diff --git a/Carpet/Carpet/src/Initialise.cc b/Carpet/Carpet/src/Initialise.cc
index 7440b5cdc..388f35c9b 100644
--- a/Carpet/Carpet/src/Initialise.cc
+++ b/Carpet/Carpet/src/Initialise.cc
@@ -15,10 +15,10 @@
#include <Requirements.hh>
+#include <CactusTimerSet.hh>
+#include <Timer.hh>
+
#include <carpet.hh>
-#include <Timers.hh>
-#include <TimerSet.hh>
-#include <TimerNode.hh>
@@ -84,7 +84,7 @@ namespace Carpet {
cctkGH->cctk_time = global_time;
cctkGH->cctk_delta_time = delta_time;
- static Timer timer ("Initialise");
+ static Timers::Timer timer ("Initialise");
timer.start();
// Delay checkpoint until MPI has been initialised
@@ -134,15 +134,11 @@ namespace Carpet {
timer.stop();
if (output_timers_every > 0) {
- TimerSet::writeData (cctkGH, timer_file);
+ Timers::CactusTimerSet::writeData (cctkGH, timer_file);
}
- if (output_initialise_timer_tree)
- {
- TimerNode *it = main_timer_tree.root->getChildTimer("Initialise");
- double total_avg, total_max;
- it->getGlobalTime(total_avg, total_max);
- it->print(cout, total_max, 0, timer_tree_threshold_percentage, timer_tree_output_precision);
+ if (output_initialise_timer_tree) {
+ Timers::Timer::outputTree("Initialise");
}
Waypoint ("Done with initialisation");
@@ -162,7 +158,7 @@ namespace Carpet {
CallSetup (cGH * const cctkGH)
{
char const * const where = "CallSetup";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
BEGIN_MGLEVEL_LOOP(cctkGH) {
@@ -206,7 +202,7 @@ namespace Carpet {
CallRecoverVariables (cGH * const cctkGH)
{
char const * const where = "CallRecoverVariables";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
DECLARE_CCTK_PARAMETERS;
@@ -273,7 +269,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallPostRecoverVariables";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
for (int rl=0; rl<reflevels; ++rl) {
@@ -366,7 +362,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallInitial";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
if (not regrid_during_initialisation) {
@@ -470,7 +466,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "Initialise::CallRestrict";
- static Timer timer ("CallRestrict");
+ static Timers::Timer timer ("CallRestrict");
timer.start();
for (int ml=mglevels-1; ml>=0; --ml) {
@@ -546,7 +542,7 @@ namespace Carpet {
CallPostInitial (cGH * const cctkGH)
{
char const * const where = "CallPostInitial";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
for (int rl=0; rl<reflevels; ++rl) {
@@ -592,7 +588,7 @@ namespace Carpet {
CallAnalysis (cGH * const cctkGH, bool const did_recover)
{
char const * const where = "CallAnalysis";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
for (int rl=0; rl<reflevels; ++rl) {
@@ -802,7 +798,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallRegridRecoverMeta";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
assert (is_meta_mode());
@@ -892,7 +888,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallRegridRecoverLevel";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
CCTK_WARN (CCTK_WARN_ALERT,
@@ -1029,7 +1025,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallRegridInitialMeta";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
assert (is_meta_mode());
@@ -1106,7 +1102,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "CallRegridInitialLevel";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
CCTK_WARN (CCTK_WARN_ALERT,
@@ -1274,7 +1270,7 @@ namespace Carpet {
Waypoint ("Initialising three timelevels:");
char const * const where = "Initialise3TL";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
#if 0
@@ -1320,7 +1316,7 @@ namespace Carpet {
initialise_3tl_evolve (cGH * const cctkGH)
{
char const * const where = "Evolve";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
BEGIN_MGLEVEL_LOOP(cctkGH) {
@@ -1360,7 +1356,7 @@ namespace Carpet {
initialise_3tl_recycle (cGH * const cctkGH)
{
char const * const where = "Recycle";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
BEGIN_MGLEVEL_LOOP(cctkGH) {
@@ -1405,7 +1401,7 @@ namespace Carpet {
void ScheduleTraverse (char const * const where, char const * const name,
cGH * const cctkGH)
{
- Timer timer(name);
+ Timers::Timer timer(name);
timer.start();
ostringstream infobuf;
@@ -1418,7 +1414,7 @@ namespace Carpet {
void OutputGH (char const * const where, cGH * const cctkGH)
{
- static Timer timer("OutputGH");
+ static Timers::Timer timer("OutputGH");
timer.start();
CCTK_OutputGH (cctkGH);
timer.stop();
diff --git a/Carpet/Carpet/src/LoadBalanceReal/splitregions_recursively.cc b/Carpet/Carpet/src/LoadBalanceReal/splitregions_recursively.cc
index fd3148864..ee0c945a5 100644
--- a/Carpet/Carpet/src/LoadBalanceReal/splitregions_recursively.cc
+++ b/Carpet/Carpet/src/LoadBalanceReal/splitregions_recursively.cc
@@ -25,6 +25,8 @@
# include "nompi.h"
#endif
+#include <Timer.hh>
+
#include <loopcontrol.h>
#include <bbox.hh>
@@ -38,7 +40,6 @@
#include <carpet.hh>
#include <modes.hh>
#include <variables.hh>
-#include <Timers.hh>
diff --git a/Carpet/Carpet/src/OutputGH.cc b/Carpet/Carpet/src/OutputGH.cc
index 6c2c4c311..8c9d8c4ac 100644
--- a/Carpet/Carpet/src/OutputGH.cc
+++ b/Carpet/Carpet/src/OutputGH.cc
@@ -6,10 +6,11 @@
#include <cctk.h>
#include <cctk_Parameters.h>
+#include <Timer.hh>
+
#include <dist.hh>
#include <carpet.hh>
-#include <Timers.hh>
@@ -23,7 +24,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- static Timer timer ("OutputGH");
+ static Timers::Timer timer ("OutputGH");
timer.start();
Checkpoint ("OutputGH");
@@ -34,7 +35,7 @@ namespace Carpet {
return -1;
}
- static vector<Timer *> timers;
+ static vector<Timers::Timer *> timers;
timers.resize (num_methods, NULL);
int num_vars = 0;
@@ -48,7 +49,7 @@ namespace Carpet {
buf << method->implementation
<< "::" << method->name
<< " [" << handle << "]";
- timers.AT(handle) = new Timer (buf.str().c_str());
+ timers.AT(handle) = new Timers::Timer (buf.str().c_str());
}
timers.AT(handle)->start();
diff --git a/Carpet/Carpet/src/Poison.cc b/Carpet/Carpet/src/Poison.cc
index 19c51d363..21310e82e 100644
--- a/Carpet/Carpet/src/Poison.cc
+++ b/Carpet/Carpet/src/Poison.cc
@@ -7,11 +7,12 @@
#include <util_ErrorCodes.h>
#include <util_Table.h>
+#include <Timer.hh>
+
#include <defs.hh>
#include <typeprops.hh>
#include <carpet.hh>
-#include "Timers.hh"
namespace Carpet {
@@ -33,7 +34,7 @@ namespace Carpet {
if (not poison_new_timelevels) return;
- Timer timer("Poison");
+ Timers::Timer timer("Poison");
timer.start();
for (int group=0; group<CCTK_NumGroups(); ++group) {
@@ -149,7 +150,7 @@ namespace Carpet {
if (not check_for_poison) return;
Checkpoint ("PoisonCheck");
- Timer timer("PoisonCheck");
+ Timers::Timer timer("PoisonCheck");
timer.start();
for (int group=0; group<CCTK_NumGroups(); ++group) {
diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc
index 703963f97..9654ecefd 100644
--- a/Carpet/Carpet/src/Recompose.cc
+++ b/Carpet/Carpet/src/Recompose.cc
@@ -25,6 +25,8 @@
# include "nompi.h"
#endif
+#include <Timer.hh>
+
#include <loopcontrol.h>
#include <balance.hh>
@@ -39,7 +41,6 @@
#include <carpet.hh>
#include <modes.hh>
#include <variables.hh>
-#include <Timers.hh>
@@ -92,7 +93,7 @@ namespace Carpet {
CheckRegions (gh::mregs const & regsss)
{
char const * const where = "CheckRegions";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
// At least one multigrid level
@@ -150,7 +151,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "Regrid";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
Checkpoint ("Regridding level %d...", reflevel);
@@ -267,7 +268,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "RegridMap";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
Waypoint ("Regridding map %d...", m);
@@ -327,7 +328,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
char const * const where = "PostRegrid";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
// Calculate new number of levels
@@ -390,7 +391,7 @@ namespace Carpet {
bool const do_init)
{
char const * const where = "Recompose";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
bool did_recompose = false;
@@ -422,7 +423,7 @@ namespace Carpet {
bool const do_init)
{
char const * const where = "RegridFree";
- static Timer timer (where);
+ static Timers::Timer timer (where);
timer.start();
Checkpoint ("Freeing after regridding level %d...", reflevel);
diff --git a/Carpet/Carpet/src/Restrict.cc b/Carpet/Carpet/src/Restrict.cc
index 6dc040c23..3598000f8 100644
--- a/Carpet/Carpet/src/Restrict.cc
+++ b/Carpet/Carpet/src/Restrict.cc
@@ -7,11 +7,12 @@
#include <Requirements.hh>
+#include <Timer.hh>
+
#include <ggf.hh>
#include <gh.hh>
#include <carpet.hh>
-#include <Timers.hh>
@@ -63,7 +64,7 @@ namespace Carpet {
// Restrict
{
- static Timer timer ("Restrict");
+ static Timers::Timer timer ("Restrict");
timer.start();
RestrictGroups (cctkGH, groups);
timer.stop();
@@ -75,7 +76,7 @@ namespace Carpet {
// be necessary.
#if 0
{
- static Timer timer ("RestrictSync");
+ static Timers::Timer timer ("RestrictSync");
timer.start();
SyncGroups (cctkGH, groups);
timer.stop();
@@ -88,9 +89,9 @@ namespace Carpet {
static void RestrictGroups (const cGH* cctkGH, const vector<int>& groups) {
DECLARE_CCTK_PARAMETERS;
- static vector<Timer*> timers;
+ static vector<Timers::Timer*> timers;
if (timers.empty()) {
- timers.push_back(new Timer("comm_state[0].create"));
+ timers.push_back(new Timers::Timer("comm_state[0].create"));
for (astate state = static_cast<astate>(0);
state != state_done;
state = static_cast<astate>(static_cast<int>(state)+1))
@@ -98,15 +99,15 @@ namespace Carpet {
ostringstream name1;
name1 << "comm_state[" << timers.size() << "]"
<< "." << tostring(state) << ".user";
- timers.push_back(new Timer(name1.str()));
+ timers.push_back(new Timers::Timer(name1.str()));
ostringstream name2;
name2 << "comm_state[" << timers.size() << "]"
<< "." << tostring(state) << ".step";
- timers.push_back(new Timer(name2.str()));
+ timers.push_back(new Timers::Timer(name2.str()));
}
}
- vector<Timer*>::iterator ti = timers.begin();
+ vector<Timers::Timer*>::iterator ti = timers.begin();
(*ti)->start();
for (comm_state state; not state.done(); state.step()) {
(*ti)->stop(); ++ti; (*ti)->start();
diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc
index f984f50eb..dfbf05fa1 100644
--- a/Carpet/Carpet/src/SetupGH.cc
+++ b/Carpet/Carpet/src/SetupGH.cc
@@ -27,6 +27,8 @@
#include <Requirements.hh>
+#include <Timer.hh>
+
#include <bbox.hh>
#include <defs.hh>
#include <dist.hh>
@@ -37,7 +39,6 @@
#include <vect.hh>
#include <carpet.hh>
-#include "Timers.hh"
@@ -546,7 +547,7 @@ namespace Carpet {
// Say hello
- Timer timer("CarpetStartup");
+ Timers::Timer timer("CarpetStartup");
timer.start();
Waypoint ("Setting up the grid hierarchy");
@@ -823,7 +824,7 @@ namespace Carpet {
// Allocate grid hierarchy
- Timer timer("AllocateGridHierarchy");
+ Timers::Timer timer("AllocateGridHierarchy");
timer.start();
vhh.resize(maps);
vhh.AT(m) = new gh (spacereffacts, refcentering,
@@ -1368,6 +1369,8 @@ namespace Carpet {
void
set_state (cGH * const cctkGH)
{
+ DECLARE_CCTK_PARAMETERS;
+
// // Allocate level times
// leveltimes.resize (mglevels);
// for (int ml=0; ml<mglevels; ++ml) {
@@ -1399,6 +1402,15 @@ namespace Carpet {
local_component = -1;
// Leave everything, so that everything is set up correctly
+ Timers::Timer("meta mode", 1).start();
+ Timers::Timer("global mode", 1).start();
+ Timers::Timer("level(0)", 1).start();
+ if (include_maps_in_mode_timer_tree) {
+ Timers::Timer("map(0)", 1).start();
+ }
+ if (include_local_mode_in_mode_timer_tree) {
+ Timers::Timer("local", 1).start();
+ }
leave_local_mode (cctkGH);
leave_singlemap_mode (cctkGH);
leave_level_mode (cctkGH);
diff --git a/Carpet/Carpet/src/Shutdown.cc b/Carpet/Carpet/src/Shutdown.cc
index c9b85019c..e4d0a2fa3 100644
--- a/Carpet/Carpet/src/Shutdown.cc
+++ b/Carpet/Carpet/src/Shutdown.cc
@@ -4,12 +4,12 @@
#include <cctk.h>
#include <cctk_Parameters.h>
+#include <CactusTimerSet.hh>
+#include <Timer.hh>
+
#include <dist.hh>
#include <carpet.hh>
-#include <Timers.hh>
-#include <TimerNode.hh>
-#include <TimerSet.hh>
@@ -28,7 +28,7 @@ namespace Carpet {
const int convlev = 0;
cGH* cctkGH = fc->GH[convlev];
- static Timer timer ("Shutdown");
+ static Timers::Timer timer ("Shutdown");
timer.start();
for (int rl=reflevels-1; rl>=0; --rl) {
BEGIN_REVERSE_MGLEVEL_LOOP(cctkGH) {
@@ -62,7 +62,7 @@ namespace Carpet {
assert (not ierr);
timer.stop();
if (output_timers_every > 0) {
- TimerSet::writeData (cctkGH, timer_file);
+ Timers::CactusTimerSet::writeData (cctkGH, timer_file);
}
BEGIN_REVERSE_MGLEVEL_LOOP(cctkGH) {
@@ -81,27 +81,16 @@ namespace Carpet {
- main_timer_tree.root->stop();
-
if (output_timer_tree_every > 0) {
- TimerNode *et = main_timer_tree.root->getChildTimer("Evolve");
- double total_avg, total_max;
- et->getGlobalTime(total_avg, total_max);
- et->print(cout, total_max, 0, timer_tree_threshold_percentage, timer_tree_output_precision);
- mode_timer_tree.root->getGlobalTime(total_avg, total_max);
- mode_timer_tree.root->print(cout, total_max, 0, timer_tree_threshold_percentage, timer_tree_output_precision);
+ Timers::Timer::outputTree("Evolve");
}
if (output_xml_timer_tree) {
- main_timer_tree.root->outputXML(out_dir,CCTK_MyProc (cctkGH));
+ Timers::Timer::outputTreeXML();
}
- // Delete timer tree
- delete main_timer_tree.root; main_timer_tree.root = 0;
- delete mode_timer_tree.root; mode_timer_tree.root = 0;
-
// Free all memory, call all destructors
for (size_t gi=0; gi<arrdata.size(); ++gi) {
for (size_t m=0; m<arrdata.AT(gi).size(); ++m) {
diff --git a/Carpet/Carpet/src/TimerNode.cc b/Carpet/Carpet/src/TimerNode.cc
deleted file mode 100644
index 93833a72d..000000000
--- a/Carpet/Carpet/src/TimerNode.cc
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- *
- * The MIT License
- *
- * Copyright (c) 1997-2010 Center for the Simulation of Accidental Fires and
- * Explosions (CSAFE), and Scientific Computing and Imaging Institute (SCI),
- * University of Utah.
- *
- * License for the specific language governing rights and limitations under
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * */
-
-#include <algorithm>
-#include <cassert>
-#include <fstream>
-#include <iomanip>
-#include <iostream>
-#include <map>
-#include <ostream>
-#include <string>
-#include <utility>
-
-#include <dist.hh>
-#include <mpi_string.hh>
-
-#include "TimerNode.hh"
-
-namespace Carpet {
-
- using namespace std;
-
- TimerNode::TimerNode(TimerTree *tree, string name):
- d_name(name), d_parent(0), d_tree(tree), d_running(0), timer(0)
- {
- }
-
- TimerNode::~TimerNode()
- {
- for(map<string,TimerNode*>::iterator iter=d_children.begin();
- iter!=d_children.end(); ++iter)
- {
- delete iter->second;
- }
- d_children.clear();
- delete timer;
- }
-
- string TimerNode::pathName() const
- {
- assert(d_parent != this);
- if (d_parent)
- return d_parent->pathName() + string("/") + getName();
- else
- return getName();
- }
-
- void TimerNode::instantiate()
- {
- assert(!d_running);
- d_parent = d_tree->current;
- d_tree->current = this;
- if (timer == 0)
- timer = new CactusTimer(pathName());
- d_tree->current = d_parent;
- }
-
- void TimerNode::start()
- {
- assert(!d_running);
-
- d_running = true;
- d_parent = d_tree->current;
- d_tree->current = this;
- if (timer == 0)
- timer = new CactusTimer(pathName());
- assert(timer);
- timer->start();
- }
-
- void TimerNode::stop()
- {
- assert(d_running);
-
- // A timer can only be stopped if it is the current timer
- if(this != d_tree->current)
- CCTK_VError (__LINE__, __FILE__, CCTK_THORNSTRING,
- "Tried to stop non-current timer '%s'", getName().c_str());
-
- timer->stop();
-
- d_running = false;
- d_tree->current = d_parent;
- }
-
- /// Get the name of the timer
- string TimerNode::getName() const
- {
- assert(d_name.length() > 0);
- return d_name;
- }
-
- /// Determine if the timer is running
- bool TimerNode::isRunning() const
- {
- return d_running;
- }
-
- /// Find the child timer that matches the name provided. If it is
- /// not found then a new timer with that name is allocated.
- TimerNode* TimerNode::getChildTimer(string name)
- {
- // Find child
- TimerNode *child=d_children[name];
-
- // If the pointer is null then allocate it
- if(child == 0)
- d_children[name] = child = new TimerNode(d_tree, name);
-
- return child;
- }
-
- /// Get the time measured by this timer
- double TimerNode::getTime()
- {
- return timer->getTime();
- }
-
- /// Get the global time measured by this timer
- void TimerNode::getGlobalTime(double& avg, double& max)
- {
- return timer->getGlobalTime(avg, max);
- }
-
- /// Get the names of all clocks of this timer
- vector<pair<string,string> > TimerNode::getAllTimerNames() const
- {
- return timer->getAllTimerNames();
- }
-
- /// Get the values of all clocks of this timer
- vector<double> TimerNode::getAllTimerValues()
- {
- return timer->getAllTimerValues();
- }
-
- /// Print this node and its children as an ASCII tree
- void TimerNode::print(ostream& out, double total, int level,
- double threshold, int precision)
- {
- string space;
-
- // Compute the level of indentation for this depth
- for(int i=0;i<level-1;i++)
- space += "| ";
-
- if (level != 0)
- space += "|_";
-
- const int pcw = 6;
- const int tw = 8;
- const int tnw = 40; // timer name
- const int vw = 9; // clock values
- const streamsize oldprecision = out.precision();
- const ios_base::fmtflags oldflags = out.flags();
-
- // const double t = getTime();
- double tavg, tmax;
- getGlobalTime(tavg, tmax);
- const vector<double> values = getAllTimerValues();
- const string hyphens = string(precision-1, '-');
- const string spaces = string(precision-1, ' ');
-
- if (level == 0)
- {
- const vector<pair<string,string> > names = getAllTimerNames();
-
- out << "--------" << hyphens
- << "--------" << hyphens
- << "--------" << hyphens
- << "--" << string(tnw, '-');
- for (size_t i=0; i<values.size(); ++i) {
- out << "--" << string(vw, '-');
- }
- out << "\n";
-
- // timer names
- out << "Time " << spaces
- << " Time " << spaces
- << " Imblnc " << spaces
- << " " << setw(tnw) << left << "Timer" << right;
- for (size_t i=0; i<names.size(); ++i) {
- out << " " << setw(vw) << names[i].first.substr(0,vw);
- }
- out << "\n";
-
- // timer units
- out << "percent " << spaces
- << " secs " << spaces
- << " percent" << spaces
- << " " << setw(tnw) << " ";
- for (size_t i=0; i<names.size(); ++i) {
- out << " " << setw(vw) << names[i].second.substr(0,vw);
- }
- out << "\n";
-
- out << "--------" << hyphens
- << "--------" << hyphens
- << "--------" << hyphens
- << "--" << string(tnw, '-');
- for (size_t i=0; i<values.size(); ++i) {
- out << "--" << string(vw, '-');
- }
- out << "\n";
- }
-
- // Print this timer value
- out << fixed << setw(pcw) << setprecision(precision)
- << 100.0 * tavg / total << "%"
- << " " << fixed << setw(tw) << setprecision(precision) << tavg
- << " " << fixed << setw(pcw) << setprecision(precision)
- << 100.0 * (1.0 - tavg / tmax) << "%"
- << " " << space << setw(max(size_t(0), tnw - space.length())) << left
- << d_name.substr(0, max(size_t(10), tnw - space.length())) << right;
- for (size_t i=0; i<values.size(); ++i) {
- out.unsetf(ios_base::floatfield);
- out << " " << setw(vw) << setprecision(vw-5) << values[i];
- }
- out << "\n";
-
- // TODO: Don't call getGlobalTime for all timers separately.
- // Instead, call a single function that takes a snapshot of all
- // timers, and reduces these snapshots to average and maximum.
- // While printing, access these snapshots.
-
- //double children_time = 0;
- double children_tavg = 0.0;
- bool printed_children = false;
-
- // Recursively print the children
- for(map<string,TimerNode*>::iterator iter = d_children.begin();
- iter != d_children.end(); iter++)
- {
- const string timername = iter->first;
- const string root_timername =
- CarpetLib::broadcast_string(dist::comm(), 0, timername);
- if (timername != root_timername) {
- CCTK_VError(__LINE__, __FILE__, CCTK_THORNSTRING,
- "Timers are inconsistent across processes: root process expects timer %s, this process has timer %s instead",
- root_timername.c_str(), timername.c_str());
- }
- double child_avg, child_max;
- iter->second->getGlobalTime(child_avg, child_max);
- if (child_max * 100.0 / total > threshold) {
- iter->second->print(out,total,level+1,threshold,precision);
- printed_children = true;
- }
- //children_time += iter->second->getTime();
- children_tavg += child_avg;
- }
- {
- const string timername = "[done]";
- const string root_timername =
- CarpetLib::broadcast_string(dist::comm(), 0, timername);
- if (timername != root_timername) {
- CCTK_VError(__LINE__, __FILE__, CCTK_THORNSTRING,
- "Timers are inconsistent across processes: root process expects timer %s, this process has timer %s instead",
- root_timername.c_str(), timername.c_str());
- }
- }
-
- if (d_children.size() > 0 && printed_children) {
- //const double untimed = t - children_time;
- const double untimed = tavg - children_tavg;
-
- if (100.0 * untimed / total > threshold) {
- // Print the untimed portion
- out << fixed << setw(pcw) << setprecision(1)
- << 100.0 * untimed / total << "%"
- << " " << fixed << setw(tw) << setprecision(1) << untimed
- << " "
- << " | " << space << "untimed" << "\n";
- }
- }
- out.precision (oldprecision);
- out.setf (oldflags);
-
- if (level == 0) {
- out << "--------" << hyphens
- << "--------" << hyphens
- << "--------" << hyphens
- << "--" << string(tnw, '-');
- for (size_t i=0; i<values.size(); ++i) {
- out << "--" << string(vw, '-');
- }
- out << "\n";
- }
- }
-
- void TimerNode::outputXML(const string &out_dir, int proc)
- {
- ostringstream filenamebuf;
- filenamebuf << out_dir << "/timertree." << proc << ".xml";
- string filenamestr = filenamebuf.str();
- const char * filename = filenamestr.c_str();
- ofstream file;
- file.open (filename, ios::out | ios::trunc);
-
- printXML(file,0);
-
- file.close();
- assert (file.good());
- }
-
- /// Print this node and its children as an XML file
- void TimerNode::printXML(ostream& out, int level)
- {
- string space;
-
- // Compute the level of indentation for this node
- for(int i=0;i<level;i++)
- space=space+" ";
-
- out << space << "<timer name = " << "\"" << escapeForXML(d_name) << "\"> ";
- out << getTime() << " ";
-
- // For compactness, only use multiple lines if there are children
- if (d_children.size() != 0)
- {
- out << "\n";
-
- // Recursively print the children
- for(map<string,TimerNode*>::iterator iter=d_children.begin();iter!=d_children.end();++iter)
- iter->second->printXML(out,level+1);
- out << space;
- }
-
- out << "</timer>" << "\n";
- }
-
- /// Make a string suitable for inclusion in an XML file
- string TimerNode::escapeForXML(const string &s) const
- {
- // XML attributes cannot contain unescaped angle-brackets. As a
- // simple solution to this, replace them with | characters.
-
- string s2(s);
- using std::string;
- using std::replace;
-
- replace(s2.begin(), s2.end(), '<', '|');
- replace(s2.begin(), s2.end(), '>', '|');
- replace(s2.begin(), s2.end(), '&', '|');
-
- return s2;
- }
-}
diff --git a/Carpet/Carpet/src/TimerNode.hh b/Carpet/Carpet/src/TimerNode.hh
deleted file mode 100644
index 5852e8379..000000000
--- a/Carpet/Carpet/src/TimerNode.hh
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *
- * The MIT License
- *
- * Copyright (c) 1997-2010 Center for the Simulation of Accidental Fires and
- * Explosions (CSAFE), and Scientific Computing and Imaging Institute (SCI),
- * University of Utah.
- *
- * License for the specific language governing rights and limitations under
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * */
-
-/* This class was originally written by Justin Luitjens and
- subsequently integrated with Cactus/Carpet by Ian Hinder and
- heavily modified. */
-
-#ifndef TIMERNODE_HH
-#define TIMERNODE_HH
-
-#include <cassert>
-#include <iostream>
-#include <map>
-#include <ostream>
-#include <string>
-#include <utility>
-
-#include "CactusTimer.hh"
-
-namespace Carpet {
-
-using namespace std;
-
-class TimerNode;
-
-class TimerTree
-{
-public:
- TimerTree()
- {
- root = 0;
- current = 0;
- }
- TimerNode *root;
- TimerNode *current;
-};
-
-/**
-
-The TimerNode class implements a tree structure where each node
-represents a timer, implemented as a CactusTimer. Each node of the
-tree can have zero of more children, where the names of the child
-nodes are unique within a single parent, but not necessarily unique
-within the entire tree. A tree formed of TimerNode objects represents
-the execution profile of the program, inasmuch as it is instrumented
-by timers.
-
-Child nodes of a given name are accessed using the getChildTimer
-method, where a node is created with the given name if none exists
-already. This ensures that the names of the child timers are unique.
-
-*/
-
-class TimerNode
-{
-public:
- TimerNode(TimerTree *root, string name);
- ~TimerNode();
-
- void instantiate();
- void start();
- void stop();
-
- string getName() const;
- string pathName() const;
-
- // Finds the child timer that matches the name provided. If it is
- // not found then that timer is allocated.
- TimerNode* getChildTimer(string name);
-
- double getTime();
- void getGlobalTime(double& avg, double &max);
- vector<pair<string, string> > getAllTimerNames() const;
- vector<double> getAllTimerValues();
- bool isRunning() const;
-
- void print(ostream& out, double total, int level=0, double threshold=0.0, int precision=1);
- void printXML(ostream& out, int level=0);
- void outputXML(const string &out_dir, int proc);
-
-private:
- string escapeForXML(const string &s) const;
-
- string d_name;
- std::map<string,TimerNode*> d_children;
- TimerNode *d_parent;
- TimerTree *d_tree;
- bool d_running;
- CactusTimer *timer;
-};
-}
-
-#endif // TIMERNODE_HH
diff --git a/Carpet/Carpet/src/TimerSet.cc b/Carpet/Carpet/src/TimerSet.cc
deleted file mode 100644
index 20b81caa6..000000000
--- a/Carpet/Carpet/src/TimerSet.cc
+++ /dev/null
@@ -1,190 +0,0 @@
-#include <cassert>
-#include <cstdio>
-#include <cstring>
-#include <list>
-
-#include <cctk.h>
-#include <cctk_Parameters.h>
-#include <util_String.h>
-
-#if HAVE_UNISTD_H
-# include <fcntl.h>
-# include <unistd.h>
-#endif
-
-#include <defs.hh>
-
-#include <Timers.hh>
-#include <CactusTimer.hh>
-#include <TimerNode.hh>
-#include <TimerSet.hh>
-
-namespace Carpet {
-
- using namespace std;
-
- // A global timer set
- TimerSet timerSet;
-
- // Add a timer
- void
- TimerSet::add (CactusTimer * const timer)
- {
- timers.push_back (timer);
- }
-
- // Remove a timer
- void
- TimerSet::remove (CactusTimer * const timer)
- {
- timers.remove (timer);
- }
-
- // Print all timer names
- void
- TimerSet::printNames ()
- const
- {
- printf ("Timer names:\n");
- int n = 0;
- for (list <CactusTimer *>::const_iterator
- itimer = timers.begin(); itimer != timers.end(); ++ itimer)
- {
- printf (" [%4d] %s\n", n, (* itimer)->name().c_str());
- ++ n;
- }
- }
-
- // Print all timer data
- void
- TimerSet::printData ()
- {
- for (list <CactusTimer *>::const_iterator
- itimer = timers.begin(); itimer != timers.end(); ++ itimer)
- {
- (* itimer)->printData ();
- }
- printf ("\n");
- }
-
- // Print all timer data
- void
- TimerSet::writeData (cGH const * const cctkGH,
- char const * const filename)
- {
- int const oldfd = redirect (cctkGH, filename);
-#if 0
- printf ("********************************************************************************\n");
-#endif
- printf ("# Carpet timing information at iteration %d time %g:\n",
- cctkGH->cctk_iteration, (double) cctkGH->cctk_time);
- timerSet.printData ();
- unredirect (oldfd);
- }
-
- // If filename is not empty, then redirect stdout to a file
- int
- TimerSet::redirect (cGH const * const cctkGH,
- char const * const filename)
- {
- DECLARE_CCTK_PARAMETERS;
-
- if (CCTK_EQUALS (filename, "")) {
- return -1;
- }
-
-#ifndef HAVE_UNISTD_H
- CCTK_WARN (1, "Cannot redirect timer output to a file; the operating system does not support this");
- return -1;
-#else
-
- int const myproc = CCTK_MyProc (cctkGH);
- char fullname [10000];
- Util_snprintf (fullname, sizeof fullname,
- "%s/%s.%04d.txt", out_dir, filename, myproc);
-
- int flags = O_WRONLY | O_CREAT | O_APPEND; // append
- static bool first_time = true;
- if (first_time) {
- first_time = false;
- if (IO_TruncateOutputFiles (cctkGH)) {
- flags = O_WRONLY | O_CREAT | O_TRUNC; // truncate
- }
- }
-
- // Temporarily redirect stdout
- fflush (stdout);
- int const oldfd = dup (1); // fd 1 is stdout
- int const mode = 0644; // rw-r--r--, or a+r u+w
- int const fdfile = open (fullname, flags, mode);
- if (fdfile < 0) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Could not open timer output file \"%s\"", fullname);
- close (oldfd);
- return -1;
- }
- // close (1);
- // int const fd = dup (fdfile); // dup to 1, i.e., stdout again
- int const fd = dup2 (fdfile, 1); // dup to 1, i.e., stdout again
- assert (fd == 1);
- close (fdfile);
- return oldfd;
-#endif
- }
-
- // Redirect stdout back
- void
- TimerSet::unredirect (int const oldfd)
- {
- if (oldfd < 0) return;
-
-#ifdef HAVE_UNISTD_H
- fflush (stdout);
- // close (1);
- // int const fd = dup (oldfd);
- int const fd = dup2 (oldfd, 1);
- if (not (fd == 1)) {
- fprintf(stderr, "oldfd=%d fd=%d\n", oldfd, fd);
- }
- assert (fd == 1);
- close (oldfd);
-#endif
- }
-
-
- /// Reduce each timers in the set across all processes and update
- /// each timer with the reduction information.
- void TimerSet::reduce()
- {
- // Collect timer names that each process has
-
- // Construct union of all timer names, sort canonically and assign
- // integer identifiers
-
- // For each timer, identify which processes have that timer
-
- // Reduce the timer across all those processes (return to root proc only)
-
- serialise(cout);
- }
-
- ostream& TimerSet::serialise(ostream &os)
- {
- for (list <CactusTimer *>::const_iterator
- itimer = timers.begin(); itimer != timers.end(); ++ itimer)
- {
- (*itimer)->serialise(os);
- os << endl;
- }
- return os;
- }
-
-/*
-
-
-Each process has a list of (string,real) pairs. I want to return a
-list of these where the reals have been reduced using a reduction
-operator. Not all processes have the same strings present.
- */
-
-} // namespace Carpet
diff --git a/Carpet/Carpet/src/TimerSet.hh b/Carpet/Carpet/src/TimerSet.hh
deleted file mode 100644
index b2d2fdd93..000000000
--- a/Carpet/Carpet/src/TimerSet.hh
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef TIMERSET_HH
-#define TIMERSET_HH
-
-#include <iostream>
-#include <list>
-
-#include <cctk.h>
-#include "CactusTimer.hh"
-
-//class Carpet::TimerSet;
-
-//ostream& operator <<(ostream &os, const Carpet::TimerSet &obj);
-
-namespace Carpet {
-
- class TimerSet;
- extern TimerSet timerSet;
-
- using namespace std;
-
- // A set of timers
- class TimerSet {
-
- list <CactusTimer *> timers;
-
- public:
-
- // Add a timer
- void
- add (CactusTimer * timer);
-
- // Remove a timer
- void
- remove (CactusTimer * timer);
-
- // Print all timer names
- void
- printNames ()
- const;
-
- // Print timer data
- void
- printData ();
-
- // Write all timer data
- static void writeData (cGH const * cctkGH, char const * filename);
-
- void reduce();
-
- ostream& serialise(ostream &os);
-
- private:
-
- // If filename is not empty, then redirect stdout to a file
- static
- int
- redirect (cGH const * cctkGH,
- char const * filename);
-
- // Redirect stdout back
- static
- void
- unredirect (int oldfd);
-
- }; // class TimerSet
-
-} // namespace Carpet
-
-#endif // TIMERSET_HH
diff --git a/Carpet/Carpet/src/Timers.cc b/Carpet/Carpet/src/Timers.cc
deleted file mode 100644
index f783c92de..000000000
--- a/Carpet/Carpet/src/Timers.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-#include <cassert>
-#include <cstdio>
-#include <cstring>
-#include <list>
-
-#include <cctk.h>
-#include <cctk_Parameters.h>
-#include <util_String.h>
-
-#if HAVE_UNISTD_H
-# include <fcntl.h>
-# include <unistd.h>
-#endif
-
-#include <defs.hh>
-
-#include <Timers.hh>
-#include <TimerNode.hh>
-#include "variables.hh"
-
-
-namespace Carpet {
-
- using namespace std;
-
-/*********************************************************************
- Timer
- *********************************************************************/
-
- /// Create a timer with a given name, but do not start it, and do
- /// not associate it with a point in the timer hierarchy.
- Timer::Timer (const string &name_p) : d_name(name_p)
- {
- d_tree = &main_timer_tree;
- }
-
- Timer::Timer (const string &name_p, TimerTree *tree) : d_name(name_p), d_tree(tree)
- {
- }
-
- /// Destroy a timer
- Timer::~Timer ()
- {
- }
-
- /// Insert the timer into the tree of timers as a child of the most
- /// recently started timer that has not been stopped. Don't start
- /// the timer. This routine ensures a timer is created even if it is
- /// never started.
- void Timer::instantiate ()
- {
- TimerNode *current_timer = d_tree->current;
- assert(current_timer);
- current_timer->getChildTimer(name())->instantiate();
- }
-
- /// Start the timer and insert it into the tree of timers as a child
- /// of the most recently started timer that has not been stopped.
- void Timer::start ()
- {
- TimerNode *current_timer = d_tree->current;
- if (not d_tree->root) return; // do nothing if there is no root
- assert(current_timer);
- current_timer->getChildTimer(name())->start();
- }
-
- /// Stop the timer - it must be the most recently started timer
- void Timer::stop ()
- {
- TimerNode *current = d_tree->current;
- if (not d_tree->root) return; // do nothing if there is no root
- if (current->getName() != name())
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Trying to stop enclosing timer '%s' before enclosed time '%s'",
- name().c_str(), current->getName().c_str());
- current->stop();
- }
-
- /// Return the name of the timer
- string Timer::name () const
- {
- return d_name;
- }
-
- /// Return the current time of the timer as a double
- double Timer::getTime ()
- {
- return d_tree->current->getTime();
- }
-} // namespace Carpet
diff --git a/Carpet/Carpet/src/Timers.hh b/Carpet/Carpet/src/Timers.hh
deleted file mode 100644
index fdd31773f..000000000
--- a/Carpet/Carpet/src/Timers.hh
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef TIMERS_HH
-#define TIMERS_HH
-
-#include <iostream>
-#include <list>
-
-#include <cctk.h>
-
-
-
-namespace Carpet {
-
- using namespace std;
-
-/**
-
-This class allows the user to instrument their code with named timers
-which can then be later queried to determine the amount of time spent
-in the code between "start" and "end" calls. The sequence of start
-and end calls of different timers determines a dynamical hierarchical
-tree structure implemented by the TimerNode class.
-
-To use this class, create a timer object with a particular name:
-
- Timer timer("MyTimer")
-
-Now wrap the code to be timed with start() and stop() calls:
-
- timer.start()
-
- some code
-
- timer.stop()
-
-You can start and stop a timer multiple times. The timer will be
-created as a child of whatever timer is current (i.e. has been started
-and not stopped) at the time of the first start() call. Any timers
-which are started between the start() and stop(), whether or not they
-are in the same file, will be stored as children of this timer.
-
-Timer objects must be started and stopped in a non-overlapping manner.
-Specifically, a timer cannot be stopped if it is not the most recently
-started timer. Doing so will generate an error.
-
-Timer objects can be allocated as "static" or not - it does not matter.
-
-*/
- class TimerTree;
-
- class Timer {
-
- public:
-
- Timer (const string &name);
- Timer (const string &name, TimerTree *tree);
- ~Timer ();
-
- void instantiate ();
- void start ();
- void stop ();
- string name () const;
- double getTime();
-
- private:
-
- string d_name;
- TimerTree *d_tree;
- };
-
- // Macros for using timers in a convenient manner
-
-#define TIMING_BEGIN(name) \
- do { \
- static Carpet::Timer timer (name); \
- timer.start(); \
- {
-#define TIMING_END \
- } \
- timer.stop(); \
- } while (0)
-
-} // namespace Carpet
-
-#endif // TIMERS_HH
diff --git a/Carpet/Carpet/src/make.code.defn b/Carpet/Carpet/src/make.code.defn
index 30f012897..f28c61427 100644
--- a/Carpet/Carpet/src/make.code.defn
+++ b/Carpet/Carpet/src/make.code.defn
@@ -1,8 +1,7 @@
# Main make.code.defn file for thorn Carpet -*-Makefile-*-
# Source files in this directory
-SRCS = CactusTimer.cc \
- CallFunction.cc \
+SRCS = CallFunction.cc \
CarpetBasegrid.cc \
CarpetParamCheck.cc \
CarpetStartup.cc \
@@ -21,9 +20,6 @@ SRCS = CactusTimer.cc \
SetupGH.cc \
Shutdown.cc \
Storage.cc \
- Timers.cc \
- TimerNode.cc \
- TimerSet.cc \
Timing.cc \
UnusedMask.cc \
adler32.cc \
diff --git a/Carpet/Carpet/src/modes.cc b/Carpet/Carpet/src/modes.cc
index 9af0039eb..5bd57e758 100644
--- a/Carpet/Carpet/src/modes.cc
+++ b/Carpet/Carpet/src/modes.cc
@@ -9,6 +9,8 @@
#include <cctk.h>
#include <cctk_Parameters.h>
+#include <Timer.hh>
+
#include <cacheinfo.hh>
#include <defs.hh>
#include <gdata.hh>
@@ -16,7 +18,7 @@
#include <carpet.hh>
-#include "Timers.hh"
+
namespace Carpet {
@@ -86,9 +88,9 @@ namespace Carpet {
assert (ml>=0 and ml<mglevels);
Checkpoint ("Entering global mode");
- Timer ftimer("enter_global_mode", &mode_timer_tree);
+ static Timers::Timer ftimer("enter_global_mode", 1);
ftimer.start();
-
+
mglevel = ml;
mglevelfact = ipow(mgfact, mglevel);
// TODO: this could also just be "mglevel" instead
@@ -198,12 +200,10 @@ namespace Carpet {
} // if grouptype
} // for group
-
+
ftimer.stop();
-
- ostringstream mode_s;
- mode_s << "global mode";
- Timer timer(mode_s.str(), &mode_timer_tree);
+
+ Timers::Timer timer("global mode", 1);
timer.start();
assert (is_global_mode());
@@ -218,18 +218,13 @@ namespace Carpet {
if (mglevel == -1) return; // early return
Checkpoint ("Leaving global mode");
-
- if (mode_timer_tree.current != mode_timer_tree.root)
- {
- ostringstream mode_s;
- mode_s << "global mode";
- Timer timer(mode_s.str(), &mode_timer_tree);
- timer.stop();
- }
-
- Timer ftimer("leave_global_mode", &mode_timer_tree);
+
+ Timers::Timer timer("global mode", 1);
+ timer.stop();
+
+ Timers::Timer ftimer("leave_global_mode", 1);
ftimer.start();
-
+
// Unset time delta
if (not adaptive_stepsize) {
cctkGH->cctk_delta_time = 0.0;
@@ -295,7 +290,7 @@ namespace Carpet {
mglevel = -1;
mglevelfact = -deadbeef;
cctkGH->cctk_convlevel = -deadbeef;
-
+
ftimer.stop();
assert (is_meta_mode());
@@ -313,9 +308,9 @@ namespace Carpet {
assert (rl>=0 and rl<reflevels);
Checkpoint ("Entering level mode");
- Timer ftimer("enter_level_mode", &mode_timer_tree);
+ static Timers::Timer ftimer("enter_level_mode", 1);
ftimer.start();
-
+
// Set mode
#ifdef HAVE_CGH_CCTK_MODE
cctkGH->cctk_mode = CCTK_MODE_LEVEL;
@@ -349,12 +344,12 @@ namespace Carpet {
} else {
tt->set_time (mglevel, reflevel, timelevel, cctkGH->cctk_time);
}
-
+
ftimer.stop();
-
+
ostringstream mode_s;
- mode_s << "level(" << rl << ")";
- Timer timer(mode_s.str(), &mode_timer_tree);
+ mode_s << "level(" << reflevel << ")";
+ Timers::Timer timer(mode_s.str(), 1);
timer.start();
assert (is_level_mode());
@@ -370,15 +365,12 @@ namespace Carpet {
Checkpoint ("Leaving level mode");
- if (mode_timer_tree.current != mode_timer_tree.root)
- {
- ostringstream mode_s;
- mode_s << "level(" << reflevel << ")";
- Timer timer(mode_s.str(), &mode_timer_tree);
- timer.stop();
- }
-
- Timer ftimer("leave_level_mode", &mode_timer_tree);
+ ostringstream mode_s;
+ mode_s << "level(" << reflevel << ")";
+ Timers::Timer timer(mode_s.str(), 1);
+ timer.stop();
+
+ static Timers::Timer ftimer("leave_level_mode", 1);
ftimer.start();
CCTK_INT const deadbeef = get_deadbeef();
@@ -440,7 +432,7 @@ namespace Carpet {
or grouptype == CCTK_GF);
Checkpoint ("Entering singlemap mode");
- Timer ftimer("enter_singlemap_mode", &mode_timer_tree);
+ static Timers::Timer ftimer("enter_singlemap_mode", 1);
ftimer.start();
// Set mode
@@ -486,15 +478,14 @@ namespace Carpet {
} // if mc_grouptype
ftimer.stop();
-
- if (include_maps_in_mode_timer_tree)
- {
+
+ if (include_maps_in_mode_timer_tree) {
ostringstream mode_s;
mode_s << "map(" << map << ")";
- Timer timer(mode_s.str(), &mode_timer_tree);
+ Timers::Timer timer(mode_s.str(), 1);
timer.start();
}
-
+
assert (is_singlemap_mode());
}
@@ -508,15 +499,14 @@ namespace Carpet {
Checkpoint ("Leaving singlemap mode");
- if (mode_timer_tree.current != mode_timer_tree.root && include_maps_in_mode_timer_tree)
- {
+ if (include_maps_in_mode_timer_tree) {
ostringstream mode_s;
mode_s << "map(" << map << ")";
- Timer timer(mode_s.str(), &mode_timer_tree);
+ Timers::Timer timer(mode_s.str(), 1);
timer.stop();
}
-
- Timer ftimer("leave_singlemap_mode", &mode_timer_tree);
+
+ static Timers::Timer ftimer("leave_singlemap_mode", 1);
ftimer.start();
assert (mc_grouptype == CCTK_SCALAR or mc_grouptype == CCTK_ARRAY
@@ -566,7 +556,7 @@ namespace Carpet {
carpetGH.map = map = -1;
ftimer.stop();
-
+
assert (is_level_mode());
}
@@ -589,7 +579,7 @@ namespace Carpet {
}
Checkpoint ("Entering local mode");
- Timer ftimer("enter_local_mode", &mode_timer_tree);
+ static Timers::Timer ftimer("enter_local_mode", 1);
ftimer.start();
// Set mode
@@ -714,11 +704,8 @@ namespace Carpet {
ftimer.stop();
- if (include_local_mode_in_mode_timer_tree)
- {
- ostringstream mode_s;
- mode_s << "local";
- Timer timer(mode_s.str(), &mode_timer_tree);
+ if (include_local_mode_in_mode_timer_tree) {
+ Timers::Timer timer("local", 1);
timer.start();
}
@@ -735,17 +722,14 @@ namespace Carpet {
Checkpoint ("Leaving local mode");
- if (mode_timer_tree.current != mode_timer_tree.root && include_local_mode_in_mode_timer_tree)
- {
- ostringstream mode_s;
- mode_s << "local";
- Timer timer(mode_s.str(), &mode_timer_tree);
+ if (include_local_mode_in_mode_timer_tree) {
+ Timers::Timer timer("local", 1);
timer.stop();
}
-
- Timer ftimer("leave_local_mode", &mode_timer_tree);
+
+ static Timers::Timer ftimer("leave_local_mode", 1);
ftimer.start();
-
+
if (mc_grouptype == CCTK_GF) {
CCTK_INT const deadbeef = get_deadbeef();
@@ -810,7 +794,7 @@ namespace Carpet {
local_component = -1;
ftimer.stop();
-
+
assert (is_singlemap_mode());
}
diff --git a/Carpet/Carpet/src/variables.cc b/Carpet/Carpet/src/variables.cc
index 7351e4073..a75323ed9 100644
--- a/Carpet/Carpet/src/variables.cc
+++ b/Carpet/Carpet/src/variables.cc
@@ -26,9 +26,6 @@ namespace Carpet {
// Maximum refinement factors on finest possible grid
int maxtimereflevelfact;
vect<int,dim> maxspacereflevelfact;
-
- TimerTree main_timer_tree;
- TimerTree mode_timer_tree;
// Base multigrid level
int basemglevel;
diff --git a/Carpet/Carpet/src/variables.hh b/Carpet/Carpet/src/variables.hh
index c8eecaaf1..235874ada 100644
--- a/Carpet/Carpet/src/variables.hh
+++ b/Carpet/Carpet/src/variables.hh
@@ -32,7 +32,7 @@
#include <vect.hh>
#include "carpet_public.h"
-#include "TimerNode.hh"
+
namespace Carpet {
@@ -93,9 +93,6 @@ namespace Carpet {
// Current refinement factors
extern int timereflevelfact;
extern vect<int,dim> spacereflevelfact;
-
- extern TimerTree main_timer_tree;
- extern TimerTree mode_timer_tree;
// Current multigrid factor
extern int mglevelfact;