diff options
author | Wilco Dijkstra <Wilco.Dijkstra@arm.com> | 2019-01-29 17:43:45 +0000 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2019-03-22 17:30:44 -0300 |
commit | 7621e38bf3c58b2d0359545f1f2898017fd89d05 (patch) | |
tree | fbf712328d2d62a509d7a048e2fb22a5bf0f4b55 /benchtests/bench-timing.h | |
parent | 1e372ded4f83362509c8672ff501cba871bb1edc (diff) | |
download | glibc-7621e38bf3c58b2d0359545f1f2898017fd89d05.tar.gz glibc-7621e38bf3c58b2d0359545f1f2898017fd89d05.tar.xz glibc-7621e38bf3c58b2d0359545f1f2898017fd89d05.zip |
Add generic hp-timing support
Add missing generic hp_timing support. It uses clock_gettime (CLOCK_MONOTONIC) which has unspecified starting time, nano-second accuracy, and should faster on architectures that implementes the symbol as vDSO. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also checked the builds for all afected ABIs. * benchtests/Makefile (USE_CLOCK_GETTIME) Remove. * benchtests/README: Update description. * benchtests/bench-timing.h: Default to hp-timing. * sysdeps/generic/hp-timing.h (HP_TIMING_DIFF, HP_TIMING_ACCUM_NT, HP_TIMING_PRINT): Remove. (HP_TIMING_NOW): Add generic implementation. (hp_timing_t): Change to uint64_t.
Diffstat (limited to 'benchtests/bench-timing.h')
-rw-r--r-- | benchtests/bench-timing.h | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h index 93fe379f99..e213dec3fd 100644 --- a/benchtests/bench-timing.h +++ b/benchtests/bench-timing.h @@ -18,49 +18,21 @@ #undef attribute_hidden #define attribute_hidden +#define __clock_gettime clock_gettime #include <hp-timing.h> #include <stdint.h> -#if HP_TIMING_INLINE && !defined USE_CLOCK_GETTIME -# define GL(x) _##x -# define GLRO(x) _##x +#define GL(x) _##x +#define GLRO(x) _##x typedef hp_timing_t timing_t; -# define TIMING_TYPE "hp_timing" +#define TIMING_TYPE "hp_timing" -# define TIMING_INIT(res) ({ (res) = 1; }) +#define TIMING_INIT(res) ({ (res) = 1; }) -# define TIMING_NOW(var) HP_TIMING_NOW (var) -# define TIMING_DIFF(diff, start, end) HP_TIMING_DIFF ((diff), (start), (end)) -# define TIMING_ACCUM(sum, diff) HP_TIMING_ACCUM_NT ((sum), (diff)) - -#else - -#include <time.h> -typedef uint64_t timing_t; - -# define TIMING_TYPE "clock_gettime" - -/* Measure the resolution of the clock so we can scale the number of - benchmark iterations by this value. */ -# define TIMING_INIT(res) \ -({ \ - struct timespec start; \ - clock_getres (CLOCK_PROCESS_CPUTIME_ID, &start); \ - (res) = start.tv_nsec; \ -}) - -# define TIMING_NOW(var) \ -({ \ - struct timespec tv; \ - clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &tv); \ - (var) = (uint64_t) (tv.tv_nsec + (uint64_t) 1000000000 * tv.tv_sec); \ -}) - -# define TIMING_DIFF(diff, start, end) (diff) = (end) - (start) -# define TIMING_ACCUM(sum, diff) (sum) += (diff) - -#endif +#define TIMING_NOW(var) HP_TIMING_NOW (var) +#define TIMING_DIFF(diff, start, end) HP_TIMING_DIFF ((diff), (start), (end)) +#define TIMING_ACCUM(sum, diff) HP_TIMING_ACCUM_NT ((sum), (diff)) #define TIMING_PRINT_MEAN(d_total_s, d_iters) \ printf ("\t%g", (d_total_s) / (d_iters)) |