Skip to content

Commit

Permalink
#2299: Replace double with std::chrono
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed Aug 28, 2024
1 parent 0bf1dad commit e987173
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/vt/vrt/collection/balance/baselb/baselb.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <map>
#include <unordered_map>
#include <tuple>
#include <chrono>

namespace vt { namespace vrt { namespace collection {

Expand Down Expand Up @@ -193,9 +194,8 @@ struct BaseLB {
*
* \return the estimated time
*/
double getCollectiveEpochCost() const {
// 100 ns
return 0.0000001;
auto getCollectiveEpochCost() const {
return std::chrono::nanoseconds(100);
}

private:
Expand Down
5 changes: 4 additions & 1 deletion src/vt/vrt/collection/balance/greedylb/greedylb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ void GreedyLB::loadStats() {
this_load_begin = this_load;

// Use an estimated load-balancing cost on average rank load to load-balance
if (avg_load > getCollectiveEpochCost()) {
auto avg_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(avg_load)
);
if (avg_ns > getCollectiveEpochCost()) {
should_lb = I > greedy_tolerance;
}

Expand Down
5 changes: 4 additions & 1 deletion src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ void HierarchicalLB::loadStats() {
this_load_begin = this_load;

// Use an estimated load-balancing cost on average rank load to load-balance
if (avg_load > getCollectiveEpochCost()) {
auto avg_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(avg_load)
);
if (avg_ns > getCollectiveEpochCost()) {
should_lb = I > hierlb_tolerance;
}

Expand Down
5 changes: 4 additions & 1 deletion src/vt/vrt/collection/balance/temperedlb/temperedlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,10 @@ void TemperedLB::runLB(LoadType total_load) {
}

// Use an estimated load-balancing cost on average rank load to load-balance
if (avg > getCollectiveEpochCost()) {
auto avg_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(avg)
);
if (avg_ns > getCollectiveEpochCost()) {
should_lb = max > (run_temperedlb_tolerance + 1.0) * target_max_load_;
}

Expand Down

0 comments on commit e987173

Please sign in to comment.