diff options
author | Erik Schnetter <schnetter@aei.mpg.de> | 2005-08-11 12:03:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@aei.mpg.de> | 2005-08-11 12:03:00 +0000 |
commit | 15702703536ece6bc3db68bd7fcd2dee5e29c4ce (patch) | |
tree | 95bc75a3625bd655c88209c13fc5d20e2908219e /Carpet | |
parent | 7f4e2e820e57e4b32852339c2d49fa28a0c92565 (diff) |
CarpetLib: Implement fast recomposing
For each refinement level that is to be recomposed, check whether it
has the same structure as before, and if so, do nothing. This is
controlled by a new flag CarpetLib::fast_recomposing.
darcs-hash:20050811120347-891bb-f937c21ddeac7d909cae41d487e9fd74a5ce8cc8.gz
Diffstat (limited to 'Carpet')
-rw-r--r-- | Carpet/CarpetLib/param.ccl | 4 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dh.cc | 82 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/ggf.cc | 24 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/ggf.hh | 1 |
4 files changed, 79 insertions, 32 deletions
diff --git a/Carpet/CarpetLib/param.ccl b/Carpet/CarpetLib/param.ccl index 2c9209fb4..3756062f3 100644 --- a/Carpet/CarpetLib/param.ccl +++ b/Carpet/CarpetLib/param.ccl @@ -26,6 +26,10 @@ BOOLEAN save_memory_during_regridding "Save some memory during regridding at the { } "yes" +BOOLEAN fast_recomposing "Take shortcuts during recomposing (EXPERIMENTAL)" +{ +} "no" + INT print_memstats_every "Report periodically how much memory is used per process" STEERABLE=always diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc index d3785be88..6b15cacfa 100644 --- a/Carpet/CarpetLib/src/dh.cc +++ b/Carpet/CarpetLib/src/dh.cc @@ -594,49 +594,71 @@ void dh::save_time (bool do_prolongate) for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_crop (); } + bool any_level_changed = false; for (int rl=0; rl<h.reflevels(); ++rl) { - for (int c = 0; c < ggfs.size(); c++) { - for (int g = 0; g < ggfs[c].members.size(); g++) { - ggfs[c].members[g]->recompose_allocate (rl); - } - for (comm_state state(ggfs[c].vartype); ! state.done(); state.step()) { + + // TODO: calculate this_level_changed only once + bool const this_level_changed + = gfs.begin()!=gfs.end() and (*gfs.begin())->recompose_did_change (rl); + any_level_changed |= this_level_changed; + if (! fast_recomposing or any_level_changed) { + + for (int c = 0; c < ggfs.size(); c++) { for (int g = 0; g < ggfs[c].members.size(); g++) { - ggfs[c].members[g]->recompose_fill (state, rl, do_prolongate); + ggfs[c].members[g]->recompose_allocate (rl); } - } - for (int g = 0; g < ggfs[c].members.size(); g++) { - ggfs[c].members[g]->recompose_free (rl); - } - for (comm_state state(ggfs[c].vartype); ! state.done(); state.step()) { - for (int g = 0; g < ggfs[c].members.size(); g++) { - ggfs[c].members[g]->recompose_bnd_prolongate (state, rl, do_prolongate); + for (comm_state state(ggfs[c].vartype); ! state.done(); state.step()) { + for (int g = 0; g < ggfs[c].members.size(); g++) { + ggfs[c].members[g]->recompose_fill (state, rl, do_prolongate); + } } - } - for (comm_state state(ggfs[c].vartype); ! state.done(); state.step()) { for (int g = 0; g < ggfs[c].members.size(); g++) { - ggfs[c].members[g]->recompose_sync (state, rl, do_prolongate); + ggfs[c].members[g]->recompose_free (rl); } - } - } // for all grid functions of same vartype + for (comm_state state(ggfs[c].vartype); ! state.done(); state.step()) { + for (int g = 0; g < ggfs[c].members.size(); g++) { + ggfs[c].members[g]->recompose_bnd_prolongate (state, rl, do_prolongate); + } + } + for (comm_state state(ggfs[c].vartype); ! state.done(); state.step()) { + for (int g = 0; g < ggfs[c].members.size(); g++) { + ggfs[c].members[g]->recompose_sync (state, rl, do_prolongate); + } + } + } // for all grid functions of same vartype + + } // if did_change } // for all refinement levels } -void dh::save_memory (bool do_prolongate) { +void dh::save_memory (bool do_prolongate) +{ + DECLARE_CCTK_PARAMETERS; + for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) { (*f)->recompose_crop (); + + bool any_level_changed = false; for (int rl=0; rl<h.reflevels(); ++rl) { - (*f)->recompose_allocate (rl); - for (comm_state state; !state.done(); state.step()) { - (*f)->recompose_fill (state, rl, do_prolongate); - } - (*f)->recompose_free (rl); - for (comm_state state; !state.done(); state.step()) { - (*f)->recompose_bnd_prolongate (state, rl, do_prolongate); - } - for (comm_state state; !state.done(); state.step()) { - (*f)->recompose_sync (state, rl, do_prolongate); - } + // TODO: calculate this_level_changed only once + bool const this_level_changed = (*f)->recompose_did_change (rl); + any_level_changed |= this_level_changed; + if (! fast_recomposing or any_level_changed) { + + (*f)->recompose_allocate (rl); + for (comm_state state; !state.done(); state.step()) { + (*f)->recompose_fill (state, rl, do_prolongate); + } + (*f)->recompose_free (rl); + for (comm_state state; !state.done(); state.step()) { + (*f)->recompose_bnd_prolongate (state, rl, do_prolongate); + } + for (comm_state state; !state.done(); state.step()) { + (*f)->recompose_sync (state, rl, do_prolongate); + } + + } // if did_change } // for rl } // for gf diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc index 9a4790b82..360ea58db 100644 --- a/Carpet/CarpetLib/src/ggf.cc +++ b/Carpet/CarpetLib/src/ggf.cc @@ -102,10 +102,30 @@ void ggf::recompose_crop () } // for ml } +bool ggf::recompose_did_change (const int rl) const +{ + // Find out whether this level changed + if (storage.size() != h.mglevels()) return true; + for (int ml=0; ml<h.mglevels(); ++ml) { + if (storage.at(ml).size() <= rl) return true; + if (storage.at(ml).at(rl).size() != h.components(rl)) return true; + for (int c=0; c<h.components(rl); ++c) { + if (storage.at(ml).at(rl).at(c).size() != timelevels()) return true; + for (int tl=0; tl<timelevels(); ++tl) { + ibbox const & wantextent = d.boxes.at(ml).at(rl).at(c).exterior; + ibbox const & haveextent = storage.at(ml).at(rl).at(c).at(tl)->extent(); + if (haveextent != wantextent) return true; + int const wantproc = h.proc(rl,c); + int const haveproc = storage.at(ml).at(rl).at(c).at(tl)->proc(); + if (haveproc != wantproc) return true; + } // for tl + } // for c + } // for ml + return false; +} + void ggf::recompose_allocate (const int rl) { - // TODO: restructure storage only when needed - // Retain storage that might be needed oldstorage.resize(storage.size()); for (int ml=0; ml<(int)storage.size(); ++ml) { diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh index 7962496b6..88fbadf07 100644 --- a/Carpet/CarpetLib/src/ggf.hh +++ b/Carpet/CarpetLib/src/ggf.hh @@ -92,6 +92,7 @@ public: void set_timelevels (int ml, int rl, int new_timelevels); void recompose_crop (); + bool recompose_did_change (int rl) const; void recompose_allocate (int rl); void recompose_fill (comm_state& state, int rl, bool do_prolongate); void recompose_free (int rl); |