Skip to content

Commit

Permalink
#2154: Working TimeType with std::chrono
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Nov 21, 2023
1 parent 0fa7ee5 commit f0996ca
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 168 deletions.
4 changes: 2 additions & 2 deletions src/vt/elm/elm_lb_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ void ElementLBData::recvToNode(
}

void ElementLBData::addTime(TimeType const& time) {
phase_timings_[cur_phase_] += time.seconds();
phase_timings_[cur_phase_] += time.seconds().count();

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.seconds().count();

vt_debug_print(
verbose,lb,
Expand Down
2 changes: 1 addition & 1 deletion src/vt/elm/elm_lb_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct ElementLBData {

protected:
bool cur_time_started_ = false;
TimeType cur_time_ = TimeType{0.0};
TimeType cur_time_ = TimeType{};
PhaseType cur_phase_ = fst_lb_phase;
std::unordered_map<PhaseType, LoadType> phase_timings_ = {};
std::unordered_map<PhaseType, CommMapType> phase_comm_ = {};
Expand Down
2 changes: 1 addition & 1 deletion src/vt/event/event_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct EventRecord {

# if vt_check_enabled(diagnostics)
/// the time this event record was created
TimeType creation_time_stamp_ = TimeType{0.};
TimeType creation_time_stamp_ = TimeType{};
# endif
};

Expand Down
8 changes: 4 additions & 4 deletions src/vt/messaging/active.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ EventType ActiveMessenger::sendMsgMPI(
{
VT_ALLOW_MPI_CALLS;
#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
auto tr_begin = TimeType{};
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
}
Expand Down Expand Up @@ -579,7 +579,7 @@ std::tuple<EventType, int> ActiveMessenger::sendDataMPI(
);
{
#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
auto tr_begin = TimeType{};
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
}
Expand Down Expand Up @@ -769,7 +769,7 @@ void ActiveMessenger::recvDataDirect(
);

#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
auto tr_begin = TimeType{};
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
}
Expand Down Expand Up @@ -1006,7 +1006,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() {

{
#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
auto tr_begin = TimeType{};
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
}
Expand Down
2 changes: 1 addition & 1 deletion src/vt/messaging/request_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
auto tr_begin = TimeType{0.0};
auto tr_begin = TimeType{};
if (theConfig()->vt_trace_irecv_polling) {
tr_begin = vt::timing::getCurrentTime();
}
Expand Down
4 changes: 2 additions & 2 deletions src/vt/runtime/component/diagnostic.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ meter::Timer<T> Diagnostic::registerTimerT(
) {
auto sum = registerDiagnostic<T>(
key + " [sum]", desc, DiagnosticUpdate::Sum, unit,
DiagnosticTypeEnum::PerformanceDiagnostic, T{0}
DiagnosticTypeEnum::PerformanceDiagnostic, T{}
);
auto min = registerDiagnostic<T>(
key + " [min]", desc, DiagnosticUpdate::Min, unit,
Expand All @@ -105,7 +105,7 @@ meter::Timer<T> Diagnostic::registerTimerT(
);
auto avg = registerDiagnostic<T>(
key + " [avg]", desc, DiagnosticUpdate::Avg, unit,
DiagnosticTypeEnum::PerformanceDiagnostic, T{0}
DiagnosticTypeEnum::PerformanceDiagnostic, T{}
);
return meter::Timer<T>{sum, avg, max, min};
}
Expand Down
6 changes: 3 additions & 3 deletions src/vt/runtime/component/diagnostic_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ struct DiagnosticValueWrapper {
*
* \return the max value
*/
T max() const { return N_ == 0 ? T{0} : max_; }
T max() const { return N_ == 0 ? T{} : max_; }

/**
* \internal \brief Get sum of values (use after reduction)
Expand All @@ -182,7 +182,7 @@ struct DiagnosticValueWrapper {
*
* \return the min value
*/
T min() const { return N_ == 0 ? T{0} : min_; }
T min() const { return N_ == 0 ? T{} : min_; }

/**
* \internal \brief Get the arithmetic mean value (use after reduction)
Expand Down Expand Up @@ -237,7 +237,7 @@ struct DiagnosticValueWrapper {
*/
T getComputedValue() const {
if (N_ > 0) {
return value_ / N_;
return value_ / static_cast<const T>(N_);
} else {
return value_;
}
Expand Down
6 changes: 3 additions & 3 deletions src/vt/runtime/component/meter/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ struct Timer : DiagnosticStatsPack<T> {
* \brief Stop the timer and record the interval
*/
void stop() {
if (start_time_ != TimeType{0.}) {
if (start_time_ != TimeType{}) {
update(start_time_, timing::getCurrentTime());
start_time_ = TimeType{0.};
start_time_ = TimeType{};
}
}

Expand All @@ -116,7 +116,7 @@ struct Timer : DiagnosticStatsPack<T> {
}

private:
T start_time_ = T{0};
T start_time_ = T{};
};

}}}} /* end namespace vt::runtime::component::meter */
Expand Down
4 changes: 2 additions & 2 deletions src/vt/scheduler/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct Scheduler : runtime::component::Component<Scheduler> {
*
* \param[in] current_time current time
*/
void runProgress(bool msg_only = false, TimeType current_time = TimeType{0.0} );
void runProgress(bool msg_only = false, TimeType current_time = TimeType{} );

/**
* \brief Runs the scheduler until a condition is met.
Expand Down Expand Up @@ -438,7 +438,7 @@ struct Scheduler : runtime::component::Component<Scheduler> {
EventTriggerContType event_triggers;
EventTriggerContType event_triggers_once;

TimeType last_progress_time_ = TimeType{0.0};
TimeType last_progress_time_ = TimeType{};
bool progress_time_enabled_ = false;
int32_t processed_after_last_progress_ = 0;

Expand Down
5 changes: 2 additions & 3 deletions src/vt/timetrigger/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ struct Trigger {
* \return the next time this should be triggered
*/
TimeType nextTriggerTime() const {
return TimeType{
(last_trigger_time_.milliseconds() + period_.count()) / 1000.0};
return TimeType{last_trigger_time_.milliseconds() + period_};
}

/**
Expand Down Expand Up @@ -142,7 +141,7 @@ struct Trigger {
private:
std::chrono::milliseconds period_; /**< The trigger's period */
ActionType trigger_ = nullptr; /**< The action to trigger */
TimeType last_trigger_time_ = TimeType{0.}; /**< The last time it was triggered */
TimeType last_trigger_time_ = TimeType{}; /**< The last time it was triggered */
int id_ = -1; /**< The trigger's id */
};

Expand Down
2 changes: 1 addition & 1 deletion src/vt/timing/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct formatter<::vt::TimeTypeWrapper> {
auto format(::vt::TimeTypeWrapper const& t, FormatContext& ctx) {
return fmt::format_to(
ctx.out(), "{}",
to_engineering_string(t.seconds(), 3, eng_exponential, "s")
to_engineering_string(t.seconds().count(), 3, eng_exponential, "s")
);
}
};
Expand Down
Loading

0 comments on commit f0996ca

Please sign in to comment.