aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2011-06-02 11:13:18 +0200
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 18:26:31 +0000
commit354e98350a75316f2976b7ccdd43938797485a7c (patch)
tree949469c4e5735a15f0edd26d557387ab28cb3e0a /Carpet/Carpet
parent26ee29ba4a30a2111bf0e130b916a657ba139a97 (diff)
Adapt Carpet to hierarchical timers
Specifically, remove any hierarchy information that has been added to the name of timers, as well as any code for creating timers dynamically, as these are now unnecessary. Additionally, time some previously-untimed parts of the code and make timer names in some places more consistent.
Diffstat (limited to 'Carpet/Carpet')
-rw-r--r--Carpet/Carpet/src/CallFunction.cc26
-rw-r--r--Carpet/Carpet/src/Checksum.cc6
-rw-r--r--Carpet/Carpet/src/Comm.cc4
-rw-r--r--Carpet/Carpet/src/Cycle.cc8
-rw-r--r--Carpet/Carpet/src/Evolve.cc49
-rw-r--r--Carpet/Carpet/src/Initialise.cc53
-rw-r--r--Carpet/Carpet/src/OutputGH.cc3
-rw-r--r--Carpet/Carpet/src/Poison.cc9
-rw-r--r--Carpet/Carpet/src/Recompose.cc12
-rw-r--r--Carpet/Carpet/src/SetupGH.cc12
10 files changed, 77 insertions, 105 deletions
diff --git a/Carpet/Carpet/src/CallFunction.cc b/Carpet/Carpet/src/CallFunction.cc
index 8cff27927..53a3e80c0 100644
--- a/Carpet/Carpet/src/CallFunction.cc
+++ b/Carpet/Carpet/src/CallFunction.cc
@@ -41,8 +41,8 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
static Timer total_timer ("CallFunction");
- static Timer user_timer ("CallFunction::thorns");
- static Timer sync_timer ("CallFunction::syncs");
+ static Timer user_timer ("thorns");
+ static Timer sync_timer ("syncs");
total_timer.start();
@@ -321,27 +321,7 @@ namespace Carpet {
attribute->thorn, attribute->routine);
int const skip = CallBeforeRoutines (cctkGH, function, attribute, data);
if (not skip) {
-
- typedef std::map <string, Timer *> timers_t;
- static timers_t * timersp = NULL;
- if (not timersp) timersp = new timers_t;
- timers_t & timers = * timersp;
-
- // Obtain timer, creating a new one if it does not yet exist
- ostringstream timernamebuf;
- timernamebuf << "CallFunction/"
- << attribute->where << "::" << attribute->routine;
- string const timername = timernamebuf.str();
- timers_t::iterator ti = timers.find (timername);
- if (ti == timers.end()) {
- pair <string, Timer *> const
- newtimer (timername, new Timer (timername.c_str()));
- ti = timers.insert(newtimer).first;
- // It is possible to find and insert with the same function
- // call, but this makes the code significantly more
- // complicated
- }
- Timer & timer = * ti->second;
+ Timer timer(attribute->routine);
// Save the time step size
CCTK_REAL const saved_cctk_delta_time = cctkGH->cctk_delta_time;
diff --git a/Carpet/Carpet/src/Checksum.cc b/Carpet/Carpet/src/Checksum.cc
index 139ba1555..877b1d209 100644
--- a/Carpet/Carpet/src/Checksum.cc
+++ b/Carpet/Carpet/src/Checksum.cc
@@ -10,7 +10,7 @@
#include <gh.hh>
#include <carpet.hh>
-
+#include "Timers.hh"
namespace Carpet {
@@ -67,6 +67,9 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
if (! checksum_timelevels) return;
+
+ Timer timer("CalculateChecksums");
+ timer.start();
Checkpoint ("CalculateChecksums");
@@ -142,6 +145,7 @@ namespace Carpet {
} // if storage
} // for group
+ timer.stop();
}
diff --git a/Carpet/Carpet/src/Comm.cc b/Carpet/Carpet/src/Comm.cc
index 6c7521740..14c244604 100644
--- a/Carpet/Carpet/src/Comm.cc
+++ b/Carpet/Carpet/src/Comm.cc
@@ -135,7 +135,7 @@ namespace Carpet {
// prolongate boundaries
bool const local_do_prolongate = do_prolongate and not do_taper;
if (local_do_prolongate) {
- static Timer timer ("Evolve::Prolongate");
+ static Timer timer ("Prolongate");
timer.start();
ProlongateGroupBoundaries (cctkGH, goodgroups);
timer.stop();
@@ -152,7 +152,7 @@ namespace Carpet {
// synchronise ghostzones
if (sync_during_time_integration or local_do_prolongate) {
- static Timer timer ("Evolve::Sync");
+ static Timer timer ("Sync");
timer.start();
SyncGroups (cctkGH, goodgroups);
timer.stop();
diff --git a/Carpet/Carpet/src/Cycle.cc b/Carpet/Carpet/src/Cycle.cc
index 566870cba..89be14882 100644
--- a/Carpet/Carpet/src/Cycle.cc
+++ b/Carpet/Carpet/src/Cycle.cc
@@ -8,7 +8,7 @@
#include <gh.hh>
#include <carpet.hh>
-
+#include "Timers.hh"
namespace Carpet {
@@ -20,7 +20,10 @@ namespace Carpet {
void CycleTimeLevels (cGH* const cctkGH)
{
DECLARE_CCTK_PARAMETERS;
-
+
+ Timer timer("CycleTimeLevels");
+ timer.start();
+
Checkpoint ("CycleTimeLevels");
assert (is_level_mode());
@@ -100,6 +103,7 @@ namespace Carpet {
CCTK_VWarn (CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING,
"Errors in %d groups detected; aborting", errors);
}
+ timer.stop();
}
diff --git a/Carpet/Carpet/src/Evolve.cc b/Carpet/Carpet/src/Evolve.cc
index 06a598ca0..a9034f774 100644
--- a/Carpet/Carpet/src/Evolve.cc
+++ b/Carpet/Carpet/src/Evolve.cc
@@ -79,6 +79,8 @@ namespace Carpet {
// Print timer values
{
+ 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
@@ -95,10 +97,13 @@ namespace Carpet {
TimerNode *et = rt->getChildTimer("Evolve");
et->print(cout, et->getTime(), 0, 1.0);
}
+ timer.stop();
}
// Ensure that all levels have consistent times
{
+ Timer timer("CheckLevelTimes");
+ timer.start();
CCTK_REAL const eps = 1.0e-12;
assert (abs (cctkGH->cctk_time - global_time) <= eps * global_time);
for (int ml=0; ml<mglevels; ++ml) {
@@ -113,6 +118,7 @@ namespace Carpet {
}
}
}
+ timer.stop();
}
} // end main loop
@@ -130,7 +136,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- static Timer timer ("Evolve::do_terminate");
+ static Timer timer ("DoTerminate");
timer.start();
bool term;
@@ -214,7 +220,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- static Timer timer ("Evolve::AdvanceTime");
+ static Timer timer ("AdvanceTime");
timer.start();
Checkpoint ("AdvanceTime");
@@ -248,7 +254,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Evolve::CallRegrid";
+ char const * const where = "CallRegrid";
static Timer timer (where);
timer.start();
@@ -351,7 +357,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Evolve::CallEvol";
+ char const * const where = "CallEvol";
static Timer timer (where);
timer.start();
@@ -438,7 +444,7 @@ namespace Carpet {
CallRestrict (cGH * const cctkGH)
{
char const * const where = "Evolve::CallRestrict";
- static Timer timer (where);
+ static Timer timer ("CallRestrict");
timer.start();
for (int ml=mglevels-1; ml>=0; --ml) {
@@ -501,7 +507,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Evolve::CallAnalysis";
+ char const * const where = "CallAnalysis";
static Timer timer (where);
timer.start();
@@ -632,29 +638,7 @@ namespace Carpet {
void ScheduleTraverse (char const * const where, char const * const name,
cGH * const cctkGH)
{
- // Obtain the set of timers, creating it explicitly if it does not
- // yet exist
- typedef std::map <string, Timer *> timers_t;
- // static timers_t timers;
- static timers_t * timersp = NULL;
- if (not timersp) timersp = new timers_t;
- timers_t & timers = * timersp;
-
- // Obtain timer, creating a new one if it does not yet exist
- // This is no longer necessary with the new timer implementation
- ostringstream timernamebuf;
- timernamebuf << where << "::" << name;
- string const timername = timernamebuf.str();
- timers_t::iterator ti = timers.find (timername);
- if (ti == timers.end()) {
- pair <string, Timer *> const
- newtimer (timername, new Timer (timername.c_str()));
- ti = timers.insert(newtimer).first;
- // It is possible to find and insert with the same function
- // call, but this makes the code significantly more complicated
- }
- Timer & timer = * ti->second;
-
+ Timer timer(name);
timer.start();
ostringstream infobuf;
infobuf << "Scheduling " << name;
@@ -666,14 +650,7 @@ namespace Carpet {
void OutputGH (char const * const where, cGH * const cctkGH)
{
- ostringstream buf;
- buf << where << "::OutputGH";
- string const timername = buf.str();
- static Timer timer (timername.c_str());
-
- timer.start();
CCTK_OutputGH (cctkGH);
- timer.stop();
}
} // namespace Carpet
diff --git a/Carpet/Carpet/src/Initialise.cc b/Carpet/Carpet/src/Initialise.cc
index 3ff57aa4e..35fe88a6b 100644
--- a/Carpet/Carpet/src/Initialise.cc
+++ b/Carpet/Carpet/src/Initialise.cc
@@ -158,7 +158,7 @@ namespace Carpet {
void
CallSetup (cGH * const cctkGH)
{
- char const * const where = "Initialise::CallSetup";
+ char const * const where = "CallSetup";
static Timer timer (where);
timer.start();
@@ -199,7 +199,7 @@ namespace Carpet {
void
CallRecoverVariables (cGH * const cctkGH)
{
- char const * const where = "Initialise::CallRecoverVariables";
+ char const * const where = "CallRecoverVariables";
static Timer timer (where);
timer.start();
@@ -266,7 +266,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Initialise::CallPostRecoverVariables";
+ char const * const where = "CallPostRecoverVariables";
static Timer timer (where);
timer.start();
@@ -316,7 +316,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Initialise::CallInitial";
+ char const * const where = "CallInitial";
static Timer timer (where);
timer.start();
@@ -419,7 +419,7 @@ namespace Carpet {
CallRestrict (cGH * const cctkGH)
{
char const * const where = "Initialise::CallRestrict";
- static Timer timer (where);
+ static Timer timer ("CallRestrict");
timer.start();
for (int rl=reflevels-2; rl>=0; --rl) {
@@ -454,7 +454,7 @@ namespace Carpet {
void
CallPostInitial (cGH * const cctkGH)
{
- char const * const where = "Initialise::CallPostInitial";
+ char const * const where = "CallPostInitial";
static Timer timer (where);
timer.start();
@@ -500,7 +500,7 @@ namespace Carpet {
void
CallAnalysis (cGH * const cctkGH)
{
- char const * const where = "Initialise::CallAnalysis";
+ char const * const where = "CallAnalysis";
static Timer timer (where);
timer.start();
@@ -706,7 +706,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Initialise::CallRegridRecoverMeta";
+ char const * const where = "CallRegridRecoverMeta";
static Timer timer (where);
timer.start();
@@ -796,7 +796,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Initialise::CallRegridRecoverLevel";
+ char const * const where = "CallRegridRecoverLevel";
static Timer timer (where);
timer.start();
@@ -892,7 +892,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Initialise::CallRegridInitialMeta";
+ char const * const where = "CallRegridInitialMeta";
static Timer timer (where);
timer.start();
@@ -957,7 +957,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Initialise::CallRegridInitialLevel";
+ char const * const where = "CallRegridInitialLevel";
static Timer timer (where);
timer.start();
@@ -1079,6 +1079,10 @@ namespace Carpet {
Waypoint ("Initialising three timelevels:");
+ char const * const where = "Initialise3TL";
+ static Timer timer (where);
+ timer.start();
+
#if 0
initialise_3tl_flip_timelevels (cctkGH);
initialise_3tl_evolve (cctkGH);
@@ -1096,7 +1100,9 @@ namespace Carpet {
initialise_3tl_recycle (cctkGH);
initialise_3tl_recycle (cctkGH);
initialise_3tl_flip_timelevels (cctkGH);
-
+
+ timer.stop();
+
Waypoint ("Finished initialising three timelevels");
}
@@ -1119,7 +1125,7 @@ namespace Carpet {
void
initialise_3tl_evolve (cGH * const cctkGH)
{
- char const * const where = "Initialise3TL::Evolve";
+ char const * const where = "Evolve";
static Timer timer (where);
timer.start();
@@ -1159,7 +1165,7 @@ namespace Carpet {
void
initialise_3tl_recycle (cGH * const cctkGH)
{
- char const * const where = "Initialise3TL::Recycle";
+ char const * const where = "Recycle";
static Timer timer (where);
timer.start();
@@ -1207,16 +1213,8 @@ namespace Carpet {
void ScheduleTraverse (char const * const where, char const * const name,
cGH * const cctkGH)
{
- ostringstream timernamebuf;
- timernamebuf << where << "::" << name;
- string const timername = timernamebuf.str();
- static std::map <string, Timer *> timers;
- Timer * & mapped = timers[timername];
- if (not mapped) {
- mapped = new Timer (timername.c_str());
- }
- Timer & timer = * mapped;
-
+ Timer timer(name);
+
timer.start();
ostringstream infobuf;
infobuf << "Scheduling " << name;
@@ -1228,14 +1226,7 @@ namespace Carpet {
void OutputGH (char const * const where, cGH * const cctkGH)
{
- ostringstream buf;
- buf << where << "::OutputGH";
- string const timername = buf.str();
- static Timer timer (timername.c_str());
-
- timer.start();
CCTK_OutputGH (cctkGH);
- timer.stop();
}
diff --git a/Carpet/Carpet/src/OutputGH.cc b/Carpet/Carpet/src/OutputGH.cc
index 52a877390..383c16fb5 100644
--- a/Carpet/Carpet/src/OutputGH.cc
+++ b/Carpet/Carpet/src/OutputGH.cc
@@ -44,8 +44,7 @@ namespace Carpet {
if (not timers.AT(handle)) {
ostringstream buf;
- buf << "OutputGH"
- << "::" << method->implementation
+ buf << method->implementation
<< "::" << method->name
<< " [" << handle << "]";
timers.AT(handle) = new Timer (buf.str().c_str());
diff --git a/Carpet/Carpet/src/Poison.cc b/Carpet/Carpet/src/Poison.cc
index 9adee4690..1846253f1 100644
--- a/Carpet/Carpet/src/Poison.cc
+++ b/Carpet/Carpet/src/Poison.cc
@@ -11,7 +11,7 @@
#include <typeprops.hh>
#include <carpet.hh>
-
+#include "Timers.hh"
namespace Carpet {
@@ -33,6 +33,9 @@ namespace Carpet {
if (not poison_new_timelevels) return;
+ Timer timer("Poison");
+ timer.start();
+
for (int group=0; group<CCTK_NumGroups(); ++group) {
if (CCTK_QueryGroupStorageI(cctkGH, group)) {
int const grouptype = CCTK_GroupTypeI (group);
@@ -45,6 +48,7 @@ namespace Carpet {
}
} // if has storage
} // for group
+ timer.stop();
}
@@ -145,6 +149,8 @@ namespace Carpet {
if (not check_for_poison) return;
Checkpoint ("PoisonCheck");
+ Timer timer("PoisonCheck");
+ timer.start();
for (int group=0; group<CCTK_NumGroups(); ++group) {
int const nvar = CCTK_NumVarsInGroupI(group);
@@ -256,6 +262,7 @@ namespace Carpet {
} // if has storage
} // for group
+ timer.stop();
}
} // namespace Carpet
diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc
index dfdeec847..8e4e53a27 100644
--- a/Carpet/Carpet/src/Recompose.cc
+++ b/Carpet/Carpet/src/Recompose.cc
@@ -90,7 +90,7 @@ namespace Carpet {
void
CheckRegions (gh::mregs const & regsss)
{
- char const * const where = "Carpet::CheckRegions";
+ char const * const where = "CheckRegions";
static Timer timer (where);
timer.start();
@@ -148,7 +148,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Carpet::Regrid";
+ char const * const where = "Regrid";
static Timer timer (where);
timer.start();
@@ -265,7 +265,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Carpet::RegridMap";
+ char const * const where = "RegridMap";
static Timer timer (where);
timer.start();
@@ -325,7 +325,7 @@ namespace Carpet {
{
DECLARE_CCTK_PARAMETERS;
- char const * const where = "Carpet::PostRegrid";
+ char const * const where = "PostRegrid";
static Timer timer (where);
timer.start();
@@ -380,7 +380,7 @@ namespace Carpet {
int const rl,
bool const do_init)
{
- char const * const where = "Carpet::Recompose";
+ char const * const where = "Recompose";
static Timer timer (where);
timer.start();
@@ -408,7 +408,7 @@ namespace Carpet {
RegridFree (cGH const * const cctkGH,
bool const do_init)
{
- char const * const where = "Carpet::RegridFree";
+ char const * const where = "RegridFree";
static Timer timer (where);
timer.start();
diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc
index c4d9074a8..8aed3e119 100644
--- a/Carpet/Carpet/src/SetupGH.cc
+++ b/Carpet/Carpet/src/SetupGH.cc
@@ -26,6 +26,7 @@
#include <vect.hh>
#include <carpet.hh>
+#include "Timers.hh"
@@ -275,6 +276,10 @@ namespace Carpet {
timelevel = 0;
// Say hello
+
+ Timer timer("CarpetStartup");
+ timer.start();
+
Waypoint ("Setting up the grid hierarchy");
// Check arguments:
@@ -317,7 +322,8 @@ namespace Carpet {
}
Waypoint ("Done with setting up the grid hierarchy");
-
+ timer.stop();
+
return & carpetGH;
}
@@ -543,10 +549,14 @@ namespace Carpet {
baseexts);
// Allocate grid hierarchy
+
+ Timer timer("AllocateGridHierarchy");
+ timer.start();
vhh.resize(maps);
vhh.AT(m) = new gh (spacereffacts, refcentering,
convergence_factor, mgcentering,
baseexts, nboundaryzones);
+ timer.stop();
}