From d8096f0a3173a594c21cf6df1a993f39c5302ad1 Mon Sep 17 00:00:00 2001 From: Hari Hara Naveen S Date: Tue, 8 Aug 2023 16:33:44 -0500 Subject: [PATCH] fixed cf Signed-off-by: Hari Hara Naveen S fixed expolicy not accepting par_unseq Signed-off-by: Hari Hara Naveen S cleanup changes Signed-off-by: Hari Hara Naveen S fixing missing concept header Signed-off-by: Hari Hara Naveen S --- .../hpx/parallel/algorithms/detail/find.hpp | 3 -- .../hpx/parallel/unseq/simd_helpers.hpp | 1 - .../include/hpx/parallel/util/loop.hpp | 32 +++++++------------ .../algorithms/util/test_simd_helpers.cpp | 2 +- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/libs/core/algorithms/include/hpx/parallel/algorithms/detail/find.hpp b/libs/core/algorithms/include/hpx/parallel/algorithms/detail/find.hpp index 8d80fe055f3c..30db28d9ac45 100644 --- a/libs/core/algorithms/include/hpx/parallel/algorithms/detail/find.hpp +++ b/libs/core/algorithms/include/hpx/parallel/algorithms/detail/find.hpp @@ -45,7 +45,6 @@ namespace hpx::parallel::detail { std::size_t base_idx, FwdIter part_begin, std::size_t part_count, Token& tok, T const& val, Proj&& proj) { - // TODO util::loop_idx_n(base_idx, part_begin, part_count, tok, [&val, &proj, &tok](auto& v, std::size_t i) -> void { if (HPX_INVOKE(proj, v) == val) @@ -102,7 +101,6 @@ namespace hpx::parallel::detail { sequential_find_if_t, FwdIter part_begin, std::size_t part_count, Token& tok, F&& op, Proj&& proj) { - // TODO util::loop_n>(part_begin, part_count, tok, [&op, &tok, &proj](auto const& curr) { if (HPX_INVOKE(op, HPX_INVOKE(proj, *curr))) @@ -118,7 +116,6 @@ namespace hpx::parallel::detail { FwdIter part_begin, std::size_t part_count, Token& tok, F&& f, Proj&& proj) { - // TODO util::loop_idx_n(base_idx, part_begin, part_count, tok, [&f, &proj, &tok](auto& v, std::size_t i) -> void { if (HPX_INVOKE(f, HPX_INVOKE(proj, v))) diff --git a/libs/core/algorithms/include/hpx/parallel/unseq/simd_helpers.hpp b/libs/core/algorithms/include/hpx/parallel/unseq/simd_helpers.hpp index 62f3caa7658a..cf7bf8380e86 100644 --- a/libs/core/algorithms/include/hpx/parallel/unseq/simd_helpers.hpp +++ b/libs/core/algorithms/include/hpx/parallel/unseq/simd_helpers.hpp @@ -13,7 +13,6 @@ #include #include - #include #include #include diff --git a/libs/core/algorithms/include/hpx/parallel/util/loop.hpp b/libs/core/algorithms/include/hpx/parallel/util/loop.hpp index e4af118ab774..a3bf3659cfb1 100644 --- a/libs/core/algorithms/include/hpx/parallel/util/loop.hpp +++ b/libs/core/algorithms/include/hpx/parallel/util/loop.hpp @@ -8,9 +8,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -185,22 +185,12 @@ namespace hpx::parallel::util { } }; - template )> + template && + hpx::is_unsequenced_execution_policy_v)> HPX_HOST_DEVICE HPX_FORCEINLINE Begin tag_invoke( - hpx::parallel::util::loop_pred_t, - Begin HPX_RESTRICT begin, End HPX_RESTRICT end, Pred&& pred) - { - return unseq_first_n( - begin, std::distance(begin, end), HPX_FORWARD(Pred, pred)); - } - - template )> - HPX_HOST_DEVICE HPX_FORCEINLINE Begin tag_invoke( - hpx::parallel::util::loop_pred_t< - hpx::execution::unsequenced_task_policy>, - Begin HPX_RESTRICT begin, End HPX_RESTRICT end, Pred&& pred) + hpx::parallel::util::loop_pred_t, Begin HPX_RESTRICT begin, + End HPX_RESTRICT end, Pred&& pred) { return unseq_first_n( begin, std::distance(begin, end), HPX_FORWARD(Pred, pred)); @@ -1147,7 +1137,7 @@ namespace hpx::parallel::util { // Helper class to repeatedly call a function a given number of times // starting from a given iterator position. - template + template struct loop_idx_n { /////////////////////////////////////////////////////////////////// @@ -1185,8 +1175,8 @@ namespace hpx::parallel::util { } }; - template - struct loop_idx_n + template <> + struct loop_idx_n { /////////////////////////////////////////////////////////////////// // handle sequences of non-futures @@ -1254,7 +1244,7 @@ namespace hpx::parallel::util { std::size_t base_idx, Iter it, std::size_t count, F&& f) { using cat = typename std::iterator_traits::iterator_category; - return detail::loop_idx_n::call( + return detail::loop_idx_n::call( base_idx, it, count, HPX_FORWARD(F, f)); } @@ -1265,7 +1255,7 @@ namespace hpx::parallel::util { F&& f) { using cat = typename std::iterator_traits::iterator_category; - return detail::loop_idx_n::call( + return detail::loop_idx_n::call( base_idx, it, count, tok, HPX_FORWARD(F, f)); } }; diff --git a/libs/core/algorithms/tests/unit/algorithms/util/test_simd_helpers.cpp b/libs/core/algorithms/tests/unit/algorithms/util/test_simd_helpers.cpp index e2927525257c..ab512b4c8316 100644 --- a/libs/core/algorithms/tests/unit/algorithms/util/test_simd_helpers.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/util/test_simd_helpers.cpp @@ -23,7 +23,7 @@ void test_unseq_first_n1_dispatch2(std::size_t length, std::size_t first_index) { first_index = first_index % length; - std::vector v(length, static_cast(0)); + std::vector v(length); std::size_t i = 0; std::for_each(v.begin(), v.end(), [&](T& t) {