diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-06-02 11:13:18 +0200 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 18:26:31 +0000 |
commit | 354e98350a75316f2976b7ccdd43938797485a7c (patch) | |
tree | 949469c4e5735a15f0edd26d557387ab28cb3e0a /Carpet/Carpet/src/Evolve.cc | |
parent | 26ee29ba4a30a2111bf0e130b916a657ba139a97 (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/src/Evolve.cc')
-rw-r--r-- | Carpet/Carpet/src/Evolve.cc | 49 |
1 files changed, 13 insertions, 36 deletions
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 |