Code beautification with uncrustify
[alexxy/gromacs.git] / src / gromacs / legacyheaders / thread_mpi / atomic / cycles.h
1 /*
2  * define HAVE_RDTSCP to use the serializing rdtscp instruction instead of rdtsc.
3  * This is only supported on newer Intel/AMD hardware, but provides better accuracy.
4  */
5
6 /* check for cycle counters on supported platforms */
7 #if ((defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__)  || defined(__PGIC__)) && (defined(__i386__) || defined(__x86_64__)))
8 #define TMPI_CYCLE_COUNT
9 /* x86 or x86-64 with GCC inline assembly */
10 typedef unsigned long long tmpi_cycles_t;
11
12 static __inline__ tmpi_cycles_t tmpi_cycles_read(void)
13 {
14     /* x86 with GCC inline assembly - pentium TSC register */
15     tmpi_cycles_t   cycle;
16     unsigned        low, high;
17
18 #ifdef HAVE_RDTSCP
19     __asm__ __volatile__("rdtscp" : "=a" (low), "=d" (high) :: "ecx" );
20 #else
21     __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high));
22 #endif
23
24     cycle = ((unsigned long long)low) | (((unsigned long long)high)<<32);
25
26     return cycle;
27 }
28 #elif (defined(__INTEL_COMPILER) && defined(__ia64__))
29 #define TMPI_CYCLE_COUNT
30 typedef unsigned long tmpi_cycles_t;
31 static __inline__ tmpi_cycles_t tmpi_cycles_read(void)
32 {
33     /* Intel compiler on ia64 */
34     return __getReg(_IA64_REG_AR_ITC);
35 }
36 #elif defined(__GNUC__) && defined(__ia64__)
37 #define TMPI_CYCLE_COUNT
38 typedef unsigned long tmpi_cycles_t;
39 static __inline__ tmpi_cycles_t tmpi_cycles_read(void)
40 {
41     /* ia64 with GCC inline assembly */
42     tmpi_cycles_t ret;
43     __asm__ __volatile__ ("mov %0=ar.itc" : "=r" (ret));
44     return ret;
45 }
46 #elif defined(_MSC_VER)
47 #define TMPI_CYCLE_COUNT
48 typedef __int64 tmpi_cycles_t;
49 static __inline tmpi_cycles_t tmpi_cycles_read(void)
50 {
51 #ifdef HAVE_RDTSCP
52     unsigned int ui;
53     return __rdtscp(&ui);
54 #else
55     return __rdtsc();
56 #endif
57 }
58 #endif