Skip to content

Commit

Permalink
Merge 1bdaccb into af33761
Browse files Browse the repository at this point in the history
  • Loading branch information
Jedi18 committed Nov 17, 2021
2 parents af33761 + 1bdaccb commit 2397a6e
Show file tree
Hide file tree
Showing 38 changed files with 81 additions and 1,117 deletions.
5 changes: 0 additions & 5 deletions libs/core/algorithms/CMakeLists.txt
Expand Up @@ -165,7 +165,6 @@ set(algorithms_headers
hpx/parallel/memory.hpp
hpx/parallel/numeric.hpp
hpx/parallel/spmd_block.hpp
hpx/parallel/tagspec.hpp
hpx/parallel/task_block.hpp
hpx/parallel/task_group.hpp
hpx/parallel/util/cancellation_token.hpp
Expand Down Expand Up @@ -195,8 +194,6 @@ set(algorithms_headers
hpx/parallel/util/ranges_facilities.hpp
hpx/parallel/util/result_types.hpp
hpx/parallel/util/scan_partitioner.hpp
hpx/parallel/util/tagged_pair.hpp
hpx/parallel/util/tagged_tuple.hpp
hpx/parallel/util/transfer.hpp
hpx/parallel/util/transform_loop.hpp
hpx/parallel/util/zip_iterator.hpp
Expand All @@ -210,8 +207,6 @@ set(algorithms_compat_headers
hpx/traits/is_value_proxy.hpp => hpx/algorithms/traits/is_value_proxy.hpp
hpx/traits/pointer_category.hpp => hpx/algorithms/traits/pointer_category.hpp
hpx/traits/segmented_iterator_traits.hpp => hpx/algorithms/traits/segmented_iterator_traits.hpp
hpx/util/tagged_pair.hpp => hpx/datastructures/tagged_pair.hpp
hpx/util/tagged_tuple.hpp => hpx/datastructures/tagged_tuple.hpp
)
# cmake-format: on

Expand Down
Expand Up @@ -38,17 +38,6 @@ namespace hpx { namespace parallel { inline namespace v1 { namespace detail {
Result>::local_raw_iterator;
};

template <typename Result1, typename Result2>
struct local_algorithm_result<std::pair<Result1, Result2>>
{
using type1 = typename hpx::traits::segmented_local_iterator_traits<
Result1>::local_raw_iterator;
using type2 = typename hpx::traits::segmented_local_iterator_traits<
Result2>::local_raw_iterator;

using type = std::pair<type1, type2>;
};

template <typename Result1, typename Result2>
struct local_algorithm_result<util::in_out_result<Result1, Result2>>
{
Expand All @@ -69,19 +58,6 @@ namespace hpx { namespace parallel { inline namespace v1 { namespace detail {
using type = util::min_max_result<type1>;
};

template <typename Result1, typename Result2, typename Result3>
struct local_algorithm_result<hpx::tuple<Result1, Result2, Result3>>
{
using type1 = typename hpx::traits::segmented_local_iterator_traits<
Result1>::local_raw_iterator;
using type2 = typename hpx::traits::segmented_local_iterator_traits<
Result2>::local_raw_iterator;
using type3 = typename hpx::traits::segmented_local_iterator_traits<
Result3>::local_raw_iterator;

using type = hpx::tuple<type1, type2, type3>;
};

template <typename Result1, typename Result2, typename Result3>
struct local_algorithm_result<
util::in_in_out_result<Result1, Result2, Result3>>
Expand Down Expand Up @@ -153,7 +129,7 @@ namespace hpx { namespace parallel { inline namespace v1 { namespace detail {
catch (...)
{
// this does not return
return hpx::parallel::detail::handle_exception<ExPolicy,
return hpx::parallel::v1::detail::handle_exception<ExPolicy,
local_result_type>::call();
}
#endif
Expand Down
Expand Up @@ -11,10 +11,8 @@
#if !defined(HPX_COMPUTE_DEVICE_CODE)
#include <hpx/algorithms/traits/segmented_iterator_traits.hpp>
#endif
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/algorithms/traits/projected.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/result_types.hpp>

Expand Down
Expand Up @@ -83,7 +83,7 @@ namespace hpx {
/// if the execution policy is of type
/// \a sequenced_task_policy or
/// \a parallel_task_policy and returns
/// \a tagged_tuple<RandIter3> otherwise.
/// \a RandIter3 otherwise.
/// The \a merge algorithm returns the destination iterator to
/// the end of the \a dest range.
///
Expand Down
Expand Up @@ -376,7 +376,6 @@ namespace hpx {
#include <hpx/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/detail/distance.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/compare_projected.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/loop.hpp>
Expand Down
8 changes: 3 additions & 5 deletions libs/core/algorithms/include/hpx/parallel/algorithms/move.hpp
Expand Up @@ -52,14 +52,12 @@ namespace hpx {
/// threads, and indeterminately sequenced within each thread.
///
/// \returns The \a move algorithm returns a
/// \a hpx::future<tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)> >
/// \a hpx::future<FwdIter2>>
/// if the execution policy is of type
/// \a sequenced_task_policy or
/// \a parallel_task_policy and
/// returns \a tagged_pair<tag::in(FwdIter1), tag::out(FwdIter2)>
/// otherwise.
/// The \a move algorithm returns the pair of the input iterator
/// \a last and the output iterator to the
/// returns \a FwdIter2 otherwise.
/// The \a move algorithm returns the output iterator to the
/// element in the destination range, one past the last element
/// moved.
///
Expand Down
74 changes: 40 additions & 34 deletions libs/core/algorithms/include/hpx/parallel/algorithms/partition.hpp
Expand Up @@ -335,18 +335,15 @@ namespace hpx {
/// calling thread.
///
/// \returns The \a partition_copy algorithm returns
/// \a tagged_tuple<tag::in(InIter), tag::out1(OutIter1),
/// tag::out2(OutIter2)>.
/// The \a partition_copy algorithm returns the tuple of
/// the source iterator \a last,
/// \a std::pair<OutIter1, OutIter2>.
/// The \a partition_copy algorithm returns the pair of
/// the destination iterator to the end of the \a dest_true
/// range, and the destination iterator to the end of the \a
/// dest_false range.
///
template <typename FwdIter1, typename FwdIter2,
typename FwdIter3, typename Pred, typename Proj>
hpx::util::tagged_tuple<tag::in(FwdIter1), tag::out1(FwdIter2),
tag::out2(FwdIter3)>
std::pair<FwdIter2 ,FwdIter3>
partition_copy(FwdIter1 first, FwdIter1 last,
FwdIter2 dest_true, FwdIter3 dest_false, Pred&& pred, Proj&& proj);

Expand Down Expand Up @@ -427,24 +424,18 @@ namespace hpx {
/// within each thread.
///
/// \returns The \a partition_copy algorithm returns a
/// \a hpx::future<tagged_tuple<tag::in(InIter),
/// tag::out1(OutIter1), tag::out2(OutIter2)> >
/// \a hpx::future<std::pair<OutIter1, OutIter2>>
/// if the execution policy is of type \a parallel_task_policy
/// and returns
/// \a tagged_tuple<tag::in(InIter),
/// tag::out1(OutIter1), tag::out2(OutIter2)>
/// otherwise.
/// The \a partition_copy algorithm returns the tuple of
/// the source iterator \a last,
/// \a std::pair<OutIter1, OutIter2> otherwise.
/// The \a partition_copy algorithm returns the pair of
/// the destination iterator to the end of the \a dest_true
/// range, and the destination iterator to the end of the \a
/// dest_false range.
///
template <typename ExPolicy, typename FwdIter1, typename FwdIter2,
typename FwdIter3, typename Pred, typename Proj>
typename util::detail::algorithm_result<ExPolicy,
hpx::util::tagged_tuple<tag::in(FwdIter1), tag::out1(FwdIter2),
tag::out2(FwdIter3)>>::type
util::detail::algorithm_result_t<ExPolicy, std::pair<FwdIter2, FwdIter3>>
partition_copy(ExPolicy&& policy, FwdIter1 first, FwdIter1 last,
FwdIter2 dest_true, FwdIter3 dest_false, Pred&& pred, Proj&& proj);

Expand All @@ -461,7 +452,6 @@ namespace hpx {
#include <hpx/futures/future.hpp>
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/modules/async_local.hpp>
#include <hpx/parallel/util/tagged_tuple.hpp>
#include <hpx/synchronization/spinlock.hpp>
#include <hpx/type_support/unused.hpp>

Expand All @@ -475,7 +465,6 @@ namespace hpx {
#include <hpx/parallel/algorithms/detail/advance_to_sentinel.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/detail/distance.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/detail/chunk_size.hpp>
#include <hpx/parallel/util/detail/handle_local_exceptions.hpp>
Expand Down Expand Up @@ -504,6 +493,31 @@ namespace hpx {
#include <vector>

namespace hpx { namespace parallel { inline namespace v1 {

template <typename Tuple>
constexpr HPX_FORCEINLINE
std::pair<typename hpx::tuple_element<1, Tuple>::type,
typename hpx::tuple_element<2, Tuple>::type>
tuple_to_pair(Tuple&& t)
{
return std::make_pair(hpx::get<1>(t), hpx::get<2>(t));
}

template <typename Tuple>
hpx::future<std::pair<typename hpx::tuple_element<1, Tuple>::type,
typename hpx::tuple_element<2, Tuple>::type>>
tuple_to_pair(hpx::future<Tuple>&& f)
{
using result_type =
std::pair<typename hpx::tuple_element<1, Tuple>::type,
typename hpx::tuple_element<2, Tuple>::type>;

return hpx::make_future<result_type>(
HPX_MOVE(f), [](Tuple&& t) -> result_type {
return tuple_to_pair(HPX_MOVE(t));
});
}

///////////////////////////////////////////////////////////////////////////
// stable_partition
namespace detail {
Expand Down Expand Up @@ -1657,9 +1671,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
traits::projected<Proj, FwdIter1>>
)>
// clang-format on
util::detail::algorithm_result_t<ExPolicy,
hpx::util::tagged_tuple<tag::in(FwdIter1), tag::out1(FwdIter2),
tag::out2(FwdIter3)>>
util::detail::algorithm_result_t<ExPolicy, std::pair<FwdIter2, FwdIter3>>
partition_copy(ExPolicy&& policy, FwdIter1 first, FwdIter1 last,
FwdIter2 dest_true, FwdIter3 dest_false, Pred&& pred,
Proj&& proj = Proj())
Expand All @@ -1677,7 +1689,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
#endif
using result_type = hpx::tuple<FwdIter1, FwdIter2, FwdIter3>;

return hpx::util::make_tagged_tuple<tag::in, tag::out1, tag::out2>(
return parallel::v1::tuple_to_pair(
detail::partition_copy<result_type>().call(
HPX_FORWARD(ExPolicy, policy), first, last, dest_true,
dest_false, HPX_FORWARD(Pred, pred), HPX_FORWARD(Proj, proj)));
Expand Down Expand Up @@ -1815,11 +1827,9 @@ namespace hpx {
parallel::traits::projected<Proj, FwdIter1>>
)>
// clang-format on
friend hpx::util::tagged_tuple<parallel::v1::tag::in(FwdIter1),
parallel::v1::tag::out1(FwdIter2),
parallel::v1::tag::out2(FwdIter3)>
tag_fallback_invoke(hpx::partition_copy_t, FwdIter1 first,
FwdIter1 last, FwdIter2 dest_true, FwdIter3 dest_false, Pred&& pred,
friend std::pair<FwdIter2, FwdIter3> tag_fallback_invoke(
hpx::partition_copy_t, FwdIter1 first, FwdIter1 last,
FwdIter2 dest_true, FwdIter3 dest_false, Pred&& pred,
Proj&& proj = Proj())
{
static_assert((hpx::traits::is_forward_iterator_v<FwdIter1>),
Expand All @@ -1831,8 +1841,7 @@ namespace hpx {

using result_type = hpx::tuple<FwdIter1, FwdIter2, FwdIter3>;

return hpx::util::make_tagged_tuple<parallel::v1::tag::in,
parallel::v1::tag::out1, parallel::v1::tag::out2>(
return parallel::v1::tuple_to_pair(
parallel::v1::detail::partition_copy<result_type>().call(
hpx::execution::seq, first, last, dest_true, dest_false,
HPX_FORWARD(Pred, pred), HPX_FORWARD(Proj, proj)));
Expand All @@ -1853,9 +1862,7 @@ namespace hpx {
)>
// clang-format on
friend parallel::util::detail::algorithm_result_t<ExPolicy,
hpx::util::tagged_tuple<parallel::v1::tag::in(FwdIter1),
parallel::v1::tag::out1(FwdIter2),
parallel::v1::tag::out2(FwdIter3)>>
std::pair<FwdIter2, FwdIter3>>
tag_fallback_invoke(hpx::partition_copy_t, ExPolicy&& policy,
FwdIter1 first, FwdIter1 last, FwdIter2 dest_true,
FwdIter3 dest_false, Pred&& pred, Proj&& proj = Proj())
Expand All @@ -1869,8 +1876,7 @@ namespace hpx {

using result_type = hpx::tuple<FwdIter1, FwdIter2, FwdIter3>;

return hpx::util::make_tagged_tuple<parallel::v1::tag::in,
parallel::v1::tag::out1, parallel::v1::tag::out2>(
return parallel::v1::tuple_to_pair(
parallel::v1::detail::partition_copy<result_type>().call(
HPX_FORWARD(ExPolicy, policy), first, last, dest_true,
dest_false, HPX_FORWARD(Pred, pred),
Expand Down
Expand Up @@ -171,7 +171,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
util::in_out_result<iKey, iVal> make_pair_result(
ZIter zipiter, iKey key_start, iVal val_start)
{
// the iterator we want is 'second' part of tagged_pair type (from copy_if)
// the iterator we want is 'second' part of pair type (from copy_if)
auto t = zipiter.out.get_iterator_tuple();
iKey key_end = hpx::get<0>(t);
return util::in_out_result<iKey, iVal>{key_end,
Expand Down
Expand Up @@ -213,7 +213,6 @@ namespace hpx {
#include <hpx/functional/invoke.hpp>
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/parallel/util/detail/sender_util.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>
#include <hpx/type_support/unused.hpp>

#include <hpx/algorithms/traits/projected.hpp>
Expand All @@ -223,7 +222,6 @@ namespace hpx {
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/detail/find.hpp>
#include <hpx/parallel/algorithms/detail/transfer.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/foreach_partitioner.hpp>
#include <hpx/parallel/util/invoke_projected.hpp>
Expand Down
Expand Up @@ -256,12 +256,10 @@ namespace hpx {
#include <hpx/functional/invoke.hpp>
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/parallel/util/detail/sender_util.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/copy.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/projection_identity.hpp>
#include <hpx/parallel/util/result_types.hpp>
Expand Down
Expand Up @@ -480,7 +480,6 @@ namespace hpx {
#include <hpx/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/for_each.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/projection_identity.hpp>
#include <hpx/parallel/util/zip_iterator.hpp>
Expand Down
Expand Up @@ -182,14 +182,12 @@ namespace hpx {
#include <hpx/concepts/concepts.hpp>
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/parallel/util/detail/sender_util.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/copy.hpp>
#include <hpx/parallel/algorithms/detail/advance_to_sentinel.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/for_each.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/projection_identity.hpp>
#include <hpx/parallel/util/ranges_facilities.hpp>
Expand Down
Expand Up @@ -185,14 +185,12 @@ namespace hpx {
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/modules/execution.hpp>
#include <hpx/pack_traversal/unwrap.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/copy.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/detail/rotate.hpp>
#include <hpx/parallel/algorithms/reverse.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/detail/sender_util.hpp>
#include <hpx/parallel/util/result_types.hpp>
Expand Down
Expand Up @@ -111,12 +111,10 @@ namespace hpx {
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/modules/execution.hpp>
#include <hpx/pack_traversal/unwrap.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/reverse.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/result_types.hpp>
#include <hpx/parallel/util/transfer.hpp>
Expand Down
Expand Up @@ -110,13 +110,11 @@ namespace hpx {
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/modules/execution.hpp>
#include <hpx/pack_traversal/unwrap.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/copy.hpp>
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
#include <hpx/parallel/algorithms/reverse.hpp>
#include <hpx/parallel/tagspec.hpp>
#include <hpx/parallel/util/detail/algorithm_result.hpp>
#include <hpx/parallel/util/result_types.hpp>
#include <hpx/parallel/util/transfer.hpp>
Expand Down

0 comments on commit 2397a6e

Please sign in to comment.