Skip to content

Commit

Permalink
remove tagged_pair, tagged and tagged_tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Jedi18 committed Nov 16, 2021
1 parent 3b4edaa commit 2ebe7b7
Show file tree
Hide file tree
Showing 30 changed files with 77 additions and 977 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 @@ -129,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,7 +11,6 @@
#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>
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
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
73 changes: 40 additions & 33 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 Down Expand Up @@ -504,6 +494,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 lcos::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 +1672,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 +1690,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 +1828,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 +1842,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 +1863,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 +1877,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 Down
Expand Up @@ -256,7 +256,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/executors/execution_policy.hpp>
#include <hpx/parallel/algorithms/copy.hpp>
Expand Down
Expand Up @@ -182,7 +182,6 @@ 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>
Expand Down
Expand Up @@ -185,7 +185,6 @@ 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>
Expand Down
Expand Up @@ -111,7 +111,6 @@ 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>
Expand Down
Expand Up @@ -110,7 +110,6 @@ 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>
Expand Down
Expand Up @@ -9,7 +9,6 @@

#include <hpx/config.hpp>
#include <hpx/datastructures/tuple.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/parallel/algorithms/sort.hpp>
#include <hpx/parallel/tagspec.hpp>
Expand Down Expand Up @@ -100,11 +99,11 @@ namespace hpx { namespace parallel { inline namespace v1 {
/// threads, and indeterminately sequenced within each thread.
///
/// \returns The \a sort_by-key algorithm returns a
/// \a hpx::future<tagged_pair<tag::in1(KeyIter>, tag::in2(ValueIter)> >
/// \a hpx::future<std::pair<KeyIter, ValueIter>>
/// if the execution policy is of type
/// \a sequenced_task_policy or
/// \a parallel_task_policy and returns \a
/// \a tagged_pair<tag::in1(KeyIter), tag::in2(ValueIter)>
/// \a std::pair<KeyIter, ValueIter>
/// otherwise.
/// The algorithm returns a pair holding an iterator pointing to
/// the first element after the last element in the input key
Expand All @@ -114,8 +113,7 @@ namespace hpx { namespace parallel { inline namespace v1 {

template <typename ExPolicy, typename KeyIter, typename ValueIter,
typename Compare = detail::less>
typename util::detail::algorithm_result<ExPolicy,
hpx::util::tagged_pair<tag::in1(KeyIter), tag::in2(ValueIter)>>::type
util::detail::algorithm_result_t<ExPolicy, std::pair<KeyIter, ValueIter>>
sort_by_key(ExPolicy&& policy, KeyIter key_first, KeyIter key_last,
ValueIter value_first, Compare&& comp = Compare())
{
Expand All @@ -124,18 +122,17 @@ namespace hpx { namespace parallel { inline namespace v1 {
"sort_by_key is not supported unless HPX_HAVE_TUPLE_RVALUE_SWAP "
"is defined");
#else
static_assert((hpx::traits::is_random_access_iterator<KeyIter>::value),
static_assert((hpx::traits::is_random_access_iterator_v<KeyIter>),
"Requires a random access iterator.");
static_assert(
(hpx::traits::is_random_access_iterator<ValueIter>::value),
static_assert((hpx::traits::is_random_access_iterator_v<ValueIter>),
"Requires a random access iterator.");

ValueIter value_last = value_first;
std::advance(value_last, std::distance(key_first, key_last));

using iterator_type = hpx::util::zip_iterator<KeyIter, ValueIter>;

return detail::get_iter_tagged_pair<tag::in1, tag::in2>(
return detail::get_iter_pair<iterator_type>(
detail::sort<iterator_type>().call(HPX_FORWARD(ExPolicy, policy),
hpx::util::make_zip_iterator(key_first, value_first),
hpx::util::make_zip_iterator(key_last, value_last),
Expand Down
Expand Up @@ -198,7 +198,6 @@ namespace hpx {
#include <hpx/concepts/concepts.hpp>
#include <hpx/functional/detail/tag_fallback_invoke.hpp>
#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/parallel/util/tagged_pair.hpp>

#include <hpx/execution/algorithms/detail/is_negative.hpp>
#include <hpx/executors/execution_policy.hpp>
Expand Down

0 comments on commit 2ebe7b7

Please sign in to comment.