Skip to content

Commit

Permalink
#431 Fix bug to build the migration information.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhetmaniuk authored and lifflander committed Feb 5, 2020
1 parent 8d63e98 commit 49c150a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
28 changes: 15 additions & 13 deletions src/vt/vrt/collection/balance/stats_lb_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ void StatsLBReader::doSend(lb::VecMsg *msg) {
StatsLBReader::msgReceived[iter] += 1;
auto &migrate = StatsLBReader::totalMove[iter];
for (size_t ii = 1; ii < sendVec.size(); ii += 3) {
auto permID = sendVec[ii];
auto nodeFrom = static_cast<NodeType>(sendVec[ii+1]);
auto nodeTo = static_cast<NodeType>(sendVec[ii+2]);
const auto permID = sendVec[ii];
const auto nodeFrom = static_cast<NodeType>(sendVec[ii+1]);
const auto nodeTo = static_cast<NodeType>(sendVec[ii+2]);
auto iptr = migrate.find(permID);
if (iptr == migrate.end()) {
migrate.insert(std::make_pair(permID, std::make_pair(nodeFrom, nodeTo)));
Expand All @@ -225,7 +225,7 @@ void StatsLBReader::doSend(lb::VecMsg *msg) {
//
// --- Check whether all the messages have been received
//
auto numNodes = theContext()->getNumNodes();
const NodeType numNodes = theContext()->getNumNodes();
if (StatsLBReader::msgReceived[iter] < numNodes)
return;
//
Expand All @@ -237,42 +237,44 @@ void StatsLBReader::doSend(lb::VecMsg *msg) {
if (iNode.second.first == in)
iCount += 1;
}
std::vector<ElementIDType> toMove(2 * iCount + 2);
const size_t header = 2;
std::vector<ElementIDType> toMove(2 * iCount + header);
iCount = 0;
toMove[iCount++] = iter;
toMove[iCount++] = static_cast<ElementIDType>(migrate.size());
for (auto iNode : migrate) {
if (iNode.second.first == in) {
toMove[iCount] = iNode.first;
toMove[iCount + 1] = static_cast<ElementIDType>(iNode.second.second);
iCount += 2;
toMove[iCount++] = iNode.first;
toMove[iCount++] = static_cast<ElementIDType>(iNode.second.second);
}
}
if (in > 0) {
auto msg2 = makeSharedMessage<lb::VecMsg>(toMove);
StatsLBReader::proxy_[in].send<lb::VecMsg,&StatsLBReader::scatterSend>
(msg2);
} else {
StatsLBReader::moveList[iter].resize(toMove.size() - 1);
std::copy(&toMove[1], &toMove[0] + toMove.size(),
StatsLBReader::phase_changed_map_[iter] = (migrate.size() > 0);
StatsLBReader::moveList[iter].resize(toMove.size() - header);
std::copy(&toMove[header], &toMove[0] + toMove.size(),
StatsLBReader::moveList[iter].begin());
}
}
migrate.clear();
}

void StatsLBReader::scatterSend(lb::VecMsg *msg) {
const size_t header = 2;
auto recvVec = msg->getTransfer();
ElementIDType iter = recvVec[0];
StatsLBReader::phase_changed_map_[iter] = (recvVec[1] > 0);
auto &myList = StatsLBReader::moveList[iter];
if (recvVec.size() <= 2) {
if (recvVec.size() <= header) {
myList.clear();
return;
}
//
myList.resize(recvVec.size() - 1);
std::copy(&recvVec[1], &recvVec[0]+recvVec.size(), myList.begin());
myList.resize(recvVec.size() - header);
std::copy(&recvVec[header], &recvVec[0]+recvVec.size(), myList.begin());
}

}}}} /* end namespace vt::vrt::collection::balance */
8 changes: 1 addition & 7 deletions src/vt/vrt/collection/balance/statsmaplb/statsmaplb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ void StatsMapLB::init(objgroup::proxy::Proxy<StatsMapLB> in_proxy) {

void StatsMapLB::runLB() {

if (!balance::StatsLBReader::phase_changed_map_[phase_]) {
return;
}

vtAssertExpr(balance::StatsLBReader::user_specified_map_.size() > phase_);

auto epoch = startMigrationCollective();
theMsg()->pushEpoch(epoch);

Expand All @@ -74,7 +68,7 @@ void StatsMapLB::runLB() {
}
else {
vtAssertExpr(iter != balance::ProcStats::proc_perm_to_temp_.end());
};
}
}

theMsg()->popEpoch(epoch);
Expand Down

0 comments on commit 49c150a

Please sign in to comment.