@@ -135,6 +135,7 @@ AC_DEFUN([OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_TEST_SOURCE],[[
135
135
typedef union {
136
136
uint64_t fake@<:@ 2@:>@ ;
137
137
_Atomic __int128 real;
138
+ __int128 real2;
138
139
} ompi128;
139
140
140
141
static void test1(void)
@@ -145,9 +146,8 @@ static void test1(void)
145
146
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
146
147
ompi128 expected = { .fake = { 0x11EEDDCCBBAA0099, 0x88776655443322FF }};
147
148
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);
151
151
if ( !(r == false && ptr.real == expected.real)) {
152
152
exit(1);
153
153
}
@@ -158,9 +158,8 @@ static void test2(void)
158
158
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
159
159
ompi128 expected = ptr;
160
160
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);
164
163
if (!(r == true && ptr.real == desired.real)) {
165
164
exit(2);
166
165
}
@@ -285,37 +284,6 @@ AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
285
284
OPAL_VAR_SCOPE_POP
286
285
] )
287
286
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
-
319
287
AC_DEFUN ( [ OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128] , [
320
288
OPAL_VAR_SCOPE_PUSH([ atomic_compare_exchange_n_128_result atomic_compare_exchange_n_128_CFLAGS_save atomic_compare_exchange_n_128_LIBS_save] )
321
289
@@ -361,9 +329,10 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
361
329
] )
362
330
363
331
AC_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] )
365
334
366
- AC_TRY_LINK ( [
335
+ AC_TRY_LINK ( [
367
336
#include <stdint.h>
368
337
uint32_t tmp, old = 0;
369
338
uint64_t tmp64, old64 = 0;] , [
@@ -372,13 +341,39 @@ __atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED
372
341
__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
373
342
__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
374
343
__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
379
373
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
382
377
] )
383
378
384
379
AC_DEFUN ( [ OPAL_CHECK_C11_CSWAP_INT128] , [
@@ -425,28 +420,6 @@ AC_DEFUN([OPAL_CHECK_C11_CSWAP_INT128], [
425
420
OPAL_VAR_SCOPE_POP
426
421
] )
427
422
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
-
450
423
dnl #################################################################
451
424
dnl
452
425
dnl OPAL_CHECK_ASM_TEXT
@@ -952,29 +925,6 @@ AC_DEFUN([OPAL_CHECK_POWERPC_64BIT],[
952
925
] ) dnl
953
926
954
927
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
-
978
928
dnl #################################################################
979
929
dnl
980
930
dnl OPAL_CHECK_CMPXCHG16B
@@ -1142,24 +1092,25 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1142
1092
1143
1093
AC_ARG_ENABLE ( [ builtin-atomics] ,
1144
1094
[ 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 )] )] )
1146
1096
1147
1097
OPAL_CHECK_C11_CSWAP_INT128
1098
+ opal_cv_asm_builtin="BUILTIN_NO"
1099
+ OPAL_CHECK_GCC_ATOMIC_BUILTINS
1148
1100
1149
1101
if test "x$enable_c11_atomics" != "xno" && test "$opal_cv_c11_supported" = "yes" ; then
1150
1102
opal_cv_asm_builtin="BUILTIN_C11"
1151
1103
OPAL_CHECK_C11_CSWAP_INT128
1152
1104
elif test "x$enable_c11_atomics" = "xyes"; then
1153
1105
AC_MSG_WARN ( [ C11 atomics were requested but are not supported] )
1154
1106
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
1163
1114
fi
1164
1115
1165
1116
OPAL_CHECK_ASM_PROC
@@ -1176,7 +1127,12 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1176
1127
# find our architecture for purposes of assembly stuff
1177
1128
opal_cv_asm_arch="UNSUPPORTED"
1178
1129
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
+
1180
1136
case "${host}" in
1181
1137
x86_64-*x32)
1182
1138
opal_cv_asm_arch="X86_64"
@@ -1194,26 +1150,17 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1194
1150
OPAL_CHECK_CMPXCHG16B
1195
1151
;;
1196
1152
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
- ;;
1202
1153
aarch64*)
1203
1154
opal_cv_asm_arch="ARM64"
1204
1155
OPAL_ASM_SUPPORT_64BIT=1
1205
1156
OPAL_ASM_ARM_VERSION=8
1206
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1207
- [ What ARM assembly version to use] )
1208
1157
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
1209
1158
;;
1210
1159
1211
1160
armv7*|arm-*-linux-gnueabihf)
1212
1161
opal_cv_asm_arch="ARM"
1213
1162
OPAL_ASM_SUPPORT_64BIT=1
1214
1163
OPAL_ASM_ARM_VERSION=7
1215
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1216
- [ What ARM assembly version to use] )
1217
1164
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
1218
1165
;;
1219
1166
@@ -1222,18 +1169,9 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1222
1169
OPAL_ASM_SUPPORT_64BIT=0
1223
1170
OPAL_ASM_ARM_VERSION=6
1224
1171
CCASFLAGS="$CCASFLAGS -march=armv7-a"
1225
- AC_DEFINE_UNQUOTED ( [ OPAL_ASM_ARM_VERSION] , [ $OPAL_ASM_ARM_VERSION] ,
1226
- [ What ARM assembly version to use] )
1227
1172
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
1228
1173
;;
1229
1174
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
-
1237
1175
powerpc-*|powerpc64-*|powerpcle-*|powerpc64le-*|rs6000-*|ppc-*)
1238
1176
OPAL_CHECK_POWERPC_REG
1239
1177
if test "$ac_cv_sizeof_long" = "4" ; then
@@ -1252,74 +1190,36 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
1252
1190
fi
1253
1191
OPAL_GCC_INLINE_ASSIGN='"1: li %0,0" : "=&r"(ret)'
1254
1192
;;
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
-
1283
1193
*)
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
+ ;;
1287
1200
esac
1288
1201
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
1294
1206
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] )
1315
1215
1316
1216
opal_cv_asm_inline_supported="no"
1317
1217
# now that we know our architecture, try to inline assemble
1318
1218
OPAL_CHECK_INLINE_C_GCC([ $OPAL_GCC_INLINE_ASSIGN] )
1319
1219
1320
1220
# format:
1321
1221
# 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 "
1323
1223
asm_format="${asm_format}-${opal_cv_asm_text}-${opal_cv_asm_global}"
1324
1224
asm_format="${asm_format}-${opal_cv_asm_label_suffix}-${opal_cv_asm_gsym}"
1325
1225
asm_format="${asm_format}-${opal_cv_asm_lsym}"
@@ -1342,7 +1242,7 @@ AC_MSG_ERROR([Can not continue.])
1342
1242
AC_DEFINE_UNQUOTED ( [ OPAL_ASSEMBLY_FORMAT] , [ "$OPAL_ASSEMBLY_FORMAT"] ,
1343
1243
[ Format of assembly file] )
1344
1244
AC_SUBST ( [ OPAL_ASSEMBLY_FORMAT] )
1345
- fi # if opal_cv_asm_builtin = BUILTIN_SYNC
1245
+ fi # if opal_cv_asm_builtin = BUILTIN_GCC
1346
1246
1347
1247
result="OPAL_$opal_cv_asm_arch"
1348
1248
OPAL_ASSEMBLY_ARCH="$opal_cv_asm_arch"
@@ -1400,7 +1300,7 @@ AC_DEFUN([OPAL_ASM_FIND_FILE], [
1400
1300
AC_REQUIRE ( [ AC_PROG_GREP ] )
1401
1301
AC_REQUIRE ( [ AC_PROG_FGREP ] )
1402
1302
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
1404
1304
AC_MSG_ERROR ( [ no atomic support available. exiting] )
1405
1305
else
1406
1306
# On windows with VC++, atomics are done with compiler primitives
0 commit comments