Basic arm64 support.
authorLeif Lindholm <leif.lindholm@linaro.org>
Wed, 16 Oct 2013 13:16:00 +0000 (14:16 +0100)
committerJulien Cristau <jcristau@debian.org>
Fri, 14 Nov 2014 16:57:11 +0000 (16:57 +0000)
Gbp-Pq: Name basic-arm64-support.diff

opal/config/opal_config_asm.m4
opal/include/opal/sys/Makefile.am
opal/include/opal/sys/arm64/Makefile.am [new file with mode: 0644]
opal/include/opal/sys/arm64/atomic.h [new file with mode: 0644]
opal/include/opal/sys/arm64/timer.h [new file with mode: 0644]
opal/include/opal/sys/atomic.h
opal/include/opal/sys/timer.h

index 7198d1aff8a51096472f1dab06e2c7e9a5ab4cf3..08afb6e63c5d1c9cb3f4f9feee89b523a7ee4ae4 100644 (file)
@@ -900,6 +900,12 @@ AC_DEFUN([OMPI_CONFIG_ASM],[
             OMPI_GCC_INLINE_ASSIGN='"bis [$]31,[$]31,%0" : "=&r"(ret)'
             ;;
 
+        aarch64*)
+            ompi_cv_asm_arch="ARM64"
+            OPAL_ASM_SUPPORT_64BIT=1
+            OMPI_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
+            ;;
+
         armv7*|arm-*-linux-gnueabihf)
             ompi_cv_asm_arch="ARM"
             OPAL_ASM_SUPPORT_64BIT=1
index c99af202796bca93820203c3b51a7c201bc78289..cc0285f8ea5e2bd06ebaf272073e6648bbf22ec7 100644 (file)
@@ -28,6 +28,7 @@ headers += \
 include opal/sys/alpha/Makefile.am
 include opal/sys/amd64/Makefile.am
 include opal/sys/arm/Makefile.am
+include opal/sys/arm64/Makefile.am
 include opal/sys/ia32/Makefile.am
 include opal/sys/ia64/Makefile.am
 include opal/sys/mips/Makefile.am
diff --git a/opal/include/opal/sys/arm64/Makefile.am b/opal/include/opal/sys/arm64/Makefile.am
new file mode 100644 (file)
index 0000000..5cfbc8d
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
+#                         University Research and Technology
+#                         Corporation.  All rights reserved.
+# Copyright (c) 2004-2008 The University of Tennessee and The University
+#                         of Tennessee Research Foundation.  All rights
+#                         reserved.
+# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
+#                         University of Stuttgart.  All rights reserved.
+# Copyright (c) 2004-2005 The Regents of the University of California.
+#                         All rights reserved.
+# $COPYRIGHT$
+# 
+# Additional copyrights may follow
+# 
+# $HEADER$
+#
+
+# This makefile.am does not stand on its own - it is included from opal/include/Makefile.am
+
+headers += \
+       opal/sys/arm64/atomic.h \
+       opal/sys/arm64/timer.h
+
diff --git a/opal/include/opal/sys/arm64/atomic.h b/opal/include/opal/sys/arm64/atomic.h
new file mode 100644 (file)
index 0000000..ce24805
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
+ *                         University Research and Technology
+ *                         Corporation.  All rights reserved.
+ * Copyright (c) 2004-2005 The University of Tennessee and The University
+ *                         of Tennessee Research Foundation.  All rights
+ *                         reserved.
+ * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
+ *                         University of Stuttgart.  All rights reserved.
+ * Copyright (c) 2004-2005 The Regents of the University of California.
+ *                         All rights reserved.
+ * Copyright (c) 2010      IBM Corporation.  All rights reserved.
+ * Copyright (c) 2010      ARM ltd.  All rights reserved.
+ * Copyright (c) 2013      Linaro ltd.  All rights reserved.
+ * $COPYRIGHT$
+ *
+ * Additional copyrights may follow
+ *
+ * $HEADER$
+ */
+
+#ifndef OMPI_SYS_ARCH_ATOMIC_H
+#define OMPI_SYS_ARCH_ATOMIC_H 1
+
+#if OPAL_WANT_SMP_LOCKS
+
+#define OPAL_HAVE_ATOMIC_MEM_BARRIER 1
+
+#define MB()  __asm__ __volatile__ ("dmb ish" : : : "memory")
+#define RMB() __asm__ __volatile__ ("dmb ish" : : : "memory")
+#define WMB() __asm__ __volatile__ ("dmb ish" : : : "memory")
+
+#else
+
+#define MB()
+#define RMB()
+#define WMB()
+
+#endif /* OPAL_WANT_SMP_LOCKS */
+
+
+
+/**********************************************************************
+ *
+ * Memory Barriers
+ *
+ *********************************************************************/
+
+#if (OPAL_HAVE_ATOMIC_MEM_BARRIER == 1)
+
+static inline
+void opal_atomic_mb(void)
+{
+    MB();
+}
+
+
+static inline
+void opal_atomic_rmb(void)
+{
+    RMB();
+}
+
+
+static inline
+void opal_atomic_wmb(void)
+{
+    WMB();
+}
+
+#endif
+
+
+/**********************************************************************
+ *
+ * Atomic math operations
+ *
+ *********************************************************************/
+
+#define OPAL_HAVE_ATOMIC_CMPSET_32 1
+static inline int opal_atomic_cmpset_32(volatile int32_t *addr,
+                                        int32_t oldval, int32_t newval)
+{
+  int32_t ret;
+  int32_t tmp;
+
+   __asm__ __volatile__ (
+                         "1:  ldxr   %w0, [%2]        \n"
+                         "    cmp    %w0, %w3          \n"
+                         "    bne    2f              \n"
+                         "    stxr   %w1, %w4, [%2]    \n"
+                         "    cmp    %w1, #0          \n"
+                         "    bne    1b              \n"
+                         "2:                          \n"
+
+                         : "=&r" (ret), "=&r" (tmp)
+                         : "r" (addr), "r" (oldval), "r" (newval)
+                         : "cc", "memory");
+
+   return (ret == oldval);
+}
+
+static inline int opal_atomic_cmpset_acq_32(volatile int32_t *addr,
+                                            int32_t oldval, int32_t newval)
+{
+    int rc;
+
+    rc = opal_atomic_cmpset_32(addr, oldval, newval);
+    opal_atomic_rmb();
+
+    return rc;
+}
+
+
+static inline int opal_atomic_cmpset_rel_32(volatile int32_t *addr,
+                                            int32_t oldval, int32_t newval)
+{
+    opal_atomic_wmb();
+    return opal_atomic_cmpset_32(addr, oldval, newval);
+}
+
+#define OPAL_HAVE_ATOMIC_CMPSET_64 1
+static inline int opal_atomic_cmpset_64(volatile int64_t *addr,
+                                        int64_t oldval, int64_t newval)
+{
+  int64_t ret;
+  int32_t tmp;
+
+   __asm__ __volatile__ (
+                         "1:  ldxr   %0, [%2]        \n"
+                         "    cmp    %0, %3          \n"
+                         "    bne    2f              \n"
+                         "    stxr   %w1, %4, [%2]   \n"
+                         "    cmp    %w1, #0         \n"
+                         "    bne    1b              \n"
+                         "2:                         \n"
+
+                         : "=&r" (ret), "=&r" (tmp)
+                         : "r" (addr), "r" (oldval), "r" (newval)
+                         : "cc", "memory");
+
+   return (ret == oldval);
+}
+
+/* these two functions aren't inlined in the non-gcc case because then
+   there would be two function calls (since neither cmpset_64 nor
+   atomic_?mb can be inlined).  Instead, we "inline" them by hand in
+   the assembly, meaning there is one function call overhead instead
+   of two */
+static inline int opal_atomic_cmpset_acq_64(volatile int64_t *addr,
+                                            int64_t oldval, int64_t newval)
+{
+    int rc;
+
+    rc = opal_atomic_cmpset_64(addr, oldval, newval);
+    opal_atomic_rmb();
+
+    return rc;
+}
+
+
+static inline int opal_atomic_cmpset_rel_64(volatile int64_t *addr,
+                                            int64_t oldval, int64_t newval)
+{
+    opal_atomic_wmb();
+    return opal_atomic_cmpset_64(addr, oldval, newval);
+}
+
+#endif /* ! OMPI_SYS_ARCH_ATOMIC_H */
diff --git a/opal/include/opal/sys/arm64/timer.h b/opal/include/opal/sys/arm64/timer.h
new file mode 100644 (file)
index 0000000..961f131
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2008      The University of Tennessee and The University
+ *                         of Tennessee Research Foundation.  All rights
+ *                         reserved.
+ * $COPYRIGHT$
+ * 
+ * Additional copyrights may follow
+ * 
+ * $HEADER$
+ */
+
+#ifndef OMPI_SYS_ARCH_TIMER_H
+#define OMPI_SYS_ARCH_TIMER_H 1
+
+#include <sys/times.h>
+
+typedef uint64_t opal_timer_t;
+
+static inline opal_timer_t
+opal_sys_timer_get_cycles(void)
+{
+    opal_timer_t ret;
+    struct tms accurate_clock;
+
+    times(&accurate_clock);
+    ret = accurate_clock.tms_utime + accurate_clock.tms_stime;
+
+    return ret;
+}
+
+#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 1
+
+#endif /* ! OMPI_SYS_ARCH_TIMER_H */
index 4911f0c259b7f178a4d74520d28d6e11023efa14..aa995c2876c03670f4bcc6bbf97e29afaa5c44ce 100644 (file)
@@ -148,6 +148,8 @@ typedef struct opal_atomic_lock_t opal_atomic_lock_t;
 #include "opal/sys/amd64/atomic.h"
 #elif OPAL_ASSEMBLY_ARCH == OMPI_ARM
 #include "opal/sys/arm/atomic.h"
+#elif OPAL_ASSEMBLY_ARCH == OMPI_ARM64
+#include "opal/sys/arm64/atomic.h"
 #elif OPAL_ASSEMBLY_ARCH == OMPI_IA32
 #include "opal/sys/ia32/atomic.h"
 #elif OPAL_ASSEMBLY_ARCH == OMPI_IA64
index 967b951fbdff40a12029bd70bf3c65a4ebfa4888..ae1c3807f04955250649393db368a44663e14647 100644 (file)
@@ -81,6 +81,8 @@ BEGIN_C_DECLS
 #include "opal/sys/amd64/timer.h"
 #elif OPAL_ASSEMBLY_ARCH == OMPI_ARM
 #include "opal/sys/arm/timer.h"
+#elif OPAL_ASSEMBLY_ARCH == OMPI_ARM64
+#include "opal/sys/arm64/timer.h"
 #elif OPAL_ASSEMBLY_ARCH == OMPI_IA32
 #include "opal/sys/ia32/timer.h"
 #elif OPAL_ASSEMBLY_ARCH == OMPI_IA64