diff --git a/src/vt/elm/elm_lb_data.cc b/src/vt/elm/elm_lb_data.cc index ff8f09ebad..b35d8ebd5e 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,13 +63,13 @@ 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) { cur_time_started_ = false; - addTime(total_time); + addTime(total_time.seconds()); } vt_debug_print( @@ -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(LoadType const timeLoad) { + phase_timings_[cur_phase_] += timeLoad; subphase_timings_[cur_phase_].resize(cur_subphase_ + 1); - subphase_timings_[cur_phase_].at(cur_subphase_) += time.seconds(); + subphase_timings_[cur_phase_].at(cur_subphase_) += timeLoad; vt_debug_print( verbose,lb, "ElementLBData: addTime: time={}, cur_load={}\n", time, - TimeTypeWrapper(phase_timings_[cur_phase_]) + phase_timings_[cur_phase_] ); } @@ -163,10 +163,10 @@ PhaseType ElementLBData::getPhase() const { return cur_phase_; } -TimeType ElementLBData::getLoad(PhaseType const& phase) const { +LoadType 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,13 +174,13 @@ TimeType ElementLBData::getLoad(PhaseType const& phase) const { total_load, phase, phase_timings_.size() ); - return total_load.seconds(); + return total_load; } else { return 0.0; } } -TimeType +LoadType ElementLBData::getLoad(PhaseType phase, SubphaseType subphase) const { if (subphase == no_subphase) return getLoad(phase); @@ -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,10 +196,10 @@ 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) { +std::vector const& ElementLBData::getSubphaseTimes(PhaseType phase) { return subphase_timings_[phase]; } diff --git a/src/vt/elm/elm_lb_data.h b/src/vt/elm/elm_lb_data.h index 1ebc07c6c3..de96110b80 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(LoadType const timeLoad); void sendToEntity(ElementIDStruct to, ElementIDStruct from, double bytes); void sendComm(elm::CommKey key, double bytes); @@ -84,12 +84,12 @@ struct ElementLBData { void updatePhase(PhaseType const& inc = 1); void resetPhase(); PhaseType getPhase() const; - TimeType getLoad(PhaseType const& phase) const; - TimeType getLoad(PhaseType phase, SubphaseType subphase) const; + LoadType getLoad(PhaseType const& phase) const; + LoadType getLoad(PhaseType phase, SubphaseType subphase) const; CommMapType const& getComm(PhaseType const& phase); std::vector const& getSubphaseComm(PhaseType phase); - std::vector const& getSubphaseTimes(PhaseType phase); + std::vector const& getSubphaseTimes(PhaseType phase); void setSubPhase(SubphaseType subphase); SubphaseType getSubPhase() const; @@ -124,13 +124,13 @@ 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_timings_ = {}; std::unordered_map phase_comm_ = {}; SubphaseType cur_subphase_ = 0; - std::unordered_map> subphase_timings_ = {}; + std::unordered_map> subphase_timings_ = {}; std::unordered_map> subphase_comm_ = {}; }; diff --git a/src/vt/event/event.cc b/src/vt/event/event.cc index 59737386cc..d3de8b195c 100644 --- a/src/vt/event/event.cc +++ b/src/vt/event/event.cc @@ -304,7 +304,7 @@ AsyncEvent::EventStateType AsyncEvent::testEventComplete(EventType const& event) void AsyncEvent::testEventsTrigger(int const& num_events) { # if vt_check_enabled(trace_enabled) int32_t num_completed = 0; - TimeType tr_begin = 0.0; + auto tr_begin = TimeType{0.0}; if (theConfig()->vt_trace_event_polling) { tr_begin = timing::getCurrentTime(); 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/messaging/active.cc b/src/vt/messaging/active.cc index 9ab3235191..a0eca38400 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -347,7 +347,7 @@ EventType ActiveMessenger::sendMsgMPI( { VT_ALLOW_MPI_CALLS; #if vt_check_enabled(trace_enabled) - double tr_begin = 0; + auto tr_begin = TimeType{0.}; if (theConfig()->vt_trace_mpi) { tr_begin = vt::timing::getCurrentTime(); } @@ -579,7 +579,7 @@ std::tuple ActiveMessenger::sendDataMPI( ); { #if vt_check_enabled(trace_enabled) - double tr_begin = 0; + auto tr_begin = TimeType{0.}; if (theConfig()->vt_trace_mpi) { tr_begin = vt::timing::getCurrentTime(); } @@ -769,7 +769,7 @@ void ActiveMessenger::recvDataDirect( ); #if vt_check_enabled(trace_enabled) - double tr_begin = 0; + auto tr_begin = TimeType{0.}; if (theConfig()->vt_trace_mpi) { tr_begin = vt::timing::getCurrentTime(); } @@ -1006,7 +1006,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() { { #if vt_check_enabled(trace_enabled) - double tr_begin = 0; + auto tr_begin = TimeType{0.}; if (theConfig()->vt_trace_mpi) { tr_begin = vt::timing::getCurrentTime(); } diff --git a/src/vt/messaging/request_holder.h b/src/vt/messaging/request_holder.h index 5f5bb7dd2c..bf48e5b098 100644 --- a/src/vt/messaging/request_holder.h +++ b/src/vt/messaging/request_holder.h @@ -98,7 +98,7 @@ struct RequestHolder { bool testAll(Callable c, int& num_mpi_tests) { # if vt_check_enabled(trace_enabled) std::size_t const holder_size_start = holder_.size(); - TimeType tr_begin = 0.0; + auto tr_begin = TimeType{0.0}; if (theConfig()->vt_trace_irecv_polling) { tr_begin = vt::timing::getCurrentTime(); } 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/trace/trace_user.cc b/src/vt/trace/trace_user.cc index ab79a9423e..ee4754ffbf 100644 --- a/src/vt/trace/trace_user.cc +++ b/src/vt/trace/trace_user.cc @@ -81,7 +81,7 @@ void addUserEvent(UserEventIDType event) { #endif } -void addUserEventBracketed(UserEventIDType event, double begin, double end) { +void addUserEventBracketed(UserEventIDType event, TimeType begin, TimeType end) { #if vt_check_enabled(trace_enabled) theTrace()->addUserEventBracketed(event, begin, end); #endif @@ -100,7 +100,7 @@ void addUserData(int32_t data) { } 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 ) { #if vt_check_enabled(trace_enabled) @@ -110,10 +110,10 @@ void addUserBracketedNote( #if vt_check_enabled(trace_enabled) struct UserSplitHolder final { - static std::unordered_map split_; + static std::unordered_map split_; }; -/*static*/ std::unordered_map UserSplitHolder::split_ = {}; +/*static*/ std::unordered_map UserSplitHolder::split_ = {}; #endif void addUserNotePre(std::string const& note, TraceEventIDType const) { diff --git a/src/vt/trace/trace_user.h b/src/vt/trace/trace_user.h index f96ef28c24..a5dbc0809e 100644 --- a/src/vt/trace/trace_user.h +++ b/src/vt/trace/trace_user.h @@ -46,6 +46,7 @@ #include "vt/config.h" #include "vt/trace/trace_common.h" +#include "vt/timing/timing_type.h" #include @@ -127,7 +128,7 @@ void addUserData(int32_t data); * \param[in] event the event ID to log */ 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 ); @@ -184,7 +185,7 @@ struct TraceScopedEventHash final { */ void end() { if (event_ != no_user_event_id) { - double end = TraceLite::getCurrentTime(); + auto end = TraceLite::getCurrentTime(); theTrace()->addUserEventBracketed(event_, begin_, end); event_ = no_user_event_id; @@ -192,7 +193,7 @@ struct TraceScopedEventHash final { } private: - double begin_ = 0.0; + TimeType begin_ = TimeType{0.0}; std::string str_ = ""; UserEventIDType event_ = no_user_event_id; }; @@ -214,7 +215,7 @@ struct TraceScopedEvent final { * \c registerEventCollective ) */ explicit TraceScopedEvent(UserEventIDType event) - : begin_(event != no_user_event_id ? TraceLite::getCurrentTime() : 0), + : begin_(event != no_user_event_id ? TraceLite::getCurrentTime() : TimeType{0.}), event_(event) { } @@ -240,7 +241,7 @@ struct TraceScopedEvent final { */ void end() { if (event_ != no_user_event_id) { - double end = TraceLite::getCurrentTime(); + auto end = TraceLite::getCurrentTime(); theTrace()->addUserEventBracketed(event_, begin_, end); event_ = no_user_event_id; @@ -248,7 +249,7 @@ struct TraceScopedEvent final { } private: - double begin_ = 0.0; + TimeType begin_ = TimeType{0.0}; UserEventIDType event_ = no_user_event_id; }; @@ -271,7 +272,7 @@ struct TraceScopedNote final { */ TraceScopedNote( std::string const& in_note, TraceEventIDType const in_event = no_trace_event - ) : begin_(in_event != no_trace_event ? TraceLite::getCurrentTime() : 0), + ) : begin_(in_event != no_trace_event ? TraceLite::getCurrentTime() : TimeType{0.}), event_(in_event), note_(in_note) { } @@ -300,7 +301,7 @@ struct TraceScopedNote final { */ void end() { if (event_ != no_user_event_id) { - double end = TraceLite::getCurrentTime(); + auto end = TraceLite::getCurrentTime(); theTrace()->addUserBracketedNote(begin_, end, note_, event_); event_ = no_user_event_id; @@ -312,7 +313,7 @@ struct TraceScopedNote final { } private: - double begin_ = 0.0; + TimeType begin_ = TimeType{0.0}; TraceEventIDType event_ = no_trace_event; std::string note_ = ""; }; diff --git a/src/vt/vrt/collection/balance/baselb/baselb.h b/src/vt/vrt/collection/balance/baselb/baselb.h index 6af9088986..01cc200efc 100644 --- a/src/vt/vrt/collection/balance/baselb/baselb.h +++ b/src/vt/vrt/collection/balance/baselb/baselb.h @@ -134,8 +134,6 @@ struct BaseLB { balance::DataMapType const& in_data_map ); - static LoadType loadMilli(LoadType const& load); - void notifyCurrentHostNodeOfObjectsDeparting( TransferMsg* msg ); @@ -143,6 +141,8 @@ struct BaseLB { TransferMsg* msg ); + LoadType loadMilli(LoadType const& load); + void applyMigrations( TransferVecType const& transfers, MigrationCountCB migration_count_callback ); @@ -167,7 +167,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..3c4b47fff1 100644 --- a/src/vt/vrt/collection/balance/baselb/load_sampler.cc +++ b/src/vt/vrt/collection/balance/baselb/load_sampler.cc @@ -49,10 +49,10 @@ namespace vt { namespace vrt { namespace collection { namespace lb { void LoadSamplerBaseLB::buildHistogram() { for (auto obj : *load_model_) { - TimeTypeWrapper load = load_model_->getModeledLoad( + auto load = load_model_->getModeledLoad( obj, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE} ); - auto const& load_milli = loadMilli(load.seconds()); + auto const& load_milli = loadMilli(load); auto const& bin = histogramSample(load_milli); if (obj.isMigratable()) { obj_sample[bin].push_back(obj); diff --git a/src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc b/src/vt/vrt/collection/balance/hierarchicallb/hierlb.cc index 4d3ba9a88d..3252e65d6b 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" @@ -791,7 +792,7 @@ void HierarchicalLB::clearObj(ObjSampleType& objs) { void HierarchicalLB::runLB(LoadType total_load) { this_load = loadMilli(total_load); 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 1d86f14ea8..eb1ec66eb6 100644 --- a/src/vt/vrt/collection/balance/hierarchicallb/hierlb.h +++ b/src/vt/vrt/collection/balance/hierarchicallb/hierlb.h @@ -77,7 +77,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_invoke/lb_manager.cc b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc index e642a0c0a1..2f05551bfe 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc @@ -43,6 +43,7 @@ #include "vt/config.h" #include "vt/configs/arguments/app_config.h" +#include "vt/configs/types/types_type.h" #include "vt/context/context.h" #include "vt/phase/phase_hook_enum.h" #include "vt/vrt/collection/balance/baselb/baselb.h" @@ -607,7 +608,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, 0.0); if (vec.size() == 0) { return reduce_ld; } else { @@ -669,7 +670,7 @@ void LBManager::computeStatistics( )); if (strategy_specific_model_) { - auto rank_strat_specific_load = 0.; + LoadType rank_strat_specific_load = 0.; std::vector obj_strat_specific_load; for (auto elm : *strategy_specific_model_) { auto work = strategy_specific_model_->getModeledLoad(elm, when); diff --git a/src/vt/vrt/collection/balance/model/comm_overhead.cc b/src/vt/vrt/collection/balance/model/comm_overhead.cc index 2913c80ba8..c672f60461 100644 --- a/src/vt/vrt/collection/balance/model/comm_overhead.cc +++ b/src/vt/vrt/collection/balance/model/comm_overhead.cc @@ -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/raw_data.cc b/src/vt/vrt/collection/balance/model/raw_data.cc index 2604454283..7eaf3d8661 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 @@ LoadType 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 0.0; } } diff --git a/src/vt/vrt/collection/balance/stats_msg.h b/src/vt/vrt/collection/balance/stats_msg.h index 965ebf46fb..542a7aca5c 100644 --- a/src/vt/vrt/collection/balance/stats_msg.h +++ b/src/vt/vrt/collection/balance/stats_msg.h @@ -84,18 +84,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; + auto delta = a2.avg_ - a1.avg_; + auto delta_sur_N = delta / static_cast(N); + auto 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_; + auto M2 = a1.M2_; + auto M2_c = a2.M2_; + auto M3 = a1.M3_; + auto M3_c = a2.M3_; a1.M4_ += a2.M4_ + prod_n * ( n2 - prod_n + n_c2 ) * delta * delta_sur_N * delta2_sur_N2 @@ -130,8 +130,8 @@ struct LoadData { } else { double nm1 = N_ - 1; double inv_n = 1. / N_; - double var_inv = nm1 / M2_; - double nvar_inv = var_inv * inv_n; + auto var_inv = nm1 / M2_; + auto nvar_inv = var_inv * inv_n; return nvar_inv * std::sqrt( var_inv ) * M3_; } } @@ -141,8 +141,8 @@ struct LoadData { } else { double nm1 = N_ - 1; double inv_n = 1. / N_; - double var_inv = nm1 / M2_; - double nvar_inv = var_inv * inv_n; + auto var_inv = nm1 / M2_; + auto nvar_inv = var_inv * inv_n; return nvar_inv * var_inv * M4_ - 3.; } } diff --git a/src/vt/vrt/collection/balance/temperedlb/temperedlb.h b/src/vt/vrt/collection/balance/temperedlb/temperedlb.h index e6f8854569..30b6247ed2 100644 --- a/src/vt/vrt/collection/balance/temperedlb/temperedlb.h +++ b/src/vt/vrt/collection/balance/temperedlb/temperedlb.h @@ -41,6 +41,7 @@ //@HEADER */ +#include "vt/configs/types/types_type.h" #if !defined INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_TEMPEREDLB_H #define INCLUDED_VT_VRT_COLLECTION_BALANCE_TEMPEREDLB_TEMPEREDLB_H diff --git a/src/vt/vrt/collection/balance/zoltanlb/zoltanlb.cc b/src/vt/vrt/collection/balance/zoltanlb/zoltanlb.cc index 978f466825..e457270424 100644 --- a/src/vt/vrt/collection/balance/zoltanlb/zoltanlb.cc +++ b/src/vt/vrt/collection/balance/zoltanlb/zoltanlb.cc @@ -131,7 +131,7 @@ void ZoltanLB::inputParams(balance::ConfigEntry* config) { void ZoltanLB::runLB(LoadType total_load) { auto const& this_node = theContext()->getNode(); - this_load = loadMilli(total_load); + this_load = total_load; if (this_node == 0) { vt_debug_print(terse, lb, "ZoltanLB: runLB: edges={}\n", do_edges_); @@ -485,8 +485,7 @@ std::unique_ptr ZoltanLB::makeGraph() { obj, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE} ); - auto time = static_cast(loadMilli(load)); - graph->vertex_weight[idx++] = time; + graph->vertex_weight[idx++] = loadMilli(load); } } 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_data_holder.cc b/tests/unit/collection/test_lb_data_holder.cc index 9b2bec90c5..a5f9cb2c88 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{3.}; } } diff --git a/tests/unit/collection/test_model_comm_overhead.nompi.cc b/tests/unit/collection/test_model_comm_overhead.nompi.cc index aef462234a..e0a41aefcc 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 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..2d61d49cce 100644 --- a/tests/unit/scheduler/test_scheduler_timings.cc +++ b/tests/unit/scheduler/test_scheduler_timings.cc @@ -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"); } }