@@ -13,7 +13,7 @@ dnl Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved.
1313dnl Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
1414dnl Copyright (c) 2015-2017 Research Organization for Information Science
1515dnl and Technology (RIST). All rights reserved.
16- dnl Copyright (c) 2014-2016 Los Alamos National Security, LLC. All rights
16+ dnl Copyright (c) 2014-2017 Los Alamos National Security, LLC. All rights
1717dnl reserved.
1818dnl Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights
1919dnl reserved.
@@ -194,9 +194,15 @@ AC_DEFUN([PMIX_CHECK_GCC_BUILTIN_CSWAP_INT128], [
194194AC_DEFUN ( [ PMIX_CHECK_GCC_ATOMIC_BUILTINS] , [
195195 AC_MSG_CHECKING ( [ for __atomic builtin atomics] )
196196
197- AC_TRY_LINK ( [ long tmp, old = 0;] , [ __atomic_thread_fence(__ATOMIC_SEQ_CST);
197+ AC_TRY_LINK ( [
198+ #include <stdint.h>
199+ uint32_t tmp, old = 0;
200+ uint64_t tmp64, old64 = 0;] , [
201+ __atomic_thread_fence(__ATOMIC_SEQ_CST);
198202__atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
199- __atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);] ,
203+ __atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
204+ __atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
205+ __atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);] ,
200206 [ AC_MSG_RESULT ( [ yes] )
201207 $1 ] ,
202208 [ AC_MSG_RESULT ( [ no] )
@@ -879,6 +885,7 @@ return ret;
879885
880886 if test "$asm_result" = "yes" ; then
881887 PMIX_C_GCC_INLINE_ASSEMBLY=1
888+ pmix_cv_asm_inline_supported="yes"
882889 else
883890 PMIX_C_GCC_INLINE_ASSEMBLY=0
884891 fi
@@ -890,70 +897,6 @@ return ret;
890897 unset PMIX_C_GCC_INLINE_ASSEMBLY assembly asm_result
891898] ) dnl
892899
893-
894- dnl #################################################################
895- dnl
896- dnl PMIX_CHECK_INLINE_DEC
897- dnl
898- dnl DEFINE PMIX_DEC to 0 or 1 depending on DEC
899- dnl support
900- dnl
901- dnl #################################################################
902- AC_DEFUN ( [ PMIX_CHECK_INLINE_C_DEC] ,[
903-
904- AC_MSG_CHECKING ( [ if $CC supports DEC inline assembly] )
905-
906- AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [
907- AC_INCLUDES_DEFAULT
908- #include <c_asm.h>] ,
909- [ [ asm("");
910- return 0;] ] ) ] ,
911- [ asm_result="yes"] , [ asm_result="no"] )
912-
913- AC_MSG_RESULT ( [ $asm_result] )
914-
915- if test "$asm_result" = "yes" ; then
916- PMIX_C_DEC_INLINE_ASSEMBLY=1
917- else
918- PMIX_C_DEC_INLINE_ASSEMBLY=0
919- fi
920-
921- AC_DEFINE_UNQUOTED ( [ PMIX_C_DEC_INLINE_ASSEMBLY] ,
922- [ $PMIX_C_DEC_INLINE_ASSEMBLY] ,
923- [ Whether C compiler supports DEC style inline assembly] )
924-
925- unset PMIX_C_DEC_INLINE_ASSEMBLY asm_result
926- ] ) dnl
927-
928-
929- dnl #################################################################
930- dnl
931- dnl PMIX_CHECK_INLINE_XLC
932- dnl
933- dnl DEFINE PMIX_XLC to 0 or 1 depending on XLC
934- dnl support
935- dnl
936- dnl #################################################################
937- AC_DEFUN ( [ PMIX_CHECK_INLINE_C_XLC] ,[
938-
939- AC_MSG_CHECKING ( [ if $CC supports XLC inline assembly] )
940-
941- PMIX_C_XLC_INLINE_ASSEMBLY=0
942- asm_result="no"
943- if test "$CC" = "xlc" ; then
944- PMIX_XLC_INLINE_ASSEMBLY=1
945- asm_result="yes"
946- fi
947-
948- AC_MSG_RESULT ( [ $asm_result] )
949- AC_DEFINE_UNQUOTED ( [ PMIX_C_XLC_INLINE_ASSEMBLY] ,
950- [ $PMIX_C_XLC_INLINE_ASSEMBLY] ,
951- [ Whether C compiler supports XLC style inline assembly] )
952-
953- unset PMIX_C_XLC_INLINE_ASSEMBLY
954- ] ) dnl
955-
956-
957900dnl #################################################################
958901dnl
959902dnl PMIX_CONFIG_ASM
@@ -975,12 +918,12 @@ AC_DEFUN([PMIX_CONFIG_ASM],[
975918 [ ] , [ enable_builtin_atomics="yes"] )
976919
977920 pmix_cv_asm_builtin="BUILTIN_NO"
978- if test "$pmix_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes" ; then
979- PMIX_CHECK_GCC_ATOMIC_BUILTINS([ pmix_cv_asm_builtin="BUILTIN_GCC"] , [ ] )
980- fi
981- if test "$pmix_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes" ; then
982- PMIX_CHECK_SYNC_BUILTINS( [ pmix_cv_asm_builtin="BUILTIN_SYNC" ] , [ ] )
983- fi
921+ AS_IF ( [ test "$pmix_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" ! = "no" ] ,
922+ [ PMIX_CHECK_GCC_ATOMIC_BUILTINS([ pmix_cv_asm_builtin="BUILTIN_GCC"] , [ ] ) ] )
923+ AS_IF ( [ test "$pmix_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" != "no" ] ,
924+ [ PMIX_CHECK_SYNC_BUILTINS( [ pmix_cv_asm_builtin="BUILTIN_SYNC" ] , [ ] ) ] )
925+ AS_IF ( [ test "$ pmix_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes" ] ,
926+ [ AC_MSG_WARN ( [ __sync builtin atomics requested but not found - proceeding with inline atomics ] ) ] )
984927
985928 PMIX_CHECK_ASM_PROC
986929 PMIX_CHECK_ASM_TEXT
@@ -1084,17 +1027,19 @@ AC_DEFUN([PMIX_CONFIG_ASM],[
10841027 fi
10851028 PMIX_GCC_INLINE_ASSIGN='"1: li %0,0" : "=&r"(ret)'
10861029 ;;
1087-
10881030 # There is no current difference between s390 and s390x
10891031 # But use two different defines in case some come later
10901032 # as s390 is 31bits while s390x is 64bits
10911033 s390-*)
10921034 pmix_cv_asm_arch="S390"
1035+ PMIX_CHECK_SYNC_BUILTINS([ pmix_cv_asm_builtin="BUILTIN_SYNC"] ,
1036+ [ AC_MSG_ERROR ( [ No atomic primitives available for $host] ) ] )
10931037 ;;
10941038 s390x-*)
10951039 pmix_cv_asm_arch="S390X"
1040+ PMIX_CHECK_SYNC_BUILTINS([ pmix_cv_asm_builtin="BUILTIN_SYNC"] ,
1041+ [ AC_MSG_ERROR ( [ No atomic primitives available for $host] ) ] )
10961042 ;;
1097-
10981043 sparc*-*)
10991044 # SPARC v9 (and above) are the only ones with 64bit support
11001045 # if compiling 32 bit, see if we are v9 (aka v8plus) or
@@ -1156,10 +1101,9 @@ AC_MSG_ERROR([Can not continue.])
11561101 ;;
11571102 esac
11581103
1104+ pmix_cv_asm_inline_supported="no"
11591105 # now that we know our architecture, try to inline assemble
11601106 PMIX_CHECK_INLINE_C_GCC([ $PMIX_GCC_INLINE_ASSIGN] )
1161- PMIX_CHECK_INLINE_C_DEC
1162- PMIX_CHECK_INLINE_C_XLC
11631107
11641108 # format:
11651109 # config_file-text-global-label_suffix-gsym-lsym-type-size-align_log-ppc_r_reg-64_bit-gnu_stack
@@ -1244,64 +1188,10 @@ AC_DEFUN([PMIX_ASM_FIND_FILE], [
12441188 AC_REQUIRE ( [ AC_PROG_GREP ] )
12451189 AC_REQUIRE ( [ AC_PROG_FGREP ] )
12461190
1247- if test "$pmix_cv_asm_arch" != "WINDOWS" && test "$pmix_cv_asm_builtin" != "BUILTIN_SYNC" && test "$pmix_cv_asm_builtin" != "BUILTIN_GCC" && test "$pmix_cv_asm_builtin" != "BUILTIN_OSX" ; then
1248- # see if we have a pre-built one already
1249- AC_MSG_CHECKING ( [ for pre-built assembly file] )
1250- pmix_cv_asm_file=""
1251- if $GREP "$pmix_cv_asm_arch" "${PMIX_TOP_SRCDIR}/src/atomics/asm/asm-data.txt" | $FGREP "$pmix_cv_asm_format" >conftest.out 2>&1 ; then
1252- pmix_cv_asm_file="`cut -f3 conftest.out`"
1253- if test ! "$pmix_cv_asm_file" = "" ; then
1254- pmix_cv_asm_file="atomic-${pmix_cv_asm_file}.s"
1255- if test -f "${PMIX_TOP_SRCDIR}/src/atomics/asm/generated/${pmix_cv_asm_file}" ; then
1256- AC_MSG_RESULT ( [ yes ($pmix_cv_asm_file)] )
1257- else
1258- AC_MSG_RESULT ( [ no ($pmix_cv_asm_file not found)] )
1259- pmix_cv_asm_file=""
1260- fi
1261- fi
1262- else
1263- AC_MSG_RESULT ( [ no (not in asm-data)] )
1264- fi
1265- rm -rf conftest.*
1266-
1267- if test "$pmix_cv_asm_file" = "" ; then
1268- # Can we generate a file?
1269- AC_MSG_CHECKING ( [ whether possible to generate assembly file] )
1270- mkdir -p pmix/asm/generated
1271- pmix_cv_asm_file="atomic-local.s"
1272- pmix_try='$PERL $PMIX_TOP_SRCDIR/src/atomics/asm/generate-asm.pl $pmix_cv_asm_arch "$pmix_cv_asm_format" $PMIX_TOP_SRCDIR/src/atomics/asm/base $PMIX_TOP_BUILDDIR/src/atomics/asm/generated/$pmix_cv_asm_file >conftest.out 2>&1'
1273- if AC_TRY_EVAL(pmix_try) ; then
1274- # save the warnings
1275- cat conftest.out >&AC_FD_CC
1276- AC_MSG_RESULT ( [ yes] )
1277- else
1278- # save output
1279- cat conftest.out >&AC_FD_CC
1280- pmix_cv_asm_file=""
1281- AC_MSG_RESULT ( [ failed] )
1282- AC_MSG_WARN ( [ Could not build atomic operations assembly file.] )
1283- AC_MSG_WARN ( [ There will be no atomic operations for this build.] )
1284- fi
1285- fi
1286- rm -rf conftest.*
1191+ if test "$pmix_cv_asm_arch" != "WINDOWS" && test "$pmix_cv_asm_builtin" != "BUILTIN_SYNC" && test "$pmix_cv_asm_builtin" != "BUILTIN_GCC" && test "$pmix_cv_asm_builtin" != "BUILTIN_OSX" && test "$pmix_cv_asm_inline_arch" = "no" ; then
1192+ AC_MSG_ERROR ( [ no atomic support available. exiting] )
12871193else
12881194 # On windows with VC++, atomics are done with compiler primitives
12891195 pmix_cv_asm_file=""
12901196fi
1291-
1292- AC_MSG_CHECKING ( [ for atomic assembly filename] )
1293- if test "$pmix_cv_asm_file" = "" ; then
1294- AC_MSG_RESULT ( [ none] )
1295- result=0
1296- else
1297- AC_MSG_RESULT ( [ $pmix_cv_asm_file] )
1298- result=1
1299- fi
1300-
1301- AC_DEFINE_UNQUOTED ( [ PMIX_HAVE_ASM_FILE] , [ $result] ,
1302- [ Whether there is an atomic assembly file available] )
1303- AM_CONDITIONAL([ PMIX_HAVE_ASM_FILE] , [ test "$result" = "1"] )
1304-
1305- PMIX_ASM_FILE=$pmix_cv_asm_file
1306- AC_SUBST ( PMIX_ASM_FILE )
13071197] ) dnl
0 commit comments