|
|
322933 |
From 351e63eeb4123aa2d2dc13a01912968ad1365fa1 Mon Sep 17 00:00:00 2001
|
|
|
322933 |
From: Brian Barrett <brbarret@open-mpi-git-mirror.example.com>
|
|
|
322933 |
Date: Wed, 23 Nov 2011 04:25:41 +0000
|
|
|
322933 |
Subject: [PATCH] Add (optional/last ditch effort) support for GCC/Intel
|
|
|
322933 |
__sync_ builtin atomic operations. Much easier than adding support for a new
|
|
|
322933 |
architecture.
|
|
|
322933 |
|
|
|
322933 |
---
|
|
|
322933 |
LICENSE | 2 +-
|
|
|
322933 |
opal/config/opal_config_asm.m4 | 38 +++++++-
|
|
|
322933 |
opal/include/opal/sys/Makefile.am | 2 +
|
|
|
322933 |
opal/include/opal/sys/architecture.h | 2 +
|
|
|
322933 |
opal/include/opal/sys/atomic.h | 9 ++
|
|
|
322933 |
opal/include/opal/sys/sync_builtin/Makefile.am | 24 +++++
|
|
|
322933 |
opal/include/opal/sys/sync_builtin/atomic.h | 116 +++++++++++++++++++++++++
|
|
|
322933 |
opal/include/opal/sys/sync_builtin/timer.h | 27 ++++++
|
|
|
322933 |
8 files changed, 217 insertions(+), 3 deletions(-)
|
|
|
322933 |
create mode 100644 opal/include/opal/sys/sync_builtin/Makefile.am
|
|
|
322933 |
create mode 100644 opal/include/opal/sys/sync_builtin/atomic.h
|
|
|
322933 |
create mode 100644 opal/include/opal/sys/sync_builtin/timer.h
|
|
|
322933 |
|
|
|
322933 |
diff --git a/LICENSE b/LICENSE
|
|
|
322933 |
index d6424ab..0712868 100644
|
|
|
322933 |
--- a/LICENSE
|
|
|
322933 |
+++ b/LICENSE
|
|
|
322933 |
@@ -19,7 +19,7 @@ Copyright (c) 2006-2010 Los Alamos National Security, LLC. All rights
|
|
|
322933 |
reserved.
|
|
|
322933 |
Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved.
|
|
|
322933 |
Copyright (c) 2006-2010 Voltaire, Inc. All rights reserved.
|
|
|
322933 |
-Copyright (c) 2006-2010 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
+Copyright (c) 2006-2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
Copyright (c) 2006-2010 Sun Microsystems, Inc. All rights reserved.
|
|
|
322933 |
Use is subject to license terms.
|
|
|
322933 |
Copyright (c) 2006-2010 The University of Houston. All rights reserved.
|
|
|
322933 |
diff --git a/opal/config/opal_config_asm.m4 b/opal/config/opal_config_asm.m4
|
|
|
322933 |
index fc7fdcd..591f4c3 100644
|
|
|
322933 |
--- a/opal/config/opal_config_asm.m4
|
|
|
322933 |
+++ b/opal/config/opal_config_asm.m4
|
|
|
322933 |
@@ -19,6 +19,17 @@ dnl $HEADER$
|
|
|
322933 |
dnl
|
|
|
322933 |
|
|
|
322933 |
|
|
|
322933 |
+AC_DEFUN([OPAL_CHECK_SYNC_BUILTINS], [
|
|
|
322933 |
+ AC_MSG_CHECKING([for __sync builtin atomics])
|
|
|
322933 |
+
|
|
|
322933 |
+ AC_TRY_COMPILE([], [__sync_synchronize()],
|
|
|
322933 |
+ [AC_MSG_RESULT([yes])
|
|
|
322933 |
+ $1],
|
|
|
322933 |
+ [AC_MSG_RESULT([no])
|
|
|
322933 |
+ $2])
|
|
|
322933 |
+])
|
|
|
322933 |
+
|
|
|
322933 |
+
|
|
|
322933 |
dnl #################################################################
|
|
|
322933 |
dnl
|
|
|
322933 |
dnl OMPI_CHECK_ASM_TEXT
|
|
|
322933 |
@@ -841,8 +852,21 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
|
|
|
322933 |
AC_DEFINE_UNQUOTED([OPAL_WANT_SMP_LOCKS], [$want_smp_locks],
|
|
|
322933 |
[whether we want to have smp locks in atomic ops or not])
|
|
|
322933 |
|
|
|
322933 |
+ AC_ARG_ENABLE([builtin-atomics],
|
|
|
322933 |
+ [AC_HELP_STRING([--enable-builtin-atomics],
|
|
|
322933 |
+ [Enable use of __sync builtin atomics (default: disabled)])])
|
|
|
322933 |
+
|
|
|
322933 |
if test "$ompi_cv_c_compiler_vendor" = "microsoft" ; then
|
|
|
322933 |
ompi_cv_asm_arch="WINDOWS"
|
|
|
322933 |
+ elif test "$enable_builtin_atomics" = "yes" ; then
|
|
|
322933 |
+ OPAL_CHECK_SYNC_BUILTINS([ompi_cv_asm_arch="SYNC_BUILTIN"],
|
|
|
322933 |
+ [AC_MSG_ERROR([__sync builtin atomics requested but not found.])])
|
|
|
322933 |
+ AC_DEFINE([OPAL_C_GCC_INLINE_ASSEMBLY], [1],
|
|
|
322933 |
+ [Whether C compiler supports GCC style inline assembly])
|
|
|
322933 |
+ m4_ifdef([project_ompi],
|
|
|
322933 |
+ [AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
|
|
|
322933 |
+ [AC_DEFINE([OMPI_CXX_GCC_INLINE_ASSEMBLY], [1],
|
|
|
322933 |
+ [Whether C++ compiler supports GCC style inline assembly])])])
|
|
|
322933 |
else
|
|
|
322933 |
OMPI_CHECK_ASM_PROC
|
|
|
322933 |
OMPI_CHECK_ASM_TEXT
|
|
|
322933 |
@@ -946,10 +970,19 @@ AC_MSG_ERROR([Can not continue.])
|
|
|
322933 |
;;
|
|
|
322933 |
|
|
|
322933 |
*)
|
|
|
322933 |
- AC_MSG_ERROR([No atomic primitives available for $host])
|
|
|
322933 |
+ OPAL_CHECK_SYNC_BUILTINS([ompi_cv_asm_arch="SYNC_BUILTIN"],
|
|
|
322933 |
+ [AC_MSG_ERROR([No atomic primitives available for $host])])
|
|
|
322933 |
;;
|
|
|
322933 |
esac
|
|
|
322933 |
|
|
|
322933 |
+ if test "$ompi_cv_asm_arch" = "SYNC_BUILTIN" ; then
|
|
|
322933 |
+ AC_DEFINE([OPAL_C_GCC_INLINE_ASSEMBLY], [1],
|
|
|
322933 |
+ [Whether C compiler supports GCC style inline assembly])
|
|
|
322933 |
+ m4_ifdef([project_ompi],
|
|
|
322933 |
+ [AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
|
|
|
322933 |
+ [AC_DEFINE([OMPI_CXX_GCC_INLINE_ASSEMBLY], [1],
|
|
|
322933 |
+ [Whether C++ compiler supports GCC style inline assembly])])])
|
|
|
322933 |
+ else
|
|
|
322933 |
AC_DEFINE_UNQUOTED([OPAL_ASM_SUPPORT_64BIT],
|
|
|
322933 |
[$OPAL_ASM_SUPPORT_64BIT],
|
|
|
322933 |
[Whether we can do 64bit assembly operations or not. Should not be used outside of the assembly header files])
|
|
|
322933 |
@@ -1004,6 +1037,7 @@ AC_MSG_ERROR([Can not continue.])
|
|
|
322933 |
AC_DEFINE_UNQUOTED([OPAL_ASSEMBLY_FORMAT], ["$OPAL_ASSEMBLY_FORMAT"],
|
|
|
322933 |
[Format of assembly file])
|
|
|
322933 |
AC_SUBST([OPAL_ASSEMBLY_FORMAT])
|
|
|
322933 |
+ fi # if ompi_cv_asm_arch = SYNC_BUILTIN
|
|
|
322933 |
fi # if cv_c_compiler_vendor = microsoft
|
|
|
322933 |
|
|
|
322933 |
result="OMPI_$ompi_cv_asm_arch"
|
|
|
322933 |
@@ -1032,7 +1066,7 @@ AC_DEFUN([OMPI_ASM_FIND_FILE], [
|
|
|
322933 |
AC_REQUIRE([AC_PROG_GREP])
|
|
|
322933 |
AC_REQUIRE([AC_PROG_FGREP])
|
|
|
322933 |
|
|
|
322933 |
-if test "$ompi_cv_asm_arch" != "WINDOWS" ; then
|
|
|
322933 |
+if test "$ompi_cv_asm_arch" != "WINDOWS" -a "$ompi_cv_asm_arch" != "SYNC_BUILTIN" ; then
|
|
|
322933 |
AC_CHECK_PROG([PERL], [perl], [perl])
|
|
|
322933 |
|
|
|
322933 |
# see if we have a pre-built one already
|
|
|
322933 |
diff --git a/opal/include/opal/sys/Makefile.am b/opal/include/opal/sys/Makefile.am
|
|
|
322933 |
index 0917c7d..6c411c5 100644
|
|
|
322933 |
--- a/opal/include/opal/sys/Makefile.am
|
|
|
322933 |
+++ b/opal/include/opal/sys/Makefile.am
|
|
|
322933 |
@@ -10,6 +10,7 @@
|
|
|
322933 |
# Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
322933 |
# All rights reserved.
|
|
|
322933 |
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
|
|
|
322933 |
+# Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
# $COPYRIGHT$
|
|
|
322933 |
#
|
|
|
322933 |
# Additional copyrights may follow
|
|
|
322933 |
@@ -34,3 +35,4 @@ include opal/sys/mips/Makefile.am
|
|
|
322933 |
include opal/sys/sparc/Makefile.am
|
|
|
322933 |
include opal/sys/sparcv9/Makefile.am
|
|
|
322933 |
include opal/sys/win32/Makefile.am
|
|
|
322933 |
+include opal/sys/sync_builtin/Makefile.am
|
|
|
322933 |
diff --git a/opal/include/opal/sys/architecture.h b/opal/include/opal/sys/architecture.h
|
|
|
322933 |
index 2e7d007..62430fa 100644
|
|
|
322933 |
--- a/opal/include/opal/sys/architecture.h
|
|
|
322933 |
+++ b/opal/include/opal/sys/architecture.h
|
|
|
322933 |
@@ -9,6 +9,7 @@
|
|
|
322933 |
* University of Stuttgart. All rights reserved.
|
|
|
322933 |
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
322933 |
* All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
* $COPYRIGHT$
|
|
|
322933 |
*
|
|
|
322933 |
* Additional copyrights may follow
|
|
|
322933 |
@@ -37,6 +38,7 @@
|
|
|
322933 |
#define OMPI_SPARCV9_64 0062
|
|
|
322933 |
#define OMPI_MIPS 0070
|
|
|
322933 |
#define OMPI_ARM 0100
|
|
|
322933 |
+#define OMPI_SYNC_BUILTIN 0200
|
|
|
322933 |
|
|
|
322933 |
/* Formats */
|
|
|
322933 |
#define OMPI_DEFAULT 1000 /* standard for given architecture */
|
|
|
322933 |
diff --git a/opal/include/opal/sys/atomic.h b/opal/include/opal/sys/atomic.h
|
|
|
322933 |
index 01e8366..bc3c07f 100644
|
|
|
322933 |
--- a/opal/include/opal/sys/atomic.h
|
|
|
322933 |
+++ b/opal/include/opal/sys/atomic.h
|
|
|
322933 |
@@ -10,6 +10,7 @@
|
|
|
322933 |
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
322933 |
* All rights reserved.
|
|
|
322933 |
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
* $COPYRIGHT$
|
|
|
322933 |
*
|
|
|
322933 |
* Additional copyrights may follow
|
|
|
322933 |
@@ -168,6 +169,8 @@ typedef struct opal_atomic_lock_t opal_atomic_lock_t;
|
|
|
322933 |
#include "opal/sys/sparcv9/atomic.h"
|
|
|
322933 |
#elif OPAL_ASSEMBLY_ARCH == OMPI_SPARCV9_64
|
|
|
322933 |
#include "opal/sys/sparcv9/atomic.h"
|
|
|
322933 |
+#elif OPAL_ASSEMBLY_ARCH == OMPI_SYNC_BUILTIN
|
|
|
322933 |
+#include "opal/sys/sync_builtin/atomic.h"
|
|
|
322933 |
#endif
|
|
|
322933 |
|
|
|
322933 |
#ifndef DOXYGEN
|
|
|
322933 |
@@ -180,6 +183,12 @@ typedef struct opal_atomic_lock_t opal_atomic_lock_t;
|
|
|
322933 |
#ifndef OPAL_HAVE_ATOMIC_CMPSET_64
|
|
|
322933 |
#define OPAL_HAVE_ATOMIC_CMPSET_64 0
|
|
|
322933 |
#endif
|
|
|
322933 |
+#ifndef OPAL_HAVE_ATOMIC_SWAP_32
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_SWAP_32 0
|
|
|
322933 |
+#endif
|
|
|
322933 |
+#ifndef OPAL_HAVE_ATOMIC_SWAP_64
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_SWAP_64 0
|
|
|
322933 |
+#endif
|
|
|
322933 |
#endif /* DOXYGEN */
|
|
|
322933 |
|
|
|
322933 |
/**********************************************************************
|
|
|
322933 |
diff --git a/opal/include/opal/sys/sync_builtin/Makefile.am b/opal/include/opal/sys/sync_builtin/Makefile.am
|
|
|
322933 |
new file mode 100644
|
|
|
322933 |
index 0000000..a0d993c
|
|
|
322933 |
--- /dev/null
|
|
|
322933 |
+++ b/opal/include/opal/sys/sync_builtin/Makefile.am
|
|
|
322933 |
@@ -0,0 +1,24 @@
|
|
|
322933 |
+#
|
|
|
322933 |
+# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
322933 |
+# University Research and Technology
|
|
|
322933 |
+# Corporation. All rights reserved.
|
|
|
322933 |
+# Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
322933 |
+# of Tennessee Research Foundation. All rights
|
|
|
322933 |
+# reserved.
|
|
|
322933 |
+# Copyright (c) 2004-2009 High Performance Computing Center Stuttgart,
|
|
|
322933 |
+# University of Stuttgart. All rights reserved.
|
|
|
322933 |
+# Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
322933 |
+# All rights reserved.
|
|
|
322933 |
+# Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
+# $COPYRIGHT$
|
|
|
322933 |
+#
|
|
|
322933 |
+# Additional copyrights may follow
|
|
|
322933 |
+#
|
|
|
322933 |
+# $HEADER$
|
|
|
322933 |
+#
|
|
|
322933 |
+
|
|
|
322933 |
+# This makefile.am does not stand on its own - it is included from opal/include/Makefile.am
|
|
|
322933 |
+
|
|
|
322933 |
+headers += \
|
|
|
322933 |
+ opal/sys/sync_builtin/atomic.h \
|
|
|
322933 |
+ opal/sys/sync_builtin/timer.h
|
|
|
322933 |
diff --git a/opal/include/opal/sys/sync_builtin/atomic.h b/opal/include/opal/sys/sync_builtin/atomic.h
|
|
|
322933 |
new file mode 100644
|
|
|
322933 |
index 0000000..307240a
|
|
|
322933 |
--- /dev/null
|
|
|
322933 |
+++ b/opal/include/opal/sys/sync_builtin/atomic.h
|
|
|
322933 |
@@ -0,0 +1,116 @@
|
|
|
322933 |
+/*
|
|
|
322933 |
+ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
322933 |
+ * University Research and Technology
|
|
|
322933 |
+ * Corporation. All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
|
322933 |
+ * of Tennessee Research Foundation. All rights
|
|
|
322933 |
+ * reserved.
|
|
|
322933 |
+ * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
322933 |
+ * University of Stuttgart. All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
322933 |
+ * All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
+ * $COPYRIGHT$
|
|
|
322933 |
+ *
|
|
|
322933 |
+ * Additional copyrights may follow
|
|
|
322933 |
+ *
|
|
|
322933 |
+ * $HEADER$
|
|
|
322933 |
+ */
|
|
|
322933 |
+
|
|
|
322933 |
+#ifndef OMPI_SYS_ARCH_ATOMIC_H
|
|
|
322933 |
+#define OMPI_SYS_ARCH_ATOMIC_H 1
|
|
|
322933 |
+
|
|
|
322933 |
+/**********************************************************************
|
|
|
322933 |
+ *
|
|
|
322933 |
+ * Memory Barriers
|
|
|
322933 |
+ *
|
|
|
322933 |
+ *********************************************************************/
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_MEM_BARRIER 1
|
|
|
322933 |
+
|
|
|
322933 |
+static inline void opal_atomic_mb(void)
|
|
|
322933 |
+{
|
|
|
322933 |
+ __sync_synchronize();
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+static inline void opal_atomic_rmb(void)
|
|
|
322933 |
+{
|
|
|
322933 |
+ __sync_synchronize();
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+static inline void opal_atomic_wmb(void)
|
|
|
322933 |
+{
|
|
|
322933 |
+ __sync_synchronize();
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+/**********************************************************************
|
|
|
322933 |
+ *
|
|
|
322933 |
+ * Atomic math operations
|
|
|
322933 |
+ *
|
|
|
322933 |
+ *********************************************************************/
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_CMPSET_32 1
|
|
|
322933 |
+static inline int opal_atomic_cmpset_acq_32( volatile int32_t *addr,
|
|
|
322933 |
+ int32_t oldval, int32_t newval)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_bool_compare_and_swap(addr, oldval, newval);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+
|
|
|
322933 |
+static inline int opal_atomic_cmpset_rel_32( volatile int32_t *addr,
|
|
|
322933 |
+ int32_t oldval, int32_t newval)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_bool_compare_and_swap(addr, oldval, newval);}
|
|
|
322933 |
+
|
|
|
322933 |
+static inline int opal_atomic_cmpset_32( volatile int32_t *addr,
|
|
|
322933 |
+ int32_t oldval, int32_t newval)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_bool_compare_and_swap(addr, oldval, newval);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_MATH_32 1
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_ADD_32 1
|
|
|
322933 |
+static inline int32_t opal_atomic_add_32(volatile int32_t *addr, int32_t delta)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_fetch_and_add(addr, delta);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_SUB_32 1
|
|
|
322933 |
+static inline int32_t opal_atomic_sub_32(volatile int32_t *addr, int32_t delta)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_fetch_and_sub(addr, delta);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_CMPSET_64 1
|
|
|
322933 |
+static inline int opal_atomic_cmpset_acq_64( volatile int64_t *addr,
|
|
|
322933 |
+ int64_t oldval, int64_t newval)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_bool_compare_and_swap(addr, oldval, newval);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+static inline int opal_atomic_cmpset_rel_64( volatile int64_t *addr,
|
|
|
322933 |
+ int64_t oldval, int64_t newval)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_bool_compare_and_swap(addr, oldval, newval);}
|
|
|
322933 |
+
|
|
|
322933 |
+
|
|
|
322933 |
+static inline int opal_atomic_cmpset_64( volatile int64_t *addr,
|
|
|
322933 |
+ int64_t oldval, int64_t newval)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_bool_compare_and_swap(addr, oldval, newval);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_MATH_64 1
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_ADD_64 1
|
|
|
322933 |
+static inline int64_t opal_atomic_add_64(volatile int64_t *addr, int64_t delta)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_fetch_and_add(addr, delta);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_ATOMIC_SUB_64 1
|
|
|
322933 |
+static inline int64_t opal_atomic_sub_64(volatile int64_t *addr, int64_t delta)
|
|
|
322933 |
+{
|
|
|
322933 |
+ return __sync_fetch_and_sub(addr, delta);
|
|
|
322933 |
+}
|
|
|
322933 |
+
|
|
|
322933 |
+#endif /* ! OMPI_SYS_ARCH_ATOMIC_H */
|
|
|
322933 |
diff --git a/opal/include/opal/sys/sync_builtin/timer.h b/opal/include/opal/sys/sync_builtin/timer.h
|
|
|
322933 |
new file mode 100644
|
|
|
322933 |
index 0000000..aafbc9b
|
|
|
322933 |
--- /dev/null
|
|
|
322933 |
+++ b/opal/include/opal/sys/sync_builtin/timer.h
|
|
|
322933 |
@@ -0,0 +1,27 @@
|
|
|
322933 |
+/*
|
|
|
322933 |
+ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
322933 |
+ * University Research and Technology
|
|
|
322933 |
+ * Corporation. All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
322933 |
+ * of Tennessee Research Foundation. All rights
|
|
|
322933 |
+ * reserved.
|
|
|
322933 |
+ * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
322933 |
+ * University of Stuttgart. All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
322933 |
+ * All rights reserved.
|
|
|
322933 |
+ * Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
+ * $COPYRIGHT$
|
|
|
322933 |
+ *
|
|
|
322933 |
+ * Additional copyrights may follow
|
|
|
322933 |
+ *
|
|
|
322933 |
+ * $HEADER$
|
|
|
322933 |
+ */
|
|
|
322933 |
+
|
|
|
322933 |
+#ifndef OMPI_SYS_ARCH_TIMER_H
|
|
|
322933 |
+#define OMPI_SYS_ARCH_TIMER_H 1
|
|
|
322933 |
+
|
|
|
322933 |
+typedef long opal_timer_t;
|
|
|
322933 |
+
|
|
|
322933 |
+#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
|
|
|
322933 |
+
|
|
|
322933 |
+#endif /* ! OMPI_SYS_ARCH_TIMER_H */
|
|
|
322933 |
--
|
|
|
322933 |
1.8.3.1
|
|
|
322933 |
|
|
|
322933 |
From 1b2fdab7b6bf77bf4e818c84a798ba205c789483 Mon Sep 17 00:00:00 2001
|
|
|
322933 |
From: Brian Barrett <brbarret@open-mpi-git-mirror.example.com>
|
|
|
322933 |
Date: Wed, 23 Nov 2011 17:05:01 +0000
|
|
|
322933 |
Subject: [PATCH] * Shouldn't have a timer header for sync_builtin, since it
|
|
|
322933 |
doesn't actually have timer support * Default timer size should be a long,
|
|
|
322933 |
not an int. Int will roll over way too fast, with no performance benifit
|
|
|
322933 |
on 64 bit machines...
|
|
|
322933 |
|
|
|
322933 |
---
|
|
|
322933 |
opal/include/opal/sys/sync_builtin/Makefile.am | 3 +--
|
|
|
322933 |
opal/include/opal/sys/sync_builtin/timer.h | 27 --------------------------
|
|
|
322933 |
opal/include/opal/sys/timer.h | 2 +-
|
|
|
322933 |
3 files changed, 2 insertions(+), 30 deletions(-)
|
|
|
322933 |
delete mode 100644 opal/include/opal/sys/sync_builtin/timer.h
|
|
|
322933 |
|
|
|
322933 |
diff --git a/opal/include/opal/sys/sync_builtin/Makefile.am b/opal/include/opal/sys/sync_builtin/Makefile.am
|
|
|
322933 |
index a0d993c..fbb8a60 100644
|
|
|
322933 |
--- a/opal/include/opal/sys/sync_builtin/Makefile.am
|
|
|
322933 |
+++ b/opal/include/opal/sys/sync_builtin/Makefile.am
|
|
|
322933 |
@@ -20,5 +20,4 @@
|
|
|
322933 |
# This makefile.am does not stand on its own - it is included from opal/include/Makefile.am
|
|
|
322933 |
|
|
|
322933 |
headers += \
|
|
|
322933 |
- opal/sys/sync_builtin/atomic.h \
|
|
|
322933 |
- opal/sys/sync_builtin/timer.h
|
|
|
322933 |
+ opal/sys/sync_builtin/atomic.h
|
|
|
322933 |
diff --git a/opal/include/opal/sys/sync_builtin/timer.h b/opal/include/opal/sys/sync_builtin/timer.h
|
|
|
322933 |
deleted file mode 100644
|
|
|
322933 |
index aafbc9b..0000000
|
|
|
322933 |
--- a/opal/include/opal/sys/sync_builtin/timer.h
|
|
|
322933 |
+++ /dev/null
|
|
|
322933 |
@@ -1,27 +0,0 @@
|
|
|
322933 |
-/*
|
|
|
322933 |
- * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
322933 |
- * University Research and Technology
|
|
|
322933 |
- * Corporation. All rights reserved.
|
|
|
322933 |
- * Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
322933 |
- * of Tennessee Research Foundation. All rights
|
|
|
322933 |
- * reserved.
|
|
|
322933 |
- * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
322933 |
- * University of Stuttgart. All rights reserved.
|
|
|
322933 |
- * Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
322933 |
- * All rights reserved.
|
|
|
322933 |
- * Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
|
|
|
322933 |
- * $COPYRIGHT$
|
|
|
322933 |
- *
|
|
|
322933 |
- * Additional copyrights may follow
|
|
|
322933 |
- *
|
|
|
322933 |
- * $HEADER$
|
|
|
322933 |
- */
|
|
|
322933 |
-
|
|
|
322933 |
-#ifndef OMPI_SYS_ARCH_TIMER_H
|
|
|
322933 |
-#define OMPI_SYS_ARCH_TIMER_H 1
|
|
|
322933 |
-
|
|
|
322933 |
-typedef long opal_timer_t;
|
|
|
322933 |
-
|
|
|
322933 |
-#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
|
|
|
322933 |
-
|
|
|
322933 |
-#endif /* ! OMPI_SYS_ARCH_TIMER_H */
|
|
|
322933 |
diff --git a/opal/include/opal/sys/timer.h b/opal/include/opal/sys/timer.h
|
|
|
322933 |
index 967b951..cc8b922 100644
|
|
|
322933 |
--- a/opal/include/opal/sys/timer.h
|
|
|
322933 |
+++ b/opal/include/opal/sys/timer.h
|
|
|
322933 |
@@ -103,7 +103,7 @@ BEGIN_C_DECLS
|
|
|
322933 |
#ifndef OPAL_HAVE_SYS_TIMER_GET_CYCLES
|
|
|
322933 |
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
|
|
|
322933 |
|
|
|
322933 |
-typedef int opal_timer_t;
|
|
|
322933 |
+typedef long opal_timer_t;
|
|
|
322933 |
#endif
|
|
|
322933 |
#endif
|
|
|
322933 |
|
|
|
322933 |
--
|
|
|
322933 |
1.8.3.1
|
|
|
322933 |
|
|
|
322933 |
From e270e4d0f7b2b89d16d0f1ac736619118ad7f340 Mon Sep 17 00:00:00 2001
|
|
|
322933 |
From: George Bosilca <bosilca@open-mpi-git-mirror.example.com>
|
|
|
322933 |
Date: Sun, 15 Dec 2013 16:48:27 +0000
|
|
|
322933 |
Subject: [PATCH] Make the builtin atomics follow the same convention as every
|
|
|
322933 |
other atomic support we have ([op]_and_fetch instead of fetch_and_[op]).
|
|
|
322933 |
|
|
|
322933 |
---
|
|
|
322933 |
opal/include/opal/sys/sync_builtin/atomic.h | 16 +++++++++++-----
|
|
|
322933 |
1 file changed, 11 insertions(+), 5 deletions(-)
|
|
|
322933 |
|
|
|
322933 |
diff --git a/opal/include/opal/sys/sync_builtin/atomic.h b/opal/include/opal/sys/sync_builtin/atomic.h
|
|
|
322933 |
index 307240a..e0dc76b 100644
|
|
|
322933 |
--- a/opal/include/opal/sys/sync_builtin/atomic.h
|
|
|
322933 |
+++ b/opal/include/opal/sys/sync_builtin/atomic.h
|
|
|
322933 |
@@ -2,7 +2,7 @@
|
|
|
322933 |
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
322933 |
* University Research and Technology
|
|
|
322933 |
* Corporation. All rights reserved.
|
|
|
322933 |
- * Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
|
322933 |
+ * Copyright (c) 2004-2013 The University of Tennessee and The University
|
|
|
322933 |
* of Tennessee Research Foundation. All rights
|
|
|
322933 |
* reserved.
|
|
|
322933 |
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
322933 |
@@ -42,6 +42,12 @@ static inline void opal_atomic_wmb(void)
|
|
|
322933 |
__sync_synchronize();
|
|
|
322933 |
}
|
|
|
322933 |
|
|
|
322933 |
+#if OPAL_WANT_SMP_LOCKS
|
|
|
322933 |
+#define MB() opal_atomic_mb()
|
|
|
322933 |
+#else
|
|
|
322933 |
+#define MB()
|
|
|
322933 |
+#endif
|
|
|
322933 |
+
|
|
|
322933 |
/**********************************************************************
|
|
|
322933 |
*
|
|
|
322933 |
* Atomic math operations
|
|
|
322933 |
@@ -72,13 +78,13 @@ static inline int opal_atomic_cmpset_32( volatile int32_t *addr,
|
|
|
322933 |
#define OPAL_HAVE_ATOMIC_ADD_32 1
|
|
|
322933 |
static inline int32_t opal_atomic_add_32(volatile int32_t *addr, int32_t delta)
|
|
|
322933 |
{
|
|
|
322933 |
- return __sync_fetch_and_add(addr, delta);
|
|
|
322933 |
+ return __sync_add_and_fetch(addr, delta);
|
|
|
322933 |
}
|
|
|
322933 |
|
|
|
322933 |
#define OPAL_HAVE_ATOMIC_SUB_32 1
|
|
|
322933 |
static inline int32_t opal_atomic_sub_32(volatile int32_t *addr, int32_t delta)
|
|
|
322933 |
{
|
|
|
322933 |
- return __sync_fetch_and_sub(addr, delta);
|
|
|
322933 |
+ return __sync_sub_and_fetch(addr, delta);
|
|
|
322933 |
}
|
|
|
322933 |
|
|
|
322933 |
#define OPAL_HAVE_ATOMIC_CMPSET_64 1
|
|
|
322933 |
@@ -104,13 +110,13 @@ static inline int opal_atomic_cmpset_64( volatile int64_t *addr,
|
|
|
322933 |
#define OPAL_HAVE_ATOMIC_ADD_64 1
|
|
|
322933 |
static inline int64_t opal_atomic_add_64(volatile int64_t *addr, int64_t delta)
|
|
|
322933 |
{
|
|
|
322933 |
- return __sync_fetch_and_add(addr, delta);
|
|
|
322933 |
+ return __sync_add_and_fetch(addr, delta);
|
|
|
322933 |
}
|
|
|
322933 |
|
|
|
322933 |
#define OPAL_HAVE_ATOMIC_SUB_64 1
|
|
|
322933 |
static inline int64_t opal_atomic_sub_64(volatile int64_t *addr, int64_t delta)
|
|
|
322933 |
{
|
|
|
322933 |
- return __sync_fetch_and_sub(addr, delta);
|
|
|
322933 |
+ return __sync_sub_and_fetch(addr, delta);
|
|
|
322933 |
}
|
|
|
322933 |
|
|
|
322933 |
#endif /* ! OMPI_SYS_ARCH_ATOMIC_H */
|
|
|
322933 |
--
|
|
|
322933 |
1.8.3.1
|
|
|
322933 |
|
|
|
322933 |
diff --git a/configure b/configure
|
|
|
322933 |
index b585768..5d3eae1 100755
|
|
|
322933 |
--- a/configure
|
|
|
322933 |
+++ b/configure
|
|
|
322933 |
@@ -1918,6 +1938,7 @@ with_wrapper_fcflags
|
|
|
322933 |
enable_cxx_exceptions
|
|
|
322933 |
with_exflags
|
|
|
322933 |
enable_smp_locks
|
|
|
322933 |
+enable_builtin_atomics
|
|
|
322933 |
with_broken_qsort
|
|
|
322933 |
with_threads
|
|
|
322933 |
enable_opal_multi_threads
|
|
|
322933 |
@@ -2720,6 +2741,9 @@ Optional Features:
|
|
|
322933 |
--enable-smp-locks enable smp locks in atomic ops. Do not disable if
|
|
|
322933 |
code will ever run in SMP or multi-threaded
|
|
|
322933 |
environment. (default: enabled)
|
|
|
322933 |
+ --enable-builtin-atomics
|
|
|
322933 |
+ Enable use of __sync builtin atomics (default:
|
|
|
322933 |
+ disabled)
|
|
|
322933 |
--enable-opal-multi-threads
|
|
|
322933 |
Enable thread support inside OPAL (default:
|
|
|
322933 |
disabled)
|
|
|
322933 |
@@ -26558,8 +26684,49 @@ cat >>confdefs.h <<_ACEOF
|
|
|
322933 |
_ACEOF
|
|
|
322933 |
|
|
|
322933 |
|
|
|
322933 |
+ # Check whether --enable-builtin-atomics was given.
|
|
|
322933 |
+if test "${enable_builtin_atomics+set}" = set; then :
|
|
|
322933 |
+ enableval=$enable_builtin_atomics;
|
|
|
322933 |
+fi
|
|
|
322933 |
+
|
|
|
322933 |
+
|
|
|
322933 |
if test "$ompi_cv_c_compiler_vendor" = "microsoft" ; then
|
|
|
322933 |
ompi_cv_asm_arch="WINDOWS"
|
|
|
322933 |
+ elif test "$enable_builtin_atomics" = "yes" ; then
|
|
|
322933 |
+
|
|
|
322933 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __sync builtin atomics" >&5
|
|
|
322933 |
+$as_echo_n "checking for __sync builtin atomics... " >&6; }
|
|
|
322933 |
+
|
|
|
322933 |
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
|
322933 |
+/* end confdefs.h. */
|
|
|
322933 |
+
|
|
|
322933 |
+int
|
|
|
322933 |
+main ()
|
|
|
322933 |
+{
|
|
|
322933 |
+__sync_synchronize()
|
|
|
322933 |
+ ;
|
|
|
322933 |
+ return 0;
|
|
|
322933 |
+}
|
|
|
322933 |
+_ACEOF
|
|
|
322933 |
+if ac_fn_c_try_compile "$LINENO"; then :
|
|
|
322933 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
|
322933 |
+$as_echo "yes" >&6; }
|
|
|
322933 |
+ ompi_cv_asm_arch="SYNC_BUILTIN"
|
|
|
322933 |
+else
|
|
|
322933 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
|
322933 |
+$as_echo "no" >&6; }
|
|
|
322933 |
+ as_fn_error $? "__sync builtin atomics requested but not found." "$LINENO" 5
|
|
|
322933 |
+fi
|
|
|
322933 |
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|
|
322933 |
+
|
|
|
322933 |
+
|
|
|
322933 |
+$as_echo "#define OPAL_C_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
|
|
|
322933 |
+
|
|
|
322933 |
+ if test "$WANT_MPI_CXX_SUPPORT" = "1"; then :
|
|
|
322933 |
+
|
|
|
322933 |
+$as_echo "#define OMPI_CXX_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
|
|
|
322933 |
+
|
|
|
322933 |
+fi
|
|
|
322933 |
else
|
|
|
322933 |
|
|
|
322933 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if .proc/endp is needed" >&5
|
|
|
322933 |
@@ -27464,10 +27631,45 @@ as_fn_error $? "Can not continue." "$LINENO" 5
|
|
|
322933 |
;;
|
|
|
322933 |
|
|
|
322933 |
*)
|
|
|
322933 |
- as_fn_error $? "No atomic primitives available for $host" "$LINENO" 5
|
|
|
322933 |
+
|
|
|
322933 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __sync builtin atomics" >&5
|
|
|
322933 |
+$as_echo_n "checking for __sync builtin atomics... " >&6; }
|
|
|
322933 |
+
|
|
|
322933 |
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
|
322933 |
+/* end confdefs.h. */
|
|
|
322933 |
+
|
|
|
322933 |
+int
|
|
|
322933 |
+main ()
|
|
|
322933 |
+{
|
|
|
322933 |
+__sync_synchronize()
|
|
|
322933 |
+ ;
|
|
|
322933 |
+ return 0;
|
|
|
322933 |
+}
|
|
|
322933 |
+_ACEOF
|
|
|
322933 |
+if ac_fn_c_try_compile "$LINENO"; then :
|
|
|
322933 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
|
|
322933 |
+$as_echo "yes" >&6; }
|
|
|
322933 |
+ ompi_cv_asm_arch="SYNC_BUILTIN"
|
|
|
322933 |
+else
|
|
|
322933 |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
|
322933 |
+$as_echo "no" >&6; }
|
|
|
322933 |
+ as_fn_error $? "No atomic primitives available for $host" "$LINENO" 5
|
|
|
322933 |
+fi
|
|
|
322933 |
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|
|
322933 |
+
|
|
|
322933 |
;;
|
|
|
322933 |
esac
|
|
|
322933 |
|
|
|
322933 |
+ if test "$ompi_cv_asm_arch" = "SYNC_BUILTIN" ; then
|
|
|
322933 |
+
|
|
|
322933 |
+$as_echo "#define OPAL_C_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
|
|
|
322933 |
+
|
|
|
322933 |
+ if test "$WANT_MPI_CXX_SUPPORT" = "1"; then :
|
|
|
322933 |
+
|
|
|
322933 |
+$as_echo "#define OMPI_CXX_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
|
|
|
322933 |
+
|
|
|
322933 |
+fi
|
|
|
322933 |
+ else
|
|
|
322933 |
|
|
|
322933 |
cat >>confdefs.h <<_ACEOF
|
|
|
322933 |
#define OPAL_ASM_SUPPORT_64BIT $OPAL_ASM_SUPPORT_64BIT
|
|
|
322933 |
@@ -27866,6 +28068,7 @@ cat >>confdefs.h <<_ACEOF
|
|
|
322933 |
_ACEOF
|
|
|
322933 |
|
|
|
322933 |
|
|
|
322933 |
+ fi # if ompi_cv_asm_arch = SYNC_BUILTIN
|
|
|
322933 |
fi # if cv_c_compiler_vendor = microsoft
|
|
|
322933 |
|
|
|
322933 |
result="OMPI_$ompi_cv_asm_arch"
|
|
|
322933 |
@@ -27885,7 +28088,7 @@ _ACEOF
|
|
|
322933 |
|
|
|
322933 |
|
|
|
322933 |
|
|
|
322933 |
-if test "$ompi_cv_asm_arch" != "WINDOWS" ; then
|
|
|
322933 |
+if test "$ompi_cv_asm_arch" != "WINDOWS" -a "$ompi_cv_asm_arch" != "SYNC_BUILTIN" ; then
|
|
|
322933 |
# Extract the first word of "perl", so it can be a program name with args.
|
|
|
322933 |
set dummy perl; ac_word=$2
|
|
|
322933 |
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|