Selaa lähdekoodia

use clock_gettime just when it is available

Samuel Thibault 15 vuotta sitten
vanhempi
commit
2ef2a414ce
3 muutettua tiedostoa jossa 8 lisäystä ja 14 poistoa
  1. 2 8
      configure.ac
  2. 3 3
      src/common/timing.c
  3. 3 3
      src/common/timing.h

+ 2 - 8
configure.ac

@@ -448,14 +448,8 @@ AC_MSG_CHECKING(performance models location)
 AC_MSG_RESULT($perf_model_dir)
 
 # On many multicore CPUs, clock cycles are not synchronized
-AC_ARG_ENABLE(sync-clock, [AS_HELP_STRING([--disable-sync-clock], [Do not use monotonic clocks])],
-		enable_sync_clock=$enableval, enable_sync_clock=yes)
-AC_MSG_CHECKING(whether using a synchronous clock)
-AC_MSG_RESULT($enable_sync_clock)
-if test x$enable_sync_clock = xyes; then
-	AC_DEFINE(USE_SYNC_CLOCK, [1], [Use a mononotic clock])
-	AC_CHECK_LIB(rt, clock_gettime,,AC_MSG_ERROR([cannot find clock_gettime]))
-fi
+AC_CHECK_LIB([rt], [clock_gettime])
+AC_CHECK_FUNCS([clock_gettime])
 
 ###############################################################################
 #                                                                             #

+ 3 - 3
src/common/timing.c

@@ -16,7 +16,7 @@
 
 #include "timing.h"
 
-#ifdef USE_SYNC_CLOCK
+#ifdef HAVE_CLOCK_GETTIME
 
 #define TICK_DIFF(t1, t2) ((long long)((t2).ts.tv_sec*1e9 + (t2).ts.tv_nsec) + \
 				- (long long)((t1).ts.tv_sec*1e9) + (long long)(t1).ts.tv_nsec)
@@ -52,7 +52,7 @@ inline double timing_now(void)
 
 
 
-#else // USE_SYNC_CLOCK
+#else // HAVE_CLOCK_GETTIME
 
 #define TICK_RAW_DIFF(t1, t2) ((t2).tick - (t1).tick)
 #define TICK_DIFF(t1, t2) (TICK_RAW_DIFF(t1, t2) - residual)
@@ -113,4 +113,4 @@ inline double timing_now(void)
 	return _starpu_tick2usec(tick_now.tick);
 }
 
-#endif // USE_SYNC_CLOCK
+#endif // HAVE_CLOCK_GETTIME

+ 3 - 3
src/common/timing.h

@@ -32,7 +32,7 @@
 #include <common/config.h>
 #include <starpu.h>
 
-#ifdef USE_SYNC_CLOCK
+#ifdef HAVE_CLOCK_GETTIME
 #include <time.h>
 #ifndef _POSIX_C_SOURCE
 /* for clock_gettime */
@@ -46,7 +46,7 @@ typedef struct tick_s
 } tick_t;
 #define GET_TICK(t) clock_gettime(CLOCK_MONOTONIC, &((t).ts))
 
-#else // !USE_SYNC_CLOCK
+#else // !HAVE_CLOCK_GETTIME
 
 typedef union u_tick
 {
@@ -69,7 +69,7 @@ typedef union u_tick
 #  define GET_TICK(t) do {} while(0);
 #endif
 
-#endif // USE_SYNC_CLOCK
+#endif // HAVE_CLOCK_GETTIME
 
 void __attribute__ ((unused)) timing_init(void);
 inline double __attribute__ ((unused)) _starpu_tick2usec(long long t);