Skip to content

Commit

Permalink
#2074: Update finding next phase for OfflineLB
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed May 16, 2023
1 parent 8984e5a commit ca02e10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
30 changes: 18 additions & 12 deletions src/vt/vrt/collection/balance/lb_data_restart_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ struct LBDataRestartReader : runtime::component::Component<LBDataRestartReader>
| num_phases_;
}

/**
* \brief Find the next phase
*
* \param phase the current phase
*
* \return the next phase
*/
PhaseType findNextPhase(PhaseType phase) const {
auto next = phase + 1;
for(; next < num_phases_; ++next) {
if(history_.find(next) != history_.end()) {
return next;
}
}
vtAssert(history_.find(next) != history_.end(), "Must have a valid phase");
return next;
}

/**
* \brief Get the elements assigned for a given phase
*
Expand All @@ -131,12 +149,6 @@ struct LBDataRestartReader : runtime::component::Component<LBDataRestartReader>
* \return element assigned to this node
*/
std::set<ElementIDStruct> const& getDistro(PhaseType phase) {
for(; phase < num_phases_; ++phase) {
if(history_.find(phase) != history_.end()) {
break;
}
}

auto iter = history_.find(phase);
vtAssert(iter != history_.end(), "Must have a valid phase");
return iter->second;
Expand All @@ -148,12 +160,6 @@ struct LBDataRestartReader : runtime::component::Component<LBDataRestartReader>
* \param[in] phase the phase to clear
*/
void clearDistro(PhaseType phase) {
for(; phase < num_phases_; ++phase) {
if(history_.find(phase) != history_.end()) {
break;
}
}

auto iter = history_.find(phase);
if (iter != history_.end()) {
history_.erase(iter);
Expand Down
5 changes: 3 additions & 2 deletions src/vt/vrt/collection/balance/offlinelb/offlinelb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ void OfflineLB::init(objgroup::proxy::Proxy<OfflineLB> in_proxy) {
}

void OfflineLB::runLB(TimeType) {
auto const& distro = theLBDataReader()->getDistro(phase_ + 1);
auto nextPhase = theLBDataReader()->findNextPhase(phase_);
auto const& distro = theLBDataReader()->getDistro(nextPhase);
for (auto&& elm : distro) {
migrateObjectTo(elm, theContext()->getNode());
}
theLBDataReader()->clearDistro(phase_ + 1);
theLBDataReader()->clearDistro(nextPhase);
}

}}}} /* end namespace vt::vrt::collection::lb */

0 comments on commit ca02e10

Please sign in to comment.