From 354bb2bbb4d908045fb038ccdd06c8c08f25c7f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Fri, 22 Dec 2023 09:58:00 +0100 Subject: [PATCH] fix icpx atomic OpenMP methods fix #2205 The compiler requires that the atomics are written in a very spezific syntax else the code is not compiling. --- include/alpaka/atomic/AtomicOmpBuiltIn.hpp | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/include/alpaka/atomic/AtomicOmpBuiltIn.hpp b/include/alpaka/atomic/AtomicOmpBuiltIn.hpp index 440b373fc460..63d6076c5288 100644 --- a/include/alpaka/atomic/AtomicOmpBuiltIn.hpp +++ b/include/alpaka/atomic/AtomicOmpBuiltIn.hpp @@ -179,7 +179,7 @@ namespace alpaka template struct AtomicOp { - ALPAKA_FN_HOST static auto atomicOp(AtomicOmpBuiltIn const&, T* const addr, T const& value) -> T + ALPAKA_FN_HOST static auto atomicOp(AtomicOmpBuiltIn const&, T* const addr, T value) -> T { T old; auto& ref(*addr); @@ -187,8 +187,12 @@ namespace alpaka # pragma omp atomic capture compare { old = ref; + // Do not remove the curly brackets of the if body else + // icpx 2024.0 is not able to compile the atomics. if(value < ref) + { ref = value; + } } return old; } @@ -198,7 +202,7 @@ namespace alpaka template struct AtomicOp { - ALPAKA_FN_HOST static auto atomicOp(AtomicOmpBuiltIn const&, T* const addr, T const& value) -> T + ALPAKA_FN_HOST static auto atomicOp(AtomicOmpBuiltIn const&, T* const addr, T value) -> T { T old; auto& ref(*addr); @@ -206,8 +210,12 @@ namespace alpaka # pragma omp atomic capture compare { old = ref; + // Do not remove the curly brackets of the if body else + // icpx 2024.0 is not able to compile the atomics. if(value > ref) + { ref = value; + } } return old; } @@ -249,11 +257,7 @@ namespace alpaka template struct AtomicOp { - ALPAKA_FN_HOST static auto atomicOp( - AtomicOmpBuiltIn const&, - T* const addr, - T const& compare, - T const& value) -> T + ALPAKA_FN_HOST static auto atomicOp(AtomicOmpBuiltIn const&, T* const addr, T compare, T value) -> T { T old; auto& ref(*addr); @@ -261,7 +265,12 @@ namespace alpaka # pragma omp atomic capture compare { old = ref; - ref = (ref == compare ? value : ref); + // Do not remove the curly brackets of the if body else + // icpx 2024.0 is not able to compile the atomics. + if(ref == compare) + { + ref = value; + } } return old; }