瀏覽代碼

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 年之前
父節點
當前提交
e211a14276
共有 1 個文件被更改,包括 9 次插入0 次删除
  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;
 } 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))
+#endif
 
 #else // !STARPU_HAVE_CLOCK_GETTIME