@@ -135,6 +135,7 @@ AC_DEFUN([OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_TEST_SOURCE],[[
135135typedef union {
136136 uint64_t fake@<:@ 2@:>@ ;
137137 _Atomic __int128 real;
138+ __int128 real2;
138139} ompi128;
139140
140141static void test1(void)
@@ -145,9 +146,8 @@ static void test1(void)
145146 ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
146147 ompi128 expected = { .fake = { 0x11EEDDCCBBAA0099, 0x88776655443322FF }};
147148 ompi128 desired = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
148- bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real,
149- desired.real, true,
150- atomic_relaxed, atomic_relaxed);
149+ bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real2,
150+ desired.real);
151151 if ( !(r == false && ptr.real == expected.real)) {
152152 exit(1);
153153 }
@@ -158,9 +158,8 @@ static void test2(void)
158158 ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
159159 ompi128 expected = ptr;
160160 ompi128 desired = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
161- bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real,
162- desired.real, true,
163- atomic_relaxed, atomic_relaxed);
161+ bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real2,
162+ desired.real);
164163 if (!(r == true && ptr.real == desired.real)) {
165164 exit(2);
166165 }
@@ -285,37 +284,6 @@ AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
285284 OPAL_VAR_SCOPE_POP
286285] )
287286
288- AC_DEFUN ( [ OPAL_CHECK_SYNC_BUILTINS] , [
289- AC_MSG_CHECKING ( [ for __sync builtin atomics] )
290-
291- AC_TRY_LINK ( [ long tmp;] , [ __sync_synchronize();
292- __sync_bool_compare_and_swap(&tmp, 0, 1);
293- __sync_add_and_fetch(&tmp, 1);] ,
294- [ AC_MSG_RESULT ( [ yes] )
295- $1 ] ,
296- [ AC_MSG_RESULT ( [ no] )
297- $2 ] )
298-
299- AC_MSG_CHECKING ( [ for 64-bit __sync builtin atomics] )
300-
301- AC_TRY_LINK ( [
302- #include <stdint.h>
303- uint64_t tmp;] , [
304- __sync_bool_compare_and_swap(&tmp, 0, 1);
305- __sync_add_and_fetch(&tmp, 1);] ,
306- [ AC_MSG_RESULT ( [ yes] )
307- opal_asm_sync_have_64bit=1] ,
308- [ AC_MSG_RESULT ( [ no] )
309- opal_asm_sync_have_64bit=0] )
310-
311- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_SYNC_HAVE_64BIT] ,[ $opal_asm_sync_have_64bit] ,
312- [ Whether 64-bit is supported by the __sync builtin atomics] )
313-
314- # Check for 128-bit support
315- OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128
316- ] )
317-
318-
319287AC_DEFUN ( [ OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128] , [
320288 OPAL_VAR_SCOPE_PUSH([ atomic_compare_exchange_n_128_result atomic_compare_exchange_n_128_CFLAGS_save atomic_compare_exchange_n_128_LIBS_save] )
321289
@@ -361,9 +329,10 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
361329] )
362330
363331AC_DEFUN ( [ OPAL_CHECK_GCC_ATOMIC_BUILTINS] , [
364- AC_MSG_CHECKING ( [ for __atomic builtin atomics] )
332+ if test -z "$opal_cv_have___atomic" ; then
333+ AC_MSG_CHECKING ( [ for 32-bit GCC built-in atomics] )
365334
366- AC_TRY_LINK ( [
335+ AC_TRY_LINK ( [
367336#include <stdint.h>
368337uint32_t tmp, old = 0;
369338uint64_t tmp64, old64 = 0;] , [
@@ -372,13 +341,39 @@ __atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED
372341__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
373342__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
374343__atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);] ,
375- [ AC_MSG_RESULT ( [ yes] )
376- $1 ] ,
377- [ AC_MSG_RESULT ( [ no] )
378- $2 ] )
344+ [ opal_cv_have___atomic=yes] ,
345+ [ opal_cv_have___atomic=no] )
346+
347+ AC_MSG_RESULT ( [ $opal_cv_have___atomic] )
348+
349+ if test $opal_cv_have___atomic = "yes" ; then
350+ AC_MSG_CHECKING ( [ for 64-bit GCC built-in atomics] )
351+
352+ AC_TRY_LINK ( [
353+ #include <stdint.h>
354+ uint64_t tmp64, old64 = 0;] , [
355+ __atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
356+ __atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);] ,
357+ [ opal_cv_have___atomic_64=yes] ,
358+ [ opal_cv_have___atomic_64=no] )
359+
360+ AC_MSG_RESULT ( [ $opal_cv_have___atomic_64] )
361+
362+ if test $opal_cv_have___atomic_64 = "yes" ; then
363+ AC_MSG_CHECKING ( [ if 64-bit GCC built-in atomics are lock-free] )
364+ AC_RUN_IFELSE ( [ AC_LANG_PROGRAM ( [ ] , [ if (!__atomic_is_lock_free (8, 0)) { return 1; }] ) ] ,
365+ [ AC_MSG_RESULT ( [ yes] ) ] ,
366+ [ AC_MSG_RESULT ( [ no] )
367+ opal_cv_have___atomic_64=no] ,
368+ [ AC_MSG_RESULT ( [ cannot test -- assume yes (cross compiling)] ) ] )
369+ fi
370+ else
371+ opal_cv_have___atomic_64=no
372+ fi
379373
380- # Check for 128-bit support
381- OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
374+ # Check for 128-bit support
375+ OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
376+ fi
382377] )
383378
384379AC_DEFUN ( [ OPAL_CHECK_C11_CSWAP_INT128] , [
@@ -425,28 +420,6 @@ AC_DEFUN([OPAL_CHECK_C11_CSWAP_INT128], [
425420 OPAL_VAR_SCOPE_POP
426421] )
427422
428- AC_DEFUN ( [ OPAL_CHECK_GCC_ATOMIC_BUILTINS] , [
429- AC_MSG_CHECKING ( [ for __atomic builtin atomics] )
430-
431- AC_TRY_LINK ( [
432- #include <stdint.h>
433- uint32_t tmp, old = 0;
434- uint64_t tmp64, old64 = 0;] , [
435- __atomic_thread_fence(__ATOMIC_SEQ_CST);
436- __atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
437- __atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
438- __atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
439- __atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);] ,
440- [ AC_MSG_RESULT ( [ yes] )
441- $1 ] ,
442- [ AC_MSG_RESULT ( [ no] )
443- $2 ] )
444-
445- # Check for 128-bit support
446- OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
447- ] )
448-
449-
450423dnl #################################################################
451424dnl
452425dnl OPAL_CHECK_ASM_TEXT
@@ -952,29 +925,6 @@ AC_DEFUN([OPAL_CHECK_POWERPC_64BIT],[
952925] ) dnl
953926
954927
955- dnl #################################################################
956- dnl
957- dnl OPAL_CHECK_SPARCV8PLUS
958- dnl
959- dnl #################################################################
960- AC_DEFUN ( [ OPAL_CHECK_SPARCV8PLUS] ,[
961- AC_MSG_CHECKING ( [ if have Sparc v8+/v9 support] )
962- sparc_result=0
963- OPAL_TRY_ASSEMBLE([ $opal_cv_asm_text
964- casa [ %o0] 0x80, %o1, %o2] ,
965- [ sparc_result=1] ,
966- [ sparc_result=0] )
967- if test "$sparc_result" = "1" ; then
968- AC_MSG_RESULT ( [ yes] )
969- ifelse ( [ $1 ] ,,: ,[ $1 ] )
970- else
971- AC_MSG_RESULT ( [ no] )
972- ifelse ( [ $2 ] ,,: ,[ $2 ] )
973- fi
974-
975- unset sparc_result
976- ] ) dnl
977-
978928dnl #################################################################
979929dnl
980930dnl OPAL_CHECK_CMPXCHG16B
@@ -1142,24 +1092,25 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
11421092
11431093 AC_ARG_ENABLE ( [ builtin-atomics] ,
11441094 [ AC_HELP_STRING ([ --enable-builtin-atomics] ,
1145- [ Enable use of __sync builtin atomics (default: disabled )] )] )
1095+ [ Enable use of GCC built-in atomics (default: autodetect )] )] )
11461096
11471097 OPAL_CHECK_C11_CSWAP_INT128
1098+ opal_cv_asm_builtin="BUILTIN_NO"
1099+ OPAL_CHECK_GCC_ATOMIC_BUILTINS
11481100
11491101 if test "x$enable_c11_atomics" != "xno" && test "$opal_cv_c11_supported" = "yes" ; then
11501102 opal_cv_asm_builtin="BUILTIN_C11"
11511103 OPAL_CHECK_C11_CSWAP_INT128
11521104 elif test "x$enable_c11_atomics" = "xyes"; then
11531105 AC_MSG_WARN ( [ C11 atomics were requested but are not supported] )
11541106 AC_MSG_ERROR ( [ Cannot continue] )
1155- else
1156- opal_cv_asm_builtin="BUILTIN_NO"
1157- AS_IF ( [ test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"] ,
1158- [ OPAL_CHECK_GCC_ATOMIC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_GCC"] , [ ] )] )
1159- AS_IF ( [ test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"] ,
1160- [ OPAL_CHECK_SYNC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_SYNC"] , [ ] )] )
1161- AS_IF ( [ test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"] ,
1162- [ AC_MSG_ERROR ( [ __sync builtin atomics requested but not found.] ) ] )
1107+ elif test "$enable_builtin_atomics" = "yes" ; then
1108+ if test $opal_cv_have___atomic = "yes" ; then
1109+ opal_cv_asm_builtin="BUILTIN_GCC"
1110+ else
1111+ AC_MSG_WARN ( [ GCC built-in atomics requested but not found.] )
1112+ AC_MSG_ERROR ( [ Cannot continue] )
1113+ fi
11631114 fi
11641115
11651116 OPAL_CHECK_ASM_PROC
@@ -1176,7 +1127,12 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
11761127 # find our architecture for purposes of assembly stuff
11771128 opal_cv_asm_arch="UNSUPPORTED"
11781129 OPAL_GCC_INLINE_ASSIGN=""
1179- OPAL_ASM_SUPPORT_64BIT=0
1130+ if test "$opal_cv_have___atomic_64" ; then
1131+ OPAL_ASM_SUPPORT_64BIT=1
1132+ else
1133+ OPAL_ASM_SUPPORT_64BIT=0
1134+ fi
1135+
11801136 case "${host}" in
11811137 x86_64-*x32)
11821138 opal_cv_asm_arch="X86_64"
@@ -1194,26 +1150,17 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
11941150 OPAL_CHECK_CMPXCHG16B
11951151 ;;
11961152
1197- ia64-*)
1198- opal_cv_asm_arch="IA64"
1199- OPAL_CHECK_SYNC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_SYNC"] ,
1200- [ AC_MSG_ERROR ( [ No atomic primitives available for $host] ) ] )
1201- ;;
12021153 aarch64*)
12031154 opal_cv_asm_arch="ARM64"
12041155 OPAL_ASM_SUPPORT_64BIT=1
12051156 OPAL_ASM_ARM_VERSION=8
1206- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1207- [ What ARM assembly version to use] )
12081157 OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
12091158 ;;
12101159
12111160 armv7*|arm-*-linux-gnueabihf)
12121161 opal_cv_asm_arch="ARM"
12131162 OPAL_ASM_SUPPORT_64BIT=1
12141163 OPAL_ASM_ARM_VERSION=7
1215- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1216- [ What ARM assembly version to use] )
12171164 OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
12181165 ;;
12191166
@@ -1222,18 +1169,9 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
12221169 OPAL_ASM_SUPPORT_64BIT=0
12231170 OPAL_ASM_ARM_VERSION=6
12241171 CCASFLAGS="$CCASFLAGS -march=armv7-a"
1225- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1226- [ What ARM assembly version to use] )
12271172 OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
12281173 ;;
12291174
1230- armv5*linux*|armv4*linux*|arm-*-linux-gnueabi)
1231- # uses Linux kernel helpers for some atomic operations
1232- opal_cv_asm_arch="ARM"
1233- OPAL_CHECK_SYNC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_SYNC"] ,
1234- [ AC_MSG_ERROR ( [ No atomic primitives available for $host] ) ] )
1235- ;;
1236-
12371175 powerpc-*|powerpc64-*|powerpcle-*|powerpc64le-*|rs6000-*|ppc-*)
12381176 OPAL_CHECK_POWERPC_REG
12391177 if test "$ac_cv_sizeof_long" = "4" ; then
@@ -1252,74 +1190,36 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
12521190 fi
12531191 OPAL_GCC_INLINE_ASSIGN='"1: li %0,0" : "=&r"(ret)'
12541192 ;;
1255- sparc*-*)
1256- # SPARC v9 (and above) are the only ones with 64bit support
1257- # if compiling 32 bit, see if we are v9 (aka v8plus) or
1258- # earlier (casa is v8+/v9).
1259- if test "$ac_cv_sizeof_long" = "4" ; then
1260- have_v8plus=0
1261- OPAL_CHECK_SPARCV8PLUS([ have_v8plus=1] )
1262- if test "$have_v8plus" = "0" ; then
1263- OPAL_ASM_SUPPORT_64BIT=0
1264- opal_cv_asm_arch="SPARC"
1265- AC_MSG_WARN ( [ Sparc v8 target is not supported in this release of Open MPI.] )
1266- AC_MSG_WARN ( [ You must specify the target architecture v8plus to compile] )
1267- AC_MSG_WARN ( [ Open MPI in 32 bit mode on Sparc processors (see the README).] )
1268- AC_MSG_ERROR ( [ Can not continue.] )
1269- else
1270- OPAL_ASM_SUPPORT_64BIT=1
1271- opal_cv_asm_arch="SPARCV9_32"
1272- fi
1273-
1274- elif test "$ac_cv_sizeof_long" = "8" ; then
1275- OPAL_ASM_SUPPORT_64BIT=1
1276- opal_cv_asm_arch="SPARCV9_64"
1277- else
1278- AC_MSG_ERROR ( [ Could not determine Sparc word size: $ac_cv_sizeof_long] )
1279- fi
1280- OPAL_GCC_INLINE_ASSIGN='"mov 0,%0" : "=&r"(ret)'
1281- ;;
1282-
12831193 *)
1284- OPAL_CHECK_SYNC_BUILTINS([ opal_cv_asm_builtin="BUILTIN_SYNC"] ,
1285- [ AC_MSG_ERROR ( [ No atomic primitives available for $host] ) ] )
1286- ;;
1194+ if test $opal_cv_have___atomic = "yes" ; then
1195+ opal_cv_asm_builtin="BUILTIN_GCC"
1196+ else
1197+ AC_MSG_ERROR ( [ No atomic primitives available for $host] )
1198+ fi
1199+ ;;
12871200 esac
12881201
1289- if test "x$OPAL_ASM_SUPPORT_64BIT" = "x1" && test "$opal_cv_asm_builtin" = "BUILTIN_SYNC" &&
1290- test "$opal_asm_sync_have_64bit" = "0" ; then
1291- # __sync builtins exist but do not implement 64-bit support. Fall back on inline asm.
1292- opal_cv_asm_builtin="BUILTIN_NO"
1293- fi
1202+ if ! test -z "$OPAL_ASM_ARM_VERSION" ; then
1203+ AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1204+ [ What ARM assembly version to use] )
1205+ fi
12941206
1295- if test "$opal_cv_asm_builtin" = "BUILTIN_SYNC" || test "$opal_cv_asm_builtin" = "BUILTIN_GCC" ; then
1296- AC_DEFINE ( [ OPAL_C_GCC_INLINE_ASSEMBLY] , [ 1] ,
1297- [ Whether C compiler supports GCC style inline assembly] )
1298- else
1299- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_SUPPORT_64BIT] ,
1300- [ $OPAL_ASM_SUPPORT_64BIT] ,
1301- [ Whether we can do 64bit assembly operations or not. Should not be used outside of the assembly header files] )
1302- AC_SUBST ( [ OPAL_ASM_SUPPORT_64BIT] )
1303-
1304- #
1305- # figure out if we need any special function start / stop code
1306- #
1307- case $host_os in
1308- aix*)
1309- opal_asm_arch_config="aix"
1310- ;;
1311- *)
1312- opal_asm_arch_config="default"
1313- ;;
1314- esac
1207+ if test "$opal_cv_asm_builtin" = "BUILTIN_GCC" ; then
1208+ AC_DEFINE ( [ OPAL_C_GCC_INLINE_ASSEMBLY] , [ 1] ,
1209+ [ Whether C compiler supports GCC style inline assembly] )
1210+ else
1211+ AC_DEFINE_UNQUOTED ( [ OPAL_ASM_SUPPORT_64BIT] ,
1212+ [ $OPAL_ASM_SUPPORT_64BIT] ,
1213+ [ Whether we can do 64bit assembly operations or not. Should not be used outside of the assembly header files] )
1214+ AC_SUBST ( [ OPAL_ASM_SUPPORT_64BIT] )
13151215
13161216 opal_cv_asm_inline_supported="no"
13171217 # now that we know our architecture, try to inline assemble
13181218 OPAL_CHECK_INLINE_C_GCC([ $OPAL_GCC_INLINE_ASSIGN] )
13191219
13201220 # format:
13211221 # config_file-text-global-label_suffix-gsym-lsym-type-size-align_log-ppc_r_reg-64_bit-gnu_stack
1322- asm_format="${opal_asm_arch_config} "
1222+ asm_format="default "
13231223 asm_format="${asm_format}-${opal_cv_asm_text}-${opal_cv_asm_global}"
13241224 asm_format="${asm_format}-${opal_cv_asm_label_suffix}-${opal_cv_asm_gsym}"
13251225 asm_format="${asm_format}-${opal_cv_asm_lsym}"
@@ -1342,7 +1242,7 @@ AC_MSG_ERROR([Can not continue.])
13421242 AC_DEFINE_UNQUOTED ( [ OPAL_ASSEMBLY_FORMAT] , [ "$OPAL_ASSEMBLY_FORMAT"] ,
13431243 [ Format of assembly file] )
13441244 AC_SUBST ( [ OPAL_ASSEMBLY_FORMAT] )
1345- fi # if opal_cv_asm_builtin = BUILTIN_SYNC
1245+ fi # if opal_cv_asm_builtin = BUILTIN_GCC
13461246
13471247 result="OPAL_$opal_cv_asm_arch"
13481248 OPAL_ASSEMBLY_ARCH="$opal_cv_asm_arch"
@@ -1400,7 +1300,7 @@ AC_DEFUN([OPAL_ASM_FIND_FILE], [
14001300 AC_REQUIRE ( [ AC_PROG_GREP ] )
14011301 AC_REQUIRE ( [ AC_PROG_FGREP ] )
14021302
1403- if test "$opal_cv_asm_arch" != "WINDOWS" && test "$opal_cv_asm_builtin" != "BUILTIN_SYNC" && test "$opal_cv_asm_builtin" != " BUILTIN_GCC" && test "$opal_cv_asm_builtin" != "BUILTIN_OSX" && test "$opal_cv_asm_inline_arch" = "no" ; then
1303+ if test "$opal_cv_asm_arch" != "WINDOWS" && test "$opal_cv_asm_builtin" != "BUILTIN_GCC" && test "$opal_cv_asm_builtin" != "BUILTIN_OSX" && test "$opal_cv_asm_inline_arch" = "no" ; then
14041304 AC_MSG_ERROR ( [ no atomic support available. exiting] )
14051305else
14061306 # On windows with VC++, atomics are done with compiler primitives
0 commit comments