Agora
1.2.0
Agora project
|
Go to the documentation of this file.
9 static inline size_t rdtsc() {
12 asm volatile(
"rdtsc" :
"=a"(rax),
"=d"(rdx));
13 return static_cast<size_t>((rdx << 32) | rax);
22 size_t upp =
static_cast<size_t>(
freq_ghz * ns);
28 clock_gettime(CLOCK_REALTIME, &
start);
29 uint64_t rdtsc_start =
rdtsc();
34 for (uint64_t
i = 0;
i < 1000000;
i++) {
35 sum +=
i + (sum +
i) * (
i % sum);
38 if (sum != 13580802877818827968ull) {
42 clock_gettime(CLOCK_REALTIME, &
end);
44 static_cast<uint64_t
>(
end.tv_sec -
start.tv_sec) * 1000000000 +
45 static_cast<uint64_t
>(
end.tv_nsec -
start.tv_nsec);
46 uint64_t rdtsc_cycles =
rdtsc() - rdtsc_start;
48 double _freq_ghz = rdtsc_cycles * 1.0 / clock_ns;
54 return (cycles / (
freq_ghz * 1000000000));
59 return (cycles / (
freq_ghz * 1000000));
68 return static_cast<size_t>(us * 1000 *
freq_ghz);
72 return static_cast<size_t>(ns *
freq_ghz);
81 static double sec_since(
const struct timespec& t0) {
83 clock_gettime(CLOCK_REALTIME, &t1);
84 return (t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec) / 1000000000.0;
88 static double ns_since(
const struct timespec& t0) {
90 clock_gettime(CLOCK_REALTIME, &t1);
91 return (t1.tv_sec - t0.tv_sec) * 1000000000.0 + (t1.tv_nsec - t0.tv_nsec);
94 static double stddev(
const std::vector<double> in_vec) {
95 if (in_vec.size() == 0)
return 0.0;
96 double sum = std::accumulate(in_vec.begin(), in_vec.end(), 0.0);
97 double mean = sum * 1.0 / in_vec.size();
99 std::inner_product(in_vec.begin(), in_vec.end(), in_vec.begin(), 0.0);
103 static double mean(
const std::vector<double> in_vec) {
104 if (in_vec.empty())
return 0.0;
105 double sum = std::accumulate(in_vec.begin(), in_vec.end(), 0.0);
106 return sum * 1.0 / in_vec.size();
float mat_mult_perf(std::vector< arma::cx_fmat > &test_matrices, std::vector< arma::cx_fmat > &test_col_vectors)
Definition: bench.cc:19
double freq_ghz
Definition: bench.cc:10
arma::cx_fmat gen_matrix_with_condition(double cond_num)
Definition: bench.cc:24
std::vector< double > ms_duration_vec
Definition: timer.h:114
auto printf(const S &fmt, const T &... args) -> int
Definition: printf.h:631
double stddev_msec()
Definition: timer.h:126
DEFINE_double(condition, 10, "Condition number of input matrix")
#define COMPILER_ID
Definition: CMakeCXXCompilerId.cpp:299
double avg_msec()
Definition: timer.h:127
#define ARCHITECTURE_ID
Definition: CMakeCXXCompilerId.cpp:525
string mode
Definition: mm_gui.py:105
void start()
Definition: timer.h:120
static double to_sec(size_t cycles, double freq_ghz)
Convert cycles measured by rdtsc with frequence freq_ghz to seconds.
Definition: timer.h:53
static const auto & dpath_rdtsc
An alias for rdtsc() to distinguish calls on the critical path.
Definition: timer.h:17
#define ARCHITECTURE_ID
Definition: CMakeCCompilerId.c:540
static double mean(const std::vector< double > in_vec)
Definition: timer.h:103
size_t start_tsc
Definition: timer.h:112
int main(int argc, char *argv[])
Definition: CMakeCCompilerId.c:645
static size_t us_to_cycles(double us, double freq_ghz)
Definition: timer.h:67
static size_t rdtsc()
Return the TSC.
Definition: timer.h:9
DEFINE_uint64(n_iters, 10000, "Number of iterations of inversion")
#define C_DIALECT
Definition: CMakeCCompilerId.c:625
constexpr std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1488
int main(int argc, char *argv[])
Definition: CMakeCXXCompilerId.cpp:637
static void condition_number_distribution(size_t n_rows, size_t n_cols)
Definition: bench.cc:12
std::pair< std::vector< arma::cx_fmat >, double > arma_pseudo_inverses(const std::vector< arma::cx_fmat > &test_matrices, PinvMode mode)
Definition: bench.cc:21
void stop()
Definition: timer.h:121
char const * info_platform
Definition: CMakeCCompilerId.c:614
char const * info_compiler
Definition: CMakeCXXCompilerId.cpp:306
#define clflushopt(addr)
Definition: bench.cc:12
uint16_t len
Definition: eth_common.h:62
for i
Definition: generate_data.m:107
j template void())
Definition: json.hpp:4744
float mat_mult_perf_jit(std::vector< arma::cx_fmat > &test_matrices, std::vector< arma::cx_fmat > &test_col_vectors)
Definition: bench.cc:40
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
Definition: printf.h:607
PinvMode
Definition: bench.cc:14
n_rows
Definition: plot_csv.py:18
end start
Definition: inspect_agora_results.m:95
static void rt_assert(bool condition, const char *throw_str)
Definition: bench.cc:19
char const * info_arch
Definition: CMakeCXXCompilerId.cpp:600
n_cols
Definition: plot_csv.py:18
TscTimer(size_t n_timestamps, double freq_ghz)
Definition: timer.h:116
#define COMPILER_ID
Definition: CMakeCCompilerId.c:314
static double to_usec(size_t cycles, double freq_ghz)
Convert cycles measured by rdtsc with frequence freq_ghz to usec.
Definition: timer.h:63
double avg_usec()
Definition: timer.h:128
char const * info_compiler
Definition: CMakeCCompilerId.c:321
char const * info_platform
Definition: CMakeCXXCompilerId.cpp:599
double freq_ghz
Definition: timer.h:113
const char * info_language_dialect_default
Definition: CMakeCCompilerId.c:634
static double to_nsec(size_t cycles, double freq_ghz)
Convert cycles measured by rdtsc with frequence freq_ghz to nsec.
Definition: timer.h:76
N_SC, NUM_UE, NUM_UE zeros()
static double measure_rdtsc_freq()
Definition: timer.h:26
#define PLATFORM_ID
Definition: CMakeCCompilerId.c:436
static constexpr double warmup_fraction
Definition: bench.cc:13
void reset()
Definition: timer.h:125
static double stddev(const std::vector< double > in_vec)
Definition: timer.h:94
static double ns_since(const struct timespec &t0)
Return nanoseconds elapsed since timestamp t0.
Definition: timer.h:88
Simple time that uses RDTSC.
Definition: timer.h:110
char const * info_arch
Definition: CMakeCCompilerId.c:615
static double to_msec(size_t cycles, double freq_ghz)
Convert cycles measured by rdtsc with frequence freq_ghz to msec.
Definition: timer.h:58
static double sec_since(const struct timespec &t0)
Return seconds elapsed since timestamp t0.
Definition: timer.h:81
#define PLATFORM_ID
Definition: CMakeCXXCompilerId.cpp:421
int main(int argc, char **argv)
Definition: bench.cc:22
const char * info_language_dialect_default
Definition: CMakeCXXCompilerId.cpp:621
static void nano_sleep(size_t ns, double freq_ghz)
Definition: timer.h:19
void flush_cache_lines(std::vector< arma::cx_fmat > &test_matrices, std::vector< arma::cx_fmat > &test_col_vectors)
Definition: bench.cc:79
static size_t ns_to_cycles(double ns, double freq_ghz)
Definition: timer.h:71