mirror of git://gcc.gnu.org/git/gcc.git
GCN, nvptx libstdc++: Force use of '__atomic' builtins [PR119645]
For both GCN, nvptx, this gets rid of 'configure'-time:
configure: WARNING: No native atomic operations are provided for this platform.
configure: WARNING: They will be faked using a mutex.
configure: WARNING: Performance of certain classes will degrade as a result.
..., and changes:
-checking for lock policy for shared_ptr reference counts... mutex
+checking for lock policy for shared_ptr reference counts... atomic
That means, '[...]/[target]/libstdc++-v3/', 'Makefile's change:
-ATOMICITY_SRCDIR = config/cpu/generic/atomicity_mutex
+ATOMICITY_SRCDIR = config/cpu/generic/atomicity_builtins
..., and '[...]/[target]/libstdc++-v3/config.h' changes:
/* Defined if shared_ptr reference counting should use atomic operations. */
-/* #undef HAVE_ATOMIC_LOCK_POLICY */
+#define HAVE_ATOMIC_LOCK_POLICY 1
/* Define if the compiler supports C++11 atomics. */
-/* #undef _GLIBCXX_ATOMIC_BUILTINS */
+#define _GLIBCXX_ATOMIC_BUILTINS 1
..., and '[...]/[target]/libstdc++-v3/include/[target]/bits/c++config.h'
changes:
/* Defined if shared_ptr reference counting should use atomic operations. */
-/* #undef _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY */
+#define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1
/* Define if the compiler supports C++11 atomics. */
-/* #undef _GLIBCXX_ATOMIC_BUILTINS */
+#define _GLIBCXX_ATOMIC_BUILTINS 1
This means that '[...]/[target]/libstdc++-v3/libsupc++/atomicity.cc',
'[...]/[target]/libstdc++-v3/libsupc++/atomicity.o' then uses atomic
instructions for synchronization instead of C++ static local variables, which
in turn for their guard variables, via 'libstdc++-v3/libsupc++/guard.cc', used
'libgcc/gthr.h' recursive mutexes, which currently are unsupported for GCN.
For GCN, this turns ~500 libstdc++ execution test FAILs into PASSes, and also
progresses:
PASS: g++.dg/tree-ssa/pr20458.C -std=gnu++17 (test for excess errors)
[-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C -std=gnu++17 execution test
PASS: g++.dg/tree-ssa/pr20458.C -std=gnu++26 (test for excess errors)
[-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C -std=gnu++26 execution test
UNSUPPORTED: g++.dg/tree-ssa/pr20458.C -std=gnu++98: exception handling not supported
(For nvptx, there is no effective change, due to other misconfiguration.)
PR target/119645
libstdc++-v3/
* acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY) [GCN, nvptx]:
Hard-code results.
* configure: Regenerate.
* configure.host [GCN, nvptx] (atomicity_dir): Set to
'cpu/generic/atomicity_builtins'.
(cherry picked from commit 059b5509c1)
This commit is contained in:
parent
2c87363e91
commit
0804fea065
|
|
@ -1,5 +1,15 @@
|
||||||
2025-04-17 Thomas Schwinge <tschwinge@baylibre.com>
|
2025-04-17 Thomas Schwinge <tschwinge@baylibre.com>
|
||||||
|
|
||||||
|
Backported from trunk:
|
||||||
|
2025-04-07 Thomas Schwinge <tschwinge@baylibre.com>
|
||||||
|
|
||||||
|
PR target/119645
|
||||||
|
* acinclude.m4 (GLIBCXX_ENABLE_LOCK_POLICY) [GCN, nvptx]:
|
||||||
|
Hard-code results.
|
||||||
|
* configure: Regenerate.
|
||||||
|
* configure.host [GCN, nvptx] (atomicity_dir): Set to
|
||||||
|
'cpu/generic/atomicity_builtins'.
|
||||||
|
|
||||||
Backported from trunk:
|
Backported from trunk:
|
||||||
2025-04-03 Thomas Schwinge <tschwinge@baylibre.com>
|
2025-04-03 Thomas Schwinge <tschwinge@baylibre.com>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4023,10 +4023,11 @@ AC_DEFUN([GLIBCXX_ENABLE_LOCK_POLICY], [
|
||||||
dnl Why don't we check 8-byte CAS for sparc64, where _Atomic_word is long?!
|
dnl Why don't we check 8-byte CAS for sparc64, where _Atomic_word is long?!
|
||||||
dnl New targets should only check for CAS for the _Atomic_word type.
|
dnl New targets should only check for CAS for the _Atomic_word type.
|
||||||
AC_TRY_COMPILE([
|
AC_TRY_COMPILE([
|
||||||
#if defined __riscv
|
#if defined __AMDGCN__ || defined __nvptx__
|
||||||
|
/* Yes, please. */
|
||||||
|
#elif defined __riscv
|
||||||
# error "Defaulting to mutex-based locks for ABI compatibility"
|
# error "Defaulting to mutex-based locks for ABI compatibility"
|
||||||
#endif
|
#elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
|
||||||
#if ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
|
|
||||||
# error "No 2-byte compare-and-swap"
|
# error "No 2-byte compare-and-swap"
|
||||||
#elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
|
#elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
|
||||||
# error "No 4-byte compare-and-swap"
|
# error "No 4-byte compare-and-swap"
|
||||||
|
|
|
||||||
|
|
@ -16394,10 +16394,11 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
/* end confdefs.h. */
|
/* end confdefs.h. */
|
||||||
|
|
||||||
#if defined __riscv
|
#if defined __AMDGCN__ || defined __nvptx__
|
||||||
|
/* Yes, please. */
|
||||||
|
#elif defined __riscv
|
||||||
# error "Defaulting to mutex-based locks for ABI compatibility"
|
# error "Defaulting to mutex-based locks for ABI compatibility"
|
||||||
#endif
|
#elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
|
||||||
#if ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
|
|
||||||
# error "No 2-byte compare-and-swap"
|
# error "No 2-byte compare-and-swap"
|
||||||
#elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
|
#elif ! defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
|
||||||
# error "No 4-byte compare-and-swap"
|
# error "No 4-byte compare-and-swap"
|
||||||
|
|
@ -16444,7 +16445,7 @@ $as_echo "mutex" >&6; }
|
||||||
# unnecessary for this test.
|
# unnecessary for this test.
|
||||||
|
|
||||||
cat > conftest.$ac_ext << EOF
|
cat > conftest.$ac_ext << EOF
|
||||||
#line 16447 "configure"
|
#line 16448 "configure"
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
_Decimal32 d1;
|
_Decimal32 d1;
|
||||||
|
|
@ -16486,7 +16487,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||||
# unnecessary for this test.
|
# unnecessary for this test.
|
||||||
|
|
||||||
cat > conftest.$ac_ext << EOF
|
cat > conftest.$ac_ext << EOF
|
||||||
#line 16489 "configure"
|
#line 16490 "configure"
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct same
|
struct same
|
||||||
{ typedef T2 type; };
|
{ typedef T2 type; };
|
||||||
|
|
|
||||||
|
|
@ -370,10 +370,21 @@ case "${host}" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
amdgcn-*-amdhsa)
|
||||||
|
# To avoid greater pain elsewhere, force use of '__atomic' builtins,
|
||||||
|
# regardless of the outcome of 'configure' checks; see PR119645
|
||||||
|
# "GCN, nvptx: libstdc++ 'checking for atomic builtins [...]... no'".
|
||||||
|
atomicity_dir=cpu/generic/atomicity_builtins
|
||||||
|
;;
|
||||||
arm*-*-freebsd*)
|
arm*-*-freebsd*)
|
||||||
port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
|
port_specific_symbol_files="\$(srcdir)/../config/os/gnu-linux/arm-eabi-extra.ver"
|
||||||
;;
|
;;
|
||||||
nvptx-*-none)
|
nvptx-*-none)
|
||||||
|
# To avoid greater pain elsewhere, force use of '__atomic' builtins,
|
||||||
|
# regardless of the outcome of 'configure' checks; see PR119645
|
||||||
|
# "GCN, nvptx: libstdc++ 'checking for atomic builtins [...]... no'".
|
||||||
|
atomicity_dir=cpu/generic/atomicity_builtins
|
||||||
|
|
||||||
# For 'make all-target-libstdc++-v3', re 'alloca'/VLA usage:
|
# For 'make all-target-libstdc++-v3', re 'alloca'/VLA usage:
|
||||||
EXTRA_CFLAGS="${EXTRA_CFLAGS} -mfake-ptx-alloca"
|
EXTRA_CFLAGS="${EXTRA_CFLAGS} -mfake-ptx-alloca"
|
||||||
OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} -mfake-ptx-alloca"
|
OPTIMIZE_CXXFLAGS="${OPTIMIZE_CXXFLAGS} -mfake-ptx-alloca"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue