Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / timing / cyclecounter.h
index 87d19b19a1c3865653b314e789343fd9d810af41..4b3bede73610ad1a63a82d059f4bd4fa1f7956cd 100644 (file)
@@ -49,9 +49,7 @@
  * define HAVE_RDTSCP to use the serializing rdtscp instruction instead of rdtsc.
  * This is only supported on newer Intel/AMD hardware, but provides better accuracy.
  */
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #ifdef _MSC_VER
 #include <intrin.h>
@@ -79,6 +77,11 @@ extern "C"
 typedef unsigned long long
     gmx_cycles_t;
 
+#elif ((defined __aarch64__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)))
+/* 64-bit ARM cycle counters with GCC inline assembly */
+typedef unsigned long long
+    gmx_cycles_t;
+
 #elif defined(_MSC_VER)
 #include <windows.h>
 typedef __int64
@@ -145,8 +148,8 @@ typedef hrtime_t
 
 #elif defined(__xlC__) && defined (_AIX)
 /* AIX compilers */
-#include <sys/time.h>
 #include <sys/systemcfg.h>
+#include <sys/time.h>
 typedef unsigned long long
     gmx_cycles_t;
 
@@ -210,6 +213,12 @@ static __inline__ int gmx_cycles_have_counter(void)
     /* x86 or x86-64 with GCC inline assembly - pentium TSC register */
     return 1;
 }
+#elif ((defined __aarch64__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)))
+static __inline int gmx_cycles_have_counter(void)
+{
+    /* 64-bit ARM cycle counters with GCC inline assembly */
+    return 1;
+}
 #elif (defined(_MSC_VER))
 static __inline int gmx_cycles_have_counter(void)
 {
@@ -350,14 +359,30 @@ static __inline__ gmx_cycles_t gmx_cycles_read(void)
 
     return cycle;
 }
+#elif ((defined __aarch64__) && (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__PATHSCALE__) || defined(__PGIC__)))
+static __inline__ gmx_cycles_t gmx_cycles_read(void)
+{
+    /* 64-bit ARM cycle counters with GCC inline assembly */
+    gmx_cycles_t   cycle;
+    __asm__ __volatile__("mrs %0, cntvct_el0" : "=r" (cycle) );
+
+    return cycle;
+}
+
 #elif defined(_MSC_VER)
 static __inline gmx_cycles_t gmx_cycles_read(void)
 {
-#ifdef HAVE_RDTSCP
+#ifdef _M_ARM
+    /* Windows on 64-bit ARM */
+    return __rdpmccntr64();
+#else
+    /* x86 */
+#    ifdef HAVE_RDTSCP
     unsigned int ui;
     return __rdtscp(&ui);
-#else
+#    else
     return __rdtsc();
+#    endif
 #endif
 }
 #elif (defined(__hpux) || defined(__HP_cc)) && defined(__ia64)