Blob Blame History Raw
From 351e63eeb4123aa2d2dc13a01912968ad1365fa1 Mon Sep 17 00:00:00 2001
From: Brian Barrett <brbarret@open-mpi-git-mirror.example.com>
Date: Wed, 23 Nov 2011 04:25:41 +0000
Subject: [PATCH] Add (optional/last ditch effort) support for GCC/Intel
 __sync_ builtin atomic operations.  Much easier than adding support for a new
 architecture.

---
 LICENSE                                        |   2 +-
 opal/config/opal_config_asm.m4                 |  38 +++++++-
 opal/include/opal/sys/Makefile.am              |   2 +
 opal/include/opal/sys/architecture.h           |   2 +
 opal/include/opal/sys/atomic.h                 |   9 ++
 opal/include/opal/sys/sync_builtin/Makefile.am |  24 +++++
 opal/include/opal/sys/sync_builtin/atomic.h    | 116 +++++++++++++++++++++++++
 opal/include/opal/sys/sync_builtin/timer.h     |  27 ++++++
 8 files changed, 217 insertions(+), 3 deletions(-)
 create mode 100644 opal/include/opal/sys/sync_builtin/Makefile.am
 create mode 100644 opal/include/opal/sys/sync_builtin/atomic.h
 create mode 100644 opal/include/opal/sys/sync_builtin/timer.h

diff --git a/LICENSE b/LICENSE
index d6424ab..0712868 100644
--- a/LICENSE
+++ b/LICENSE
@@ -19,7 +19,7 @@ Copyright (c) 2006-2010 Los Alamos National Security, LLC.  All rights
                         reserved. 
 Copyright (c) 2006-2010 Cisco Systems, Inc.  All rights reserved.
 Copyright (c) 2006-2010 Voltaire, Inc. All rights reserved.
-Copyright (c) 2006-2010 Sandia National Laboratories. All rights reserved.
+Copyright (c) 2006-2011 Sandia National Laboratories. All rights reserved.
 Copyright (c) 2006-2010 Sun Microsystems, Inc.  All rights reserved.
                         Use is subject to license terms.
 Copyright (c) 2006-2010 The University of Houston. All rights reserved.
diff --git a/opal/config/opal_config_asm.m4 b/opal/config/opal_config_asm.m4
index fc7fdcd..591f4c3 100644
--- a/opal/config/opal_config_asm.m4
+++ b/opal/config/opal_config_asm.m4
@@ -19,6 +19,17 @@ dnl $HEADER$
 dnl
 
 
+AC_DEFUN([OPAL_CHECK_SYNC_BUILTINS], [
+  AC_MSG_CHECKING([for __sync builtin atomics])
+
+  AC_TRY_COMPILE([], [__sync_synchronize()], 
+    [AC_MSG_RESULT([yes])
+     $1],
+    [AC_MSG_RESULT([no])
+     $2])
+])
+
+
 dnl #################################################################
 dnl
 dnl OMPI_CHECK_ASM_TEXT
@@ -841,8 +852,21 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
     AC_DEFINE_UNQUOTED([OPAL_WANT_SMP_LOCKS], [$want_smp_locks],
                        [whether we want to have smp locks in atomic ops or not])
 
+    AC_ARG_ENABLE([builtin-atomics],
+      [AC_HELP_STRING([--enable-builtin-atomics],
+         [Enable use of __sync builtin atomics (default: disabled)])])
+
     if test "$ompi_cv_c_compiler_vendor" = "microsoft" ; then
         ompi_cv_asm_arch="WINDOWS"
+    elif test "$enable_builtin_atomics" = "yes" ; then
+       OPAL_CHECK_SYNC_BUILTINS([ompi_cv_asm_arch="SYNC_BUILTIN"],
+         [AC_MSG_ERROR([__sync builtin atomics requested but not found.])])
+       AC_DEFINE([OPAL_C_GCC_INLINE_ASSEMBLY], [1],
+         [Whether C compiler supports GCC style inline assembly])
+       m4_ifdef([project_ompi],
+                [AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
+         [AC_DEFINE([OMPI_CXX_GCC_INLINE_ASSEMBLY], [1],
+           [Whether C++ compiler supports GCC style inline assembly])])])
     else
         OMPI_CHECK_ASM_PROC
         OMPI_CHECK_ASM_TEXT
@@ -946,10 +970,19 @@ AC_MSG_ERROR([Can not continue.])
             ;;
 
         *)
-            AC_MSG_ERROR([No atomic primitives available for $host])
+            OPAL_CHECK_SYNC_BUILTINS([ompi_cv_asm_arch="SYNC_BUILTIN"],
+              [AC_MSG_ERROR([No atomic primitives available for $host])])
             ;;
         esac
 
+      if test "$ompi_cv_asm_arch" = "SYNC_BUILTIN" ; then
+        AC_DEFINE([OPAL_C_GCC_INLINE_ASSEMBLY], [1],
+          [Whether C compiler supports GCC style inline assembly])
+        m4_ifdef([project_ompi],
+                 [AS_IF([test "$WANT_MPI_CXX_SUPPORT" = "1"],
+          [AC_DEFINE([OMPI_CXX_GCC_INLINE_ASSEMBLY], [1],
+            [Whether C++ compiler supports GCC style inline assembly])])])
+      else
         AC_DEFINE_UNQUOTED([OPAL_ASM_SUPPORT_64BIT],
             [$OPAL_ASM_SUPPORT_64BIT],
             [Whether we can do 64bit assembly operations or not.  Should not be used outside of the assembly header files])
@@ -1004,6 +1037,7 @@ AC_MSG_ERROR([Can not continue.])
         AC_DEFINE_UNQUOTED([OPAL_ASSEMBLY_FORMAT], ["$OPAL_ASSEMBLY_FORMAT"],
                            [Format of assembly file])
         AC_SUBST([OPAL_ASSEMBLY_FORMAT])
+      fi # if ompi_cv_asm_arch = SYNC_BUILTIN
     fi # if cv_c_compiler_vendor = microsoft
 
     result="OMPI_$ompi_cv_asm_arch"
@@ -1032,7 +1066,7 @@ AC_DEFUN([OMPI_ASM_FIND_FILE], [
     AC_REQUIRE([AC_PROG_GREP])
     AC_REQUIRE([AC_PROG_FGREP])
 
-if test "$ompi_cv_asm_arch" != "WINDOWS" ; then
+if test "$ompi_cv_asm_arch" != "WINDOWS" -a "$ompi_cv_asm_arch" != "SYNC_BUILTIN" ; then
     AC_CHECK_PROG([PERL], [perl], [perl])
 
     # see if we have a pre-built one already
diff --git a/opal/include/opal/sys/Makefile.am b/opal/include/opal/sys/Makefile.am
index 0917c7d..6c411c5 100644
--- a/opal/include/opal/sys/Makefile.am
+++ b/opal/include/opal/sys/Makefile.am
@@ -10,6 +10,7 @@
 # Copyright (c) 2004-2005 The Regents of the University of California.
 #                         All rights reserved.
 # Copyright (c) 2010      Cisco Systems, Inc.  All rights reserved.
+# Copyright (c) 2011      Sandia National Laboratories. All rights reserved.
 # $COPYRIGHT$
 # 
 # Additional copyrights may follow
@@ -34,3 +35,4 @@ include opal/sys/mips/Makefile.am
 include opal/sys/sparc/Makefile.am
 include opal/sys/sparcv9/Makefile.am
 include opal/sys/win32/Makefile.am
+include opal/sys/sync_builtin/Makefile.am
diff --git a/opal/include/opal/sys/architecture.h b/opal/include/opal/sys/architecture.h
index 2e7d007..62430fa 100644
--- a/opal/include/opal/sys/architecture.h
+++ b/opal/include/opal/sys/architecture.h
@@ -9,6 +9,7 @@
  *                         University of Stuttgart.  All rights reserved.
  * Copyright (c) 2004-2005 The Regents of the University of California.
  *                         All rights reserved.
+ * Copyright (c) 2011      Sandia National Laboratories. All rights reserved.
  * $COPYRIGHT$
  * 
  * Additional copyrights may follow
@@ -37,6 +38,7 @@
 #define OMPI_SPARCV9_64     0062
 #define OMPI_MIPS           0070
 #define OMPI_ARM            0100
+#define OMPI_SYNC_BUILTIN   0200
 
 /* Formats */
 #define OMPI_DEFAULT        1000  /* standard for given architecture */
diff --git a/opal/include/opal/sys/atomic.h b/opal/include/opal/sys/atomic.h
index 01e8366..bc3c07f 100644
--- a/opal/include/opal/sys/atomic.h
+++ b/opal/include/opal/sys/atomic.h
@@ -10,6 +10,7 @@
  * Copyright (c) 2004-2005 The Regents of the University of California.
  *                         All rights reserved.
  * Copyright (c) 2007      Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2011      Sandia National Laboratories. All rights reserved.
  * $COPYRIGHT$
  * 
  * Additional copyrights may follow
@@ -168,6 +169,8 @@ typedef struct opal_atomic_lock_t opal_atomic_lock_t;
 #include "opal/sys/sparcv9/atomic.h"
 #elif OPAL_ASSEMBLY_ARCH == OMPI_SPARCV9_64
 #include "opal/sys/sparcv9/atomic.h"
+#elif OPAL_ASSEMBLY_ARCH == OMPI_SYNC_BUILTIN
+#include "opal/sys/sync_builtin/atomic.h"
 #endif
 
 #ifndef DOXYGEN
@@ -180,6 +183,12 @@ typedef struct opal_atomic_lock_t opal_atomic_lock_t;
 #ifndef OPAL_HAVE_ATOMIC_CMPSET_64
 #define OPAL_HAVE_ATOMIC_CMPSET_64 0
 #endif
+#ifndef OPAL_HAVE_ATOMIC_SWAP_32
+#define OPAL_HAVE_ATOMIC_SWAP_32 0
+#endif
+#ifndef OPAL_HAVE_ATOMIC_SWAP_64
+#define OPAL_HAVE_ATOMIC_SWAP_64 0
+#endif
 #endif /* DOXYGEN */
 
 /**********************************************************************
diff --git a/opal/include/opal/sys/sync_builtin/Makefile.am b/opal/include/opal/sys/sync_builtin/Makefile.am
new file mode 100644
index 0000000..a0d993c
--- /dev/null
+++ b/opal/include/opal/sys/sync_builtin/Makefile.am
@@ -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-2005 The University of Tennessee and The University
+#                         of Tennessee Research Foundation.  All rights
+#                         reserved.
+# Copyright (c) 2004-2009 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) 2011      Sandia National Laboratories. 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/sync_builtin/atomic.h \
+	opal/sys/sync_builtin/timer.h
diff --git a/opal/include/opal/sys/sync_builtin/atomic.h b/opal/include/opal/sys/sync_builtin/atomic.h
new file mode 100644
index 0000000..307240a
--- /dev/null
+++ b/opal/include/opal/sys/sync_builtin/atomic.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
+ *                         University Research and Technology
+ *                         Corporation.  All rights reserved.
+ * Copyright (c) 2004-2006 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) 2011      Sandia National Laboratories. All rights reserved.
+ * $COPYRIGHT$
+ * 
+ * Additional copyrights may follow
+ * 
+ * $HEADER$
+ */
+
+#ifndef OMPI_SYS_ARCH_ATOMIC_H
+#define OMPI_SYS_ARCH_ATOMIC_H 1
+
+/**********************************************************************
+ *
+ * Memory Barriers
+ *
+ *********************************************************************/
+#define OPAL_HAVE_ATOMIC_MEM_BARRIER 1
+
+static inline void opal_atomic_mb(void)
+{    
+    __sync_synchronize();
+}
+
+static inline void opal_atomic_rmb(void)
+{
+    __sync_synchronize();
+}
+
+static inline void opal_atomic_wmb(void)
+{    
+    __sync_synchronize();
+}
+
+/**********************************************************************
+ *
+ * Atomic math operations
+ *
+ *********************************************************************/
+
+#define OPAL_HAVE_ATOMIC_CMPSET_32 1
+static inline int opal_atomic_cmpset_acq_32( volatile int32_t *addr,
+                                             int32_t oldval, int32_t newval)
+{
+    return __sync_bool_compare_and_swap(addr, oldval, newval);
+}
+
+
+static inline int opal_atomic_cmpset_rel_32( volatile int32_t *addr,
+                                             int32_t oldval, int32_t newval)
+{
+    return __sync_bool_compare_and_swap(addr, oldval, newval);}
+
+static inline int opal_atomic_cmpset_32( volatile int32_t *addr,
+                                         int32_t oldval, int32_t newval)
+{
+    return __sync_bool_compare_and_swap(addr, oldval, newval);
+}
+
+#define OPAL_HAVE_ATOMIC_MATH_32 1
+
+#define OPAL_HAVE_ATOMIC_ADD_32 1
+static inline int32_t opal_atomic_add_32(volatile int32_t *addr, int32_t delta)
+{
+    return __sync_fetch_and_add(addr, delta);
+}
+
+#define OPAL_HAVE_ATOMIC_SUB_32 1
+static inline int32_t opal_atomic_sub_32(volatile int32_t *addr, int32_t delta)
+{
+    return __sync_fetch_and_sub(addr, delta);
+}
+
+#define OPAL_HAVE_ATOMIC_CMPSET_64 1
+static inline int opal_atomic_cmpset_acq_64( volatile int64_t *addr,
+                                             int64_t oldval, int64_t newval)
+{
+    return __sync_bool_compare_and_swap(addr, oldval, newval);
+}
+
+static inline int opal_atomic_cmpset_rel_64( volatile int64_t *addr,
+                                             int64_t oldval, int64_t newval)
+{
+    return __sync_bool_compare_and_swap(addr, oldval, newval);}
+
+
+static inline int opal_atomic_cmpset_64( volatile int64_t *addr,
+                                         int64_t oldval, int64_t newval)
+{
+    return __sync_bool_compare_and_swap(addr, oldval, newval);
+}
+
+#define OPAL_HAVE_ATOMIC_MATH_64 1
+#define OPAL_HAVE_ATOMIC_ADD_64 1
+static inline int64_t opal_atomic_add_64(volatile int64_t *addr, int64_t delta)
+{
+    return __sync_fetch_and_add(addr, delta);
+}
+
+#define OPAL_HAVE_ATOMIC_SUB_64 1
+static inline int64_t opal_atomic_sub_64(volatile int64_t *addr, int64_t delta)
+{
+    return __sync_fetch_and_sub(addr, delta);
+}
+
+#endif /* ! OMPI_SYS_ARCH_ATOMIC_H */
diff --git a/opal/include/opal/sys/sync_builtin/timer.h b/opal/include/opal/sys/sync_builtin/timer.h
new file mode 100644
index 0000000..aafbc9b
--- /dev/null
+++ b/opal/include/opal/sys/sync_builtin/timer.h
@@ -0,0 +1,27 @@
+/*
+ * 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) 2011      Sandia National Laboratories. All rights reserved.
+ * $COPYRIGHT$
+ * 
+ * Additional copyrights may follow
+ * 
+ * $HEADER$
+ */
+
+#ifndef OMPI_SYS_ARCH_TIMER_H
+#define OMPI_SYS_ARCH_TIMER_H 1
+
+typedef long opal_timer_t;
+
+#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
+
+#endif /* ! OMPI_SYS_ARCH_TIMER_H */
-- 
1.8.3.1

From 1b2fdab7b6bf77bf4e818c84a798ba205c789483 Mon Sep 17 00:00:00 2001
From: Brian Barrett <brbarret@open-mpi-git-mirror.example.com>
Date: Wed, 23 Nov 2011 17:05:01 +0000
Subject: [PATCH] * Shouldn't have a timer header for sync_builtin, since it
 doesn't actually   have timer support * Default timer size should be a long,
 not an int.  Int will roll over way   too fast, with no performance benifit
 on 64 bit machines...

---
 opal/include/opal/sys/sync_builtin/Makefile.am |  3 +--
 opal/include/opal/sys/sync_builtin/timer.h     | 27 --------------------------
 opal/include/opal/sys/timer.h                  |  2 +-
 3 files changed, 2 insertions(+), 30 deletions(-)
 delete mode 100644 opal/include/opal/sys/sync_builtin/timer.h

diff --git a/opal/include/opal/sys/sync_builtin/Makefile.am b/opal/include/opal/sys/sync_builtin/Makefile.am
index a0d993c..fbb8a60 100644
--- a/opal/include/opal/sys/sync_builtin/Makefile.am
+++ b/opal/include/opal/sys/sync_builtin/Makefile.am
@@ -20,5 +20,4 @@
 # This makefile.am does not stand on its own - it is included from opal/include/Makefile.am
 
 headers += \
-	opal/sys/sync_builtin/atomic.h \
-	opal/sys/sync_builtin/timer.h
+	opal/sys/sync_builtin/atomic.h
diff --git a/opal/include/opal/sys/sync_builtin/timer.h b/opal/include/opal/sys/sync_builtin/timer.h
deleted file mode 100644
index aafbc9b..0000000
--- a/opal/include/opal/sys/sync_builtin/timer.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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) 2011      Sandia National Laboratories. All rights reserved.
- * $COPYRIGHT$
- * 
- * Additional copyrights may follow
- * 
- * $HEADER$
- */
-
-#ifndef OMPI_SYS_ARCH_TIMER_H
-#define OMPI_SYS_ARCH_TIMER_H 1
-
-typedef long opal_timer_t;
-
-#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
-
-#endif /* ! OMPI_SYS_ARCH_TIMER_H */
diff --git a/opal/include/opal/sys/timer.h b/opal/include/opal/sys/timer.h
index 967b951..cc8b922 100644
--- a/opal/include/opal/sys/timer.h
+++ b/opal/include/opal/sys/timer.h
@@ -103,7 +103,7 @@ BEGIN_C_DECLS
 #ifndef OPAL_HAVE_SYS_TIMER_GET_CYCLES
 #define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
 
-typedef int opal_timer_t;
+typedef long opal_timer_t;
 #endif
 #endif
 
-- 
1.8.3.1

From e270e4d0f7b2b89d16d0f1ac736619118ad7f340 Mon Sep 17 00:00:00 2001
From: George Bosilca <bosilca@open-mpi-git-mirror.example.com>
Date: Sun, 15 Dec 2013 16:48:27 +0000
Subject: [PATCH] Make the builtin atomics follow the same convention as every
 other atomic support we have ([op]_and_fetch instead of fetch_and_[op]).

---
 opal/include/opal/sys/sync_builtin/atomic.h | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/opal/include/opal/sys/sync_builtin/atomic.h b/opal/include/opal/sys/sync_builtin/atomic.h
index 307240a..e0dc76b 100644
--- a/opal/include/opal/sys/sync_builtin/atomic.h
+++ b/opal/include/opal/sys/sync_builtin/atomic.h
@@ -2,7 +2,7 @@
  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
  *                         University Research and Technology
  *                         Corporation.  All rights reserved.
- * Copyright (c) 2004-2006 The University of Tennessee and The University
+ * Copyright (c) 2004-2013 The University of Tennessee and The University
  *                         of Tennessee Research Foundation.  All rights
  *                         reserved.
  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
@@ -42,6 +42,12 @@ static inline void opal_atomic_wmb(void)
     __sync_synchronize();
 }
 
+#if OPAL_WANT_SMP_LOCKS
+#define MB() opal_atomic_mb()
+#else
+#define MB()
+#endif
+
 /**********************************************************************
  *
  * Atomic math operations
@@ -72,13 +78,13 @@ static inline int opal_atomic_cmpset_32( volatile int32_t *addr,
 #define OPAL_HAVE_ATOMIC_ADD_32 1
 static inline int32_t opal_atomic_add_32(volatile int32_t *addr, int32_t delta)
 {
-    return __sync_fetch_and_add(addr, delta);
+    return __sync_add_and_fetch(addr, delta);
 }
 
 #define OPAL_HAVE_ATOMIC_SUB_32 1
 static inline int32_t opal_atomic_sub_32(volatile int32_t *addr, int32_t delta)
 {
-    return __sync_fetch_and_sub(addr, delta);
+    return __sync_sub_and_fetch(addr, delta);
 }
 
 #define OPAL_HAVE_ATOMIC_CMPSET_64 1
@@ -104,13 +110,13 @@ static inline int opal_atomic_cmpset_64( volatile int64_t *addr,
 #define OPAL_HAVE_ATOMIC_ADD_64 1
 static inline int64_t opal_atomic_add_64(volatile int64_t *addr, int64_t delta)
 {
-    return __sync_fetch_and_add(addr, delta);
+    return __sync_add_and_fetch(addr, delta);
 }
 
 #define OPAL_HAVE_ATOMIC_SUB_64 1
 static inline int64_t opal_atomic_sub_64(volatile int64_t *addr, int64_t delta)
 {
-    return __sync_fetch_and_sub(addr, delta);
+    return __sync_sub_and_fetch(addr, delta);
 }
 
 #endif /* ! OMPI_SYS_ARCH_ATOMIC_H */
-- 
1.8.3.1

diff --git a/configure b/configure
index b585768..5d3eae1 100755
--- a/configure
+++ b/configure
@@ -1918,6 +1938,7 @@ with_wrapper_fcflags
 enable_cxx_exceptions
 with_exflags
 enable_smp_locks
+enable_builtin_atomics
 with_broken_qsort
 with_threads
 enable_opal_multi_threads
@@ -2720,6 +2741,9 @@ Optional Features:
   --enable-smp-locks      enable smp locks in atomic ops. Do not disable if
                           code will ever run in SMP or multi-threaded
                           environment. (default: enabled)
+  --enable-builtin-atomics
+                          Enable use of __sync builtin atomics (default:
+                          disabled)
   --enable-opal-multi-threads
                           Enable thread support inside OPAL (default:
                           disabled)
@@ -26558,8 +26684,49 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+    # Check whether --enable-builtin-atomics was given.
+if test "${enable_builtin_atomics+set}" = set; then :
+  enableval=$enable_builtin_atomics;
+fi
+
+
     if test "$ompi_cv_c_compiler_vendor" = "microsoft" ; then
         ompi_cv_asm_arch="WINDOWS"
+    elif test "$enable_builtin_atomics" = "yes" ; then
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __sync builtin atomics" >&5
+$as_echo_n "checking for __sync builtin atomics... " >&6; }
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+__sync_synchronize()
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+     ompi_cv_asm_arch="SYNC_BUILTIN"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+     as_fn_error $? "__sync builtin atomics requested but not found." "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+$as_echo "#define OPAL_C_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
+
+       if test "$WANT_MPI_CXX_SUPPORT" = "1"; then :
+
+$as_echo "#define OMPI_CXX_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
+
+fi
     else
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking if .proc/endp is needed" >&5
@@ -27464,10 +27631,45 @@ as_fn_error $? "Can not continue." "$LINENO" 5
             ;;
 
         *)
-            as_fn_error $? "No atomic primitives available for $host" "$LINENO" 5
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __sync builtin atomics" >&5
+$as_echo_n "checking for __sync builtin atomics... " >&6; }
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+__sync_synchronize()
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+     ompi_cv_asm_arch="SYNC_BUILTIN"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+     as_fn_error $? "No atomic primitives available for $host" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
             ;;
         esac
 
+      if test "$ompi_cv_asm_arch" = "SYNC_BUILTIN" ; then
+
+$as_echo "#define OPAL_C_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
+
+        if test "$WANT_MPI_CXX_SUPPORT" = "1"; then :
+
+$as_echo "#define OMPI_CXX_GCC_INLINE_ASSEMBLY 1" >>confdefs.h
+
+fi
+      else
 
 cat >>confdefs.h <<_ACEOF
 #define OPAL_ASM_SUPPORT_64BIT $OPAL_ASM_SUPPORT_64BIT
@@ -27866,6 +28068,7 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+      fi # if ompi_cv_asm_arch = SYNC_BUILTIN
     fi # if cv_c_compiler_vendor = microsoft
 
     result="OMPI_$ompi_cv_asm_arch"
@@ -27885,7 +28088,7 @@ _ACEOF
 
 
 
-if test "$ompi_cv_asm_arch" != "WINDOWS" ; then
+if test "$ompi_cv_asm_arch" != "WINDOWS" -a "$ompi_cv_asm_arch" != "SYNC_BUILTIN" ; then
     # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5