diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2007-05-10 22:30:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2007-05-10 22:30:00 +0000 |
commit | 5770264f3f39f7bc8e17885fde99f8f859ab59fb (patch) | |
tree | 7ce51f4e9b90697d82e4747e2ebf5cf520aeedb3 /Carpet/Carpet/src/Evolve.cc | |
parent | 110af7bc6df61403e0159f79676b4092e9b7ac01 (diff) |
Carpet: Add timers measuring initialisation and I/O
darcs-hash:20070510223037-dae7b-115fc6391d2f18dc73e12774185b1d50f3618ab6.gz
Diffstat (limited to 'Carpet/Carpet/src/Evolve.cc')
-rw-r--r-- | Carpet/Carpet/src/Evolve.cc | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/Carpet/Carpet/src/Evolve.cc b/Carpet/Carpet/src/Evolve.cc index 15c63999a..9d5179083 100644 --- a/Carpet/Carpet/src/Evolve.cc +++ b/Carpet/Carpet/src/Evolve.cc @@ -1,6 +1,9 @@ #include <cassert> #include <cstdio> #include <cstdlib> +#include <map> +#include <string> +#include <sstream> #include <cctk.h> #include <cctk_Parameters.h> @@ -32,6 +35,10 @@ namespace Carpet { static void print_internal_data (); + static void ScheduleTraverse + (char const * where, char const * name, cGH * cctkGH); + static void OutputGH (char const * where, cGH * cctkGH); + int @@ -412,8 +419,9 @@ namespace Carpet { CallAnalysis (cGH * const cctkGH) { DECLARE_CCTK_PARAMETERS; - - static Timer timer ("Evolve::CallAnalysis"); + + char const * const where = "Evolve::CallAnalysis"; + static Timer timer (where); timer.start(); for (int ml=mglevels-1; ml>=0; --ml) { @@ -440,29 +448,24 @@ namespace Carpet { (do_meta_mode ? " (meta)" : "")); if (reflevel < reflevels-1) { - Checkpoint ("Scheduling POSTRESTRICT"); - CCTK_ScheduleTraverse ("CCTK_POSTRESTRICT", cctkGH, CallFunction); + ScheduleTraverse (where, "CCTK_POSTRESTRICT", cctkGH); } // Poststep - Checkpoint ("Scheduling POSTSTEP"); - CCTK_ScheduleTraverse ("CCTK_POSTSTEP", cctkGH, CallFunction); + ScheduleTraverse (where, "CCTK_POSTSTEP", cctkGH); // Checking PoisonCheck (cctkGH, currenttime); CalculateChecksums (cctkGH, currenttime); // Checkpoint - Checkpoint ("Scheduling CHECKPOINT"); - CCTK_ScheduleTraverse ("CCTK_CHECKPOINT", cctkGH, CallFunction); + ScheduleTraverse (where, "CCTK_CHECKPOINT", cctkGH); // Analysis - Checkpoint ("Scheduling ANALYSIS"); - CCTK_ScheduleTraverse ("CCTK_ANALYSIS", cctkGH, CallFunction); + ScheduleTraverse (where, "CCTK_ANALYSIS", cctkGH); // Output - Checkpoint ("OutputGH"); - CCTK_OutputGH (cctkGH); + OutputGH (where, cctkGH); // Checking CheckChecksums (cctkGH, alltimes); @@ -510,4 +513,39 @@ 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.start(); + ostringstream infobuf; + infobuf << "Scheduling " << name; + string const info = infobuf.str(); + Checkpoint (info.c_str()); + CCTK_ScheduleTraverse (name, cctkGH, CallFunction); + timer.stop(); + } + + 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(); + Checkpoint ("OutputGH"); + CCTK_OutputGH (cctkGH); + timer.stop(); + } + } // namespace Carpet |