Skip to content

Commit

Permalink
#2074: Disallow runing of OfflineLB for skipped phases.
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed Jun 12, 2023
1 parent c2b59d0 commit ef91bad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/vt/vrt/collection/balance/lb_data_restart_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ void LBDataRestartReader::determinePhasesToMigrate() {
);

std::set_difference(
history_[curr]->begin(), history_[curr]->end(),
history_[next]->begin(), history_[next]->end(),
history_[curr]->begin(), history_[curr]->end(),
history_[next]->begin(), history_[next]->end(),
std::inserter(departing, departing.begin())
);

Expand Down
26 changes: 13 additions & 13 deletions src/vt/vrt/collection/balance/lb_data_restart_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,6 @@ 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 iter = history_.upper_bound(phase);
vtAssert(iter != history_.end(), "Must have a valid phase");
return iter->first;
}

/**
* \brief Get the elements assigned for a given phase
*
Expand Down Expand Up @@ -186,6 +173,19 @@ struct LBDataRestartReader : runtime::component::Component<LBDataRestartReader>
}

private:
/**
* \brief Find the next specified phase or an identical one
*
* \param phase the current phase
*
* \return the next phase
*/
PhaseType findNextPhase(PhaseType phase) const {
auto iter = history_.upper_bound(phase);
vtAssert(iter != history_.end(), "Must have a valid phase");
return iter->first;
}

/**
* \brief Reduce distribution changes globally to find where migrations need
* to occur
Expand Down
5 changes: 2 additions & 3 deletions src/vt/vrt/collection/balance/offlinelb/offlinelb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ void OfflineLB::init(objgroup::proxy::Proxy<OfflineLB> in_proxy) {
}

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

}}}} /* end namespace vt::vrt::collection::lb */
20 changes: 17 additions & 3 deletions tests/unit/lb/test_offlinelb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ struct SimCol : vt::Collection<SimCol, vt::Index1D> {
auto const num_nodes = theContext()->getNumNodes();
auto const next_node = (this_node + 1) % num_nodes;
vt_debug_print(terse, lb, "sparseHandler: idx={}: elm={}\n", getIndex(), getElmID());
if (m->iter == 0 or m->iter == 1) {
if (m->iter == 0 or m->iter == 1 or m->iter == 2 or m->iter == 3 or m->iter == 4) {
EXPECT_EQ(getIndex().x() / 2, this_node);
} else if (m->iter == 2 or m->iter == 3 or m->iter == 4 or m->iter == 5 or m->iter == 6) {
} else if (m->iter == 5 or m->iter == 6) {
EXPECT_EQ(getIndex().x() / 2, next_node);
}
}
Expand Down Expand Up @@ -224,8 +224,22 @@ TEST_F(TestOfflineLB, test_offlinelb_2) {
}
stream = w->finish();

// Preapre configuration file
std::string file_name = "test_offlinelb_2.txt";
std::ofstream out(file_name);
out << ""
"0 OfflineLB\n"
"1 NoLB\n"
"2 NoLB\n"
"3 NoLB\n"
"4 OfflineLB\n"
"5 OfflineLB\n"
"6 NoLB\n";
out.close();

theConfig()->vt_lb = true;
theConfig()->vt_lb_name = "OfflineLB";
theConfig()->vt_lb_file_name = "test_offlinelb_2.txt";

auto up = LBDataRestartReader::construct();
curRT->theLBDataReader = up.get();
theLBDataReader()->readLBDataFromStream(std::move(stream));
Expand Down

0 comments on commit ef91bad

Please sign in to comment.