From 2b12618947ad790304aa22d4ea2c132668bda284 Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Wed, 24 May 2023 16:28:08 +0200 Subject: [PATCH] #2150: Types: Make Time a strong type and use it across the codebase --- src/vt/elm/elm_lb_data.cc | 26 ++-- src/vt/elm/elm_lb_data.h | 4 +- src/vt/event/event_record.h | 2 +- src/vt/phase/phase_manager.cc | 12 +- src/vt/runnable/runnable.cc | 4 +- src/vt/runtime/component/diagnostic.impl.h | 4 +- .../component/diagnostic_erased_value.h | 3 +- src/vt/runtime/component/diagnostic_value.cc | 4 +- src/vt/runtime/component/diagnostic_value.h | 12 +- src/vt/runtime/component/meter/timer.h | 6 +- src/vt/scheduler/scheduler.cc | 2 +- src/vt/scheduler/scheduler.h | 4 +- src/vt/timetrigger/trigger.h | 5 +- src/vt/timing/timing.cc | 2 +- src/vt/timing/timing_type.h | 140 +++++++++++++++++- src/vt/trace/trace.cc | 10 +- src/vt/trace/trace.h | 10 +- src/vt/trace/trace_lite.cc | 19 +-- src/vt/trace/trace_lite.h | 24 +-- src/vt/trace/trace_log.h | 21 +-- .../vrt/collection/balance/baselb/baselb.cc | 2 +- src/vt/vrt/collection/balance/baselb/baselb.h | 2 +- .../collection/balance/baselb/load_sampler.cc | 2 +- .../collection/balance/greedylb/greedylb.cc | 4 +- .../balance/hierarchicallb/hierlb.cc | 9 +- .../balance/hierarchicallb/hierlb.h | 2 +- src/vt/vrt/collection/balance/lb_common.cc | 2 +- src/vt/vrt/collection/balance/lb_common.h | 2 +- .../vrt/collection/balance/lb_data_holder.cc | 8 +- .../balance/lb_invoke/lb_manager.cc | 44 +++--- .../collection/balance/lb_invoke/lb_manager.h | 2 +- .../collection/balance/model/comm_overhead.cc | 4 +- .../collection/balance/model/comm_overhead.h | 4 +- .../collection/balance/model/linear_model.cc | 4 +- .../vrt/collection/balance/model/load_model.h | 4 +- .../balance/model/multiple_phases.cc | 2 +- src/vt/vrt/collection/balance/model/norm.cc | 8 +- .../vrt/collection/balance/model/raw_data.cc | 2 +- .../balance/model/select_subphases.cc | 2 +- .../model/weighted_communication_volume.cc | 2 +- .../balance/model/weighted_messages.cc | 2 +- .../balance/model/weighted_messages.h | 2 +- src/vt/vrt/collection/balance/stats_msg.h | 61 ++++---- .../balance/temperedlb/temperedlb.cc | 66 ++++----- .../balance/temperedlb/temperedlb.h | 6 +- tests/perf/common/test_harness.h | 7 +- tests/perf/common/timers.h | 8 +- tests/unit/collection/test_lb.extended.cc | 4 +- tests/unit/collection/test_lb_data_holder.cc | 2 +- .../test_model_comm_overhead.nompi.cc | 5 +- .../unit/collection/test_model_norm.nompi.cc | 2 +- .../test_model_per_collection.extended.cc | 2 +- .../test_model_weighted_messages.nompi.cc | 4 +- tests/unit/lb/test_offlinelb.cc | 2 +- tests/unit/lb/test_temperedlb.nompi.cc | 26 ++-- .../test_scheduler_progress.extended.cc | 4 +- .../unit/scheduler/test_scheduler_timings.cc | 6 +- .../timetrigger/test_time_trigger.extended.cc | 28 ++-- tests/unit/timing/test_timing.nompi.cc | 14 +- 59 files changed, 407 insertions(+), 269 deletions(-) diff --git a/src/vt/elm/elm_lb_data.cc b/src/vt/elm/elm_lb_data.cc index ff8f09ebad..75b3864f13 100644 --- a/src/vt/elm/elm_lb_data.cc +++ b/src/vt/elm/elm_lb_data.cc @@ -51,8 +51,8 @@ namespace vt { namespace elm { void ElementLBData::start(TimeType time) { - TimeTypeWrapper const start_time = time; - cur_time_ = start_time.seconds(); + auto const start_time = time; + cur_time_ = start_time; cur_time_started_ = true; vt_debug_print( @@ -63,8 +63,8 @@ void ElementLBData::start(TimeType time) { } void ElementLBData::stop(TimeType time) { - TimeTypeWrapper const stop_time = time; - TimeTypeWrapper const total_time = stop_time.seconds() - cur_time_; + auto const stop_time = time; + auto const total_time = stop_time - cur_time_; //vtAssert(cur_time_started_, "Must have started time"); auto const started = cur_time_started_; if (started) { @@ -124,17 +124,17 @@ void ElementLBData::recvToNode( recvComm(key, bytes); } -void ElementLBData::addTime(TimeTypeWrapper const& time) { - phase_timings_[cur_phase_] += time.seconds(); +void ElementLBData::addTime(TimeType const& time) { + phase_timings_[cur_phase_] += time; subphase_timings_[cur_phase_].resize(cur_subphase_ + 1); - subphase_timings_[cur_phase_].at(cur_subphase_) += time.seconds(); + subphase_timings_[cur_phase_].at(cur_subphase_) += time; vt_debug_print( verbose,lb, "ElementLBData: addTime: time={}, cur_load={}\n", time, - TimeTypeWrapper(phase_timings_[cur_phase_]) + phase_timings_[cur_phase_] ); } @@ -166,7 +166,7 @@ PhaseType ElementLBData::getPhase() const { TimeType ElementLBData::getLoad(PhaseType const& phase) const { auto iter = phase_timings_.find(phase); if (iter != phase_timings_.end()) { - TimeTypeWrapper const total_load = phase_timings_.at(phase); + auto const total_load = phase_timings_.at(phase); vt_debug_print( verbose, lb, @@ -174,9 +174,9 @@ TimeType ElementLBData::getLoad(PhaseType const& phase) const { total_load, phase, phase_timings_.size() ); - return total_load.seconds(); + return total_load; } else { - return 0.0; + return TimeType{0.0}; } } @@ -188,7 +188,7 @@ ElementLBData::getLoad(PhaseType phase, SubphaseType subphase) const { auto const& subphase_loads = subphase_timings_.at(phase); vtAssert(subphase_loads.size() > subphase, "Must have subphase"); - TimeTypeWrapper const total_load = subphase_loads.at(subphase); + auto const total_load = subphase_loads.at(subphase); vt_debug_print( verbose, lb, @@ -196,7 +196,7 @@ ElementLBData::getLoad(PhaseType phase, SubphaseType subphase) const { total_load, phase, subphase ); - return total_load.seconds(); + return total_load; } std::vector const& ElementLBData::getSubphaseTimes(PhaseType phase) { diff --git a/src/vt/elm/elm_lb_data.h b/src/vt/elm/elm_lb_data.h index 1ebc07c6c3..3e245e4337 100644 --- a/src/vt/elm/elm_lb_data.h +++ b/src/vt/elm/elm_lb_data.h @@ -63,7 +63,7 @@ struct ElementLBData { void start(TimeType time); void stop(TimeType time); - void addTime(TimeTypeWrapper const& time); + void addTime(TimeType const& time); void sendToEntity(ElementIDStruct to, ElementIDStruct from, double bytes); void sendComm(elm::CommKey key, double bytes); @@ -124,7 +124,7 @@ struct ElementLBData { protected: bool cur_time_started_ = false; - TimeType cur_time_ = 0.0; + TimeType cur_time_ = TimeType{0.0}; PhaseType cur_phase_ = fst_lb_phase; std::unordered_map phase_timings_ = {}; std::unordered_map phase_comm_ = {}; diff --git a/src/vt/event/event_record.h b/src/vt/event/event_record.h index 620d93b060..84ba9ea012 100644 --- a/src/vt/event/event_record.h +++ b/src/vt/event/event_record.h @@ -138,7 +138,7 @@ struct EventRecord { # if vt_check_enabled(diagnostics) /// the time this event record was created - TimeType creation_time_stamp_ = 0.; + TimeType creation_time_stamp_ = TimeType{0.}; # endif }; diff --git a/src/vt/phase/phase_manager.cc b/src/vt/phase/phase_manager.cc index 8ab41ab086..99089d10c2 100644 --- a/src/vt/phase/phase_manager.cc +++ b/src/vt/phase/phase_manager.cc @@ -296,17 +296,17 @@ void PhaseManager::printSummary(vrt::collection::lb::PhaseInfo* last_phase_info) auto lb_name = vrt::collection::balance::get_lb_names()[ last_phase_info->lb_type ]; - TimeTypeWrapper const total_time = timing::getCurrentTime() - start_time_; + auto const total_time = timing::getCurrentTime() - start_time_; vt_print( phase, "phase={}, duration={}, rank_max_compute_time={}, rank_avg_compute_time={}, imbalance={:.3f}, " "grain_max_time={}, migration count={}, lb_name={}\n", cur_phase_, total_time, - TimeTypeWrapper(last_phase_info->max_load), - TimeTypeWrapper(last_phase_info->avg_load), + TimeType(last_phase_info->max_load), + TimeType(last_phase_info->avg_load), last_phase_info->imb_load, - TimeTypeWrapper(last_phase_info->max_obj), + TimeType(last_phase_info->max_obj), last_phase_info->migration_count, lb_name ); @@ -315,8 +315,8 @@ void PhaseManager::printSummary(vrt::collection::lb::PhaseInfo* last_phase_info) // "POST phase={}, total time={}, max_load={}, avg_load={}, imbalance={:.3f}, migration count={}\n", // cur_phase_, // total_time, - // TimeTypeWrapper(last_phase_info->max_load_post_lb), - // TimeTypeWrapper(last_phase_info->avg_load_post_lb), + // TimeType(last_phase_info->max_load_post_lb), + // TimeType(last_phase_info->avg_load_post_lb), // last_phase_info->imb_load_post_lb, // last_phase_info->migration_count // ); diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index 4beb1dba91..b260b46962 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -124,7 +124,7 @@ void RunnableNew::run() { { needs_time = contexts_.lb.needsTime(); } - TimeType start_time = needs_time ? theSched()->getRecentTime() : NAN; + TimeType start_time = needs_time ? theSched()->getRecentTime() : TimeType{NAN}; #if vt_check_enabled(fcontext) if (suspended_) { @@ -175,7 +175,7 @@ void RunnableNew::run() { #endif } theSched()->setRecentTimeToStale(); - TimeType end_time = needs_time ? theSched()->getRecentTime() : NAN; + TimeType end_time = needs_time ? theSched()->getRecentTime() : TimeType{NAN}; diff --git a/src/vt/runtime/component/diagnostic.impl.h b/src/vt/runtime/component/diagnostic.impl.h index 041705eeb8..77fd279b53 100644 --- a/src/vt/runtime/component/diagnostic.impl.h +++ b/src/vt/runtime/component/diagnostic.impl.h @@ -93,7 +93,7 @@ meter::Timer Diagnostic::registerTimerT( ) { auto sum = registerDiagnostic( key + " [sum]", desc, DiagnosticUpdate::Sum, unit, - DiagnosticTypeEnum::PerformanceDiagnostic, 0 + DiagnosticTypeEnum::PerformanceDiagnostic, T{0} ); auto min = registerDiagnostic( key + " [min]", desc, DiagnosticUpdate::Min, unit, @@ -105,7 +105,7 @@ meter::Timer Diagnostic::registerTimerT( ); auto avg = registerDiagnostic( key + " [avg]", desc, DiagnosticUpdate::Avg, unit, - DiagnosticTypeEnum::PerformanceDiagnostic, 0 + DiagnosticTypeEnum::PerformanceDiagnostic, T{0} ); return meter::Timer{sum, avg, max, min}; } diff --git a/src/vt/runtime/component/diagnostic_erased_value.h b/src/vt/runtime/component/diagnostic_erased_value.h index ac4f450aed..df32860313 100644 --- a/src/vt/runtime/component/diagnostic_erased_value.h +++ b/src/vt/runtime/component/diagnostic_erased_value.h @@ -46,6 +46,7 @@ #include "vt/runtime/component/diagnostic_types.h" #include "vt/utils/adt/histogram_approx.h" +#include "vt/timing/timing_type.h" #include "vt/utils/strong/strong_type.h" #include @@ -62,7 +63,7 @@ namespace vt { namespace runtime { namespace component { struct DiagnosticErasedValue { /// These are the set of valid diagnostic value types after being erased from /// \c DiagnosticValue get turned into this union for saving the value. - using UnionValueType = std::variant; + using UnionValueType = std::variant; // The trio (min, max, sum) save the actual type with the value to print it // correctly diff --git a/src/vt/runtime/component/diagnostic_value.cc b/src/vt/runtime/component/diagnostic_value.cc index aed26aaaf2..75c6d48e0f 100644 --- a/src/vt/runtime/component/diagnostic_value.cc +++ b/src/vt/runtime/component/diagnostic_value.cc @@ -47,6 +47,7 @@ #include "vt/collective/reduce/operators/default_msg.h" #include "vt/collective/reduce/reduce.h" #include "vt/pipe/pipe_manager.h" +#include "vt/timing/timing_type.h" #include @@ -80,7 +81,7 @@ void reduceHelper( if (update == DiagnosticUpdate::Min) { out->is_valid_value_ = reduced_val.min() != std::numeric_limits::max(); } else { - out->is_valid_value_ = reduced_val.sum() != 0; + out->is_valid_value_ = reduced_val.sum() != T{0}; } } ); @@ -110,5 +111,6 @@ void reduceHelper( DIAGNOSTIC_VALUE_INSTANCE(int64_t) DIAGNOSTIC_VALUE_INSTANCE(double) +DIAGNOSTIC_VALUE_INSTANCE(TimeType) }}}} /* end namespace vt::runtime::component::detail */ diff --git a/src/vt/runtime/component/diagnostic_value.h b/src/vt/runtime/component/diagnostic_value.h index 9916dca5bc..6d3995dacf 100644 --- a/src/vt/runtime/component/diagnostic_value.h +++ b/src/vt/runtime/component/diagnostic_value.h @@ -93,15 +93,15 @@ struct DiagnosticValueWrapper { N_(in_N), min_(updated ? in_value : std::numeric_limits::max()), max_(updated ? in_value : std::numeric_limits::lowest()), - sum_(updated ? in_value : 0), - avg_(updated ? in_value : 0), + sum_(updated ? in_value : T{0}), + avg_(updated ? static_cast(in_value) : 0), M2_(0.), M3_(0.), M4_(0.), hist_(16) { // add to histogram when starting the reduction - hist_.add(value_); + hist_.add(static_cast(value_)); } /** @@ -168,7 +168,7 @@ struct DiagnosticValueWrapper { * * \return the max value */ - T max() const { return N_ == 0 ? 0 : max_; } + T max() const { return N_ == 0 ? T{0} : max_; } /** * \internal \brief Get sum of values (use after reduction) @@ -182,7 +182,7 @@ struct DiagnosticValueWrapper { * * \return the min value */ - T min() const { return N_ == 0 ? 0 : min_; } + T min() const { return N_ == 0 ? T{0} : min_; } /** * \internal \brief Get the arithmetic mean value (use after reduction) @@ -280,7 +280,7 @@ struct DiagnosticValueWrapper { private: T value_; /**< The raw value */ std::size_t N_ = 0; /**< The cardinality */ - T min_ = {}, max_ = {}, sum_ = {}; /**< The min/max/sum for reduction */ + T min_ = T{}, max_ = T{}, sum_ = T{}; /**< The min/max/sum for reduction */ /** * The avg and 2/3/4 moments for reduction */ diff --git a/src/vt/runtime/component/meter/timer.h b/src/vt/runtime/component/meter/timer.h index 65cc0d4e40..7e1a40efc9 100644 --- a/src/vt/runtime/component/meter/timer.h +++ b/src/vt/runtime/component/meter/timer.h @@ -102,9 +102,9 @@ struct Timer : DiagnosticStatsPack { * \brief Stop the timer and record the interval */ void stop() { - if (start_time_ != 0) { + if (start_time_ != TimeType{0.}) { update(start_time_, timing::getCurrentTime()); - start_time_ = 0; + start_time_ = TimeType{0.}; } } @@ -116,7 +116,7 @@ struct Timer : DiagnosticStatsPack { } private: - T start_time_ = 0; + T start_time_ = T{0}; }; }}}} /* end namespace vt::runtime::component::meter */ diff --git a/src/vt/scheduler/scheduler.cc b/src/vt/scheduler/scheduler.cc index c5e3fba67f..7c15cc3482 100644 --- a/src/vt/scheduler/scheduler.cc +++ b/src/vt/scheduler/scheduler.cc @@ -179,7 +179,7 @@ bool Scheduler::shouldCallProgress( processed_since_last_progress >= theConfig()->vt_sched_progress_han; bool enough_time_passed = progress_time_enabled_ and - time_since_last_progress > theConfig()->vt_sched_progress_sec; + time_since_last_progress > TimeType{theConfig()->vt_sched_progress_sec}; return (not progress_time_enabled_ and not k_handler_enabled) or diff --git a/src/vt/scheduler/scheduler.h b/src/vt/scheduler/scheduler.h index 1f01738c0b..85fbb2a58f 100644 --- a/src/vt/scheduler/scheduler.h +++ b/src/vt/scheduler/scheduler.h @@ -178,7 +178,7 @@ struct Scheduler : runtime::component::Component { * * \param[in] current_time current time */ - void runProgress(bool msg_only = false, TimeType current_time = 0.0 ); + void runProgress(bool msg_only = false, TimeType current_time = TimeType{0.0} ); /** * \brief Runs the scheduler until a condition is met. @@ -438,7 +438,7 @@ struct Scheduler : runtime::component::Component { EventTriggerContType event_triggers; EventTriggerContType event_triggers_once; - TimeType last_progress_time_ = 0.0; + TimeType last_progress_time_ = TimeType{0.0}; bool progress_time_enabled_ = false; int32_t processed_after_last_progress_ = 0; diff --git a/src/vt/timetrigger/trigger.h b/src/vt/timetrigger/trigger.h index 2b382141ae..ebc5a947de 100644 --- a/src/vt/timetrigger/trigger.h +++ b/src/vt/timetrigger/trigger.h @@ -85,7 +85,8 @@ struct Trigger { * \return the next time this should be triggered */ TimeType nextTriggerTime() const { - return (last_trigger_time_*1000.0 + period_.count())/1000.0; + return TimeType{ + (last_trigger_time_.milliseconds() + period_.count()) / 1000.0}; } /** @@ -141,7 +142,7 @@ struct Trigger { private: std::chrono::milliseconds period_; /**< The trigger's period */ ActionType trigger_ = nullptr; /**< The action to trigger */ - TimeType last_trigger_time_ = 0.; /**< The last time it was triggered */ + TimeType last_trigger_time_ = TimeType{0.}; /**< The last time it was triggered */ int id_ = -1; /**< The trigger's id */ }; diff --git a/src/vt/timing/timing.cc b/src/vt/timing/timing.cc index 059449d502..76b5bf5e99 100644 --- a/src/vt/timing/timing.cc +++ b/src/vt/timing/timing.cc @@ -49,7 +49,7 @@ namespace vt { namespace timing { TimeType getCurrentTime() { - return MPI_Wtime(); + return TimeType{MPI_Wtime()}; } }} /* end namespace vt::timing */ diff --git a/src/vt/timing/timing_type.h b/src/vt/timing/timing_type.h index 222b2085c3..8dc16c0922 100644 --- a/src/vt/timing/timing_type.h +++ b/src/vt/timing/timing_type.h @@ -44,14 +44,116 @@ #if !defined INCLUDED_VT_TIMING_TIMING_TYPE_H #define INCLUDED_VT_TIMING_TIMING_TYPE_H -namespace vt { +#include +#include +#include -using TimeType = double; +namespace vt { struct TimeTypeWrapper { - TimeTypeWrapper(const TimeType time) : time_(time) {} + using TimeTypeInternal = double; + explicit constexpr TimeTypeWrapper(const TimeTypeInternal time = 0.0) + : time_(time) { } + + explicit operator double() const { return time_; } + + TimeTypeWrapper& operator+=(const TimeTypeWrapper& other) { + time_ += other.time_; + return *this; + } + + TimeTypeWrapper& operator-=(const TimeTypeWrapper& other) { + time_ -= other.time_; + return *this; + } + + TimeTypeWrapper& operator*=(const double scalar) { + time_ *= scalar; + return *this; + } + + TimeTypeWrapper& operator/=(const double scalar) { + time_ /= scalar; + return *this; + } + + friend TimeTypeWrapper + operator+(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return TimeTypeWrapper(lhs.time_ + rhs.time_); + } + + friend TimeTypeWrapper + operator-(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return TimeTypeWrapper(lhs.time_ - rhs.time_); + } + + friend TimeTypeWrapper + operator*(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return TimeTypeWrapper(lhs.time_ * rhs.time_); + } + + friend TimeTypeWrapper + operator*(const TimeTypeWrapper& time, const double scalar) { + return TimeTypeWrapper(time.time_ * scalar); + } + + friend TimeTypeWrapper + operator*(const double scalar, const TimeTypeWrapper& time) { + return TimeTypeWrapper(time.time_ * scalar); + } + + friend TimeTypeWrapper + operator/(const double scalar, const TimeTypeWrapper& time) { + return TimeTypeWrapper(scalar / time.time_); + } + + friend TimeTypeWrapper + operator/(const TimeTypeWrapper& time, const double scalar) { + return TimeTypeWrapper(time.time_ / scalar); + } + + friend TimeTypeWrapper + operator/(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return TimeTypeWrapper(lhs.time_ / rhs.time_); + } + + friend bool + operator<(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return lhs.time_ < rhs.time_; + } + + friend bool + operator<=(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return lhs.time_ <= rhs.time_; + } + + friend bool + operator>(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return lhs.time_ > rhs.time_; + } + + friend bool + operator>=(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return lhs.time_ >= rhs.time_; + } + + friend bool + operator==(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return lhs.time_ == rhs.time_; + } + + friend bool + operator!=(const TimeTypeWrapper& lhs, const TimeTypeWrapper& rhs) { + return lhs.time_ != rhs.time_; + } - TimeType seconds() const {return time_; } + friend TimeTypeWrapper sqrt(const TimeTypeWrapper& time) { + return TimeTypeWrapper{std::sqrt(time.time_)}; + } + + TimeTypeInternal seconds() const { return time_; } + TimeTypeInternal milliseconds() const { return time_ * 1000; } + TimeTypeInternal microseconds() const { return time_ * 1000000; } template void serialize(Serializer& s) { @@ -59,9 +161,37 @@ struct TimeTypeWrapper { } private: - TimeType time_; + TimeTypeInternal time_; }; +using TimeType = TimeTypeWrapper; + } /* end namespace vt */ +namespace std { +template <> +class numeric_limits { + using Type = typename vt::TimeTypeWrapper::TimeTypeInternal; + +public: + static constexpr vt::TimeTypeWrapper max() noexcept { + return vt::TimeTypeWrapper(std::numeric_limits::max()); + } + + static constexpr vt::TimeTypeWrapper lowest() noexcept { + return vt::TimeTypeWrapper(std::numeric_limits::lowest()); + } + + inline vt::TimeTypeWrapper + min(const vt::TimeTypeWrapper& lhs, const vt::TimeTypeWrapper& rhs) { + return vt::TimeTypeWrapper(std::min(lhs.seconds(), rhs.seconds())); + } + + inline vt::TimeTypeWrapper + max(const vt::TimeTypeWrapper& lhs, const vt::TimeTypeWrapper& rhs) { + return vt::TimeTypeWrapper(std::max(lhs.seconds(), rhs.seconds())); + } +}; +} // namespace std + #endif /*INCLUDED_VT_TIMING_TIMING_TYPE_H*/ diff --git a/src/vt/trace/trace.cc b/src/vt/trace/trace.cc index c9416f28c0..7d3b8331a1 100644 --- a/src/vt/trace/trace.cc +++ b/src/vt/trace/trace.cc @@ -311,7 +311,7 @@ void Trace::addUserEventBracketedManualEnd(UserSpecEventIDType event) { } void Trace::addUserEventBracketedManual( - UserSpecEventIDType event, double begin, double end + UserSpecEventIDType event, TimeType begin, TimeType end ) { if (not checkDynamicRuntimeEnabled()) { return; @@ -327,7 +327,7 @@ void Trace::addUserEventBracketedManual( addUserEventBracketed(id, begin, end); } -void Trace::addMemoryEvent(std::size_t memory, double time) { +void Trace::addMemoryEvent(std::size_t memory, TimeType time) { auto const type = TraceConstantsType::MemoryUsageCurrent; logEvent(LogType{time, type, memory}); } @@ -455,7 +455,7 @@ void Trace::endSchedulerLoop() { } TraceEventIDType Trace::messageCreation( - TraceEntryIDType const ep, TraceMsgLenType const len, double const time + TraceEntryIDType const ep, TraceMsgLenType const len, TimeType const time ) { if (not checkDynamicRuntimeEnabled()) { return no_trace_event; @@ -470,7 +470,7 @@ TraceEventIDType Trace::messageCreation( } TraceEventIDType Trace::messageCreationBcast( - TraceEntryIDType const ep, TraceMsgLenType const len, double const time + TraceEntryIDType const ep, TraceMsgLenType const len, TimeType const time ) { if (not checkDynamicRuntimeEnabled()) { return no_trace_event; @@ -486,7 +486,7 @@ TraceEventIDType Trace::messageCreationBcast( TraceEventIDType Trace::messageRecv( TraceEntryIDType const ep, TraceMsgLenType const len, - NodeType const from_node, double const time + NodeType const from_node, TimeType const time ) { if (not checkDynamicRuntimeEnabled()) { return no_trace_event; diff --git a/src/vt/trace/trace.h b/src/vt/trace/trace.h index 30fc33695d..c364a644e4 100644 --- a/src/vt/trace/trace.h +++ b/src/vt/trace/trace.h @@ -242,7 +242,7 @@ struct Trace : runtime::component::Component, TraceLite { * \param[in] end the end time */ void addUserEventBracketedManual( - UserSpecEventIDType event, double begin, double end + UserSpecEventIDType event, TimeType begin, TimeType end ); /** @@ -295,7 +295,7 @@ struct Trace : runtime::component::Component, TraceLite { */ void addMemoryEvent( std::size_t memory, - double const time = getCurrentTime() + TimeType const time = getCurrentTime() ); /** @@ -309,7 +309,7 @@ struct Trace : runtime::component::Component, TraceLite { */ TraceEventIDType messageCreation( TraceEntryIDType const ep, TraceMsgLenType const len, - double const time = getCurrentTime() + TimeType const time = getCurrentTime() ); /** @@ -323,7 +323,7 @@ struct Trace : runtime::component::Component, TraceLite { */ TraceEventIDType messageCreationBcast( TraceEntryIDType const ep, TraceMsgLenType const len, - double const time = getCurrentTime() + TimeType const time = getCurrentTime() ); /** @@ -338,7 +338,7 @@ struct Trace : runtime::component::Component, TraceLite { */ TraceEventIDType messageRecv( TraceEntryIDType const ep, TraceMsgLenType const len, - NodeType const from_node, double const time = getCurrentTime() + NodeType const from_node, TimeType const time = getCurrentTime() ); /** diff --git a/src/vt/trace/trace_lite.cc b/src/vt/trace/trace_lite.cc index 3e134bf91c..035d3370e3 100644 --- a/src/vt/trace/trace_lite.cc +++ b/src/vt/trace/trace_lite.cc @@ -42,6 +42,7 @@ */ #include "vt/trace/trace_lite.h" +#include "vt/timing/timing_type.h" #if !vt_check_enabled(trace_only) #include "vt/collective/collective_alg.h" #endif @@ -248,7 +249,7 @@ bool TraceLite::checkDynamicRuntimeEnabled(bool is_end_event) { } void TraceLite::addUserEventBracketed( - UserEventIDType event, double begin, double end) { + UserEventIDType event, TimeType begin, TimeType end) { if (not checkDynamicRuntimeEnabled()) { return; } @@ -266,7 +267,7 @@ void TraceLite::addUserEventBracketed( } void TraceLite::addUserBracketedNote( - double const begin, double const end, std::string const& note, + TimeType const begin, TimeType const end, std::string const& note, TraceEventIDType const event ) { if (not checkDynamicRuntimeEnabled()) { @@ -295,7 +296,7 @@ TraceEventIDType TraceLite::logEvent(LogType&& log) { TraceRegistry::getEvent(log.ep).theEventId() not_eq no_trace_entry_id, "Event must exist that was logged"); - double time = log.time; + TimeType time = log.time; // Close any idle event as soon as we encounter any other type of event. if (idle_begun_) { @@ -348,7 +349,7 @@ TraceEventIDType TraceLite::logEvent(LogType&& log) { } -void TraceLite::beginIdle(double const time) { +void TraceLite::beginIdle(TimeType const time) { if (idle_begun_) { return; } @@ -370,7 +371,7 @@ void TraceLite::beginIdle(double const time) { idle_begun_ = true; // must set AFTER logEvent } -void TraceLite::endIdle(double const time) { +void TraceLite::endIdle(TimeType const time) { if (not idle_begun_) { return; } @@ -393,7 +394,7 @@ void TraceLite::endIdle(double const time) { } void TraceLite::emitTraceForTopProcessingEvent( - double const time, TraceConstantsType const type) { + TimeType const time, TraceConstantsType const type) { if (not open_events_.empty()) { traces_.push(LogType{open_events_.back(), time, type}); } @@ -508,7 +509,7 @@ void TraceLite::writeTracesFile(int flush, bool is_incremental_flush) { } /*static*/ void TraceLite::outputTraces( - vt_gzFile* file, TraceContainerType& traces, double start_time, int flush) { + vt_gzFile* file, TraceContainerType& traces, TimeType start_time, int flush) { auto const num_nodes = theContext()->getNumNodes(); gzFile gzfile = file->file_type; @@ -713,7 +714,7 @@ void TraceLite::outputControlFile(std::ofstream& file) { } /*static*/ void TraceLite::outputHeader( - vt_gzFile* file, NodeType const node, double const start) { + vt_gzFile* file, NodeType const node, TimeType const start) { gzFile gzfile = file->file_type; // Output header for projections file // '6' means COMPUTATION_BEGIN to Projections: this starts a trace @@ -722,7 +723,7 @@ void TraceLite::outputControlFile(std::ofstream& file) { } /*static*/ void TraceLite::outputFooter( - vt_gzFile* file, NodeType const node, double const start) { + vt_gzFile* file, NodeType const node, TimeType const start) { gzFile gzfile = file->file_type; // Output footer for projections file, // '7' means COMPUTATION_END to Projections diff --git a/src/vt/trace/trace_lite.h b/src/vt/trace/trace_lite.h index e39e4da45c..e1d53a4316 100644 --- a/src/vt/trace/trace_lite.h +++ b/src/vt/trace/trace_lite.h @@ -172,7 +172,7 @@ struct TraceLite { * \param[in] begin the begin time * \param[in] end the end time */ - void addUserEventBracketed(UserEventIDType event, double begin, double end); + void addUserEventBracketed(UserEventIDType event, TimeType begin, TimeType end); /** * \brief Log a user bracketed event with a note @@ -183,7 +183,7 @@ struct TraceLite { * \param[in] event the event ID */ void addUserBracketedNote( - double const begin, double const end, std::string const& note, + TimeType const begin, TimeType const end, std::string const& note, TraceEventIDType const event = no_trace_event ); @@ -192,14 +192,14 @@ struct TraceLite { * * \param[in] time time it begins idle */ - void beginIdle(double const time = getCurrentTime()); + void beginIdle(TimeType const time = getCurrentTime()); /** * \brief Scheduler trigger for \c sched::SchedulerEvent::EndIdle * * \param[in] time time it ends idle */ - void endIdle(double const time = getCurrentTime()); + void endIdle(TimeType const time = getCurrentTime()); /** * \internal \brief Check if tracing is enabled @@ -237,7 +237,7 @@ struct TraceLite { * * \return query the current clock time */ - static inline double getCurrentTime() { + static inline TimeType getCurrentTime() { return ::vt::timing::getCurrentTime(); } @@ -248,8 +248,8 @@ struct TraceLite { * * \return time in microsecond as integer */ - static inline TimeIntegerType timeToMicros(double const time) { - return static_cast(time * 1e6); + static inline TimeIntegerType timeToMicros(TimeType const time) { + return time.microseconds(); } /** @@ -279,7 +279,7 @@ struct TraceLite { * \param[in] type type of event to emit */ void emitTraceForTopProcessingEvent( - double const time, TraceConstantsType const type + TimeType const time, TraceConstantsType const type ); /** @@ -293,7 +293,7 @@ struct TraceLite { */ static void outputTraces( vt_gzFile* file, TraceContainerType& traces, - double start_time, int flush + TimeType start_time, int flush ); /** @@ -304,7 +304,7 @@ struct TraceLite { * \param[in] start the start time */ static void outputHeader( - vt_gzFile* file, NodeType const node, double const start + vt_gzFile* file, NodeType const node, TimeType const start ); /** @@ -315,7 +315,7 @@ struct TraceLite { * \param[in] start the start time */ static void outputFooter( - vt_gzFile* file, NodeType const node, double const start + vt_gzFile* file, NodeType const node, TimeType const start ); /** @@ -385,7 +385,7 @@ struct TraceLite { TraceEventIDType cur_event_ = 1; UserEventIDType flush_event_ = no_user_event_id; bool enabled_ = true; - double start_time_ = 0.0; + TimeType start_time_ = TimeType{0.0}; std::string prog_name_ = ""; std::string trace_name_ = ""; std::string full_trace_name_ = ""; diff --git a/src/vt/trace/trace_log.h b/src/vt/trace/trace_log.h index cf495a3eb5..3447f2ab4c 100644 --- a/src/vt/trace/trace_log.h +++ b/src/vt/trace/trace_log.h @@ -47,6 +47,7 @@ #include "vt/config.h" #include "vt/trace/trace_common.h" #include "vt/trace/trace_constants.h" +#include "vt/timing/timing_type.h" #include #include @@ -246,7 +247,7 @@ struct Log final { // User event Log( - double const in_begin_time, double const in_end_time, + TimeType const in_begin_time, TimeType const in_end_time, TraceConstantsType const in_type, std::string const& in_note, TraceEventIDType const in_event ) : time(in_begin_time), end_time(in_end_time), @@ -257,7 +258,7 @@ struct Log final { // User event Log( - double const in_time, TraceConstantsType const in_type, + TimeType const in_time, TraceConstantsType const in_type, std::string const& in_note, UserDataType in_data ) : time(in_time), type(in_type), data(Data::UserData{in_note, 0, 0, false}) @@ -266,7 +267,7 @@ struct Log final { // User event Log( - double const in_time, TraceConstantsType const in_type, + TimeType const in_time, TraceConstantsType const in_type, NodeType in_node, UserEventIDType in_user_event, bool in_user_start ) : time(in_time), type(in_type), @@ -277,7 +278,7 @@ struct Log final { // Used for idle Log( - double const in_time, TraceConstantsType const in_type, + TimeType const in_time, TraceConstantsType const in_type, NodeType in_node ) : time(in_time), type(in_type), node(in_node), @@ -287,7 +288,7 @@ struct Log final { // Used for messages Log( - double const in_time, TraceEntryIDType const in_ep, TraceConstantsType const in_type, + TimeType const in_time, TraceEntryIDType const in_ep, TraceConstantsType const in_type, NodeType in_node, TraceMsgLenType const in_msg_len ) : time(in_time), type(in_type), ep(in_ep), @@ -299,7 +300,7 @@ struct Log final { // Generate paired begin/end logs (copies with few changes) // NOT VALID FOR USER EVENTS Log( - Log const& in, double in_time, TraceConstantsType in_type + Log const& in, TimeType in_time, TraceConstantsType in_type ) : time(in_time), type(in_type), ep(in.ep), event(in.event), node(in.node), data(in.sys_data()) @@ -307,7 +308,7 @@ struct Log final { } Log( - double in_time, TraceEntryIDType in_ep, TraceConstantsType in_type, + TimeType in_time, TraceEntryIDType in_ep, TraceConstantsType in_type, TraceEventIDType in_event, TraceMsgLenType in_msg_len, NodeType in_node, uint64_t in_idx1, uint64_t in_idx2, uint64_t in_idx3, uint64_t in_idx4 ) : time(in_time), type(in_type), ep(in_ep), event(in_event), @@ -319,7 +320,7 @@ struct Log final { // Memory usage event, could create another union type here, but hardly seems // worth it; re-use SysData Log( - double in_time, TraceConstantsType in_type, std::size_t in_memory_bytes + TimeType in_time, TraceConstantsType in_type, std::size_t in_memory_bytes ) : time(in_time), type(in_type), data(Data::SysData{in_memory_bytes}) { } @@ -350,10 +351,10 @@ struct Log final { // Excluding sys/user-specific data, expected ~24 bytes // Time of the event - all events need a time. - double time = 0.0; + TimeType time = TimeType{0.0}; // If a duration can be expressed in a single event. // (Currently only for user-events.. could elim explicit end events.) - double end_time = 0.0; + TimeType end_time = TimeType{0.0}; TraceConstantsType type = TraceConstantsType::InvalidTraceType; TraceEntryIDType ep = no_trace_entry_id; diff --git a/src/vt/vrt/collection/balance/baselb/baselb.cc b/src/vt/vrt/collection/balance/baselb/baselb.cc index 773c3be388..3c934cec07 100644 --- a/src/vt/vrt/collection/balance/baselb/baselb.cc +++ b/src/vt/vrt/collection/balance/baselb/baselb.cc @@ -251,7 +251,7 @@ void BaseLB::finalize(int32_t global_count) { auto const& this_node = theContext()->getNode(); if (this_node == 0) { - TimeTypeWrapper const total_time = timing::getCurrentTime() - start_time_; + TimeType const total_time = timing::getCurrentTime() - start_time_; vt_debug_print( terse, lb, "BaseLB::finalize: LB total time={}\n", diff --git a/src/vt/vrt/collection/balance/baselb/baselb.h b/src/vt/vrt/collection/balance/baselb/baselb.h index 0ed065de76..46a6064259 100644 --- a/src/vt/vrt/collection/balance/baselb/baselb.h +++ b/src/vt/vrt/collection/balance/baselb/baselb.h @@ -168,7 +168,7 @@ struct BaseLB { protected: void getArgs(PhaseType phase); - double start_time_ = 0.0f; + TimeType start_time_ = TimeType{0.0}; ElementCommType const* comm_data = nullptr; balance::DataMapType const* user_data_ = nullptr; objgroup::proxy::Proxy proxy_ = {}; diff --git a/src/vt/vrt/collection/balance/baselb/load_sampler.cc b/src/vt/vrt/collection/balance/baselb/load_sampler.cc index 1ac32631d4..cda4df4060 100644 --- a/src/vt/vrt/collection/balance/baselb/load_sampler.cc +++ b/src/vt/vrt/collection/balance/baselb/load_sampler.cc @@ -49,7 +49,7 @@ namespace vt { namespace vrt { namespace collection { namespace lb { void LoadSamplerBaseLB::buildHistogram() { for (auto obj : *load_model_) { - TimeTypeWrapper load = load_model_->getModeledLoad( + TimeType load = load_model_->getModeledLoad( obj, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE} ); auto const& load_milli = loadMilli(load.seconds()); diff --git a/src/vt/vrt/collection/balance/greedylb/greedylb.cc b/src/vt/vrt/collection/balance/greedylb/greedylb.cc index ac02d87e38..550eba9495 100644 --- a/src/vt/vrt/collection/balance/greedylb/greedylb.cc +++ b/src/vt/vrt/collection/balance/greedylb/greedylb.cc @@ -144,7 +144,7 @@ void GreedyLB::inputParams(balance::ConfigEntry* config) { } void GreedyLB::runLB(TimeType total_load) { - this_load = loadMilli(total_load); + this_load = loadMilli(total_load.seconds()); buildHistogram(); loadStats(); } @@ -414,7 +414,7 @@ void GreedyLB::loadOverBin(ObjBinType bin, ObjBinListType& bin_list) { auto const& obj_time_milli = loadMilli(load_model_->getModeledLoad( obj_id, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE} - )); + ).seconds()); this_load -= obj_time_milli; diff --git a/src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc b/src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc index 5c3a7bf825..9b52b38c01 100644 --- a/src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc +++ b/src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc @@ -42,6 +42,7 @@ */ #include "vt/config.h" +#include "vt/timing/timing_type.h" #include "vt/vrt/collection/balance/hierarchicallb/hierlb.h" #include "vt/vrt/collection/balance/hierarchicallb/hierlb.fwd.h" #include "vt/vrt/collection/balance/hierarchicallb/hierlb_types.h" @@ -153,7 +154,7 @@ void HierarchicalLB::inputParams(balance::ConfigEntry* config) { } } -void HierarchicalLB::setupTree(TimeTypeWrapper const threshold) { +void HierarchicalLB::setupTree(TimeType const threshold) { vtAssert( tree_setup == false, "Tree must not already be set up when is this called" @@ -313,7 +314,7 @@ void HierarchicalLB::loadOverBin(ObjBinType bin, ObjBinListType& bin_list) { auto const& obj_time_milli = loadMilli(load_model_->getModeledLoad(obj_id, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE} - )); + ).seconds()); this_load -= obj_time_milli; @@ -789,9 +790,9 @@ void HierarchicalLB::clearObj(ObjSampleType& objs) { } void HierarchicalLB::runLB(TimeType total_load) { - this_load = loadMilli(total_load); + this_load = total_load.milliseconds(); buildHistogram(); - setupTree(min_threshold); + setupTree(TimeType{min_threshold}); proxy.allreduce<&HierarchicalLB::setupDone>(); } diff --git a/src/vt/vrt/collection/balance/hierarchicallb/hierlb.h b/src/vt/vrt/collection/balance/hierarchicallb/hierlb.h index 2a2fbc1aa1..77f73519f2 100644 --- a/src/vt/vrt/collection/balance/hierarchicallb/hierlb.h +++ b/src/vt/vrt/collection/balance/hierarchicallb/hierlb.h @@ -78,7 +78,7 @@ struct HierarchicalLB : LoadSamplerBaseLB { static std::unordered_map getInputKeysWithHelp(); - void setupTree(TimeTypeWrapper const threshold); + void setupTree(TimeType const threshold); void calcLoadOver(HeapExtractEnum const extract); void loadOverBin(ObjBinType bin, ObjBinListType& bin_list); void procDataIn(ElementLoadType const& data_in); diff --git a/src/vt/vrt/collection/balance/lb_common.cc b/src/vt/vrt/collection/balance/lb_common.cc index 2a52049170..43aba1de7b 100644 --- a/src/vt/vrt/collection/balance/lb_common.cc +++ b/src/vt/vrt/collection/balance/lb_common.cc @@ -102,7 +102,7 @@ LoadSummary getNodeLoads(std::shared_ptr model, PhaseOffset when) LoadSummary ret; auto subphases = model->getNumSubphases(); - ret.subphase_loads.resize(subphases, 0.0); + ret.subphase_loads.resize(subphases, TimeType{0.0}); for (auto obj : *model) { ret += getObjectLoads(model, obj, when); diff --git a/src/vt/vrt/collection/balance/lb_common.h b/src/vt/vrt/collection/balance/lb_common.h index 5bf55487fa..40c118a6e2 100644 --- a/src/vt/vrt/collection/balance/lb_common.h +++ b/src/vt/vrt/collection/balance/lb_common.h @@ -85,7 +85,7 @@ struct PhaseOffset { }; struct LoadSummary { - TimeType whole_phase_load = 0.0; + TimeType whole_phase_load = TimeType{0.0}; std::vector subphase_loads = {}; TimeType get(PhaseOffset when) const diff --git a/src/vt/vrt/collection/balance/lb_data_holder.cc b/src/vt/vrt/collection/balance/lb_data_holder.cc index c2da1c2bf5..0c213e6b44 100644 --- a/src/vt/vrt/collection/balance/lb_data_holder.cc +++ b/src/vt/vrt/collection/balance/lb_data_holder.cc @@ -138,7 +138,7 @@ std::unique_ptr LBDataHolder::toJson(PhaseType phase) const { TimeType time = elm.second.whole_phase_load; j["tasks"][i]["resource"] = "cpu"; j["tasks"][i]["node"] = id.getCurrNode(); - j["tasks"][i]["time"] = time; + j["tasks"][i]["time"] = time.seconds(); if (user_defined_json_.find(phase) != user_defined_json_.end()) { auto &user_def_this_phase = user_defined_json_.at(phase); if (user_def_this_phase.find(id) != user_def_this_phase.end()) { @@ -155,7 +155,7 @@ std::unique_ptr LBDataHolder::toJson(PhaseType phase) const { if (subphases != 0) { for (std::size_t s = 0; s < subphases; s++) { j["tasks"][i]["subphases"][s]["id"] = s; - j["tasks"][i]["subphases"][s]["time"] = subphase_times[s]; + j["tasks"][i]["subphases"][s]["time"] = subphase_times[s].seconds(); } } @@ -251,7 +251,7 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j) vtAssertExpr(object.is_number()); auto elm = ElementIDStruct{object, node}; - this->node_data_[id][elm].whole_phase_load = time; + this->node_data_[id][elm].whole_phase_load = TimeType{time}; if ( task["entity"].find("collection_id") != task["entity"].end() and @@ -278,7 +278,7 @@ LBDataHolder::LBDataHolder(nlohmann::json const& j) this->node_data_[id][elm].subphase_loads.resize( static_cast(sid) + 1); - this->node_data_[id][elm].subphase_loads[sid] = stime; + this->node_data_[id][elm].subphase_loads[sid] = TimeType{stime}; } } } diff --git a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc index 82a80e351c..dd3f91136c 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc @@ -499,31 +499,31 @@ void LBManager::statsHandler(std::vector const& in_stat_vec) auto skew = st.skew(); auto krte = st.krte(); - stats[stat][lb::StatisticQuantity::max] = max; - stats[stat][lb::StatisticQuantity::min] = min; - stats[stat][lb::StatisticQuantity::avg] = avg; - stats[stat][lb::StatisticQuantity::sum] = sum; + stats[stat][lb::StatisticQuantity::max] = max.seconds(); + stats[stat][lb::StatisticQuantity::min] = min.seconds(); + stats[stat][lb::StatisticQuantity::avg] = avg.seconds(); + stats[stat][lb::StatisticQuantity::sum] = sum.seconds(); stats[stat][lb::StatisticQuantity::npr] = npr; stats[stat][lb::StatisticQuantity::car] = car; - stats[stat][lb::StatisticQuantity::var] = var; + stats[stat][lb::StatisticQuantity::var] = var.seconds(); stats[stat][lb::StatisticQuantity::npr] = npr; - stats[stat][lb::StatisticQuantity::imb] = imb; - stats[stat][lb::StatisticQuantity::std] = stdv; - stats[stat][lb::StatisticQuantity::skw] = skew; - stats[stat][lb::StatisticQuantity::kur] = krte; + stats[stat][lb::StatisticQuantity::imb] = imb.seconds(); + stats[stat][lb::StatisticQuantity::std] = stdv.seconds(); + stats[stat][lb::StatisticQuantity::skw] = skew.seconds(); + stats[stat][lb::StatisticQuantity::kur] = krte.seconds(); if (stat == rank_statistic) { if (before_lb_stats_) { - last_phase_info_->max_load = max; - last_phase_info_->avg_load = avg; - last_phase_info_->imb_load = imb; + last_phase_info_->max_load = max.seconds(); + last_phase_info_->avg_load = avg.seconds(); + last_phase_info_->imb_load = imb.seconds(); } else { - last_phase_info_->max_load_post_lb = max; - last_phase_info_->avg_load_post_lb = avg; - last_phase_info_->imb_load_post_lb = imb; + last_phase_info_->max_load_post_lb = max.seconds(); + last_phase_info_->avg_load_post_lb = avg.seconds(); + last_phase_info_->imb_load_post_lb = imb.seconds(); } } else if (stat == obj_statistic and before_lb_stats_) { - last_phase_info_->max_obj = max; + last_phase_info_->max_obj = max.seconds(); } if (theContext()->getNode() == 0) { @@ -607,7 +607,7 @@ void LBManager::commitPhaseStatistics(PhaseType phase) { balance::LoadData reduceVec( lb::Statistic stat, std::vector&& vec ) { - balance::LoadData reduce_ld(stat, 0.0f); + balance::LoadData reduce_ld(stat, TimeType{0.0}); if (vec.size() == 0) { return reduce_ld; } else { @@ -631,7 +631,7 @@ void LBManager::computeStatistics( balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE }; - total_load_from_model = 0.; + total_load_from_model = TimeType{0.}; std::vector obj_load_model; for (auto elm : *model) { auto work = model->getModeledLoad(elm, when); @@ -641,7 +641,7 @@ void LBManager::computeStatistics( total_load_from_model += work; } - TimeType total_load_raw = 0.; + TimeType total_load_raw = TimeType{0.}; std::vector obj_load_raw; if (model->hasRawLoad()) { for (auto elm : *model) { @@ -669,7 +669,7 @@ void LBManager::computeStatistics( )); if (strategy_specific_model_) { - auto rank_strat_specific_load = 0.; + TimeType rank_strat_specific_load = TimeType{0.}; std::vector obj_strat_specific_load; for (auto elm : *strategy_specific_model_) { auto work = strategy_specific_model_->getModeledLoad(elm, when); @@ -703,7 +703,7 @@ void LBManager::computeStatistics( for (auto&& elm : *comm_data) { // Only count object-to-object direct edges in the Object_comm statistics if (elm.first.cat_ == elm::CommCategory::SendRecv and not elm.first.selfEdge()) { - obj_comm.emplace_back(LoadData{lb::Statistic::Object_comm, elm.second.bytes}); + obj_comm.emplace_back(LoadData{lb::Statistic::Object_comm, TimeType{elm.second.bytes}}); } if (not comm_collectives and isCollectiveComm(elm.first.cat_)) { @@ -716,7 +716,7 @@ void LBManager::computeStatistics( comm_load += elm.second.bytes; } - lstats.emplace_back(LoadData{lb::Statistic::Rank_comm, comm_load}); + lstats.emplace_back(LoadData{lb::Statistic::Rank_comm, TimeType{comm_load}}); lstats.emplace_back(reduceVec( lb::Statistic::Object_comm, std::move(obj_comm) )); diff --git a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h index 6d7bb04764..05ed05802c 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h @@ -287,7 +287,7 @@ struct LBManager : runtime::component::Component { std::shared_ptr strategy_specific_model_; std::unordered_map lb_instances_; StatisticMapType stats; - TimeType total_load_from_model = 0.; + TimeType total_load_from_model = TimeType{0.}; std::unique_ptr last_phase_info_ = nullptr; bool before_lb_stats_ = true; /// The appender for outputting statistics in JSON format diff --git a/src/vt/vrt/collection/balance/model/comm_overhead.cc b/src/vt/vrt/collection/balance/model/comm_overhead.cc index e4c113346d..64190722d6 100644 --- a/src/vt/vrt/collection/balance/model/comm_overhead.cc +++ b/src/vt/vrt/collection/balance/model/comm_overhead.cc @@ -67,7 +67,7 @@ CommOverhead::getModeledLoad(ElementIDStruct object, PhaseOffset offset) const { auto phase = getNumCompletedPhases() + offset.phases; auto& comm = proc_comm_->at(phase); - TimeType overhead = 0.; + TimeType overhead = TimeType{0.}; for (auto&& c : comm) { // find messages that go off-node and are sent to this object if (c.first.offNode() and c.first.toObj() == object) { @@ -83,7 +83,7 @@ CommOverhead::getModeledLoad(ElementIDStruct object, PhaseOffset offset) const { auto whole_phase_work = ComposedModel::getModeledLoad( object, PhaseOffset{offset.phases, PhaseOffset::WHOLE_PHASE} ); - return work + overhead * ( static_cast(work)/whole_phase_work ); + return work + overhead * ( work/whole_phase_work ); } } diff --git a/src/vt/vrt/collection/balance/model/comm_overhead.h b/src/vt/vrt/collection/balance/model/comm_overhead.h index ff68140f47..8c098b95da 100644 --- a/src/vt/vrt/collection/balance/model/comm_overhead.h +++ b/src/vt/vrt/collection/balance/model/comm_overhead.h @@ -72,8 +72,8 @@ struct CommOverhead : public ComposedModel { private: std::unordered_map const* proc_comm_; /**< Underlying comm data */ - TimeType per_msg_weight_ = 0.001; /**< Cost per message */ - TimeType per_byte_weight_ = 0.000001; /**< Cost per bytes */ + TimeType per_msg_weight_ = TimeType{0.001}; /**< Cost per message */ + TimeType per_byte_weight_ = TimeType{0.000001}; /**< Cost per bytes */ }; // class CommOverhead }}}} // end namespace diff --git a/src/vt/vrt/collection/balance/model/linear_model.cc b/src/vt/vrt/collection/balance/model/linear_model.cc index 2d7f8a4377..9bfbaf8d05 100644 --- a/src/vt/vrt/collection/balance/model/linear_model.cc +++ b/src/vt/vrt/collection/balance/model/linear_model.cc @@ -65,12 +65,12 @@ TimeType LinearModel::getModeledLoad(ElementIDStruct object, PhaseOffset when) c for (int i = -1 * static_cast(phases); i < 0; i++) { x.emplace_back(i); past_phase.phases = i; - y.emplace_back(ComposedModel::getModeledLoad(object, past_phase)); + y.emplace_back(ComposedModel::getModeledLoad(object, past_phase).seconds()); } // should we re-create this every time? LinearRegression regression{x, y}; - return regression.predict(when.phases); + return TimeType{regression.predict(when.phases)}; } unsigned int LinearModel::getNumPastPhasesNeeded(unsigned int look_back) const diff --git a/src/vt/vrt/collection/balance/model/load_model.h b/src/vt/vrt/collection/balance/model/load_model.h index 6593278e05..34424736dd 100644 --- a/src/vt/vrt/collection/balance/model/load_model.h +++ b/src/vt/vrt/collection/balance/model/load_model.h @@ -244,7 +244,7 @@ struct LoadModel vtAbort( "LoadModel::getRawLoad() called on a model that does not implement it" ); - return 0.0; + return TimeType{0.0}; }; /** @@ -260,7 +260,7 @@ struct LoadModel * this. */ virtual TimeType getModeledComm(ElementIDStruct object, PhaseOffset when) const { - return {}; + return TimeType{0.0}; } /** diff --git a/src/vt/vrt/collection/balance/model/multiple_phases.cc b/src/vt/vrt/collection/balance/model/multiple_phases.cc index b33d3c863c..6e6c413df8 100644 --- a/src/vt/vrt/collection/balance/model/multiple_phases.cc +++ b/src/vt/vrt/collection/balance/model/multiple_phases.cc @@ -51,7 +51,7 @@ MultiplePhases::getModeledLoad(ElementIDStruct object, PhaseOffset when) const { if (when.phases < 0) return ComposedModel::getModeledLoad(object, when); - TimeType sum = 0.0; + TimeType sum = TimeType{0.0}; for (int i = 0; i < future_phase_block_size_; ++i) { PhaseOffset p{future_phase_block_size_*when.phases + i, when.subphase}; diff --git a/src/vt/vrt/collection/balance/model/norm.cc b/src/vt/vrt/collection/balance/model/norm.cc index 5f8bbe7754..961027474f 100644 --- a/src/vt/vrt/collection/balance/model/norm.cc +++ b/src/vt/vrt/collection/balance/model/norm.cc @@ -64,22 +64,22 @@ TimeType Norm::getModeledLoad(ElementIDStruct object, PhaseOffset offset) const for (int i = 0; i < getNumSubphases(); ++i) { offset.subphase = i; - auto t = ComposedModel::getModeledLoad(object, offset); + auto t = ComposedModel::getModeledLoad(object, offset).seconds(); sum += std::pow(t, power_); } - return std::pow(sum, 1.0/power_); + return TimeType{std::pow(sum, 1.0/power_)}; } else { // l-infinity implies a max norm double max = 0.0; for (int i = 0; i < getNumSubphases(); ++i) { offset.subphase = i; - auto t = ComposedModel::getModeledLoad(object, offset); + auto t = ComposedModel::getModeledLoad(object, offset).seconds(); max = std::max(max, t); } - return max; + return TimeType{max}; } } diff --git a/src/vt/vrt/collection/balance/model/raw_data.cc b/src/vt/vrt/collection/balance/model/raw_data.cc index 743499476e..5e60b67b35 100644 --- a/src/vt/vrt/collection/balance/model/raw_data.cc +++ b/src/vt/vrt/collection/balance/model/raw_data.cc @@ -107,7 +107,7 @@ TimeType RawData::getRawLoad(ElementIDStruct object, PhaseOffset offset) const { if (phase_data.find(object) != phase_data.end()) { return phase_data.at(object).get(offset); } else { - return 0; + return TimeType{0.0}; } } diff --git a/src/vt/vrt/collection/balance/model/select_subphases.cc b/src/vt/vrt/collection/balance/model/select_subphases.cc index 7a821e0353..ae7a12cc54 100644 --- a/src/vt/vrt/collection/balance/model/select_subphases.cc +++ b/src/vt/vrt/collection/balance/model/select_subphases.cc @@ -62,7 +62,7 @@ TimeType SelectSubphases::getModeledLoad(ElementIDStruct object, PhaseOffset when) const { if (when.subphase == PhaseOffset::WHOLE_PHASE) { // Sum up the selected subphases as if they represent the entire phase - TimeType sum = 0.0; + TimeType sum = TimeType{0.0}; for (auto s : subphases_) { PhaseOffset p{when.phases, s}; sum += ComposedModel::getModeledLoad(object, p); diff --git a/src/vt/vrt/collection/balance/model/weighted_communication_volume.cc b/src/vt/vrt/collection/balance/model/weighted_communication_volume.cc index 421f519428..ab14563d9e 100644 --- a/src/vt/vrt/collection/balance/model/weighted_communication_volume.cc +++ b/src/vt/vrt/collection/balance/model/weighted_communication_volume.cc @@ -50,7 +50,7 @@ TimeType WeightedCommunicationVolume::getModeledLoad( ElementIDStruct object, PhaseOffset when ) const { return alpha_ * ComposedModel::getModeledLoad(object, when) + - beta_ * ComposedModel::getModeledComm(object, when) + gamma_; + beta_ * ComposedModel::getModeledComm(object, when) + TimeType{gamma_}; } }}}} // namespace vt::vrt::collection::balance diff --git a/src/vt/vrt/collection/balance/model/weighted_messages.cc b/src/vt/vrt/collection/balance/model/weighted_messages.cc index c71827afd7..84779737e0 100644 --- a/src/vt/vrt/collection/balance/model/weighted_messages.cc +++ b/src/vt/vrt/collection/balance/model/weighted_messages.cc @@ -50,7 +50,7 @@ WeightedMessages::getModeledComm(ElementIDStruct object, PhaseOffset when) const auto phase = getNumCompletedPhases() + when.phases; auto& comm = proc_comm_->at(phase); - TimeType incoming = 0., outgoing = 0.; + TimeType incoming = TimeType{0.}, outgoing = TimeType{0.}; for (auto&& c : comm) { if ( c.first.commCategory() == elm::CommCategory::SendRecv and diff --git a/src/vt/vrt/collection/balance/model/weighted_messages.h b/src/vt/vrt/collection/balance/model/weighted_messages.h index 0d595b7289..428f7660dc 100644 --- a/src/vt/vrt/collection/balance/model/weighted_messages.h +++ b/src/vt/vrt/collection/balance/model/weighted_messages.h @@ -59,7 +59,7 @@ struct WeightedMessages : public ComposedModel { */ explicit WeightedMessages( std::shared_ptr base, - TimeType in_per_msg_weight = 0.0, TimeType in_per_byte_weight = 1.0 + TimeType in_per_msg_weight = TimeType{0.0}, TimeType in_per_byte_weight = TimeType{1.0} ) : ComposedModel(base), per_msg_weight_(in_per_msg_weight), per_byte_weight_(in_per_byte_weight) { } diff --git a/src/vt/vrt/collection/balance/stats_msg.h b/src/vt/vrt/collection/balance/stats_msg.h index ae4b126e52..4659a752f9 100644 --- a/src/vt/vrt/collection/balance/stats_msg.h +++ b/src/vt/vrt/collection/balance/stats_msg.h @@ -41,6 +41,7 @@ //@HEADER */ +#include "vt/timing/timing_type.h" #if !defined INCLUDED_VT_VRT_COLLECTION_BALANCE_STATS_MSG_H #define INCLUDED_VT_VRT_COLLECTION_BALANCE_STATS_MSG_H @@ -63,8 +64,8 @@ struct LoadData { LoadData() = default; LoadData(lb::Statistic in_stat, TimeType const y) - : max_(y), sum_(y), min_(y), avg_(y), M2_(0.0f), M3_(0.0f), M4_(0.0f), - N_(1), P_(y not_eq 0.0f), stat_(in_stat) + : max_(y), sum_(y), min_(y), avg_(y), M2_(0.0), M3_(0.0), M4_(0.0), + N_(1), P_(y not_eq TimeType{0.0}), stat_(in_stat) { vt_debug_print( verbose, lb, @@ -84,18 +85,18 @@ struct LoadData { ); int32_t N = a1.N_ + a2.N_; - double delta = a2.avg_ - a1.avg_; - double delta_sur_N = delta / static_cast(N); - double delta2_sur_N2 = delta_sur_N * delta_sur_N; + TimeType delta = a2.avg_ - a1.avg_; + TimeType delta_sur_N = delta / static_cast(N); + TimeType delta2_sur_N2 = delta_sur_N * delta_sur_N; int32_t n2 = a1.N_ * a1.N_; int32_t n_c2 = a2.N_ * a2.N_; int32_t prod_n = a1.N_ * a2.N_; int32_t n_c = a2.N_; int32_t n = a1.N_; - double M2 = a1.M2_; - double M2_c = a2.M2_; - double M3 = a1.M3_; - double M3_c = a2.M3_; + TimeType M2 = a1.M2_; + TimeType M2_c = a2.M2_; + TimeType M3 = a1.M3_; + TimeType M3_c = a2.M3_; a1.M4_ += a2.M4_ + prod_n * ( n2 - prod_n + n_c2 ) * delta * delta_sur_N * delta2_sur_N2 @@ -122,46 +123,46 @@ struct LoadData { TimeType sum() const { return sum_; } TimeType min() const { return min_; } TimeType avg() const { return avg_; } - TimeType var() const { return N_ > 0 ? M2_ * (1.0f / N_) : 0.0; } + TimeType var() const { return N_ > 0 ? M2_ * (1.0f / N_) : TimeType{0.0}; } TimeType skew() const { - static const double min_sqrt = std::sqrt(std::numeric_limits::min()); + static const TimeType min_sqrt = TimeType{std::sqrt(std::numeric_limits::min())}; if (N_ == 1 or M2_ < min_sqrt) { // 1.e-150 - return 0.0; + return TimeType{0.0}; } else { double nm1 = N_ - 1; double inv_n = 1. / N_; - double var_inv = nm1 / M2_; - double nvar_inv = var_inv * inv_n; - return nvar_inv * std::sqrt( var_inv ) * M3_; + TimeType var_inv = nm1 / M2_; + TimeType nvar_inv = var_inv * inv_n; + return nvar_inv * std::sqrt( var_inv.seconds() ) * M3_; } } TimeType krte() const { - if (N_ == 1 or M2_ < 1.e-150) { - return 0.0; + if (N_ == 1 or M2_ < TimeType{1.e-150}) { + return TimeType{0.0}; } else { double nm1 = N_ - 1; double inv_n = 1. / N_; - double var_inv = nm1 / M2_; - double nvar_inv = var_inv * inv_n; - return nvar_inv * var_inv * M4_ - 3.; + TimeType var_inv = nm1 / M2_; + TimeType nvar_inv = var_inv * inv_n; + return nvar_inv * var_inv * M4_ - TimeType{3.}; } } - TimeType I() const { return avg() > 0.0 ? (max() / avg()) - 1.0f : 0.0; } - TimeType stdv() const { return std::sqrt(var()); } + TimeType I() const { return avg() > TimeType{0.0} ? (max() / avg()) - TimeType{1.0} : TimeType{0.0}; } + TimeType stdv() const { return TimeType{std::sqrt(var().seconds())}; } int32_t npr() const { return P_; } static_assert( - std::is_same::value == true, + std::is_same::value == true, "TimeType must be a double" ); - TimeType max_ = 0.0; - TimeType sum_ = 0.0; - TimeType min_ = 0.0; - TimeType avg_ = 0.0; - TimeType M2_ = 0.0; - TimeType M3_ = 0.0; - TimeType M4_ = 0.0; + TimeType max_ = TimeType{0.0}; + TimeType sum_ = TimeType{0.0}; + TimeType min_ = TimeType{0.0}; + TimeType avg_ = TimeType{0.0}; + TimeType M2_ = TimeType{0.0}; + TimeType M3_ = TimeType{0.0}; + TimeType M4_ = TimeType{0.0}; int32_t N_ = 0; int32_t P_ = 0; lb::Statistic stat_ = lb::Statistic::Rank_load_modeled; diff --git a/src/vt/vrt/collection/balance/temperedlb/temperedlb.cc b/src/vt/vrt/collection/balance/temperedlb/temperedlb.cc index 2a70068cc8..6a50090b68 100644 --- a/src/vt/vrt/collection/balance/temperedlb/temperedlb.cc +++ b/src/vt/vrt/collection/balance/temperedlb/temperedlb.cc @@ -69,11 +69,11 @@ void TemperedLB::init(objgroup::proxy::Proxy in_proxy) { } bool TemperedLB::isUnderloaded(LoadType load) const { - return load < target_max_load_ * temperedlb_load_threshold; + return load < target_max_load_.seconds() * temperedlb_load_threshold; } bool TemperedLB::isOverloaded(LoadType load) const { - return load > target_max_load_ * temperedlb_load_threshold; + return load > target_max_load_.seconds() * temperedlb_load_threshold; } /*static*/ std::unordered_map @@ -423,7 +423,7 @@ void TemperedLB::inputParams(balance::ConfigEntry* config) { void TemperedLB::runLB(TimeType total_load) { bool should_lb = false; - this_load = total_load; + this_load = total_load.seconds(); stats = *getStats(); auto const avg = stats.at(lb::Statistic::Rank_load_modeled).at( @@ -444,21 +444,21 @@ void TemperedLB::runLB(TimeType total_load) { // we can't get the processor max lower than the max object load, so // modify the algorithm to define overloaded as exceeding the max // object load instead of the processor average load - target_max_load_ = (pole > avg ? pole : avg); + target_max_load_ = TimeType{(pole > avg ? pole : avg)}; } else { - target_max_load_ = avg; + target_max_load_ = TimeType{avg}; } if (avg > 0.0000000001) { - should_lb = max > (run_temperedlb_tolerance + 1.0) * target_max_load_; + should_lb = max > (run_temperedlb_tolerance + 1.0) * target_max_load_.seconds(); } if (theContext()->getNode() == 0) { vt_debug_print( terse, temperedlb, "TemperedLB::runLB: avg={}, max={}, pole={}, imb={}, load={}, should_lb={}\n", - TimeTypeWrapper(avg), TimeTypeWrapper(max), TimeTypeWrapper(pole), imb, - TimeTypeWrapper(load), should_lb + TimeType(avg), TimeType(max), TimeType(pole), imb, + TimeType(load), should_lb ); if (!should_lb) { @@ -470,14 +470,14 @@ void TemperedLB::runLB(TimeType total_load) { } if (should_lb) { - doLBStages(imb); + doLBStages(TimeType{imb}); } } void TemperedLB::doLBStages(TimeType start_imb) { decltype(this->cur_objs_) best_objs; LoadType best_load = 0; - TimeType best_imb = start_imb + 10; + TimeType best_imb = start_imb + TimeType{10.}; uint16_t best_trial = 0; auto this_node = theContext()->getNode(); @@ -489,7 +489,7 @@ void TemperedLB::doLBStages(TimeType start_imb) { load_info_.clear(); is_overloaded_ = is_underloaded_ = false; - TimeType best_imb_this_trial = start_imb + 10; + TimeType best_imb_this_trial = start_imb + TimeType{10.}; for (iter_ = 0; iter_ < num_iters_; iter_++) { bool first_iter = iter_ == 0; @@ -551,7 +551,7 @@ void TemperedLB::doLBStages(TimeType start_imb) { // Perform the reduction for Rank_load_modeled -> processor load only proxy_.allreduce<&TemperedLB::loadStatsHandler, collective::PlusOp>( std::vector{ - {balance::LoadData{Statistic::Rank_load_modeled, this_new_load_}} + {balance::LoadData{Statistic::Rank_load_modeled, TimeType{this_new_load_}}} } ); }); @@ -910,7 +910,7 @@ std::vector TemperedLB::createCMF(NodeSetType const& under) { switch (cmf_type_) { case CMFTypeEnum::Original: - factor = 1.0 / target_max_load_; + factor = 1.0 / target_max_load_.seconds(); break; case CMFTypeEnum::NormBySelf: factor = 1.0 / this_new_load_; @@ -927,7 +927,7 @@ std::vector TemperedLB::createCMF(NodeSetType const& under) { l_max = load; } } - factor = 1.0 / (l_max > target_max_load_ ? l_max : target_max_load_); + factor = 1.0 / (l_max > target_max_load_.seconds() ? l_max : target_max_load_.seconds()); } break; default: @@ -998,7 +998,7 @@ std::vector TemperedLB::makeSufficientlyUnderloaded( std::vector sufficiently_under = {}; for (auto&& elm : load_info_) { bool eval = Criterion(criterion_)( - this_new_load_, elm.second, load_to_accommodate, target_max_load_ + this_new_load_, elm.second, load_to_accommodate.seconds(), target_max_load_.seconds() ); if (eval) { sufficiently_under.push_back(elm.first); @@ -1052,12 +1052,12 @@ std::vector TemperedLB::orderObjects( { // first find the load of the smallest single object that, if migrated // away, could bring this processor's load below the target load - auto over_avg = this_new_load - target_max_load; + auto over_avg = this_new_load - target_max_load.seconds(); // if no objects are larger than over_avg, then single_obj_load will still // (incorrectly) reflect the total load, which will not be a problem auto single_obj_load = this_new_load; for (auto &obj : cur_objs) { - auto obj_load = obj.second; + auto obj_load = obj.second.seconds(); if (obj_load > over_avg && obj_load < single_obj_load) { single_obj_load = obj_load; } @@ -1069,8 +1069,8 @@ std::vector TemperedLB::orderObjects( [&cur_objs, single_obj_load]( const ObjIDType &left, const ObjIDType &right ) { - auto left_load = cur_objs[left]; - auto right_load = cur_objs[right]; + auto left_load = cur_objs[left].seconds(); + auto right_load = cur_objs[right].seconds(); if (left_load <= single_obj_load && right_load <= single_obj_load) { // we're in the sort load descending regime (first section) return left_load > right_load; @@ -1101,7 +1101,7 @@ std::vector TemperedLB::orderObjects( // first find the smallest object that, if migrated away along with all // smaller objects, could bring this processor's load below the target // load - auto over_avg = this_new_load - target_max_load; + auto over_avg = this_new_load - target_max_load.seconds(); std::sort( ordered_obj_ids.begin(), ordered_obj_ids.end(), [&cur_objs](const ObjIDType &left, const ObjIDType &right) { @@ -1112,9 +1112,9 @@ std::vector TemperedLB::orderObjects( } ); auto cum_obj_load = this_new_load; - auto single_obj_load = cur_objs[ordered_obj_ids[0]]; + auto single_obj_load = cur_objs[ordered_obj_ids[0]].seconds(); for (auto obj_id : ordered_obj_ids) { - auto this_obj_load = cur_objs[obj_id]; + auto this_obj_load = cur_objs[obj_id].seconds(); if (cum_obj_load - this_obj_load < over_avg) { single_obj_load = this_obj_load; break; @@ -1130,8 +1130,8 @@ std::vector TemperedLB::orderObjects( [&cur_objs, single_obj_load]( const ObjIDType &left, const ObjIDType &right ) { - auto left_load = cur_objs[left]; - auto right_load = cur_objs[right]; + auto left_load = cur_objs[left].seconds(); + auto right_load = cur_objs[right].seconds(); if (left_load <= single_obj_load && right_load <= single_obj_load) { // we're in the sort load descending regime (first section) return left_load > right_load; @@ -1152,7 +1152,7 @@ std::vector TemperedLB::orderObjects( normal, temperedlb, "TemperedLB::decide: over_avg={}, marginal_obj_load={}\n", TimeTypeWrapper(over_avg), - TimeTypeWrapper(cur_objs[ordered_obj_ids[0]]) + cur_objs[ordered_obj_ids[0]] ); } } @@ -1234,7 +1234,7 @@ void TemperedLB::decide() { auto& selected_load = load_iter->second; bool eval = Criterion(criterion_)( - this_new_load_, selected_load, obj_load, target_max_load_ + this_new_load_, selected_load, obj_load.seconds(), target_max_load_.seconds() ); vt_debug_print( @@ -1250,9 +1250,9 @@ void TemperedLB::decide() { selected_load, obj_id.id, obj_id.getHomeNode(), - TimeTypeWrapper(obj_load), - TimeTypeWrapper(target_max_load_), - TimeTypeWrapper(this_new_load_), + obj_load, + target_max_load_, + this_new_load_, eval ); @@ -1260,10 +1260,10 @@ void TemperedLB::decide() { ++n_transfers; // transfer the object load in seconds // to match the object load units on the receiving end - migrate_objs[selected_node][obj_id] = obj_load; + migrate_objs[selected_node][obj_id] = obj_load.seconds(); - this_new_load_ -= obj_load; - selected_load += obj_load; + this_new_load_ -= obj_load.seconds(); + selected_load += obj_load.seconds(); iter = ordered_obj_ids.erase(iter); cur_objs_.erase(obj_id); @@ -1272,7 +1272,7 @@ void TemperedLB::decide() { iter++; } - if (not (this_new_load_ > target_max_load_)) { + if (not (this_new_load_ > target_max_load_.seconds())) { break; } } diff --git a/src/vt/vrt/collection/balance/temperedlb/temperedlb.h b/src/vt/vrt/collection/balance/temperedlb/temperedlb.h index 07fd69c933..6c74b56f67 100644 --- a/src/vt/vrt/collection/balance/temperedlb/temperedlb.h +++ b/src/vt/vrt/collection/balance/temperedlb/temperedlb.h @@ -104,7 +104,7 @@ struct TemperedLB : BaseLB { NodeType sampleFromCMF(NodeSetType const& under, std::vector const& cmf); std::vector makeUnderloaded() const; std::vector makeSufficientlyUnderloaded( - LoadType load_to_accommodate + TimeType load_to_accommodate ) const; ElementLoadType::iterator selectObject( LoadType size, ElementLoadType& load, std::set const& available @@ -167,8 +167,8 @@ struct TemperedLB : BaseLB { std::unordered_set new_underloaded_ = {}; std::unordered_map cur_objs_ = {}; LoadType this_new_load_ = 0.0; - TimeType new_imbalance_ = 0.0; - TimeType target_max_load_ = 0.0; + TimeType new_imbalance_ = TimeType{0.0}; + TimeType target_max_load_ = TimeType{0.0}; CriterionEnum criterion_ = CriterionEnum::ModifiedGrapevine; InformTypeEnum inform_type_ = InformTypeEnum::AsyncInform; ObjectOrderEnum obj_ordering_ = ObjectOrderEnum::FewestMigrations; diff --git a/tests/perf/common/test_harness.h b/tests/perf/common/test_harness.h index 5504307658..1b51501937 100644 --- a/tests/perf/common/test_harness.h +++ b/tests/perf/common/test_harness.h @@ -67,12 +67,11 @@ struct TestResultHolder { struct PerfTestHarness : TestHarnessBase { using TestName = std::string; - using TestResult = std::pair; - - using FinalTestResult = std::pair>; + using TestResult = std::pair; + using FinalTestResult = std::pair>; using TestResults = std::vector>; using PerNodeResults = - std::unordered_map>; + std::unordered_map>; using CombinedResults = std::vector>; // Memory use at the end of test iteration (i.e. phase) diff --git a/tests/perf/common/timers.h b/tests/perf/common/timers.h index 5cb9917a38..cd070cf944 100644 --- a/tests/perf/common/timers.h +++ b/tests/perf/common/timers.h @@ -51,9 +51,9 @@ namespace vt { namespace tests { namespace perf { namespace common { using TimePoint = std::chrono::time_point; -using DurationMicro = std::chrono::duration; -using DurationMilli = std::chrono::duration; -using DurationSec = std::chrono::duration; +using DurationMicro = std::chrono::duration; +using DurationMilli = std::chrono::duration; +using DurationSec = std::chrono::duration; template struct DurationConverter { static DurationMicro ToMicro(Duration const& in_duration) { @@ -86,7 +86,7 @@ struct StopWatch { void Start(); template - TimeType Stop() { + TimeType::TimeTypeInternal Stop() { auto const now = std::chrono::steady_clock::now(); auto const delta = Duration{now - cur_time_}; cur_time_ = now; diff --git a/tests/unit/collection/test_lb.extended.cc b/tests/unit/collection/test_lb.extended.cc index d6e8d47e44..e5dfc08b33 100644 --- a/tests/unit/collection/test_lb.extended.cc +++ b/tests/unit/collection/test_lb.extended.cc @@ -541,7 +541,7 @@ TEST_F(TestRestoreLBData, test_restore_lb_data_data_1) { for (int i=0; i( elm_ptr->toJson() ); - lbdh.node_data_[phase][elm_id].whole_phase_load = 1.0; + lbdh.node_data_[phase][elm_id].whole_phase_load = TimeType{1.0}; } } diff --git a/tests/unit/collection/test_lb_data_holder.cc b/tests/unit/collection/test_lb_data_holder.cc index 9b2bec90c5..e61c55d954 100644 --- a/tests/unit/collection/test_lb_data_holder.cc +++ b/tests/unit/collection/test_lb_data_holder.cc @@ -76,7 +76,7 @@ void addPhasesDataToJson(nlohmann::json& json, PhaseType amountOfPhasesToAdd, st LBDataHolder dh; for (unsigned i = 0; i < amountOfPhasesToAdd; i++) { for (auto&& elm : ids[i]) { - dh.node_data_[i][elm] = LoadSummary{3}; + dh.node_data_[i][elm] = LoadSummary{TimeType{3.}}; } } diff --git a/tests/unit/collection/test_model_comm_overhead.nompi.cc b/tests/unit/collection/test_model_comm_overhead.nompi.cc index f193a0db56..8059ccc954 100644 --- a/tests/unit/collection/test_model_comm_overhead.nompi.cc +++ b/tests/unit/collection/test_model_comm_overhead.nompi.cc @@ -48,6 +48,7 @@ #include #include "test_harness.h" +#include "vt/timing/timing_type.h" #include @@ -146,8 +147,8 @@ TEST_F(TestModelCommOverhead, test_model_comm_overhead_1) { } }; - constexpr auto per_msg_weight = 3.0; - constexpr auto per_byte_weight = 5.0; + constexpr auto per_msg_weight = TimeType{3.0}; + constexpr auto per_byte_weight = TimeType{5.0}; auto test_model = std::make_shared( std::make_shared(), per_msg_weight, per_byte_weight diff --git a/tests/unit/collection/test_model_norm.nompi.cc b/tests/unit/collection/test_model_norm.nompi.cc index 2765837a7b..85483c0708 100644 --- a/tests/unit/collection/test_model_norm.nompi.cc +++ b/tests/unit/collection/test_model_norm.nompi.cc @@ -156,7 +156,7 @@ TEST_F(TestModelNorm, test_model_norm_2) { auto work_val = test_model->getModeledLoad(obj, PhaseOffset{0, PhaseOffset::WHOLE_PHASE}); - EXPECT_NEAR(work_val, expected_norms[obj.id - 1], 0.001); + EXPECT_NEAR(work_val.seconds(), expected_norms[obj.id - 1].seconds(), 0.001); } EXPECT_EQ(objects_seen, 2); diff --git a/tests/unit/collection/test_model_per_collection.extended.cc b/tests/unit/collection/test_model_per_collection.extended.cc index 2c539f0b53..fc2e86a70d 100644 --- a/tests/unit/collection/test_model_per_collection.extended.cc +++ b/tests/unit/collection/test_model_per_collection.extended.cc @@ -158,7 +158,7 @@ TEST_F(TestModelPerCollection, test_model_per_collection_1) { obj, {PhaseOffset::NEXT_PHASE, PhaseOffset::WHOLE_PHASE} ); if (id_proxy_map.find(obj) != id_proxy_map.end()) { - EXPECT_DOUBLE_EQ(work_val, static_cast(id_proxy_map[obj])); + EXPECT_DOUBLE_EQ(work_val.seconds(), static_cast(id_proxy_map[obj])); } if (model->hasRawLoad()) { auto raw_load_val = model->getRawLoad(obj, {PhaseOffset::NEXT_PHASE, PhaseOffset::WHOLE_PHASE}); diff --git a/tests/unit/collection/test_model_weighted_messages.nompi.cc b/tests/unit/collection/test_model_weighted_messages.nompi.cc index 91cce389c4..feb4a070e6 100644 --- a/tests/unit/collection/test_model_weighted_messages.nompi.cc +++ b/tests/unit/collection/test_model_weighted_messages.nompi.cc @@ -141,8 +141,8 @@ TEST_F(TestModelWeightedMessages, test_model) { } }; - constexpr auto per_msg_weight = 3.0; - constexpr auto per_byte_weight = 5.0; + constexpr auto per_msg_weight = TimeType{3.0}; + constexpr auto per_byte_weight = TimeType{5.0}; auto test_model = std::make_shared( std::make_shared(), per_msg_weight, per_byte_weight diff --git a/tests/unit/lb/test_offlinelb.cc b/tests/unit/lb/test_offlinelb.cc index 981e09d801..e0f6dda52f 100644 --- a/tests/unit/lb/test_offlinelb.cc +++ b/tests/unit/lb/test_offlinelb.cc @@ -112,7 +112,7 @@ TEST_F(TestOfflineLB, test_offlinelb_1) { LBDataHolder dh; for (PhaseType i = 0; i < num_phases; i++) { for (auto&& elm : ids[i]) { - dh.node_data_[i][elm] = LoadSummary{3}; + dh.node_data_[i][elm] = LoadSummary{TimeType{3}}; } } diff --git a/tests/unit/lb/test_temperedlb.nompi.cc b/tests/unit/lb/test_temperedlb.nompi.cc index e54fe99618..a71870a215 100644 --- a/tests/unit/lb/test_temperedlb.nompi.cc +++ b/tests/unit/lb/test_temperedlb.nompi.cc @@ -67,7 +67,7 @@ TimeType setupProblem( cur_objs.emplace(ElementIDStruct{4,0}, 3.0); // compute the load for this processor - TimeType my_load = 0; + TimeType my_load = TimeType{0.}; for (auto &obj : cur_objs) { my_load += obj.second; } @@ -82,9 +82,9 @@ void orderAndVerify( // have TemperedLB order the objects auto ordered_objs = use_tempered_wmin ? vt::vrt::collection::lb::TemperedWMin::orderObjects( - order, cur_objs, my_load, target_load) : + order, cur_objs, my_load.seconds(), target_load) : vt::vrt::collection::lb::TemperedLB::orderObjects( - order, cur_objs, my_load, target_load); + order, cur_objs, my_load.seconds(), target_load); // verify correctness of the returned ordering int i = 0; @@ -123,7 +123,7 @@ void orderUsingTargetLoadAndVerify( TEST_F(TestTemperedLB, test_temperedlb_ordering_elmid) { ObjectOrdering order = ObjectOrdering::ElmID; - TimeType over_avg = 4.5; + TimeType over_avg = TimeType{4.5}; // result will be independent of over_avg std::vector soln = {0, 1, 2, 3, 4, 5}; @@ -134,7 +134,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_elmid) { TEST_F(TestTemperedLB, test_temperedlb_ordering_fewestmigrations_intermediate) { ObjectOrdering order = ObjectOrdering::FewestMigrations; - TimeType over_avg = 4.5; + TimeType over_avg = TimeType{4.5}; // single_obj_load will be 5.0 // load order will be 5.0, 4.0, 3.0, 2.0, 6.0, 9.0 std::vector soln = {5, 3, 4, 0, 1, 2}; @@ -144,7 +144,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_fewestmigrations_intermediate) { TEST_F(TestTemperedLB, test_temperedlb_ordering_fewestmigrations_largest) { ObjectOrdering order = ObjectOrdering::FewestMigrations; - TimeType over_avg = 12.5; + TimeType over_avg = TimeType{12.5}; // single_obj_load will be 9.0 // load order will be 9.0, 6.0, 5.0, 4.0, 3.0, 2.0 std::vector soln = {2, 1, 5, 3, 4, 0}; @@ -154,7 +154,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_fewestmigrations_largest) { TEST_F(TestTemperedLB, test_temperedlb_ordering_fewestmigrations_smallest) { ObjectOrdering order = ObjectOrdering::FewestMigrations; - TimeType over_avg = 1.5; + TimeType over_avg = TimeType{1.5}; // single_obj_load will be 2.0 // load order will be 2.0, 3.0, 4.0, 5.0, 6.0, 9.0 std::vector soln = {0, 4, 3, 5, 1, 2}; @@ -166,7 +166,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_fewestmigrations_smallest) { TEST_F(TestTemperedLB, test_temperedlb_ordering_smallobjects_intermediate) { ObjectOrdering order = ObjectOrdering::SmallObjects; - TimeType over_avg = 4.5; + TimeType over_avg = TimeType{4.5}; // marginal_obj_load will be 3.0 // load order will be 3.0, 2.0, 4.0, 5.0, 6.0, 9.0 std::vector soln = {4, 0, 3, 5, 1, 2}; @@ -176,7 +176,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_smallobjects_intermediate) { TEST_F(TestTemperedLB, test_temperedlb_ordering_smallobjects_largest) { ObjectOrdering order = ObjectOrdering::SmallObjects; - TimeType target_load = 0.5; + TimeType target_load = TimeType{0.5}; // marginal_obj_load will be 9.0 // load order will be 9.0, 6.0, 5.0, 4.0, 3.0, 2.0 std::vector soln = {2, 1, 5, 3, 4, 0}; @@ -186,7 +186,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_smallobjects_largest) { TEST_F(TestTemperedLB, test_temperedlb_ordering_smallobjects_smallest) { ObjectOrdering order = ObjectOrdering::SmallObjects; - TimeType over_avg = 1.5; + TimeType over_avg = TimeType{1.5}; // marginal_obj_load will be 2.0 // load order will be 2.0, 3.0, 4.0, 5.0, 6.0, 9.0 std::vector soln = {0, 4, 3, 5, 1, 2}; @@ -198,7 +198,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_smallobjects_smallest) { TEST_F(TestTemperedLB, test_temperedlb_ordering_largestobjects) { ObjectOrdering order = ObjectOrdering::LargestObjects; - TimeType over_avg = 4.5; + TimeType over_avg = TimeType{4.5}; // result will be independent of over_avg std::vector soln = {2, 1, 5, 3, 4, 0}; @@ -209,7 +209,7 @@ TEST_F(TestTemperedLB, test_temperedlb_ordering_largestobjects) { TEST_F(TestTemperedLB, test_temperedwmin_ordering_elmid) { ObjectOrdering order = ObjectOrdering::ElmID; - TimeType over_avg = 4.5; + TimeType over_avg = TimeType{4.5}; // result will be independent of over_avg std::vector soln = {0, 1, 2, 3, 4, 5}; @@ -218,7 +218,7 @@ TEST_F(TestTemperedLB, test_temperedwmin_ordering_elmid) { TEST_F(TestTemperedLB, test_temperedwmin_ordering_smallobjects_largest) { ObjectOrdering order = ObjectOrdering::SmallObjects; - TimeType target_load = 0.5; + TimeType target_load = TimeType{0.5}; // marginal_obj_load will be 9.0 // load order will be 9.0, 6.0, 5.0, 4.0, 3.0, 2.0 std::vector soln = {2, 1, 5, 3, 4, 0}; diff --git a/tests/unit/scheduler/test_scheduler_progress.extended.cc b/tests/unit/scheduler/test_scheduler_progress.extended.cc index 9715e27ec7..100fe98488 100644 --- a/tests/unit/scheduler/test_scheduler_progress.extended.cc +++ b/tests/unit/scheduler/test_scheduler_progress.extended.cc @@ -86,7 +86,7 @@ TEST_F(TestSchedProgress, test_scheduler_progress_1) { // This ought to take close to a second EXPECT_GT( - vt::timing::getCurrentTime() - cur_time, + TimeType{vt::timing::getCurrentTime() - cur_time}.seconds(), vt::theConfig()->vt_sched_progress_sec * fudge ); @@ -125,7 +125,7 @@ TEST_F(TestSchedProgress, test_scheduler_progress_2) { // This ought to take close to a second EXPECT_GT( - vt::timing::getCurrentTime() - cur_time, + (vt::timing::getCurrentTime() - cur_time).seconds(), vt::theConfig()->vt_sched_progress_sec * fudge ); diff --git a/tests/unit/scheduler/test_scheduler_timings.cc b/tests/unit/scheduler/test_scheduler_timings.cc index 3521cd7973..15c76c9246 100644 --- a/tests/unit/scheduler/test_scheduler_timings.cc +++ b/tests/unit/scheduler/test_scheduler_timings.cc @@ -101,7 +101,7 @@ void myHandler(MyMsg* msg) { auto load = 1000.0* data->getLoad(0); fmt::print("expected time={}, observed time={}\n", time, load); double margin = 30+ time*0.20; - if ((time - load)< margin) { num_pass++; } + if ((time - load.seconds())< margin) { num_pass++; } } EXPECT_GT (num_pass, num_iter - num_pass); @@ -136,7 +136,7 @@ TEST_F(TestSchedTimings, test_sched_msg) { // This ought to take close to a second (with ms_delay = 100) EXPECT_GT( - observed_time, + observed_time.seconds(), vt::theConfig()->vt_sched_progress_sec * fudge ); @@ -144,7 +144,7 @@ TEST_F(TestSchedTimings, test_sched_msg) { fmt::print("expected time={}, observed time={}\n", sum_time, observed_time); //double margin =30+ sum_time*0.2; //EXPECT_NEAR(sum_time, observed_time, margin ); - EXPECT_GT(observed_time, sum_time); + EXPECT_GT(observed_time.seconds(), sum_time); } diff --git a/tests/unit/timetrigger/test_time_trigger.extended.cc b/tests/unit/timetrigger/test_time_trigger.extended.cc index 660dac0b0f..8f804c1183 100644 --- a/tests/unit/timetrigger/test_time_trigger.extended.cc +++ b/tests/unit/timetrigger/test_time_trigger.extended.cc @@ -60,7 +60,7 @@ TEST_F(TestTimeTrigger, test_time_trigger) { using namespace std::chrono_literals; auto trigger_period_ms = 100ms; - auto trigger_period_s = duration(trigger_period_ms).count(); + auto trigger_period_s = duration(trigger_period_ms).count(); int trigger_id = 42; int triggered = 0; @@ -69,24 +69,24 @@ TEST_F(TestTimeTrigger, test_time_trigger) { }, trigger_id}; EXPECT_EQ(trigger.getID(), trigger_id); - EXPECT_DOUBLE_EQ(trigger.getLastTriggerTime(), 0.0); - EXPECT_DOUBLE_EQ(trigger.nextTriggerTime(), 0.0 + trigger_period_s); + EXPECT_DOUBLE_EQ(trigger.getLastTriggerTime().seconds(), 0.0); + EXPECT_DOUBLE_EQ(trigger.nextTriggerTime().seconds(), 0.0 + trigger_period_s); EXPECT_EQ(triggered, 0); - TimeType start_time = 4.0; + TimeType start_time = TimeType{4.0}; trigger.runAction(start_time); - EXPECT_DOUBLE_EQ(trigger.getLastTriggerTime(), start_time); - EXPECT_DOUBLE_EQ(trigger.nextTriggerTime(), start_time + trigger_period_s); - EXPECT_EQ(trigger.ready(start_time + trigger_period_s), false); - EXPECT_EQ(trigger.ready(start_time + trigger_period_s + 0.001), true); + EXPECT_DOUBLE_EQ(trigger.getLastTriggerTime().seconds(), start_time.seconds()); + EXPECT_DOUBLE_EQ(trigger.nextTriggerTime().seconds(), start_time.seconds() + trigger_period_s); + EXPECT_EQ(trigger.ready(start_time + TimeType{trigger_period_s}), false); + EXPECT_EQ(trigger.ready(start_time + TimeType{trigger_period_s + 0.001}), true); EXPECT_EQ(triggered, 1); } TEST_F(TestTimeTrigger, test_time_trigger_manager_add_trigger) { using namespace std::chrono_literals; - TimeType current_time = 5.2; + TimeType current_time = TimeType{5.2}; auto trigger_period_ms = 100ms; int triggered = 0; @@ -110,9 +110,9 @@ TEST_F(TestTimeTrigger, test_time_trigger_manager_trigger_ready) { using namespace std::chrono; using namespace std::chrono_literals; - TimeType current_time = 5.2; + TimeType current_time = TimeType{5.2}; auto trigger_period_ms = 100ms; - auto trigger_period_s = duration(trigger_period_ms).count(); + auto trigger_period_s = duration(trigger_period_ms).count(); int triggered = 0; auto trigger_manager = @@ -124,16 +124,16 @@ TEST_F(TestTimeTrigger, test_time_trigger_manager_trigger_ready) { }, true); EXPECT_EQ(triggered, 1); - trigger_manager->triggerReady(current_time + trigger_period_s); + trigger_manager->triggerReady(current_time + TimeType{trigger_period_s}); EXPECT_EQ(triggered, 1); - trigger_manager->triggerReady(current_time + trigger_period_s + 0.01); + trigger_manager->triggerReady(current_time + TimeType{trigger_period_s + 0.01}); EXPECT_EQ(triggered, 2); // test unregistration of triggers auto prev_triggered = triggered; trigger_manager->removeTrigger(id); - trigger_manager->triggerReady(current_time + trigger_period_s + 0.01); + trigger_manager->triggerReady(current_time + TimeType{trigger_period_s + 0.01}); // should not have been triggered again! EXPECT_EQ(prev_triggered, triggered); diff --git a/tests/unit/timing/test_timing.nompi.cc b/tests/unit/timing/test_timing.nompi.cc index fd6310ea80..3b9e104d3e 100644 --- a/tests/unit/timing/test_timing.nompi.cc +++ b/tests/unit/timing/test_timing.nompi.cc @@ -53,37 +53,37 @@ using TestTiming = TestHarness; TEST_F(TestTiming, test_time_formatting) { { - TimeTypeWrapper const t = 15664645.400691890716; + TimeType const t = TimeType{15664645.400691890716}; EXPECT_EQ(fmt::format("{}", t), "15.7e6 s"); } { - TimeTypeWrapper const t = 4.0006918907165527344; + TimeType const t = TimeType{4.0006918907165527344}; EXPECT_EQ(fmt::format("{}", t), "4.00e0 s"); } { - TimeTypeWrapper const t = 0.0691890716552734423; + TimeType const t = TimeType{0.0691890716552734423}; EXPECT_EQ(fmt::format("{}", t), "69.2e-3 s"); } { - TimeTypeWrapper const t = -0.0691890716552734423; + TimeType const t = TimeType{-0.0691890716552734423}; EXPECT_EQ(fmt::format("{}", t), "-69.2e-3 s"); } { - TimeTypeWrapper const t = 0.0006918907165527344; + TimeType const t = TimeType{0.0006918907165527344}; EXPECT_EQ(fmt::format("{}", t), "692e-6 s"); } { - TimeTypeWrapper const t = 0.0000006918907165527; + TimeType const t = TimeType{0.0000006918907165527}; EXPECT_EQ(fmt::format("{}", t), "692e-9 s"); } { - TimeTypeWrapper const t = 3.14; + TimeType const t = TimeType{3.14}; EXPECT_EQ(fmt::format("{}", t), "3.14e0 s"); } }