Browse Source

The CLOCK_MONOTONIC_RAW clock is not subject to NTP adjustments, but is not
available on all systems. In that case we use the CLOCK_MONOTONIC clock
instead.

Cédric Augonnet 15 years ago
parent
commit
e211a14276
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/common/timing.h

+ 9 - 0
src/common/timing.h

@@ -44,7 +44,16 @@ typedef struct starpu_tick_s
 {
 {
 	struct timespec ts;
 	struct timespec ts;
 } starpu_tick_t;
 } starpu_tick_t;
+
+/* Modern CPUs' clocks are usually not synchronized so we use a monotonic clock
+ * to have consistent timing measurements. The CLOCK_MONOTONIC_RAW clock is not
+ * subject to NTP adjustments, but is not available on all systems (in that
+ * case we use the CLOCK_MONOTONIC clock instead). */
+#ifndef CLOCK_MONOTONIC_RAW
+#define STARPU_GET_TICK(t) clock_gettime(CLOCK_MONOTONIC_RAW, &((t).ts))
+#else
 #define STARPU_GET_TICK(t) clock_gettime(CLOCK_MONOTONIC, &((t).ts))
 #define STARPU_GET_TICK(t) clock_gettime(CLOCK_MONOTONIC, &((t).ts))
+#endif
 
 
 #else // !STARPU_HAVE_CLOCK_GETTIME
 #else // !STARPU_HAVE_CLOCK_GETTIME