Skip to content

Commit

Permalink
#708: Add API for picking a subphase to represent the overall phase load
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Miller authored and lifflander committed Apr 20, 2020
1 parent bd168d8 commit c549453
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/vt/vrt/collection/balance/elm_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,28 @@ PhaseType ElementStats::getPhase() const {

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

debug_print(
lb, node,
"ElementStats: getLoad: load={}, phase={}, size={}\n",
total_load, phase, phase_timings_.size()
);
if (focused_subphase_ != no_subphase) {
auto const& total_load = subphase_timings_.at(phase).at(focused_subphase_);

return total_load;
debug_print(
lb, node,
"ElementStats: getLoad: load={}, phase={}, focused_subphase={}, size={}\n",
total_load, phase, focused_subphase_, phase_timings_.size()
);

return total_load;
} else {
auto const& total_load = phase_timings_.at(phase);

debug_print(
lb, node,
"ElementStats: getLoad: load={}, phase={}, size={}\n",
total_load, phase, phase_timings_.size()
);

return total_load;
}
}

TimeType ElementStats::getLoad(PhaseType phase, SubphaseType subphase) const {
Expand All @@ -176,7 +189,6 @@ TimeType ElementStats::getLoad(PhaseType phase, SubphaseType subphase) const {
return total_load;
}


CommMapType const&
ElementStats::getComm(PhaseType const& phase) {
comm_.resize(phase + 1);
Expand All @@ -192,7 +204,14 @@ ElementStats::getComm(PhaseType const& phase) {
}

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

void ElementStats::setFocusedSubPhase(SubphaseType subphase) {
focused_subphase_ = subphase;
}

/*static*/ ElementStats::SubphaseType ElementStats::focused_subphase_ = ElementStats::no_subphase;

}}}} /* end namespace vt::vrt::collection::balance */
5 changes: 5 additions & 0 deletions src/vt/vrt/collection/balance/elm_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct ElementStats {
CommMapType const& getComm(PhaseType const& phase);
void setSubPhase(SubphaseType subphase);

static const constexpr SubphaseType no_subphase = std::numeric_limits<SubphaseType>::max();
static void setFocusedSubPhase(SubphaseType subphase);

template <typename Serializer>
void serialize(Serializer& s);

Expand All @@ -113,6 +116,8 @@ struct ElementStats {

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

static SubphaseType focused_subphase_;
};

}}}} /* end namespace vt::vrt::collection::balance */
Expand Down

0 comments on commit c549453

Please sign in to comment.