89 #if TIME_WITH_SYS_TIME 90 # include <sys/time.h> 94 # include <sys/time.h> 101 #define INLINE_ELAPSED(INL) static INL double elapsed(ticks t1, ticks t0) \ 103 return (double)t1 - (double)t0; \ 108 #if defined(WINDOWS) && !defined(HAVE_TICK_COUNTER) 110 typedef __int64 ticks;
112 static __inline ticks
115 LARGE_INTEGER retval;
116 QueryPerformanceCounter (&retval);
117 return retval.QuadPart;
120 static __inline
double 121 elapsed (ticks t1, ticks t0)
123 return (
double) t1 - (double) t0;
126 #define HAVE_TICK_COUNTER 132 #if defined(HAVE_GETHRTIME) && defined(HAVE_HRTIME_T) && !defined(HAVE_TICK_COUNTER) 133 typedef hrtime_t ticks;
135 #define getticks gethrtime 138 #define HAVE_TICK_COUNTER 142 #if defined(HAVE_READ_REAL_TIME) && defined(HAVE_TIME_BASE_TO_TIME) && !defined(HAVE_TICK_COUNTER) 143 typedef timebasestruct_t ticks;
145 static __inline ticks getticks (
void)
148 read_real_time (&t, TIMEBASE_SZ);
152 static __inline
double 153 elapsed (ticks t1, ticks t0)
155 time_base_to_time (&t1, TIMEBASE_SZ);
156 time_base_to_time (&t0, TIMEBASE_SZ);
157 return (((
double) t1.tb_high - (
double) t0.tb_high) * 1.0e9 + ((
double) t1.tb_low - (
double) t0.tb_low));
160 #define HAVE_TICK_COUNTER 167 #if ((((defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))) || (defined(__MWERKS__) && defined(macintosh)))) || (defined(__IBM_GCC_ASM) && (defined(__powerpc__) || defined(__ppc__)))) && !defined(HAVE_TICK_COUNTER) 168 typedef unsigned long long ticks;
170 static __inline__ ticks
173 unsigned int tbl, tbu0, tbu1;
177 __asm__ __volatile__ (
"mftbu %0":
"=r" (tbu0));
178 __asm__ __volatile__ (
"mftb %0":
"=r" (tbl));
179 __asm__ __volatile__ (
"mftbu %0":
"=r" (tbu1));
181 while (tbu0 != tbu1);
183 return (((
unsigned long long) tbu0) << 32) | tbl;
187 #define HAVE_TICK_COUNTER 191 #if defined(HAVE_MACH_ABSOLUTE_TIME) && defined(HAVE_MACH_MACH_TIME_H) && !defined(HAVE_TICK_COUNTER) 192 #include <mach/mach_time.h> 193 typedef uint64_t ticks;
194 #define getticks mach_absolute_time 196 #define HAVE_TICK_COUNTER 202 #if (defined(__GNUC__) || defined(__ICC)) && defined(__i386__) && !defined(HAVE_TICK_COUNTER) 203 typedef unsigned long long ticks;
205 static __inline__ ticks getticks (
void)
209 __asm__ __volatile__ (
"rdtsc":
"=A" (ret));
215 #define HAVE_TICK_COUNTER 216 #define TIME_MIN 5000.0 219 #if _MSC_VER >= 1200 && _M_IX86 >= 500 && !defined(HAVE_TICK_COUNTER) 221 typedef LARGE_INTEGER ticks;
222 #define RDTSC __asm __emit 0fh __asm __emit 031h 224 static __inline ticks getticks (
void)
230 RDTSC mov retval.HighPart, edx mov retval.LowPart, eax}
234 static __inline
double 235 elapsed (ticks t1, ticks t0)
237 return (
double) t1.QuadPart - (double) t0.QuadPart;
240 #define HAVE_TICK_COUNTER 241 #define TIME_MIN 5000.0 248 #if (defined(__GNUC__) || defined(__ICC) || defined(__SUNPRO_C)) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER) 249 typedef unsigned long long ticks;
251 static __inline__ ticks
255 asm volatile (
"rdtsc":
"=a" (a),
"=d" (d));
256 return ((ticks) a) | (((ticks) d) << 32);
260 #define HAVE_TICK_COUNTER 265 #if defined(__PGI) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER) 266 typedef unsigned long long ticks;
267 static ticks getticks (
void)
269 asm (
" rdtsc; shl $0x20,%rdx; mov %eax,%eax; or %rdx,%rax; ");
273 #define HAVE_TICK_COUNTER 276 #if _MSC_VER >= 1400 && (defined(_M_AMD64) || defined(_M_X64)) && !defined(HAVE_TICK_COUNTER) 278 #pragma intrinsic(__rdtsc) 279 typedef unsigned __int64 ticks;
280 #define getticks __rdtsc 282 #define HAVE_TICK_COUNTER 289 #if (defined(__EDG_VERSION) || defined(__ECC)) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER) 290 typedef unsigned long ticks;
291 #include <ia64intrin.h> 293 static __inline__ ticks getticks (
void)
295 return __getReg (_IA64_REG_AR_ITC);
299 #define HAVE_TICK_COUNTER 302 #if defined(__GNUC__) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER) 303 typedef unsigned long ticks;
305 static __inline__ ticks getticks (
void)
309 __asm__ __volatile__ (
"mov %0=ar.itc":
"=r" (ret));
314 #define HAVE_TICK_COUNTER 317 #if defined(__hpux) && defined(__ia64) && !defined(HAVE_TICK_COUNTER) 318 #include <machine/sys/inline.h> 319 typedef unsigned long ticks;
321 static inline ticks getticks (
void)
325 ret = _Asm_mov_from_ar (_AREG_ITC);
330 #define HAVE_TICK_COUNTER 333 #if defined(_MSC_VER) && defined(_M_IA64) && !defined(HAVE_TICK_COUNTER) 334 typedef unsigned __int64 ticks;
339 ticks __getReg (
int whichReg);
340 #pragma intrinsic(__getReg) 342 static __inline ticks getticks (
void)
345 temp = __getReg (3116);
350 #define HAVE_TICK_COUNTER 356 #if defined(__hppa__) || defined(__hppa) && !defined(HAVE_TICK_COUNTER) 357 typedef unsigned long ticks;
360 static __inline__ ticks getticks (
void)
364 __asm__ __volatile__ (
"mfctl 16, %0":
"=r" (ret));
369 # include <machine/inline.h> 370 static inline unsigned long getticks (
void)
379 #define HAVE_TICK_COUNTER 383 #if defined(__GNUC__) && defined(__s390__) && !defined(HAVE_TICK_COUNTER) 384 typedef unsigned long long ticks;
386 static __inline__ ticks getticks (
void)
389 __asm__ (
"stck 0(%0)": :
"a" (&(cycles)):
"memory",
"cc");
394 #define HAVE_TICK_COUNTER 397 #if defined(__GNUC__) && defined(__alpha__) && !defined(HAVE_TICK_COUNTER) 402 typedef unsigned int ticks;
404 static __inline__ ticks getticks (
void)
407 __asm__ __volatile__ (
"rpcc %0":
"=r" (cc));
408 return (cc & 0xFFFFFFFF);
412 #define HAVE_TICK_COUNTER 415 #if defined(__GNUC__) && defined(__sparc_v9__) && !defined(HAVE_TICK_COUNTER) 416 typedef unsigned long ticks;
418 static __inline__ ticks getticks (
void)
421 __asm__ __volatile__ (
"rd %%tick, %0":
"=r" (ret));
426 #define HAVE_TICK_COUNTER 429 #if (defined(__DECC) || defined(__DECCXX)) && defined(__alpha) && defined(HAVE_C_ASM_H) && !defined(HAVE_TICK_COUNTER) 431 typedef unsigned int ticks;
433 static __inline ticks getticks (
void)
436 cc =
asm (
"rpcc %v0");
437 return (cc & 0xFFFFFFFF);
441 #define HAVE_TICK_COUNTER 445 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER) 446 typedef struct timespec ticks;
448 static inline ticks getticks (
void)
451 clock_gettime (CLOCK_SGI_CYCLE, &t);
456 elapsed (ticks t1, ticks t0)
458 return ((
double) t1.tv_sec - (
double) t0.tv_sec) * 1.0E9 + ((double) t1.tv_nsec - (
double) t0.tv_nsec);
461 #define HAVE_TICK_COUNTER 466 #if defined(HAVE__RTC) && !defined(HAVE_TICK_COUNTER) 467 #ifdef HAVE_INTRINSICS_H 468 # include <intrinsics.h> 471 typedef long long ticks;
473 #define getticks _rtc 476 #define HAVE_TICK_COUNTER 480 #if HAVE_MIPS_ZBUS_TIMER 481 #if defined(__mips__) && !defined(HAVE_TICK_COUNTER) 482 #include <sys/mman.h> 485 typedef uint64_t ticks;
487 static inline ticks getticks (
void)
489 static uint64_t *addr = 0;
493 uint32_t rq_addr = 0x10030000;
497 pgsize = getpagesize ();
498 fd = open (
"/dev/mem", O_RDONLY | O_SYNC, 0);
504 addr = mmap (0, pgsize, PROT_READ, MAP_SHARED, fd, rq_addr);
506 if (addr == (uint64_t *) - 1)
517 #define HAVE_TICK_COUNTER #define INLINE_ELAPSED(INL)