1
1

Merge pull request #7453 from hjelmn/purge_sparc_v9_atomic_support_in_favor_of_just_builtins_for_this_platform

Purge Sparc v9 and sync atomics.
Этот коммит содержится в:
Nathan Hjelm 2020-02-26 14:39:46 -08:00 коммит произвёл GitHub
родитель ceb52126a8 2277453737
Коммит 9cc0f6348d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 80 добавлений и 721 удалений

Просмотреть файл

@ -135,6 +135,7 @@ AC_DEFUN([OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_TEST_SOURCE],[[
typedef union {
uint64_t fake@<:@2@:>@;
_Atomic __int128 real;
__int128 real2;
} ompi128;
static void test1(void)
@ -145,9 +146,8 @@ static void test1(void)
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
ompi128 expected = { .fake = { 0x11EEDDCCBBAA0099, 0x88776655443322FF }};
ompi128 desired = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real,
desired.real, true,
atomic_relaxed, atomic_relaxed);
bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real2,
desired.real);
if ( !(r == false && ptr.real == expected.real)) {
exit(1);
}
@ -158,9 +158,8 @@ static void test2(void)
ompi128 ptr = { .fake = { 0xFFEEDDCCBBAA0099, 0x8877665544332211 }};
ompi128 expected = ptr;
ompi128 desired = { .fake = { 0x1122DDCCBBAA0099, 0x887766554433EEFF }};
bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real,
desired.real, true,
atomic_relaxed, atomic_relaxed);
bool r = atomic_compare_exchange_strong (&ptr.real, &expected.real2,
desired.real);
if (!(r == true && ptr.real == desired.real)) {
exit(2);
}
@ -285,37 +284,6 @@ AC_DEFUN([OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128], [
OPAL_VAR_SCOPE_POP
])
AC_DEFUN([OPAL_CHECK_SYNC_BUILTINS], [
AC_MSG_CHECKING([for __sync builtin atomics])
AC_TRY_LINK([long tmp;], [__sync_synchronize();
__sync_bool_compare_and_swap(&tmp, 0, 1);
__sync_add_and_fetch(&tmp, 1);],
[AC_MSG_RESULT([yes])
$1],
[AC_MSG_RESULT([no])
$2])
AC_MSG_CHECKING([for 64-bit __sync builtin atomics])
AC_TRY_LINK([
#include <stdint.h>
uint64_t tmp;], [
__sync_bool_compare_and_swap(&tmp, 0, 1);
__sync_add_and_fetch(&tmp, 1);],
[AC_MSG_RESULT([yes])
opal_asm_sync_have_64bit=1],
[AC_MSG_RESULT([no])
opal_asm_sync_have_64bit=0])
AC_DEFINE_UNQUOTED([OPAL_ASM_SYNC_HAVE_64BIT],[$opal_asm_sync_have_64bit],
[Whether 64-bit is supported by the __sync builtin atomics])
# Check for 128-bit support
OPAL_CHECK_SYNC_BUILTIN_CSWAP_INT128
])
AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
OPAL_VAR_SCOPE_PUSH([atomic_compare_exchange_n_128_result atomic_compare_exchange_n_128_CFLAGS_save atomic_compare_exchange_n_128_LIBS_save])
@ -361,9 +329,10 @@ AC_DEFUN([OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128], [
])
AC_DEFUN([OPAL_CHECK_GCC_ATOMIC_BUILTINS], [
AC_MSG_CHECKING([for __atomic builtin atomics])
if test -z "$opal_cv_have___atomic" ; then
AC_MSG_CHECKING([for 32-bit GCC built-in atomics])
AC_TRY_LINK([
AC_TRY_LINK([
#include <stdint.h>
uint32_t tmp, old = 0;
uint64_t tmp64, old64 = 0;], [
@ -372,13 +341,39 @@ __atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED
__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
__atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);],
[AC_MSG_RESULT([yes])
$1],
[AC_MSG_RESULT([no])
$2])
[opal_cv_have___atomic=yes],
[opal_cv_have___atomic=no])
# Check for 128-bit support
OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
AC_MSG_RESULT([$opal_cv_have___atomic])
if test $opal_cv_have___atomic = "yes" ; then
AC_MSG_CHECKING([for 64-bit GCC built-in atomics])
AC_TRY_LINK([
#include <stdint.h>
uint64_t tmp64, old64 = 0;], [
__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
__atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);],
[opal_cv_have___atomic_64=yes],
[opal_cv_have___atomic_64=no])
AC_MSG_RESULT([$opal_cv_have___atomic_64])
if test $opal_cv_have___atomic_64 = "yes" ; then
AC_MSG_CHECKING([if 64-bit GCC built-in atomics are lock-free])
AC_RUN_IFELSE([AC_LANG_PROGRAM([], [if (!__atomic_is_lock_free (8, 0)) { return 1; }])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
opal_cv_have___atomic_64=no],
[AC_MSG_RESULT([cannot test -- assume yes (cross compiling)])])
fi
else
opal_cv_have___atomic_64=no
fi
# Check for 128-bit support
OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
fi
])
AC_DEFUN([OPAL_CHECK_C11_CSWAP_INT128], [
@ -425,28 +420,6 @@ AC_DEFUN([OPAL_CHECK_C11_CSWAP_INT128], [
OPAL_VAR_SCOPE_POP
])
AC_DEFUN([OPAL_CHECK_GCC_ATOMIC_BUILTINS], [
AC_MSG_CHECKING([for __atomic builtin atomics])
AC_TRY_LINK([
#include <stdint.h>
uint32_t tmp, old = 0;
uint64_t tmp64, old64 = 0;], [
__atomic_thread_fence(__ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&tmp, &old, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
__atomic_add_fetch(&tmp, 1, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&tmp64, &old64, 1, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
__atomic_add_fetch(&tmp64, 1, __ATOMIC_RELAXED);],
[AC_MSG_RESULT([yes])
$1],
[AC_MSG_RESULT([no])
$2])
# Check for 128-bit support
OPAL_CHECK_GCC_BUILTIN_CSWAP_INT128
])
dnl #################################################################
dnl
dnl OPAL_CHECK_ASM_TEXT
@ -952,29 +925,6 @@ AC_DEFUN([OPAL_CHECK_POWERPC_64BIT],[
])dnl
dnl #################################################################
dnl
dnl OPAL_CHECK_SPARCV8PLUS
dnl
dnl #################################################################
AC_DEFUN([OPAL_CHECK_SPARCV8PLUS],[
AC_MSG_CHECKING([if have Sparc v8+/v9 support])
sparc_result=0
OPAL_TRY_ASSEMBLE([$opal_cv_asm_text
casa [%o0] 0x80, %o1, %o2],
[sparc_result=1],
[sparc_result=0])
if test "$sparc_result" = "1" ; then
AC_MSG_RESULT([yes])
ifelse([$1],,:,[$1])
else
AC_MSG_RESULT([no])
ifelse([$2],,:,[$2])
fi
unset sparc_result
])dnl
dnl #################################################################
dnl
dnl OPAL_CHECK_CMPXCHG16B
@ -1142,9 +1092,11 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
AC_ARG_ENABLE([builtin-atomics],
[AC_HELP_STRING([--enable-builtin-atomics],
[Enable use of __sync builtin atomics (default: disabled)])])
[Enable use of GCC built-in atomics (default: autodetect)])])
OPAL_CHECK_C11_CSWAP_INT128
opal_cv_asm_builtin="BUILTIN_NO"
OPAL_CHECK_GCC_ATOMIC_BUILTINS
if test "x$enable_c11_atomics" != "xno" && test "$opal_cv_c11_supported" = "yes" ; then
opal_cv_asm_builtin="BUILTIN_C11"
@ -1152,14 +1104,13 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
elif test "x$enable_c11_atomics" = "xyes"; then
AC_MSG_WARN([C11 atomics were requested but are not supported])
AC_MSG_ERROR([Cannot continue])
else
opal_cv_asm_builtin="BUILTIN_NO"
AS_IF([test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"],
[OPAL_CHECK_GCC_ATOMIC_BUILTINS([opal_cv_asm_builtin="BUILTIN_GCC"], [])])
AS_IF([test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"],
[OPAL_CHECK_SYNC_BUILTINS([opal_cv_asm_builtin="BUILTIN_SYNC"], [])])
AS_IF([test "$opal_cv_asm_builtin" = "BUILTIN_NO" && test "$enable_builtin_atomics" = "yes"],
[AC_MSG_ERROR([__sync builtin atomics requested but not found.])])
elif test "$enable_builtin_atomics" = "yes" ; then
if test $opal_cv_have___atomic = "yes" ; then
opal_cv_asm_builtin="BUILTIN_GCC"
else
AC_MSG_WARN([GCC built-in atomics requested but not found.])
AC_MSG_ERROR([Cannot continue])
fi
fi
OPAL_CHECK_ASM_PROC
@ -1176,7 +1127,12 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
# find our architecture for purposes of assembly stuff
opal_cv_asm_arch="UNSUPPORTED"
OPAL_GCC_INLINE_ASSIGN=""
OPAL_ASM_SUPPORT_64BIT=0
if test "$opal_cv_have___atomic_64" ; then
OPAL_ASM_SUPPORT_64BIT=1
else
OPAL_ASM_SUPPORT_64BIT=0
fi
case "${host}" in
x86_64-*x32)
opal_cv_asm_arch="X86_64"
@ -1194,17 +1150,10 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
OPAL_CHECK_CMPXCHG16B
;;
ia64-*)
opal_cv_asm_arch="IA64"
OPAL_CHECK_SYNC_BUILTINS([opal_cv_asm_builtin="BUILTIN_SYNC"],
[AC_MSG_ERROR([No atomic primitives available for $host])])
;;
aarch64*)
opal_cv_asm_arch="ARM64"
OPAL_ASM_SUPPORT_64BIT=1
OPAL_ASM_ARM_VERSION=8
AC_DEFINE_UNQUOTED([OPAL_ASM_ARM_VERSION], [$OPAL_ASM_ARM_VERSION],
[What ARM assembly version to use])
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
;;
@ -1212,8 +1161,6 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
opal_cv_asm_arch="ARM"
OPAL_ASM_SUPPORT_64BIT=1
OPAL_ASM_ARM_VERSION=7
AC_DEFINE_UNQUOTED([OPAL_ASM_ARM_VERSION], [$OPAL_ASM_ARM_VERSION],
[What ARM assembly version to use])
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
;;
@ -1222,18 +1169,9 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
OPAL_ASM_SUPPORT_64BIT=0
OPAL_ASM_ARM_VERSION=6
CCASFLAGS="$CCASFLAGS -march=armv7-a"
AC_DEFINE_UNQUOTED([OPAL_ASM_ARM_VERSION], [$OPAL_ASM_ARM_VERSION],
[What ARM assembly version to use])
OPAL_GCC_INLINE_ASSIGN='"mov %0, #0" : "=&r"(ret)'
;;
armv5*linux*|armv4*linux*|arm-*-linux-gnueabi)
# uses Linux kernel helpers for some atomic operations
opal_cv_asm_arch="ARM"
OPAL_CHECK_SYNC_BUILTINS([opal_cv_asm_builtin="BUILTIN_SYNC"],
[AC_MSG_ERROR([No atomic primitives available for $host])])
;;
powerpc-*|powerpc64-*|powerpcle-*|powerpc64le-*|rs6000-*|ppc-*)
OPAL_CHECK_POWERPC_REG
if test "$ac_cv_sizeof_long" = "4" ; then
@ -1252,66 +1190,28 @@ AC_DEFUN([OPAL_CONFIG_ASM],[
fi
OPAL_GCC_INLINE_ASSIGN='"1: li %0,0" : "=&r"(ret)'
;;
sparc*-*)
# SPARC v9 (and above) are the only ones with 64bit support
# if compiling 32 bit, see if we are v9 (aka v8plus) or
# earlier (casa is v8+/v9).
if test "$ac_cv_sizeof_long" = "4" ; then
have_v8plus=0
OPAL_CHECK_SPARCV8PLUS([have_v8plus=1])
if test "$have_v8plus" = "0" ; then
OPAL_ASM_SUPPORT_64BIT=0
opal_cv_asm_arch="SPARC"
AC_MSG_WARN([Sparc v8 target is not supported in this release of Open MPI.])
AC_MSG_WARN([You must specify the target architecture v8plus to compile])
AC_MSG_WARN([Open MPI in 32 bit mode on Sparc processors (see the README).])
AC_MSG_ERROR([Can not continue.])
else
OPAL_ASM_SUPPORT_64BIT=1
opal_cv_asm_arch="SPARCV9_32"
fi
elif test "$ac_cv_sizeof_long" = "8" ; then
OPAL_ASM_SUPPORT_64BIT=1
opal_cv_asm_arch="SPARCV9_64"
else
AC_MSG_ERROR([Could not determine Sparc word size: $ac_cv_sizeof_long])
fi
OPAL_GCC_INLINE_ASSIGN='"mov 0,%0" : "=&r"(ret)'
;;
*)
OPAL_CHECK_SYNC_BUILTINS([opal_cv_asm_builtin="BUILTIN_SYNC"],
[AC_MSG_ERROR([No atomic primitives available for $host])])
;;
if test $opal_cv_have___atomic = "yes" ; then
opal_cv_asm_builtin="BUILTIN_GCC"
else
AC_MSG_ERROR([No atomic primitives available for $host])
fi
;;
esac
if test "x$OPAL_ASM_SUPPORT_64BIT" = "x1" && test "$opal_cv_asm_builtin" = "BUILTIN_SYNC" &&
test "$opal_asm_sync_have_64bit" = "0" ; then
# __sync builtins exist but do not implement 64-bit support. Fall back on inline asm.
opal_cv_asm_builtin="BUILTIN_NO"
fi
if ! test -z "$OPAL_ASM_ARM_VERSION" ; then
AC_DEFINE_UNQUOTED([OPAL_ASM_ARM_VERSION], [$OPAL_ASM_ARM_VERSION],
[What ARM assembly version to use])
fi
if test "$opal_cv_asm_builtin" = "BUILTIN_SYNC" || test "$opal_cv_asm_builtin" = "BUILTIN_GCC" ; then
AC_DEFINE([OPAL_C_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])
AC_SUBST([OPAL_ASM_SUPPORT_64BIT])
#
# figure out if we need any special function start / stop code
#
case $host_os in
aix*)
opal_asm_arch_config="aix"
;;
*)
opal_asm_arch_config="default"
;;
esac
if test "$opal_cv_asm_builtin" = "BUILTIN_GCC" ; then
AC_DEFINE([OPAL_C_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])
AC_SUBST([OPAL_ASM_SUPPORT_64BIT])
opal_cv_asm_inline_supported="no"
# now that we know our architecture, try to inline assemble
@ -1319,7 +1219,7 @@ AC_MSG_ERROR([Can not continue.])
# format:
# config_file-text-global-label_suffix-gsym-lsym-type-size-align_log-ppc_r_reg-64_bit-gnu_stack
asm_format="${opal_asm_arch_config}"
asm_format="default"
asm_format="${asm_format}-${opal_cv_asm_text}-${opal_cv_asm_global}"
asm_format="${asm_format}-${opal_cv_asm_label_suffix}-${opal_cv_asm_gsym}"
asm_format="${asm_format}-${opal_cv_asm_lsym}"
@ -1342,7 +1242,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 opal_cv_asm_builtin = BUILTIN_SYNC
fi # if opal_cv_asm_builtin = BUILTIN_GCC
result="OPAL_$opal_cv_asm_arch"
OPAL_ASSEMBLY_ARCH="$opal_cv_asm_arch"
@ -1400,7 +1300,7 @@ AC_DEFUN([OPAL_ASM_FIND_FILE], [
AC_REQUIRE([AC_PROG_GREP])
AC_REQUIRE([AC_PROG_FGREP])
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
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
AC_MSG_ERROR([no atomic support available. exiting])
else
# On windows with VC++, atomics are done with compiler primitives

Просмотреть файл

@ -15,6 +15,7 @@
# reserved.
# Copyright (c) 2017 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# Copyright (c) 2020 Google, LLC. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -37,6 +38,4 @@ include opal/sys/arm/Makefile.am
include opal/sys/arm64/Makefile.am
include opal/sys/ia32/Makefile.am
include opal/sys/powerpc/Makefile.am
include opal/sys/sparcv9/Makefile.am
include opal/sys/sync_builtin/Makefile.am
include opal/sys/gcc_builtin/Makefile.am

Просмотреть файл

@ -33,24 +33,16 @@
/* Architectures */
#define OPAL_UNSUPPORTED 0000
#define OPAL_IA32 0010
#define OPAL_IA64 0020
#define OPAL_X86_64 0030
#define OPAL_POWERPC32 0050
#define OPAL_POWERPC64 0051
#define OPAL_SPARC 0060
#define OPAL_SPARCV9_32 0061
#define OPAL_SPARCV9_64 0062
#define OPAL_ARM 0100
#define OPAL_ARM64 0101
#define OPAL_BUILTIN_SYNC 0200
#define OPAL_BUILTIN_GCC 0202
#define OPAL_BUILTIN_NO 0203
#define OPAL_BUILTIN_C11 0204
/* Formats */
#define OPAL_DEFAULT 1000 /* standard for given architecture */
#define OPAL_DARWIN 1001 /* Darwin / OS X on PowerPC */
#define OPAL_PPC_LINUX 1002 /* Linux on PowerPC */
#define OPAL_AIX 1003 /* AIX on Power / PowerPC */
#endif /* #ifndef OPAL_SYS_ARCHITECTURE_H */

Просмотреть файл

@ -16,6 +16,7 @@
* reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2020 Google, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -175,18 +176,10 @@ enum {
#include "opal/sys/arm64/atomic.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA32
#include "opal/sys/ia32/atomic.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA64
#include "opal/sys/ia64/atomic.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32
#include "opal/sys/powerpc/atomic.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
#include "opal/sys/powerpc/atomic.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_SPARC
#include "opal/sys/sparc/atomic.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_32
#include "opal/sys/sparcv9/atomic.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_64
#include "opal/sys/sparcv9/atomic.h"
#endif
#ifndef DOXYGEN

Просмотреть файл

@ -44,9 +44,6 @@
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA32
#define __NR_process_vm_readv 347
#define __NR_process_vm_writev 348
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA64
#define __NR_process_vm_readv 1332
#define __NR_process_vm_writev 1333
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32
#define __NR_process_vm_readv 351
#define __NR_process_vm_writev 352

Просмотреть файл

@ -1,23 +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$
#
# 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/sparcv9/atomic.h \
opal/sys/sparcv9/timer.h

Просмотреть файл

@ -1,202 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* 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) 2007 Sun Microsystems, Inc. All rights reserverd.
* Copyright (c) 2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017-2018 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef OPAL_SYS_ARCH_ATOMIC_H
#define OPAL_SYS_ARCH_ATOMIC_H 1
/*
* On sparc v9, use casa and casxa (compare and swap) instructions.
*/
#define ASI_P "0x80"
#define MEMBAR(type) __asm__ __volatile__ ("membar " type : : : "memory")
/**********************************************************************
*
* Define constants for Sparc v9 (Ultra Sparc)
*
*********************************************************************/
#define OPAL_HAVE_ATOMIC_MEM_BARRIER 1
#define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 1
#define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 1
/**********************************************************************
*
* Memory Barriers
*
*********************************************************************/
#if OPAL_GCC_INLINE_ASSEMBLY
static inline void opal_atomic_mb(void)
{
MEMBAR("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad");
}
static inline void opal_atomic_rmb(void)
{
MEMBAR("#LoadLoad");
}
static inline void opal_atomic_wmb(void)
{
MEMBAR("#StoreStore");
}
static inline void opal_atomic_isync(void)
{
}
#endif /* OPAL_GCC_INLINE_ASSEMBLY */
/**********************************************************************
*
* Atomic math operations
*
*********************************************************************/
#if OPAL_GCC_INLINE_ASSEMBLY
static inline bool opal_atomic_compare_exchange_strong_32 (opal_atomic_int32_t *addr, int32_t *oldval, int32_t newval)
{
/* casa [reg(rs1)] %asi, reg(rs2), reg(rd)
*
* if (*(reg(rs1)) == reg(rs2) )
* swap reg(rd), *(reg(rs1))
* else
* reg(rd) = *(reg(rs1))
*/
int32_t prev = newval;
bool ret;
__asm__ __volatile__("casa [%1] " ASI_P ", %2, %0"
: "+r" (prev)
: "r" (addr), "r" (*oldval));
ret = (prev == *oldval);
*oldval = prev;
return ret;
}
static inline bool opal_atomic_compare_exchange_strong_acq_32 (opal_atomic_int32_t *addr, int32_t *oldval, int32_t newval)
{
bool rc;
rc = opal_atomic_compare_exchange_strong_32 (addr, oldval, newval);
opal_atomic_rmb();
return rc;
}
static inline bool opal_atomic_compare_exchange_strong_rel_32 (opal_atomic_int32_t *addr, int32_t *oldval, int32_t newval)
{
opal_atomic_wmb();
return opal_atomic_compare_exchange_strong_32 (addr, oldval, newval);
}
#if OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_64
static inline bool opal_atomic_compare_exchange_strong_64 (opal_atomic_int64_t *addr, int64_t *oldval, int64_t newval)
{
/* casa [reg(rs1)] %asi, reg(rs2), reg(rd)
*
* if (*(reg(rs1)) == reg(rs1) )
* swap reg(rd), *(reg(rs1))
* else
* reg(rd) = *(reg(rs1))
*/
int64_t prev = newval;
bool ret;
__asm__ __volatile__("casxa [%1] " ASI_P ", %2, %0"
: "+r" (prev)
: "r" (addr), "r" (*oldval));
ret = (prev == *oldval);
*oldval = prev;
return ret;
}
#else /* OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_64 */
static inline bool opal_atomic_compare_exchange_strong_64 (opal_atomic_int64_t *addr, int64_t *oldval, int64_t newval)
{
/* casa [reg(rs1)] %asi, reg(rs2), reg(rd)
*
* if (*(reg(rs1)) == reg(rs1) )
* swap reg(rd), *(reg(rs1))
* else
* reg(rd) = *(reg(rs1))
*
*/
int64_t prev = newval;
bool ret;
__asm__ __volatile__(
"ldx %0, %%g1 \n\t" /* g1 = ret */
"ldx %2, %%g2 \n\t" /* g2 = oldval */
"casxa [%1] " ASI_P ", %%g2, %%g1 \n\t"
"stx %%g1, %0 \n"
: "+m"(prev)
: "r"(addr), "m"(*oldval)
: "%g1", "%g2"
);
ret = (prev == *oldval);
*oldval = prev;
return ret;
}
#endif /* OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_64 */
static inline bool opal_atomic_compare_exchange_strong_acq_64 (opal_atomic_int64_t *addr, int64_t *oldval, int64_t newval)
{
bool rc;
rc = opal_atomic_compare_exchange_strong_64 (addr, oldval, newval);
opal_atomic_rmb();
return rc;
}
static inline bool opal_atomic_compare_exchange_strong_rel_64 (opal_atomic_int64_t *addr, int64_t *oldval, int64_t newval)
{
opal_atomic_wmb();
return opal_atomic_compare_exchange_strong_64 (addr, oldval, newval);
}
#endif /* OPAL_GCC_INLINE_ASSEMBLY */
#endif /* ! OPAL_SYS_ARCH_ATOMIC_H */

Просмотреть файл

@ -1,67 +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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef OPAL_SYS_ARCH_TIMER_H
#define OPAL_SYS_ARCH_TIMER_H 1
typedef uint64_t opal_timer_t;
#if OPAL_GCC_INLINE_ASSEMBLY
#if OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_64
static inline opal_timer_t
opal_sys_timer_get_cycles(void)
{
opal_timer_t ret;
__asm__ __volatile__("rd %%tick, %0" : "=r"(ret));
return ret;
}
#else /* OPAL_SPARCV9_32 */
static inline opal_timer_t
opal_sys_timer_get_cycles(void)
{
opal_timer_t ret;
int a, b;
__asm__ __volatile__("rd %%tick, %0 \n"
"srlx %0, 32, %1 " :
"=r"(a), "=r"(b)
);
ret = (0x00000000FFFFFFFF & a) | (((opal_timer_t) b) << 32);
return ret;
}
#endif
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 1
#else
#define OPAL_HAVE_SYS_TIMER_GET_CYCLES 0
#endif /* OPAL_GCC_INLINE_ASSEMBLY */
#endif /* ! OPAL_SYS_ARCH_TIMER_H */

Просмотреть файл

@ -1,37 +0,0 @@
#!/bin/sh
#
# 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$
#
# Additional copyrights may follow
#
# $HEADER$
#
CFILE=/tmp/opal_atomic_$$.c
trap "/bin/rm -f $CFILE; exit 0" 0 1 2 15
echo Updating atomic.s from atomic.h using gcc
cat > $CFILE<<EOF
#include "../architecture.h"
#include <stdlib.h>
#include <inttypes.h>
#define static
#define inline
#define OPAL_GCC_INLINE_ASSEMBLY 1
#include "atomic.h"
EOF
gcc -m64 -O3 -DOPAL_ASSEMBLY_ARCH=OPAL_SPARCV9_64 -I. -S $CFILE -o atomic64.s
gcc -mv8plus -DOPAL_ASSEMBLY_ARCH=OPAL_SPARCV9_32 -O3 -I. -S $CFILE -o atomic32.s

Просмотреть файл

@ -1,23 +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-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

Просмотреть файл

@ -1,165 +0,0 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* 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,
* 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 (c) 2014-2018 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef OPAL_SYS_ARCH_ATOMIC_H
#define OPAL_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();
}
#define MB() opal_atomic_mb()
/**********************************************************************
*
* Atomic math operations
*
*********************************************************************/
#define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 1
static inline bool opal_atomic_compare_exchange_strong_32 (opal_atomic_int32_t *addr, int32_t *oldval, int32_t newval)
{
int32_t prev = __sync_val_compare_and_swap (addr, *oldval, newval);
bool ret = prev == *oldval;
*oldval = prev;
return ret;
}
#define opal_atomic_compare_exchange_strong_acq_32 opal_atomic_compare_exchange_strong_32
#define opal_atomic_compare_exchange_strong_rel_32 opal_atomic_compare_exchange_strong_32
#define OPAL_HAVE_ATOMIC_MATH_32 1
#define OPAL_HAVE_ATOMIC_ADD_32 1
static inline int32_t opal_atomic_fetch_add_32(opal_atomic_int32_t *addr, int32_t delta)
{
return __sync_fetch_and_add(addr, delta);
}
#define OPAL_HAVE_ATOMIC_AND_32 1
static inline int32_t opal_atomic_fetch_and_32(opal_atomic_int32_t *addr, int32_t value)
{
return __sync_fetch_and_and(addr, value);
}
#define OPAL_HAVE_ATOMIC_OR_32 1
static inline int32_t opal_atomic_fetch_or_32(opal_atomic_int32_t *addr, int32_t value)
{
return __sync_fetch_and_or(addr, value);
}
#define OPAL_HAVE_ATOMIC_XOR_32 1
static inline int32_t opal_atomic_fetch_xor_32(opal_atomic_int32_t *addr, int32_t value)
{
return __sync_fetch_and_xor(addr, value);
}
#define OPAL_HAVE_ATOMIC_SUB_32 1
static inline int32_t opal_atomic_fetch_sub_32(opal_atomic_int32_t *addr, int32_t delta)
{
return __sync_fetch_and_sub(addr, delta);
}
#if OPAL_ASM_SYNC_HAVE_64BIT
#define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 1
static inline bool opal_atomic_compare_exchange_strong_64 (opal_atomic_int64_t *addr, int64_t *oldval, int64_t newval)
{
int64_t prev = __sync_val_compare_and_swap (addr, *oldval, newval);
bool ret = prev == *oldval;
*oldval = prev;
return ret;
}
#define opal_atomic_compare_exchange_strong_acq_64 opal_atomic_compare_exchange_strong_64
#define opal_atomic_compare_exchange_strong_rel_64 opal_atomic_compare_exchange_strong_64
#define OPAL_HAVE_ATOMIC_MATH_64 1
#define OPAL_HAVE_ATOMIC_ADD_64 1
static inline int64_t opal_atomic_fetch_add_64(opal_atomic_int64_t *addr, int64_t delta)
{
return __sync_fetch_and_add(addr, delta);
}
#define OPAL_HAVE_ATOMIC_AND_64 1
static inline int64_t opal_atomic_fetch_and_64(opal_atomic_int64_t *addr, int64_t value)
{
return __sync_fetch_and_and(addr, value);
}
#define OPAL_HAVE_ATOMIC_OR_64 1
static inline int64_t opal_atomic_fetch_or_64(opal_atomic_int64_t *addr, int64_t value)
{
return __sync_fetch_and_or(addr, value);
}
#define OPAL_HAVE_ATOMIC_XOR_64 1
static inline int64_t opal_atomic_fetch_xor_64(opal_atomic_int64_t *addr, int64_t value)
{
return __sync_fetch_and_xor(addr, value);
}
#define OPAL_HAVE_ATOMIC_SUB_64 1
static inline int64_t opal_atomic_fetch_sub_64(opal_atomic_int64_t *addr, int64_t delta)
{
return __sync_fetch_and_sub(addr, delta);
}
#endif
#if OPAL_HAVE_SYNC_BUILTIN_CSWAP_INT128
static inline bool opal_atomic_compare_exchange_strong_128 (opal_atomic_int128_t *addr,
opal_int128_t *oldval, opal_int128_t newval)
{
opal_int128_t prev = __sync_val_compare_and_swap (addr, *oldval, newval);
bool ret = prev == *oldval;
*oldval = prev;
return ret;
}
#define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_128 1
#endif
#endif /* ! OPAL_SYS_ARCH_ATOMIC_H */

Просмотреть файл

@ -14,6 +14,7 @@
* Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2020 Intel, Inc. All rights reserved.
* Copyright (c) 2020 Google, LLC. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -79,16 +80,10 @@ BEGIN_C_DECLS
#include "opal/sys/arm64/timer.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA32
#include "opal/sys/ia32/timer.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_IA64
#include "opal/sys/ia64/timer.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32
#include "opal/sys/powerpc/timer.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
#include "opal/sys/powerpc/timer.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_32
#include "opal/sys/sparcv9/timer.h"
#elif OPAL_ASSEMBLY_ARCH == OPAL_SPARCV9_64
#include "opal/sys/sparcv9/timer.h"
#endif
#ifndef DOXYGEN