Skip to content

Commit

Permalink
#1830: extract more helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Jun 22, 2022
1 parent afa4669 commit 413f98c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/vt/vrt/collection/balance/temperedlb/temperedlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ void TemperedLB::informAsync() {
auto propagate_epoch = theTerm()->makeEpochCollective("TemperedLB: informAsync");

// Underloaded start the round
if (is_underloaded_) {
if (canPropagate()) {
uint8_t k_cur_async = 0;
propagateRound(k_cur_async, false, propagate_epoch);
}
Expand Down Expand Up @@ -721,7 +721,7 @@ void TemperedLB::informSync() {
underloaded_.insert(this_node);
}

auto propagate_this_round = is_underloaded_;
auto propagate_this_round = canPropagate();
propagate_next_round_ = false;
new_underloaded_ = underloaded_;
new_load_info_ = load_info_;
Expand Down Expand Up @@ -792,6 +792,9 @@ void TemperedLB::propagateRound(uint8_t k_cur, bool sync, EpochType epoch) {
gen_propagate_.seed(seed_());
}

// remove 1 line
// selected = getSelectedNodessss
// selected = all?
auto& selected = selected_;
selected = underloaded_;
if (selected.find(this_node) == selected.end()) {
Expand All @@ -813,6 +816,8 @@ void TemperedLB::propagateRound(uint8_t k_cur, bool sync, EpochType epoch) {
return;
}

// extract generateRandomNode
// auto random_node = generateRandomNode(dist);
// First, randomly select a node
NodeType random_node = uninitialized_destination;

Expand Down Expand Up @@ -1202,7 +1207,7 @@ void TemperedLB::decide() {

int n_transfers = 0, n_rejected = 0;

if (is_overloaded_) {
if (canMigrate()) {
std::vector<NodeType> under = makeUnderloaded();
std::unordered_map<NodeType, ObjsType> migrate_objs;

Expand Down
3 changes: 3 additions & 0 deletions src/vt/vrt/collection/balance/temperedlb/temperedlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ struct TemperedLB : BaseLB {
void migrate();
void clearDataStructures();

virtual bool canMigrate() const { return is_overloaded_; }
virtual bool canPropagate() const { return is_underloaded_; }

void propagateRound(uint8_t k_cur_async, bool sync, EpochType epoch = no_epoch);
void propagateIncomingAsync(LoadMsgAsync* msg);
void propagateIncomingSync(LoadMsgSync* msg);
Expand Down
2 changes: 2 additions & 0 deletions src/vt/vrt/collection/balance/temperedwmin/temperedwmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ struct TemperedWMin : TemperedLB {
void inputParams(balance::SpecEntry* spec) override;

protected:
bool canPropagate() const override { return true; }

TimeType getModeledWork(const elm::ElementIDStruct& obj) override;

private:
Expand Down

0 comments on commit 413f98c

Please sign in to comment.