Skip to content

Commit

Permalink
#941: Checkpoint before rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Braden Mailloux committed Oct 13, 2020
1 parent cf75702 commit 4919ca3
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 149 deletions.
4 changes: 2 additions & 2 deletions src/vt/configs/types/types_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ using GroupType = uint64_t;
using MsgSizeType = int32_t;
/// Used for hold a phase for load balancing
using PhaseType = uint64_t;
/// Used for hold a phase for load balancing
using SubphaseType = uint16_t;
/// Used for hold a subphase for load balancing
using SubphaseType = int16_t;
/// Used for hold the identifier for a pipe (callbacks)
using PipeType = uint64_t;
/// Used for hold the proxy ID for an objgroup
Expand Down
38 changes: 9 additions & 29 deletions src/vt/vrt/collection/balance/elm_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,38 +79,31 @@ void ElementStats::stopTime() {
);
}

void ElementStats::recvComm(
LBCommKey key, double bytes
) {
comm_.resize(cur_phase_ + 1);
comm_.at(cur_phase_)[key].receiveMsg(bytes);
subphase_comm_.resize(cur_phase_ + 1);
subphase_comm_.at(cur_phase_).resize(cur_subphase_ + 1);
subphase_comm_.at(cur_phase_).at(cur_subphase_)[key].receiveMsg(bytes);
}

void ElementStats::recvObjData(
ElementIDType pto, ElementIDType tto,
ElementIDType pfrom, ElementIDType tfrom, double bytes, bool bcast
) {
comm_.resize(cur_phase_ + 1);
LBCommKey key(LBCommKey::CollectionTag{}, pfrom, tfrom, pto, tto, bcast);
recvComm(key, bytes);
comm_.at(cur_phase_)[key].receiveMsg(bytes);
}

void ElementStats::recvFromNode(
ElementIDType pto, ElementIDType tto, NodeType from,
double bytes, bool bcast
) {
comm_.resize(cur_phase_ + 1);
LBCommKey key(LBCommKey::NodeToCollectionTag{}, from, pto, tto, bcast);
recvComm(key, bytes);
comm_.at(cur_phase_)[key].receiveMsg(bytes);
}

void ElementStats::recvToNode(
NodeType to, ElementIDType pfrom, ElementIDType tfrom,
double bytes, bool bcast
) {
comm_.resize(cur_phase_ + 1);
LBCommKey key(LBCommKey::CollectionToNodeTag{}, pfrom, tfrom, to, bcast);
recvComm(key, bytes);
comm_.at(cur_phase_)[key].receiveMsg(bytes);
}

void ElementStats::setModelWeight(TimeType const& time) {
Expand Down Expand Up @@ -202,25 +195,12 @@ ElementStats::getComm(PhaseType const& phase) {
return phase_comm;
}

std::vector<CommMapType> const& ElementStats::getSubphaseComm(PhaseType phase) {
subphase_comm_.resize(phase + 1);
auto const& subphase_comm = subphase_comm_[phase];

vt_debug_print(
lb, node,
"ElementStats: getSubphaseComm: comm size={}, phase={}\n",
subphase_comm.size(), phase
);

return subphase_comm;
}

void ElementStats::setSubPhase(SubphaseType subphase) {
vtAssert(subphase < no_subphase, "subphase must be less than sentinel");
cur_subphase_ = subphase;
}

SubphaseType ElementStats::getSubPhase() const {
typename ElementStats::SubphaseType ElementStats::getSubPhase() const {
return cur_subphase_;
}

Expand All @@ -230,14 +210,14 @@ void ElementStats::setFocusedSubPhase(VirtualProxyType collection, SubphaseType
}

/*static*/
SubphaseType ElementStats::getFocusedSubPhase(VirtualProxyType collection) {
ElementStats::SubphaseType ElementStats::getFocusedSubPhase(VirtualProxyType collection) {
auto i = focused_subphase_.find(collection);
if (i != focused_subphase_.end())
return i->second;
else
return no_subphase;
}

/*static*/ std::unordered_map<VirtualProxyType,SubphaseType> ElementStats::focused_subphase_;
/*static*/ std::unordered_map<VirtualProxyType,ElementStats::SubphaseType> ElementStats::focused_subphase_;

}}}} /* end namespace vt::vrt::collection::balance */
6 changes: 3 additions & 3 deletions src/vt/vrt/collection/balance/elm_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@
namespace vt { namespace vrt { namespace collection { namespace balance {

struct ElementStats {
using PhaseType = uint64_t;
using SubphaseType = uint16_t;

ElementStats() = default;
ElementStats(ElementStats const&) = default;
ElementStats(ElementStats&&) = default;

void startTime();
void stopTime();
void addTime(TimeType const& time);
void recvComm(LBCommKey key, double bytes);
void recvObjData(
ElementIDType to_perm, ElementIDType to_temp,
ElementIDType from_perm, ElementIDType from_temp, double bytes, bool bcast
Expand All @@ -89,7 +91,6 @@ struct ElementStats {
TimeType getLoad(PhaseType phase, SubphaseType subphase) const;

CommMapType const& getComm(PhaseType const& phase);
std::vector<CommMapType> const& getSubphaseComm(PhaseType phase);
void setSubPhase(SubphaseType subphase);
SubphaseType getSubPhase() const;

Expand All @@ -115,7 +116,6 @@ struct ElementStats {

SubphaseType cur_subphase_ = 0;
std::vector<std::vector<TimeType>> subphase_timings_ = {};
std::vector<std::vector<CommMapType>> subphase_comm_ = {};

static std::unordered_map<VirtualProxyType, SubphaseType> focused_subphase_;
};
Expand Down
11 changes: 6 additions & 5 deletions src/vt/vrt/collection/balance/elm_stats.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ template <typename ColT>
auto const& total_load = stats.getLoad(cur_phase, getFocusedSubPhase(untyped_proxy));
auto const& subphase_loads = stats.subphase_timings_.at(cur_phase);
auto const& comm = stats.getComm(cur_phase);
auto const& subphase_comm = stats.getSubphaseComm(cur_phase);
auto const& idx = col->getIndex();
auto const& elm_proxy = proxy[idx];

theNodeStats()->addNodeStats(col, cur_phase, total_load, subphase_loads, comm, subphase_comm);
theNodeStats()->addNodeStats(col, cur_phase, total_load, subphase_loads, comm);

auto const before_ready = theCollection()->numReadyCollections();
theCollection()->makeCollectionReady(untyped_proxy);
Expand All @@ -107,17 +106,19 @@ template <typename ColT>
before_ready, after_ready, ready
);

using MsgType = InvokeReduceMsg;

auto lb_man = theLBManager()->getProxy();

auto const single_node = theContext()->getNumNodes() == 1;
auto const lb = lb_man.get()->decideLBToRun(cur_phase);
bool const must_run_lb = lb != LBType::NoLB and not single_node;
auto const num_collections = theCollection()->numCollections<>();
auto const do_sync = msg->doSync();
auto nmsg = makeMessage<InvokeMsg>(cur_phase,lb,msg->manual(),num_collections);
auto nmsg = makeMessage<MsgType>(cur_phase,lb,msg->manual(),num_collections);

if (must_run_lb) {
auto cb = theCB()->makeBcast<LBManager,InvokeMsg,&LBManager::sysLB>(lb_man);
auto cb = theCB()->makeBcast<LBManager,MsgType,&LBManager::sysLB<MsgType>>(lb_man);
proxy.reduce(nmsg.get(),cb);
} else {

Expand All @@ -128,7 +129,7 @@ template <typename ColT>
theCollection()->elmFinishedLB(elm_proxy,cur_phase);
}

auto cb = theCB()->makeBcast<LBManager,InvokeMsg,&LBManager::sysReleaseLB>(lb_man);
auto cb = theCB()->makeBcast<LBManager,MsgType,&LBManager::sysReleaseLB<MsgType>>(lb_man);
proxy.reduce(nmsg.get(),cb);
}
}
Expand Down
Loading

0 comments on commit 4919ca3

Please sign in to comment.