Skip to content

Commit

Permalink
#1570: LB: pass load to runLB, fix ms/sec conv. in TemperedLB
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Sep 30, 2021
1 parent 744b82f commit 4cee196
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 60 deletions.
20 changes: 9 additions & 11 deletions src/vt/vrt/collection/balance/baselb/baselb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void BaseLB::startLB(
objgroup::proxy::Proxy<BaseLB> proxy,
balance::LoadModel* model,
StatisticMapType const& in_stats,
ElementCommType const& in_comm_stats
ElementCommType const& in_comm_stats,
TimeType total_load
) {
start_time_ = timing::Timing::getCurrentTime();
phase_ = phase;
Expand All @@ -74,7 +75,11 @@ void BaseLB::startLB(
importProcessorData(in_stats, in_comm_stats);

runInEpochCollective(
"BaseLB::startLB -> finishedStats", [this]{ finishedStats(); }
"BaseLB::startLB -> finishedStats", [this,total_load]{
getArgs(phase_);
inputParams(spec_entry_.get());
runLB(total_load);
}
);
}

Expand Down Expand Up @@ -105,14 +110,13 @@ void BaseLB::importProcessorData(
auto load = load_model_->getWork(obj, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE});
auto const& load_milli = loadMilli(load);
auto const& bin = histogramSample(load_milli);
this_load += load_milli;
obj_sample[bin].push_back(obj);

vt_debug_print(
verbose, lb,
"\t {}: importProcessorData: this_load={}, obj={}, home={}, load={}, "
"\t {}: importProcessorData: obj={}, home={}, load={}, "
"load_milli={}, bin={}\n",
this_node, this_load, obj.id, obj.home_node, load, load_milli, bin
this_node, obj.id, obj.home_node, load, load_milli, bin
);
}

Expand Down Expand Up @@ -230,12 +234,6 @@ NodeType BaseLB::objGetNode(ObjIDType const id) const {
return balance::objGetNode(id);
}

void BaseLB::finishedStats() {
getArgs(phase_);
this->inputParams(spec_entry_.get());
this->runLB();
}

}}}} /* end namespace vt::vrt::collection::lb */

#endif /*INCLUDED_VT_VRT_COLLECTION_BALANCE_BASELB_BASELB_CC*/
7 changes: 3 additions & 4 deletions src/vt/vrt/collection/balance/baselb/baselb.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ struct BaseLB {
objgroup::proxy::Proxy<BaseLB> proxy,
balance::LoadModel *model,
StatisticMapType const& in_stats,
ElementCommType const& in_comm_stats
ElementCommType const& in_comm_stats,
TimeType total_load
);

void importProcessorData(
StatisticMapType const& in_stats, ElementCommType const& cm
);
void finishedStats();

ObjBinType histogramSample(LoadType const& load) const;
static LoadType loadMilli(LoadType const& load);
Expand All @@ -132,7 +132,7 @@ struct BaseLB {
void finalize(CountMsg* msg);

virtual void inputParams(balance::SpecEntry* spec) = 0;
virtual void runLB() = 0;
virtual void runLB(TimeType total_load) = 0;

StatisticMapType const* getStats() const {
return base_stats_;
Expand All @@ -147,7 +147,6 @@ struct BaseLB {
double start_time_ = 0.0f;
int32_t bin_size_ = 10;
ObjSampleType obj_sample = {};
LoadType this_load = 0.0f;
ElementCommType const* comm_data = nullptr;
objgroup::proxy::Proxy<BaseLB> proxy_ = {};
PhaseType phase_ = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/vt/vrt/collection/balance/greedylb/greedylb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void GreedyLB::inputParams(balance::SpecEntry* spec) {
strat_ = strategy_converter_.getFromSpec(spec, strat_);
}

void GreedyLB::runLB() {
void GreedyLB::runLB(TimeType total_load) {
this_load = loadMilli(total_load);
loadStats();
}

Expand Down
3 changes: 2 additions & 1 deletion src/vt/vrt/collection/balance/greedylb/greedylb.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct GreedyLB : BaseLB {
virtual ~GreedyLB() {}

void init(objgroup::proxy::Proxy<GreedyLB> in_proxy);
void runLB() override;
void runLB(TimeType total_load) override;
void inputParams(balance::SpecEntry* spec) override;

private:
Expand Down Expand Up @@ -120,6 +120,7 @@ struct GreedyLB : BaseLB {
bool auto_threshold = true;

DataDistStrategy strat_ = DataDistStrategy::scatter;
LoadType this_load = 0.0f;
};

}}}} /* end namespace vt::vrt::collection::lb */
Expand Down
3 changes: 2 additions & 1 deletion src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ void HierarchicalLB::clearObj(ObjSampleType& objs) {
}
}

void HierarchicalLB::runLB() {
void HierarchicalLB::runLB(TimeType total_load) {
this_load = loadMilli(total_load);
setupTree(min_threshold);

auto cb = vt::theCB()->makeBcast<
Expand Down
3 changes: 2 additions & 1 deletion src/vt/vrt/collection/balance/hierarchicallb/hierlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct HierarchicalLB : BaseLB {
virtual ~HierarchicalLB() {}

void init(objgroup::proxy::Proxy<HierarchicalLB> in_proxy);
void runLB() override;
void runLB(TimeType total_load) override;
void inputParams(balance::SpecEntry* spec) override;

void setupTree(double const threshold);
Expand Down Expand Up @@ -134,6 +134,7 @@ struct HierarchicalLB : BaseLB {
double min_threshold = 0.0f;
bool auto_threshold = true;
HeapExtractEnum extract_strategy = HeapExtractEnum::LoadOverLessThan;
LoadType this_load = 0.0f;
};

}}}} /* end namespace vt::vrt::collection::lb */
Expand Down
4 changes: 2 additions & 2 deletions src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ LBManager::runLB(LBProxyType base_proxy, PhaseType phase) {
if (iter != theNodeStats()->getNodeComm()->end()) {
comm = &iter->second;
}
strat->startLB(phase, base_proxy, model_.get(), stats, *comm);
strat->startLB(phase, base_proxy, model_.get(), stats, *comm, total_load);
});

int32_t global_migration_count = 0;
Expand Down Expand Up @@ -357,7 +357,7 @@ void LBManager::computeStatistics(PhaseType phase) {
LBManager, StatsMsgType, &LBManager::statsHandler
>(proxy_);

TimeType total_load = 0;
total_load = 0.;
std::vector<balance::LoadData> P_c;
for (auto elm : *model_) {
auto work = model_->getWork(
Expand Down
1 change: 1 addition & 0 deletions src/vt/vrt/collection/balance/lb_invoke/lb_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ struct LBManager : runtime::component::Component<LBManager> {
std::shared_ptr<LoadModel> model_;
std::unordered_map<std::string, LBProxyType> lb_instances_;
StatisticMapType stats;
TimeType total_load = 0.;
};

}}}} /* end namespace vt::vrt::collection::balance */
Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/randomlb/randomlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void RandomLB::inputParams(balance::SpecEntry* spec) {
randomize_seed_ = spec->getOrDefault<bool>("randomize_seed", randomize_seed_);
}

void RandomLB::runLB() {
void RandomLB::runLB(TimeType) {
auto const this_node = theContext()->getNode();
auto const num_nodes = static_cast<int32_t>(theContext()->getNumNodes());

Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/randomlb/randomlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct RandomLB : BaseLB {
RandomLB() = default;

void init(objgroup::proxy::Proxy<RandomLB> in_proxy);
void runLB() override;
void runLB(TimeType) override;
void inputParams(balance::SpecEntry* spec) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/rotatelb/rotatelb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void RotateLB::init(objgroup::proxy::Proxy<RotateLB> in_proxy) {

void RotateLB::inputParams(balance::SpecEntry* spec) { }

void RotateLB::runLB() {
void RotateLB::runLB(TimeType) {
auto const& this_node = theContext()->getNode();
auto const& num_nodes = theContext()->getNumNodes();
auto const next_node = this_node + 1 > num_nodes-1 ? 0 : this_node + 1;
Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/rotatelb/rotatelb.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct RotateLB : BaseLB {
virtual ~RotateLB() {}

void init(objgroup::proxy::Proxy<RotateLB> in_proxy);
void runLB() override;
void runLB(TimeType) override;
void inputParams(balance::SpecEntry* spec) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/statsmaplb/statsmaplb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void StatsMapLB::init(objgroup::proxy::Proxy<StatsMapLB> in_proxy) {
proxy_ = in_proxy;
}

void StatsMapLB::runLB() {
void StatsMapLB::runLB(TimeType) {
auto const& myNewList = theStatsReader()->getMoveList(phase_);
for (size_t in = 0; in < myNewList.size(); in += 2) {
auto this_node = theContext()->getNode();
Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/statsmaplb/statsmaplb.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct StatsMapLB : BaseLB {
virtual ~StatsMapLB() = default;

void init(objgroup::proxy::Proxy<StatsMapLB> in_proxy);
void runLB() override;
void runLB(TimeType) override;
void inputParams(balance::SpecEntry* spec) override { }

private:
Expand Down
Loading

0 comments on commit 4cee196

Please sign in to comment.