Skip to content

Commit

Permalink
fixed cf
Browse files Browse the repository at this point in the history
Signed-off-by: Hari Hara Naveen S <[email protected]>

fixed expolicy not accepting par_unseq

Signed-off-by: Hari Hara Naveen S <[email protected]>

cleanup changes

Signed-off-by: Hari Hara Naveen S <[email protected]>

fixing missing concept header

Signed-off-by: Hari Hara Naveen S <[email protected]>
  • Loading branch information
Johan511 committed Feb 8, 2024
1 parent 7f69717 commit d8096f0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExPolicy>(base_idx, part_begin, part_count, tok,
[&val, &proj, &tok](auto& v, std::size_t i) -> void {
if (HPX_INVOKE(proj, v) == val)
Expand Down Expand Up @@ -102,7 +101,6 @@ namespace hpx::parallel::detail {
sequential_find_if_t<ExPolicy>, FwdIter part_begin,
std::size_t part_count, Token& tok, F&& op, Proj&& proj)
{
// TODO
util::loop_n<std::decay_t<ExPolicy>>(part_begin, part_count, tok,
[&op, &tok, &proj](auto const& curr) {
if (HPX_INVOKE(op, HPX_INVOKE(proj, *curr)))
Expand All @@ -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<ExPolicy>(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)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <hpx/parallel/unseq/reduce_helpers.hpp>
#include <hpx/type_support/construct_at.hpp>


#include <algorithm>
#include <cstddef>
#include <cstdint>
Expand Down
32 changes: 11 additions & 21 deletions libs/core/algorithms/include/hpx/parallel/util/loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <hpx/config.hpp>
#include <hpx/assert.hpp>
#include <hpx/concepts/concepts.hpp>
#include <hpx/datastructures/tuple.hpp>
#include <hpx/execution/traits/is_execution_policy.hpp>
#include <hpx/executors/execution_policy.hpp>
#include <hpx/functional/detail/invoke.hpp>
#include <hpx/functional/detail/tag_fallback_invoke.hpp>
#include <hpx/functional/invoke_result.hpp>
Expand Down Expand Up @@ -185,22 +185,12 @@ namespace hpx::parallel::util {
}
};

template <typename Begin, typename End, typename Pred,
HPX_CONCEPT_REQUIRES_(hpx::traits::is_random_access_iterator_v<Begin>)>
template <typename Begin, typename End, typename Pred, typename ExPolicy,
HPX_CONCEPT_REQUIRES_(hpx::traits::is_random_access_iterator_v<Begin>&&
hpx::is_unsequenced_execution_policy_v<ExPolicy>)>
HPX_HOST_DEVICE HPX_FORCEINLINE Begin tag_invoke(
hpx::parallel::util::loop_pred_t<hpx::execution::unsequenced_policy>,
Begin HPX_RESTRICT begin, End HPX_RESTRICT end, Pred&& pred)
{
return unseq_first_n(
begin, std::distance(begin, end), HPX_FORWARD(Pred, pred));
}

template <typename Begin, typename End, typename Pred,
HPX_CONCEPT_REQUIRES_(hpx::traits::is_random_access_iterator_v<Begin>)>
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<ExPolicy>, Begin HPX_RESTRICT begin,
End HPX_RESTRICT end, Pred&& pred)
{
return unseq_first_n(
begin, std::distance(begin, end), HPX_FORWARD(Pred, pred));
Expand Down Expand Up @@ -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 <typename IterCat, typename Dummy = void>
template <typename IterCat>
struct loop_idx_n
{
///////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1185,8 +1175,8 @@ namespace hpx::parallel::util {
}
};

template <typename ExPolicy>
struct loop_idx_n<std::random_access_iterator_tag, ExPolicy>
template <>
struct loop_idx_n<std::random_access_iterator_tag>
{
///////////////////////////////////////////////////////////////////
// handle sequences of non-futures
Expand Down Expand Up @@ -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<Iter>::iterator_category;
return detail::loop_idx_n<cat, ExPolicy>::call(
return detail::loop_idx_n<cat>::call(
base_idx, it, count, HPX_FORWARD(F, f));
}

Expand All @@ -1265,7 +1255,7 @@ namespace hpx::parallel::util {
F&& f)
{
using cat = typename std::iterator_traits<Iter>::iterator_category;
return detail::loop_idx_n<cat, ExPolicy>::call(
return detail::loop_idx_n<cat>::call(
base_idx, it, count, tok, HPX_FORWARD(F, f));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> v(length, static_cast<T>(0));
std::vector<T> v(length);
std::size_t i = 0;

std::for_each(v.begin(), v.end(), [&](T& t) {
Expand Down

0 comments on commit d8096f0

Please sign in to comment.