Skip to content

Commit 362f533

Browse files
committed
#2154: Use std::chrono for TimeType
1 parent 65e7ebc commit 362f533

File tree

21 files changed

+101
-130
lines changed

21 files changed

+101
-130
lines changed

src/vt/elm/elm_lb_data.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void ElementLBData::stop(TimeType time) {
6969
auto const started = cur_time_started_;
7070
if (started) {
7171
cur_time_started_ = false;
72-
addTime(total_time.seconds());
72+
addTime(total_time.seconds().count());
7373
}
7474

7575
vt_debug_print(

src/vt/elm/elm_lb_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct ElementLBData {
125125

126126
protected:
127127
bool cur_time_started_ = false;
128-
TimeType cur_time_ = TimeType{0.0};
128+
TimeType cur_time_ = TimeType{};
129129
PhaseType cur_phase_ = fst_lb_phase;
130130
std::unordered_map<PhaseType, LoadType> phase_timings_ = {};
131131
std::unordered_map<PhaseType, CommMapType> phase_comm_ = {};

src/vt/event/event_record.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct EventRecord {
138138

139139
# if vt_check_enabled(diagnostics)
140140
/// the time this event record was created
141-
TimeType creation_time_stamp_ = TimeType{0.};
141+
TimeType creation_time_stamp_ = TimeType{};
142142
# endif
143143
};
144144

src/vt/messaging/active.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ EventType ActiveMessenger::sendMsgMPI(
347347
{
348348
VT_ALLOW_MPI_CALLS;
349349
#if vt_check_enabled(trace_enabled)
350-
auto tr_begin = TimeType{0.};
350+
auto tr_begin = TimeType{};
351351
if (theConfig()->vt_trace_mpi) {
352352
tr_begin = vt::timing::getCurrentTime();
353353
}
@@ -579,7 +579,7 @@ std::tuple<EventType, int> ActiveMessenger::sendDataMPI(
579579
);
580580
{
581581
#if vt_check_enabled(trace_enabled)
582-
auto tr_begin = TimeType{0.};
582+
auto tr_begin = TimeType{};
583583
if (theConfig()->vt_trace_mpi) {
584584
tr_begin = vt::timing::getCurrentTime();
585585
}
@@ -769,7 +769,7 @@ void ActiveMessenger::recvDataDirect(
769769
);
770770

771771
#if vt_check_enabled(trace_enabled)
772-
auto tr_begin = TimeType{0.};
772+
auto tr_begin = TimeType{};
773773
if (theConfig()->vt_trace_mpi) {
774774
tr_begin = vt::timing::getCurrentTime();
775775
}
@@ -1006,7 +1006,7 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() {
10061006

10071007
{
10081008
#if vt_check_enabled(trace_enabled)
1009-
auto tr_begin = TimeType{0.};
1009+
auto tr_begin = TimeType{};
10101010
if (theConfig()->vt_trace_mpi) {
10111011
tr_begin = vt::timing::getCurrentTime();
10121012
}

src/vt/messaging/request_holder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct RequestHolder {
9898
bool testAll(Callable c, int& num_mpi_tests) {
9999
# if vt_check_enabled(trace_enabled)
100100
std::size_t const holder_size_start = holder_.size();
101-
auto tr_begin = TimeType{0.0};
101+
auto tr_begin = TimeType{};
102102
if (theConfig()->vt_trace_irecv_polling) {
103103
tr_begin = vt::timing::getCurrentTime();
104104
}

src/vt/runtime/component/diagnostic.impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ meter::Timer<T> Diagnostic::registerTimerT(
9393
) {
9494
auto sum = registerDiagnostic<T>(
9595
key + " [sum]", desc, DiagnosticUpdate::Sum, unit,
96-
DiagnosticTypeEnum::PerformanceDiagnostic, T{0}
96+
DiagnosticTypeEnum::PerformanceDiagnostic, T{}
9797
);
9898
auto min = registerDiagnostic<T>(
9999
key + " [min]", desc, DiagnosticUpdate::Min, unit,
@@ -105,7 +105,7 @@ meter::Timer<T> Diagnostic::registerTimerT(
105105
);
106106
auto avg = registerDiagnostic<T>(
107107
key + " [avg]", desc, DiagnosticUpdate::Avg, unit,
108-
DiagnosticTypeEnum::PerformanceDiagnostic, T{0}
108+
DiagnosticTypeEnum::PerformanceDiagnostic, T{}
109109
);
110110
return meter::Timer<T>{sum, avg, max, min};
111111
}

src/vt/runtime/component/diagnostic_value.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct DiagnosticValueWrapper {
168168
*
169169
* \return the max value
170170
*/
171-
T max() const { return N_ == 0 ? T{0} : max_; }
171+
T max() const { return N_ == 0 ? T{} : max_; }
172172

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

187187
/**
188188
* \internal \brief Get the arithmetic mean value (use after reduction)
@@ -237,7 +237,7 @@ struct DiagnosticValueWrapper {
237237
*/
238238
T getComputedValue() const {
239239
if (N_ > 0) {
240-
return value_ / N_;
240+
return value_ / static_cast<const T>(N_);
241241
} else {
242242
return value_;
243243
}

src/vt/runtime/component/meter/timer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ struct Timer : DiagnosticStatsPack<T> {
102102
* \brief Stop the timer and record the interval
103103
*/
104104
void stop() {
105-
if (start_time_ != TimeType{0.}) {
105+
if (start_time_ != TimeType{}) {
106106
update(start_time_, timing::getCurrentTime());
107-
start_time_ = TimeType{0.};
107+
start_time_ = TimeType{};
108108
}
109109
}
110110

@@ -116,7 +116,7 @@ struct Timer : DiagnosticStatsPack<T> {
116116
}
117117

118118
private:
119-
T start_time_ = T{0};
119+
T start_time_ = T{};
120120
};
121121

122122
}}}} /* end namespace vt::runtime::component::meter */

src/vt/scheduler/scheduler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct Scheduler : runtime::component::Component<Scheduler> {
178178
*
179179
* \param[in] current_time current time
180180
*/
181-
void runProgress(bool msg_only = false, TimeType current_time = TimeType{0.0} );
181+
void runProgress(bool msg_only = false, TimeType current_time = TimeType{} );
182182

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

441-
TimeType last_progress_time_ = TimeType{0.0};
441+
TimeType last_progress_time_ = TimeType{};
442442
bool progress_time_enabled_ = false;
443443
int32_t processed_after_last_progress_ = 0;
444444

src/vt/timetrigger/trigger.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ struct Trigger {
8585
* \return the next time this should be triggered
8686
*/
8787
TimeType nextTriggerTime() const {
88-
return TimeType{
89-
(last_trigger_time_.milliseconds() + period_.count()) / 1000.0};
88+
return TimeType{last_trigger_time_.milliseconds() + period_};
9089
}
9190

9291
/**
@@ -142,7 +141,7 @@ struct Trigger {
142141
private:
143142
std::chrono::milliseconds period_; /**< The trigger's period */
144143
ActionType trigger_ = nullptr; /**< The action to trigger */
145-
TimeType last_trigger_time_ = TimeType{0.}; /**< The last time it was triggered */
144+
TimeType last_trigger_time_ = TimeType{}; /**< The last time it was triggered */
146145
int id_ = -1; /**< The trigger's id */
147146
};
148147

0 commit comments

Comments
 (0)