Skip to content

Commit

Permalink
#1122: collection: make element stats use unordered map
Browse files Browse the repository at this point in the history
  • Loading branch information
nlslatt committed Nov 18, 2020
1 parent 7425502 commit 92c5e4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
25 changes: 7 additions & 18 deletions src/vt/vrt/collection/balance/elm_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ 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);
comm_[cur_phase_][key].receiveMsg(bytes);
subphase_comm_[cur_phase_].resize(cur_subphase_ + 1);
subphase_comm_[cur_phase_].at(cur_subphase_)[key].receiveMsg(bytes);
}

void ElementStats::recvObjData(
Expand Down Expand Up @@ -114,17 +112,15 @@ void ElementStats::recvToNode(
}

void ElementStats::addTime(TimeType const& time) {
phase_timings_.resize(cur_phase_ + 1);
phase_timings_.at(cur_phase_) += time;
phase_timings_[cur_phase_] += time;

subphase_timings_.resize(cur_phase_ + 1);
subphase_timings_.at(cur_phase_).resize(cur_subphase_ + 1);
subphase_timings_.at(cur_phase_).at(cur_subphase_) += time;
subphase_timings_[cur_phase_].resize(cur_subphase_ + 1);
subphase_timings_[cur_phase_].at(cur_subphase_) += time;

vt_debug_print(
lb, node,
"ElementStats: addTime: time={}, cur_load={}\n",
time, phase_timings_.at(cur_phase_)
time, phase_timings_[cur_phase_]
);
}

Expand All @@ -136,17 +132,13 @@ void ElementStats::updatePhase(PhaseType const& inc) {
);

cur_phase_ += inc;
phase_timings_.resize(cur_phase_ + 1);
subphase_timings_.resize(cur_phase_ + 1);
}

PhaseType ElementStats::getPhase() const {
return cur_phase_;
}

TimeType ElementStats::getLoad(PhaseType const& phase) const {
vtAssert(phase_timings_.size() > phase, "Must have phase");

auto const& total_load = phase_timings_.at(phase);

vt_debug_print(
Expand All @@ -162,7 +154,6 @@ TimeType ElementStats::getLoad(PhaseType phase, SubphaseType subphase) const {
if (subphase == no_subphase)
return getLoad(phase);

vtAssert(phase_timings_.size() > phase, "Must have phase");
auto const& subphase_loads = subphase_timings_.at(phase);

vtAssert(subphase_loads.size() > subphase, "Must have subphase");
Expand All @@ -179,7 +170,6 @@ TimeType ElementStats::getLoad(PhaseType phase, SubphaseType subphase) const {

CommMapType const&
ElementStats::getComm(PhaseType const& phase) {
comm_.resize(phase + 1);
auto const& phase_comm = comm_[phase];

vt_debug_print(
Expand All @@ -192,7 +182,6 @@ ElementStats::getComm(PhaseType const& phase) {
}

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

vt_debug_print(
Expand Down
8 changes: 4 additions & 4 deletions src/vt/vrt/collection/balance/elm_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ struct ElementStats {
bool cur_time_started_ = false;
TimeType cur_time_ = 0.0;
PhaseType cur_phase_ = fst_lb_phase;
std::vector<TimeType> phase_timings_ = {};
std::vector<CommMapType> comm_ = {};
std::unordered_map<PhaseType, TimeType> phase_timings_ = {};
std::unordered_map<PhaseType, CommMapType> comm_ = {};

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

static std::unordered_map<VirtualProxyType, SubphaseType> focused_subphase_;
};
Expand Down

0 comments on commit 92c5e4b

Please sign in to comment.