From e52434a2e4d1105272daaef87678da950fbec73f Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 5 Jun 2020 09:48:04 -0700 Subject: benchtests: Restore the clock_gettime option commit 7621e38bf3c58b2d0359545f1f2898017fd89d05 Author: Wilco Dijkstra Date: Tue Jan 29 17:43:45 2019 +0000 Add generic hp-timing support removed the clock_gettime option. Restore the clock_gettime option for some x86 CPUs on which value from RDTSC may not be incremented at a fixed rate. Reviewed-by: Carlos O'Donell --- benchtests/Makefile | 6 ++++++ benchtests/README | 7 ++++++- benchtests/bench-timing.h | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/benchtests/Makefile b/benchtests/Makefile index 335d643ecb..99e90d17a0 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -132,11 +132,17 @@ endif CPPFLAGS-nonlib += -DDURATION=$(BENCH_DURATION) -D_ISOMAC +# Use clock_gettime to measure performance of functions. The default is +# to use the architecture-specific high precision timing instructions. +ifdef USE_CLOCK_GETTIME +CPPFLAGS-nonlib += -DUSE_CLOCK_GETTIME +else # On x86 processors, use RDTSCP, instead of RDTSC, to measure performance # of functions. All x86 processors since 2010 support RDTSCP instruction. ifdef USE_RDTSCP CPPFLAGS-nonlib += -DUSE_RDTSCP endif +endif DETAILED_OPT := diff --git a/benchtests/README b/benchtests/README index c4f03fd872..f440f3295a 100644 --- a/benchtests/README +++ b/benchtests/README @@ -27,7 +27,12 @@ BENCH_DURATION. The benchmark suite does function call measurements using architecture-specific high precision timing instructions whenever available. When such support is -not available, it uses clock_gettime (CLOCK_MONOTONIC). +not available, it uses clock_gettime (CLOCK_MONOTONIC). One can force the +benchmark to use clock_gettime by invoking make as follows: + + $ make USE_CLOCK_GETTIME=1 bench + +Again, one must run `make bench-clean' before changing the measurement method. On x86 processors, RDTSCP instruction provides more precise timing data than RDTSC instruction. All x86 processors since 2010 support RDTSCP diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h index d0176fb76e..c632d4440e 100644 --- a/benchtests/bench-timing.h +++ b/benchtests/bench-timing.h @@ -18,7 +18,11 @@ #undef attribute_hidden #define attribute_hidden -#include +#ifdef USE_CLOCK_GETTIME +# include +#else +# include +#endif #include #define GL(x) _##x -- cgit 1.4.1