diff options
Diffstat (limited to 'Carpet/Carpet/src/Comm.cc')
-rw-r--r-- | Carpet/Carpet/src/Comm.cc | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/Carpet/Carpet/src/Comm.cc b/Carpet/Carpet/src/Comm.cc index ab6106c2b..55be38251 100644 --- a/Carpet/Carpet/src/Comm.cc +++ b/Carpet/Carpet/src/Comm.cc @@ -3,6 +3,7 @@ #include <cmath> #include <cstdlib> #include <iostream> +#include <vector> #include <cctk.h> #include <cctk_Parameters.h> @@ -180,8 +181,29 @@ 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; + if (timers.empty()) { + timers.push_back(new Timer("comm_state[0].create")); + for (astate state = static_cast<astate>(0); + state != state_done; + state = static_cast<astate>(static_cast<int>(state)+1)) + { + ostringstream name1; + name1 << "comm_state[" << timers.size() << "]" + << "." << tostring(state) << ".user"; + timers.push_back(new Timer(name1.str())); + ostringstream name2; + name2 << "comm_state[" << timers.size() << "]" + << "." << tostring(state) << ".step"; + timers.push_back(new Timer(name2.str())); + } + } + vector<Timer*>::iterator ti = timers.begin(); + (*ti)->start(); for (comm_state state; not state.done(); state.step()) { + (*ti)->stop(); ++ti; (*ti)->start(); for (int group = 0; group < (int)groups.size(); ++group) { const int g = groups.AT(group); const int grouptype = CCTK_GroupTypeI (g); @@ -202,7 +224,10 @@ namespace Carpet { } } } + (*ti)->stop(); ++ti; (*ti)->start(); } + (*ti)->stop(); + ++ti; assert(ti == timers.end()); } @@ -219,7 +244,28 @@ namespace Carpet { Accelerator_PreSync(cctkGH, &groups.front(), groups.size()); } + static vector<Timer*> timers; + if (timers.empty()) { + timers.push_back(new Timer("comm_state[0].create")); + for (astate state = static_cast<astate>(0); + state != state_done; + state = static_cast<astate>(static_cast<int>(state)+1)) + { + ostringstream name1; + name1 << "comm_state[" << timers.size() << "]" + << "." << tostring(state) << ".user"; + timers.push_back(new Timer(name1.str())); + ostringstream name2; + name2 << "comm_state[" << timers.size() << "]" + << "." << tostring(state) << ".step"; + timers.push_back(new Timer(name2.str())); + } + } + + vector<Timer*>::iterator ti = timers.begin(); + (*ti)->start(); for (comm_state state; not state.done(); state.step()) { + (*ti)->stop(); ++ti; (*ti)->start(); for (int group = 0; group < (int)groups.size(); ++group) { const int g = groups.AT(group); const int grouptype = CCTK_GroupTypeI (g); @@ -235,8 +281,11 @@ namespace Carpet { } } } + (*ti)->stop(); ++ti; (*ti)->start(); } - + (*ti)->stop(); + ++ti; assert(ti == timers.end()); + if (CCTK_IsFunctionAliased("Accelerator_PostSync")) { Accelerator_PostSync(cctkGH, &groups.front(), groups.size()); } |