92#define INLINE_ELAPSED(INL) static INL double elapsed(ticks t1, ticks t0) \
94 return (double)t1 - (double)t0; \
99#if defined(HAVE_GETHRTIME) && defined(HAVE_HRTIME_T) && !defined(HAVE_TICK_COUNTER)
100typedef hrtime_t ticks;
102#define getticks gethrtime
106#define HAVE_TICK_COUNTER
111#if defined(HAVE_READ_REAL_TIME) && defined(HAVE_TIME_BASE_TO_TIME) && !defined(HAVE_TICK_COUNTER)
112typedef timebasestruct_t ticks;
114static __inline ticks getticks(
void)
117 read_real_time(&t, TIMEBASE_SZ);
121static __inline
double elapsed(ticks t1, ticks t0)
123 time_base_to_time(&t1, TIMEBASE_SZ);
124 time_base_to_time(&t0, TIMEBASE_SZ);
125 return (((
double)t1.tb_high - (
double)t0.tb_high) * 1.0e9 +
126 ((
double)t1.tb_low - (
double)t0.tb_low));
129#define HAVE_TICK_COUNTER
136#if ((((defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))) || (defined(__MWERKS__) && defined(macintosh)))) || (defined(__IBM_GCC_ASM) && (defined(__powerpc__) || defined(__ppc__)))) && !defined(HAVE_TICK_COUNTER)
137typedef unsigned long long ticks;
139static __inline__ ticks getticks(
void)
141 unsigned int tbl, tbu0, tbu1;
144 __asm__ __volatile__ (
"mftbu %0" :
"=r"(tbu0));
145 __asm__ __volatile__ (
"mftb %0" :
"=r"(tbl));
146 __asm__ __volatile__ (
"mftbu %0" :
"=r"(tbu1));
147 }
while (tbu0 != tbu1);
149 return (((
unsigned long long)tbu0) << 32) | tbl;
154#define HAVE_TICK_COUNTER
159#if defined(HAVE_MACH_ABSOLUTE_TIME) && defined(HAVE_MACH_MACH_TIME_H) && !defined(HAVE_TICK_COUNTER)
160#include <mach/mach_time.h>
161typedef uint64_t ticks;
162#define getticks mach_absolute_time
164#define HAVE_TICK_COUNTER
171#if (defined(__GNUC__) || defined(__ICC)) && defined(__i386__) && !defined(HAVE_TICK_COUNTER)
172typedef unsigned long long ticks;
174static __inline__ ticks getticks(
void)
178 __asm__ __volatile__(
"rdtsc":
"=A" (ret));
185#define HAVE_TICK_COUNTER
186#define TIME_MIN 5000.0
190#if _MSC_VER >= 1200 && _M_IX86 >= 500 && !defined(HAVE_TICK_COUNTER)
192typedef LARGE_INTEGER ticks;
193#define RDTSC __asm __emit 0fh __asm __emit 031h
195static __inline ticks getticks(
void)
201 mov retval.HighPart, edx
202 mov retval.LowPart, eax
207static __inline
double elapsed(ticks t1, ticks t0)
209 return (
double)t1.QuadPart - (double)t0.QuadPart;
212#define HAVE_TICK_COUNTER
213#define TIME_MIN 5000.0
220#if (defined(__GNUC__) || defined(__ICC) || defined(__SUNPRO_C)) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER)
221typedef unsigned long long ticks;
223static __inline__ ticks getticks(
void)
226 asm volatile(
"rdtsc" :
"=a" (
a),
"=d" (d));
227 return ((ticks)
a) | (((ticks)d) << 32);
232#define HAVE_TICK_COUNTER
238#if defined(__PGI) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER)
239typedef unsigned long long ticks;
240static ticks getticks(
void)
242 asm(
" rdtsc; shl $0x20,%rdx; mov %eax,%eax; or %rdx,%rax; ");
245#define HAVE_TICK_COUNTER
249#if _MSC_VER >= 1400 && (defined(_M_AMD64) || defined(_M_X64)) && !defined(HAVE_TICK_COUNTER)
252#pragma intrinsic(__rdtsc)
253typedef unsigned __int64 ticks;
254#define getticks __rdtsc
257#define HAVE_TICK_COUNTER
266#if (defined(__EDG_VERSION) || defined(__ECC)) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER)
267typedef unsigned long ticks;
268#include <ia64intrin.h>
270static __inline__ ticks getticks(
void)
272 return __getReg(_IA64_REG_AR_ITC);
277#define HAVE_TICK_COUNTER
281#if defined(__GNUC__) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER)
282typedef unsigned long ticks;
284static __inline__ ticks getticks(
void)
288 __asm__ __volatile__ (
"mov %0=ar.itc" :
"=r"(ret));
294#define HAVE_TICK_COUNTER
298#if defined(__hpux) && defined(__ia64) && !defined(HAVE_TICK_COUNTER)
299#include <machine/sys/inline.h>
300typedef unsigned long ticks;
302static inline ticks getticks(
void)
306 ret = _Asm_mov_from_ar (_AREG_ITC);
312#define HAVE_TICK_COUNTER
316#if defined(_MSC_VER) && defined(_M_IA64) && !defined(HAVE_TICK_COUNTER)
317typedef unsigned __int64 ticks;
322ticks __getReg(
int whichReg);
323#pragma intrinsic(__getReg)
325static __inline ticks getticks(
void)
328 temp = __getReg(3116);
334#define HAVE_TICK_COUNTER
341#if defined(__hppa__) || defined(__hppa) && !defined(HAVE_TICK_COUNTER)
342typedef unsigned long ticks;
345static __inline__ ticks getticks(
void)
349 __asm__ __volatile__(
"mfctl 16, %0":
"=r" (ret));
354# include <machine/inline.h>
355static inline unsigned long getticks(
void)
365#define HAVE_TICK_COUNTER
370#if defined(__GNUC__) && defined(__s390__) && !defined(HAVE_TICK_COUNTER)
371typedef unsigned long long ticks;
373static __inline__ ticks getticks(
void)
376 __asm__(
"stck 0(%0)" : :
"a" (&(cycles)) :
"memory",
"cc");
382#define HAVE_TICK_COUNTER
385#if defined(__GNUC__) && defined(__alpha__) && !defined(HAVE_TICK_COUNTER)
390typedef unsigned int ticks;
392static __inline__ ticks getticks(
void)
395 __asm__ __volatile__ (
"rpcc %0" :
"=r"(cc));
396 return (cc & 0xFFFFFFFF);
401#define HAVE_TICK_COUNTER
405#if defined(__GNUC__) && defined(__sparc_v9__) && !defined(HAVE_TICK_COUNTER)
406typedef unsigned long ticks;
408static __inline__ ticks getticks(
void)
411 __asm__ __volatile__(
"rd %%tick, %0" :
"=r" (ret));
417#define HAVE_TICK_COUNTER
421#if (defined(__DECC) || defined(__DECCXX)) && defined(__alpha) && defined(HAVE_C_ASM_H) && !defined(HAVE_TICK_COUNTER)
423typedef unsigned int ticks;
425static __inline ticks getticks(
void)
428 cc =
asm(
"rpcc %v0");
429 return (cc & 0xFFFFFFFF);
434#define HAVE_TICK_COUNTER
438#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER)
439typedef struct timespec ticks;
441static inline ticks getticks(
void)
444 clock_gettime(CLOCK_SGI_CYCLE, &t);
448static inline double elapsed(ticks t1, ticks t0)
450 return ((
double)t1.tv_sec - (
double)t0.tv_sec) * 1.0E9 +
451 ((double)t1.tv_nsec - (double)t0.tv_nsec);
453#define HAVE_TICK_COUNTER
458#if defined(HAVE__RTC) && !defined(HAVE_TICK_COUNTER)
459#ifdef HAVE_INTRINSICS_H
460# include <intrinsics.h>
463typedef long long ticks;
469#define HAVE_TICK_COUNTER
474#if HAVE_MIPS_ZBUS_TIMER
475#if defined(__mips__) && !defined(HAVE_TICK_COUNTER)
480typedef uint64_t ticks;
482static inline ticks getticks(
void)
484 static uint64_t* addr = 0;
488 uint32_t rq_addr = 0x10030000;
492 pgsize = getpagesize();
493 fd = open (
"/dev/mem", O_RDONLY | O_SYNC, 0);
498 addr = mmap(0, pgsize, PROT_READ, MAP_SHARED, fd, rq_addr);
500 if (addr == (uint64_t *)-1) {
511#define HAVE_TICK_COUNTER
#define INLINE_ELAPSED(INL)