diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2010-10-13 14:09:48 -0500 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 18:25:34 +0000 |
commit | 624c5115f4e8d82dff4db3311edd96a0224926ca (patch) | |
tree | 3c5ebcef4908b114182f7786ac4cdeac5f60886d /Carpet | |
parent | 7b4ce92891d13e29042a55cbe0f147a766ee4c4c (diff) |
Carpet: Return status value from routines called before/after scheduled routines
Return a status value from routines called before or after scheduled
routines. Possibly skip calling the scheduled routines based on this
status.
Diffstat (limited to 'Carpet')
-rw-r--r-- | Carpet/Carpet/src/CallFunction.cc | 59 | ||||
-rw-r--r-- | Carpet/Carpet/src/ScheduleWrapper.cc | 10 |
2 files changed, 37 insertions, 32 deletions
diff --git a/Carpet/Carpet/src/CallFunction.cc b/Carpet/Carpet/src/CallFunction.cc index 9239935b8..ffd695c45 100644 --- a/Carpet/Carpet/src/CallFunction.cc +++ b/Carpet/Carpet/src/CallFunction.cc @@ -318,36 +318,39 @@ namespace Carpet { time_and_mode, attribute->where, attribute->thorn, attribute->routine); - CallBeforeRoutines (cctkGH, function, attribute, data); - - 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 + 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; + + user_timer.start(); + timer.start(); + int const res = CCTK_CallFunction (function, attribute, data); + assert (res==0); + timer.stop(); + user_timer.stop(); + } - Timer & timer = * ti->second; - - user_timer.start(); - timer.start(); - int const res = CCTK_CallFunction (function, attribute, data); - timer.stop(); - user_timer.stop(); - CallAfterRoutines (cctkGH, function, attribute, data); - assert (res==0); } diff --git a/Carpet/Carpet/src/ScheduleWrapper.cc b/Carpet/Carpet/src/ScheduleWrapper.cc index 624dacbf9..13a665938 100644 --- a/Carpet/Carpet/src/ScheduleWrapper.cc +++ b/Carpet/Carpet/src/ScheduleWrapper.cc @@ -48,29 +48,31 @@ namespace Carpet { - void + int CallBeforeRoutines (cGH const * const cctkGH, void * const function, cFunctionData * const attribute, void * const data) { + int skip = 0; for (flist::const_iterator fli = func_befores.begin(); fli != func_befores.end(); ++ fli) { - (* fli) (cctkGH, function, attribute, data); + skip |= (* fli) (cctkGH, function, attribute, data); } } - void + int CallAfterRoutines (cGH const * const cctkGH, void * const function, cFunctionData * const attribute, void * const data) { + int res = 0; for (flist::const_iterator fli = func_afters.begin(); fli != func_afters.end(); ++ fli) { - (* fli) (cctkGH, function, attribute, data); + res |= (* fli) (cctkGH, function, attribute, data); } } |