From be708b65dc487932b363ceedcf596b56b40f2b6d Mon Sep 17 00:00:00 2001 From: Nicole Lemaster Slattengren Date: Fri, 13 May 2022 14:50:01 -0700 Subject: [PATCH] #1129: phase and elm: centralize subphases --- src/vt/elm/elm_lb_data.cc | 29 ++++++++++++++--------------- src/vt/elm/elm_lb_data.h | 4 ---- src/vt/phase/phase_manager.cc | 1 + src/vt/phase/phase_manager.h | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/vt/elm/elm_lb_data.cc b/src/vt/elm/elm_lb_data.cc index 3496f48b19..1d1e11385d 100644 --- a/src/vt/elm/elm_lb_data.cc +++ b/src/vt/elm/elm_lb_data.cc @@ -45,6 +45,7 @@ #define INCLUDED_VT_ELM_ELM_LB_DATA_CC #include "vt/elm/elm_lb_data.h" +#include "vt/phase/phase_manager.h" #include "vt/config.h" @@ -87,17 +88,19 @@ void ElementLBData::sendToEntity( } void ElementLBData::sendComm(elm::CommKey key, double bytes) { + auto cur_subphase = thePhase()->getCurrentSubphase(); phase_comm_[cur_phase_][key].sendMsg(bytes); - subphase_comm_[cur_phase_].resize(cur_subphase_ + 1); - subphase_comm_[cur_phase_].at(cur_subphase_)[key].sendMsg(bytes); + subphase_comm_[cur_phase_].resize(cur_subphase + 1); + subphase_comm_[cur_phase_].at(cur_subphase)[key].sendMsg(bytes); } void ElementLBData::recvComm( elm::CommKey key, double bytes ) { + auto cur_subphase = thePhase()->getCurrentSubphase(); phase_comm_[cur_phase_][key].receiveMsg(bytes); - subphase_comm_[cur_phase_].resize(cur_subphase_ + 1); - subphase_comm_[cur_phase_].at(cur_subphase_)[key].receiveMsg(bytes); + subphase_comm_[cur_phase_].resize(cur_subphase + 1); + subphase_comm_[cur_phase_].at(cur_subphase)[key].receiveMsg(bytes); } void ElementLBData::recvObjData( @@ -127,8 +130,9 @@ void ElementLBData::recvToNode( void ElementLBData::addTime(TimeTypeWrapper const& time) { phase_timings_[cur_phase_] += time.seconds(); - subphase_timings_[cur_phase_].resize(cur_subphase_ + 1); - subphase_timings_[cur_phase_].at(cur_subphase_) += time.seconds(); + auto cur_subphase = thePhase()->getCurrentSubphase(); + subphase_timings_[cur_phase_].resize(cur_subphase + 1); + subphase_timings_[cur_phase_].at(cur_subphase) += time.seconds(); vt_debug_print( verbose,lb, @@ -199,6 +203,8 @@ TimeType ElementLBData::getLoad(PhaseType phase, SubphaseType subphase) const { } std::vector const& ElementLBData::getSubphaseTimes(PhaseType phase) { + auto cur_subphase = thePhase()->getCurrentSubphase(); + subphase_timings_[phase].resize(cur_subphase + 1); return subphase_timings_[phase]; } @@ -216,6 +222,8 @@ ElementLBData::getComm(PhaseType const& phase) { } std::vector const& ElementLBData::getSubphaseComm(PhaseType phase) { + auto cur_subphase = thePhase()->getCurrentSubphase(); + subphase_comm_[phase].resize(cur_subphase + 1); auto const& subphase_comm = subphase_comm_[phase]; vt_debug_print( @@ -227,15 +235,6 @@ std::vector const& ElementLBData::getSubphaseComm(PhaseType phase) return subphase_comm; } -void ElementLBData::setSubPhase(SubphaseType subphase) { - vtAssert(subphase < no_subphase, "subphase must be less than sentinel"); - cur_subphase_ = subphase; -} - -SubphaseType ElementLBData::getSubPhase() const { - return cur_subphase_; -} - void ElementLBData::releaseLBDataFromUnneededPhases(PhaseType phase, unsigned int look_back) { if (phase >= look_back) { phase_timings_.erase(phase - look_back); diff --git a/src/vt/elm/elm_lb_data.h b/src/vt/elm/elm_lb_data.h index 554856f8d1..79701adf7d 100644 --- a/src/vt/elm/elm_lb_data.h +++ b/src/vt/elm/elm_lb_data.h @@ -90,8 +90,6 @@ struct ElementLBData { CommMapType const& getComm(PhaseType const& phase); std::vector const& getSubphaseComm(PhaseType phase); std::vector const& getSubphaseTimes(PhaseType phase); - void setSubPhase(SubphaseType subphase); - SubphaseType getSubPhase() const; // these are just for unit testing std::size_t getLoadPhaseCount() const; @@ -106,7 +104,6 @@ struct ElementLBData { s | cur_phase_; s | phase_timings_; s | phase_comm_; - s | cur_subphase_; s | subphase_timings_; s | subphase_comm_; } @@ -129,7 +126,6 @@ struct ElementLBData { std::unordered_map phase_timings_ = {}; std::unordered_map phase_comm_ = {}; - SubphaseType cur_subphase_ = 0; std::unordered_map> subphase_timings_ = {}; std::unordered_map> subphase_comm_ = {}; }; diff --git a/src/vt/phase/phase_manager.cc b/src/vt/phase/phase_manager.cc index 8c875dab18..59a6bc8408 100644 --- a/src/vt/phase/phase_manager.cc +++ b/src/vt/phase/phase_manager.cc @@ -160,6 +160,7 @@ void PhaseManager::nextPhaseCollective() { runHooks(PhaseHook::EndPostMigration); cur_phase_++; + cur_subphase_ = 0; vt_debug_print( normal, phase, diff --git a/src/vt/phase/phase_manager.h b/src/vt/phase/phase_manager.h index 1a8b2a019e..bfa3cbd6f8 100644 --- a/src/vt/phase/phase_manager.h +++ b/src/vt/phase/phase_manager.h @@ -105,6 +105,18 @@ struct PhaseManager : runtime::component::Component { */ PhaseType getCurrentPhase() const { return cur_phase_; } + /** + * \brief Get the current subphase + * + * \return the current subphase + */ + SubphaseType getCurrentSubphase() const { return cur_subphase_; } + + /** + * \brief Advance subphase + */ + void advanceSubphase() { ++cur_subphase_; } + /** * \brief Collectively register a phase hook that triggers depending on the * type of hook @@ -200,6 +212,7 @@ struct PhaseManager : runtime::component::Component { template void serialize(SerializerT& s) { s | cur_phase_ + | cur_subphase_ | proxy_ | collective_hooks_ | rooted_hooks_ @@ -213,6 +226,7 @@ struct PhaseManager : runtime::component::Component { private: PhaseType cur_phase_ = 0; /**< Current phase */ + SubphaseType cur_subphase_ = 0; /**< Current subphase */ ObjGroupProxyType proxy_ = no_obj_group; /**< Objgroup proxy */ HookIDMapType collective_hooks_; /**< Collective regisstered hooks */ HookIDMapType rooted_hooks_; /**< Rooted regisstered hooks */