17 #ifndef SCIP2_WALLTIME_H 18 #define SCIP2_WALLTIME_H 24 template <
int DEVICE_TIMESTAMP_BITS>
32 constexpr
static uint32_t
middle_bits_ = (1 << DEVICE_TIMESTAMP_BITS) / 2;
35 uint64_t
update(
const uint32_t& time_device)
39 time_device_prev_ = time_device;
45 if (walltime_device_base_ >= (1 << DEVICE_TIMESTAMP_BITS))
47 time_device_prev_ = (1 << DEVICE_TIMESTAMP_BITS) - time_device;
50 logger::warn() <<
"Device time jumped. prev: " << time_device_prev_
51 <<
", current: " << time_device << std::endl;
54 if (time_device < middle_bits_ &&
55 middle_bits_ < time_device_prev_)
57 walltime_device_base_ += 1 << DEVICE_TIMESTAMP_BITS;
60 time_device_prev_ = time_device;
62 return walltime_device_base_ + time_device;
67 return (time_device_prev_ < middle_bits_ &&
68 middle_bits_ < time_device &&
69 time_device - time_device_prev_ > middle_bits_);
74 , time_device_prev_(0)
75 , walltime_device_base_(0)
81 #endif // SCIP2_WALLTIME_H bool detectDeviceTimeUnderflow(const uint32_t &time_device) const
uint64_t update(const uint32_t &time_device)
uint64_t walltime_device_base_
uint32_t time_device_prev_
static constexpr uint32_t middle_bits_