Agora
1.2.0
Agora project
|
Go to the documentation of this file.
16 clock_gettime(CLOCK_MONOTONIC, &tv);
17 return tv.tv_sec * 1000000 + tv.tv_nsec / 1000.0;
28 asm volatile(
"rdtsc" :
"=a"(rax),
"=d"(rdx));
29 return static_cast<size_t>((rdx << 32) | rax);
42 auto upp =
static_cast<size_t>(
freq_ghz * ns);
52 struct timespec
start;
54 clock_gettime(CLOCK_REALTIME, &
start);
55 uint64_t rdtsc_start =
Rdtsc();
60 for (uint64_t
i = 0;
i < 1000000;
i++) {
61 sum +=
i + (sum +
i) * (
i % sum);
63 if (sum != 13580802877818827968ull) {
65 throw std::runtime_error(
"Error in RDTSC freq measurement");
68 clock_gettime(CLOCK_REALTIME, &
end);
70 static_cast<uint64_t
>(
end.tv_sec -
start.tv_sec) * 1000000000 +
71 static_cast<uint64_t
>(
end.tv_nsec -
start.tv_nsec);
74 double freq_ghz = rdtsc_cycles * 1.0 / clock_ns;
77 if (freq_ghz < 1.0 && freq_ghz > 4.0) {
79 throw std::runtime_error(
"Invalid RDTSC frequency");
86 return (cycles / (
freq_ghz * 1000000000));
92 return (cycles / (
freq_ghz * 1000000));
108 return static_cast<size_t>(ms * 1000 * 1000 *
freq_ghz);
112 return static_cast<size_t>(us * 1000 *
freq_ghz);
116 return static_cast<size_t>(ns *
freq_ghz);
120 static inline double SecSince(
const struct timespec& t0) {
122 clock_gettime(CLOCK_REALTIME, &t1);
123 return (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec) / 1000000000.0;
127 static inline double NsSince(
const struct timespec& t0) {
129 clock_gettime(CLOCK_REALTIME, &t1);
130 return (t1.tv_sec - t0.tv_sec) * 1000000000.0 + (t1.tv_nsec - t0.tv_nsec);
135 #endif // GETTIME_INC_
double freq_ghz
Definition: bench.cc:10
auto printf(const S &fmt, const T &... args) -> int
Definition: printf.h:631
static double CyclesToNs(size_t cycles, double freq_ghz)
Definition: gettime.h:103
static size_t MsToCycles(double ms, double freq_ghz)
Definition: gettime.h:107
static double NsSince(const struct timespec &t0)
Return nanoseconds elapsed since timestamp t0.
Definition: gettime.h:127
static double GetTimeUs()
Definition: gettime.h:14
static size_t UsToCycles(double us, double freq_ghz)
Definition: gettime.h:111
static double CyclesToUs(size_t cycles, double freq_ghz)
Definition: gettime.h:97
for i
Definition: generate_data.m:107
static void NanoSleep(size_t ns, double freq_ghz)
Sleep for some nanoseconds.
Definition: gettime.h:39
static size_t Rdtsc()
Return the TSC.
Definition: gettime.h:25
static double SecSince(const struct timespec &t0)
Return seconds elapsed since timestamp t0.
Definition: gettime.h:120
end start
Definition: inspect_agora_results.m:95
static double CyclesToSec(size_t cycles, double freq_ghz)
Convert cycles measured by rdtsc with frequence freq_ghz to seconds.
Definition: gettime.h:85
static constexpr bool kIsWorkerTimingEnabled
Definition: symbols.h:303
static size_t NsToCycles(double ns, double freq_ghz)
Definition: gettime.h:115
static double MeasureRdtscFreq()
Definition: gettime.h:51
static double GetTime()
Definition: gettime.h:22
static size_t WorkerRdtsc()
Definition: gettime.h:34
static double CyclesToMs(size_t cycles, double freq_ghz)
Definition: gettime.h:91