From 6a223f39837d8fddb6de572783d9c643250545cc Mon Sep 17 00:00:00 2001 From: Pansysk75 Date: Thu, 10 Oct 2024 13:34:22 -0500 Subject: [PATCH] Fix omp vectorization pragma errors --- .jenkins/lsu/env-clang-17.sh | 1 + .jenkins/lsu/env-gcc-13.sh | 1 + .../include/hpx/parallel/unseq/loop.hpp | 34 +++++++++---------- .../hpx/parallel/unseq/reduce_helpers.hpp | 34 +++++++++---------- .../hpx/parallel/unseq/transform_loop.hpp | 8 ++--- .../include/hpx/parallel/util/loop.hpp | 33 +++++++++--------- 6 files changed, 55 insertions(+), 56 deletions(-) diff --git a/.jenkins/lsu/env-clang-17.sh b/.jenkins/lsu/env-clang-17.sh index cf8ef3e3aed5..b307443ff475 100644 --- a/.jenkins/lsu/env-clang-17.sh +++ b/.jenkins/lsu/env-clang-17.sh @@ -18,6 +18,7 @@ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH configure_extra_options+=" -DCMAKE_BUILD_TYPE=${build_type}" configure_extra_options+=" -DHPX_WITH_CXX_STANDARD=${CXX_STD}" +configure_extra_options+=" -DCMAKE_CXX_FLAGS=-fopenmp" configure_extra_options+=" -DHPX_WITH_MALLOC=system" configure_extra_options+=" -DHPX_WITH_FETCH_ASIO=ON" configure_extra_options+=" -DHPX_WITH_COMPILER_WARNINGS=ON" diff --git a/.jenkins/lsu/env-gcc-13.sh b/.jenkins/lsu/env-gcc-13.sh index 06910b0f4037..e59dc916d0ef 100644 --- a/.jenkins/lsu/env-gcc-13.sh +++ b/.jenkins/lsu/env-gcc-13.sh @@ -17,6 +17,7 @@ export CXX_STD="20" export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH configure_extra_options+=" -DHPX_WITH_CXX_STANDARD=${CXX_STD}" +configure_extra_options+=" -DCMAKE_CXX_FLAGS=-fopenmp" configure_extra_options+=" -DHPX_WITH_MALLOC=system" configure_extra_options+=" -DHPX_WITH_FETCH_ASIO=ON" configure_extra_options+=" -DHPX_WITH_COMPILER_WARNINGS=ON" diff --git a/libs/core/algorithms/include/hpx/parallel/unseq/loop.hpp b/libs/core/algorithms/include/hpx/parallel/unseq/loop.hpp index 3b7e5d3c7526..bb9ce0bd5039 100644 --- a/libs/core/algorithms/include/hpx/parallel/unseq/loop.hpp +++ b/libs/core/algorithms/include/hpx/parallel/unseq/loop.hpp @@ -26,7 +26,7 @@ namespace hpx::parallel::util { struct unseq_loop_n { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr InIter call( + HPX_HOST_DEVICE HPX_FORCEINLINE static InIter call( InIter HPX_RESTRICT it, std::size_t num, F&& f) { // clang-format off @@ -136,7 +136,7 @@ namespace hpx::parallel::util { { template HPX_HOST_DEVICE - HPX_FORCEINLINE static constexpr std::pair + HPX_FORCEINLINE static std::pair call(InIter1 HPX_RESTRICT it1, InIter1 HPX_RESTRICT last1, InIter2 HPX_RESTRICT it2, F&& f) { @@ -216,19 +216,18 @@ namespace hpx::parallel::util { // clang-format off HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (std::size_t i = 0; i < count; - (void) ++it, i += 4) // -V112 + for (std::size_t i = 0; i < count; i += 4) // -V112 { - HPX_INVOKE(f, it); - HPX_INVOKE(f, ++it); - HPX_INVOKE(f, ++it); - HPX_INVOKE(f, ++it); + HPX_INVOKE(f, it++); + HPX_INVOKE(f, it++); + HPX_INVOKE(f, it++); + HPX_INVOKE(f, it++); } HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (/**/; count < num; (void) ++count, ++it) + for (std::size_t i = count; i < num; ++i) { - HPX_INVOKE(f, it); + HPX_INVOKE(f, it++); } // clang-format on @@ -256,19 +255,18 @@ namespace hpx::parallel::util { // clang-format off HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (std::size_t i = 0; i < count; (void) ++it, ++dest, - i += 4) // -V112 + for (std::size_t i = 0; i < count; i += 4) // -V112 { - HPX_INVOKE(f, it, dest); - HPX_INVOKE(f, ++it, ++dest); - HPX_INVOKE(f, ++it, ++dest); - HPX_INVOKE(f, ++it, ++dest); + HPX_INVOKE(f, it++, dest++); + HPX_INVOKE(f, it++, dest++); + HPX_INVOKE(f, it++, dest++); + HPX_INVOKE(f, it++, dest++); } HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (/**/; count < num; (void) ++count, ++it, ++dest) + for (std::size_t i = count; i < num; ++i) { - HPX_INVOKE(f, it, dest); + HPX_INVOKE(f, it++, dest++); } //clang-format on diff --git a/libs/core/algorithms/include/hpx/parallel/unseq/reduce_helpers.hpp b/libs/core/algorithms/include/hpx/parallel/unseq/reduce_helpers.hpp index 4f89171ee642..53536b4ad92e 100644 --- a/libs/core/algorithms/include/hpx/parallel/unseq/reduce_helpers.hpp +++ b/libs/core/algorithms/include/hpx/parallel/unseq/reduce_helpers.hpp @@ -85,7 +85,7 @@ namespace hpx::parallel::util::detail { { #if defined(HPX_HAVE_VECTOR_REDUCTION) template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_plus_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -99,7 +99,7 @@ namespace hpx::parallel::util::detail { } template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_minus_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -113,7 +113,7 @@ namespace hpx::parallel::util::detail { } template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_multiplies_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -127,7 +127,7 @@ namespace hpx::parallel::util::detail { } template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_bit_and_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -141,7 +141,7 @@ namespace hpx::parallel::util::detail { } template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_bit_or_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -155,7 +155,7 @@ namespace hpx::parallel::util::detail { } template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_bit_xor_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -169,7 +169,7 @@ namespace hpx::parallel::util::detail { } template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_logical_and_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -183,7 +183,7 @@ namespace hpx::parallel::util::detail { } template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_logical_or_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce /* */, Convert conv) { @@ -197,7 +197,7 @@ namespace hpx::parallel::util::detail { } #endif template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_not_omp_reduction_v, T> reduce(Iter1 it, std::size_t count, T init, Reduce r, Convert conv) { @@ -274,7 +274,7 @@ namespace hpx::parallel::util::detail { #if defined(HPX_HAVE_VECTOR_REDUCTION) template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_plus_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce /* */, Convert conv) @@ -290,7 +290,7 @@ namespace hpx::parallel::util::detail { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_minus_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce /* */, Convert conv) @@ -306,7 +306,7 @@ namespace hpx::parallel::util::detail { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_multiplies_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce /* */, Convert conv) @@ -322,7 +322,7 @@ namespace hpx::parallel::util::detail { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_bit_and_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce /* */, Convert conv) @@ -338,7 +338,7 @@ namespace hpx::parallel::util::detail { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_bit_or_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce /* */, Convert conv) @@ -370,7 +370,7 @@ namespace hpx::parallel::util::detail { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_logical_and_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce /* */, Convert conv) @@ -386,7 +386,7 @@ namespace hpx::parallel::util::detail { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_arithmetic_logical_or_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce /* */, Convert conv) @@ -402,7 +402,7 @@ namespace hpx::parallel::util::detail { #endif template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr std::enable_if_t< + HPX_HOST_DEVICE HPX_FORCEINLINE static std::enable_if_t< is_not_omp_reduction_v, T> reduce(Iter1 it1, Iter2 it2, std::size_t count, T init, Reduce r, Convert conv) diff --git a/libs/core/algorithms/include/hpx/parallel/unseq/transform_loop.hpp b/libs/core/algorithms/include/hpx/parallel/unseq/transform_loop.hpp index 08423c3842ee..dfe859dc4a30 100644 --- a/libs/core/algorithms/include/hpx/parallel/unseq/transform_loop.hpp +++ b/libs/core/algorithms/include/hpx/parallel/unseq/transform_loop.hpp @@ -26,7 +26,7 @@ namespace hpx::parallel::util { { template HPX_HOST_DEVICE - HPX_FORCEINLINE static constexpr std::pair + HPX_FORCEINLINE static std::pair call(InIter HPX_RESTRICT it, std::size_t num, OutIter HPX_RESTRICT dest, F&& f) { @@ -76,7 +76,7 @@ namespace hpx::parallel::util { { template HPX_HOST_DEVICE - HPX_FORCEINLINE static constexpr std::pair + HPX_FORCEINLINE static std::pair call(InIter HPX_RESTRICT it, std::size_t num, OutIter HPX_RESTRICT dest, F&& f) { @@ -240,7 +240,7 @@ namespace hpx::parallel::util { { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr hpx::tuple call(InIter1 HPX_RESTRICT first1, std::size_t num, InIter2 HPX_RESTRICT first2, OutIter HPX_RESTRICT dest, F&& f) @@ -401,7 +401,7 @@ namespace hpx::parallel::util { { template - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr hpx::tuple call(InIter1 HPX_RESTRICT first1, std::size_t num, InIter2 HPX_RESTRICT first2, OutIter HPX_RESTRICT dest, F&& f) diff --git a/libs/core/algorithms/include/hpx/parallel/util/loop.hpp b/libs/core/algorithms/include/hpx/parallel/util/loop.hpp index b3207bc980e7..ff5dea5c3105 100644 --- a/libs/core/algorithms/include/hpx/parallel/util/loop.hpp +++ b/libs/core/algorithms/include/hpx/parallel/util/loop.hpp @@ -58,14 +58,14 @@ namespace hpx::parallel::util { HPX_CONCEPT_REQUIRES_( // forces hpx::execution::unseq hpx::is_unsequenced_execution_policy_v && !hpx::is_parallel_execution_policy_v)> - HPX_HOST_DEVICE HPX_FORCEINLINE static constexpr Begin call( + HPX_HOST_DEVICE HPX_FORCEINLINE static Begin call( ExPolicy&&, Begin it, End end, F&& f) { // clang-format off HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (/**/; it != end; ++it) + for (Begin& iter = it; iter != end; ++iter) { - HPX_INVOKE(f, it); + HPX_INVOKE(f, iter); } // clang-format on @@ -695,8 +695,9 @@ namespace hpx::parallel::util { { // clang-format off HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (/**/; it != last; (void) ++it) - HPX_INVOKE(f, it); + for (FwdIter& iter = it; iter != last; ++iter){ + HPX_INVOKE(f, iter); + } // clang-format on return it; @@ -721,8 +722,8 @@ namespace hpx::parallel::util { { // clang-format off HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (/**/; it != last; (void) ++it, ++dest) - f(it, dest); + for (Iter& iter = it; iter != last; ++iter) + f(iter, dest++); // clang-format on return dest; @@ -913,16 +914,15 @@ namespace hpx::parallel::util { // clang-format off HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (std::size_t i = 0; i < count; - (void) ++it, ++dest, ++i) // -V112 + for (std::size_t i = 0; i < count; ++i) // -V112 { - HPX_INVOKE(f, it, dest); + HPX_INVOKE(f, it++, dest++); } HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (/**/; count < num; (void) ++count, ++it, ++dest) + for (std::size_t i = count; i < num; ++i) { - HPX_INVOKE(f, it, dest); + HPX_INVOKE(f, it++, dest++); } // clang-format on @@ -950,16 +950,15 @@ namespace hpx::parallel::util { // clang-format off HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (std::size_t i = 0; i < count; - (void) ++it, ++i) // -V112 + for (std::size_t i = 0; i < count; ++i) // -V112 { - HPX_INVOKE(f, it); + HPX_INVOKE(f, it++); } HPX_IVDEP HPX_UNROLL HPX_VECTORIZE - for (/**/; count < num; (void) ++count, ++it) + for (std::size_t i = count; i < num; ++i) { - HPX_INVOKE(f, it); + HPX_INVOKE(f, it++); } // clang-format on