From eb579fd7d6d9772ab8f16b2ef7fcd71b5b3b6aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Fri, 29 Jul 2022 10:25:14 +0200 Subject: [PATCH] HIP: workaround atomicMax and atomicMin For architectures where __hip_atomic_compare_exchange_strong is false HIP is emulating atomics with `atomicCAS` but with a broken implementation. --- .../alpaka/atomic/AtomicUniformCudaHip.hpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/alpaka/atomic/AtomicUniformCudaHip.hpp b/include/alpaka/atomic/AtomicUniformCudaHip.hpp index 6c61eb53b166..0d09d9652d0c 100644 --- a/include/alpaka/atomic/AtomicUniformCudaHip.hpp +++ b/include/alpaka/atomic/AtomicUniformCudaHip.hpp @@ -222,6 +222,18 @@ inline namespace alpakaGlobal struct AlpakaBuiltInAtomic : std::false_type { }; + +# if !__has_builtin(__hip_atomic_compare_exchange_strong) + template + struct AlpakaBuiltInAtomic : std::false_type + { + }; + + template<> + struct AlpakaBuiltInAtomic : std::false_type + { + }; +# endif # endif // Max. @@ -275,6 +287,18 @@ inline namespace alpakaGlobal struct AlpakaBuiltInAtomic : std::false_type { }; + +# if !__has_builtin(__hip_atomic_compare_exchange_strong) + template + struct AlpakaBuiltInAtomic : std::false_type + { + }; + + template<> + struct AlpakaBuiltInAtomic : std::false_type + { + }; +# endif # endif