[PATCHv2,3/4] Add generic hp-timing support
Commit Message
v2: use stdint.h rather than inttypes.h
Add missing generic hp_timing support. Remove unused HP_TIMING_AVAIL
and HP_SMALL_TIMING_AVAIL. Use the VDSO clock_gettime (CLOCK_MONOTONIC, )
on targets which don't use an inlined instruction returning time/cycles.
ChangeLog:
2019-01-25 Wilco Dijkstra <wdijkstr@arm.com>
* sysdeps/alpha/hp-timing.h (HP_TIMING_AVAIL): Remove define.
(HP_SMALL_TIMING_AVAIL) Remove.
* sysdeps/generic/hp-timing.h (HP_TIMING_NONAVAIL): Remove.
(HP_TIMING_NOW): Add generic implementation.
* sysdeps/generic/hp-timing-common.h (HP_TIMING_AVAIL): Remove.
* sysdeps/ia64/hp-timing.h (HP_TIMING_AVAIL): Remove define.
(HP_SMALL_TIMING_AVAIL) Remove.
* sysdeps/powerpc/powerpc32/power4/hp-timing.h: Likewise.
* sysdeps/powerpc/powerpc64/hp-timing.h: Likewise.
* sysdeps/sparc/sparc32/sparcv9/hp-timing.h: Likewise.
* sysdeps/sparc/sparc64/hp-timing.h: Likewise.
* sysdeps/x86/hp-timing.h: Likewise.
--
@@ -21,12 +21,8 @@
#define _HP_TIMING_H 1
/* We always have the timestamp register, but it's got only a 4 second
- range. Use it for ld.so profiling only. */
-#define HP_TIMING_AVAIL (0)
-#define HP_SMALL_TIMING_AVAIL (1)
-
-/* We indeed have inlined functions. */
-#define HP_TIMING_INLINE (1)
+ range. Only use it for benchmarking. */
+#define HP_TIMING_INLINE (0)
/* We use 32 bit values for the times. */
typedef unsigned int hp_timing_t;
@@ -20,8 +20,6 @@
/* In case a platform supports timers in the hardware the following macros
and types must be defined:
- - HP_TIMING_AVAIL: test for availability.
-
- HP_TIMING_INLINE: this macro is non-zero if the functionality is not
implemented using function calls but instead uses some inlined code
which might simply consist of a few assembler instructions. We have to
@@ -20,21 +20,19 @@
#ifndef _HP_TIMING_H
#define _HP_TIMING_H 1
-/* There are no generic definitions for the times. We could write something
- using the `gettimeofday' system call where available but the overhead of
- the system call might be too high. */
+#include <time.h>
+#include <stdint.h>
+#include <hp-timing-common.h>
-/* Provide dummy definitions. */
-#define HP_TIMING_AVAIL (0)
-#define HP_SMALL_TIMING_AVAIL (0)
#define HP_TIMING_INLINE (0)
-typedef int hp_timing_t;
-#define HP_TIMING_NOW(var)
-#define HP_TIMING_DIFF(Diff, Start, End)
-#define HP_TIMING_ACCUM_NT(Sum, Diff)
-#define HP_TIMING_PRINT(Buf, Len, Val)
-
-/* Since this implementation is not available we tell the user about it. */
-#define HP_TIMING_NONAVAIL 1
+
+typedef uint64_t hp_timing_t;
+
+#define HP_TIMING_NOW(var) \
+({ \
+ struct timespec tv; \
+ __clock_gettime (CLOCK_MONOTONIC, &tv); \
+ (var) = (tv.tv_nsec + (uint64_t) 1000000000 * tv.tv_sec); \
+})
#endif /* hp-timing.h */
@@ -20,10 +20,6 @@
#ifndef _HP_TIMING_H
#define _HP_TIMING_H 1
-/* We always assume having the timestamp register. */
-#define HP_TIMING_AVAIL (1)
-#define HP_SMALL_TIMING_AVAIL (1)
-
/* We indeed have inlined functions. */
#define HP_TIMING_INLINE (1)
@@ -20,10 +20,6 @@
#ifndef _HP_TIMING_H
#define _HP_TIMING_H 1
-/* We always assume having the timestamp register. */
-#define HP_TIMING_AVAIL (1)
-#define HP_SMALL_TIMING_AVAIL (1)
-
/* We indeed have inlined functions. */
#define HP_TIMING_INLINE (1)
@@ -20,10 +20,6 @@
#ifndef _HP_TIMING_H
#define _HP_TIMING_H 1
-/* We always assume having the timestamp register. */
-#define HP_TIMING_AVAIL (1)
-#define HP_SMALL_TIMING_AVAIL (1)
-
/* We indeed have inlined functions. */
#define HP_TIMING_INLINE (1)
@@ -20,8 +20,6 @@
#ifndef _HP_TIMING_H
#define _HP_TIMING_H 1
-#define HP_TIMING_AVAIL (1)
-#define HP_SMALL_TIMING_AVAIL (1)
#define HP_TIMING_INLINE (1)
typedef unsigned long long int hp_timing_t;
@@ -20,8 +20,6 @@
#ifndef _HP_TIMING_H
#define _HP_TIMING_H 1
-#define HP_TIMING_AVAIL (1)
-#define HP_SMALL_TIMING_AVAIL (1)
#define HP_TIMING_INLINE (1)
typedef unsigned long int hp_timing_t;
@@ -22,9 +22,6 @@
#include <isa.h>
#if MINIMUM_ISA == 686 || MINIMUM_ISA == 8664
-/* We always assume having the timestamp register. */
-# define HP_TIMING_AVAIL (1)
-# define HP_SMALL_TIMING_AVAIL (1)
/* We indeed have inlined functions. */
# define HP_TIMING_INLINE (1)