From 354e98350a75316f2976b7ccdd43938797485a7c Mon Sep 17 00:00:00 2001 From: Ian Hinder Date: Thu, 2 Jun 2011 11:13:18 +0200 Subject: 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. --- Carpet/Carpet/src/Evolve.cc | 49 ++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) (limited to 'Carpet/Carpet/src/Evolve.cc') 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=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 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 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 -- cgit v1.2.3