Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added range version of parallel::move #3028

Merged
merged 2 commits into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hpx/include/parallel_move.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define HPX_PARALLEL_MOVE_JUN_28_2014_0827AM

#include <hpx/parallel/algorithms/move.hpp>
#include <hpx/parallel/container_algorithms/move.hpp>

#endif

48 changes: 26 additions & 22 deletions hpx/parallel/container_algorithms/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@

namespace hpx { namespace parallel { inline namespace v1
{
/// Copies the elements in the range, defined by [first, last), to another
/// Copies the elements in the range \a rng to another
/// range beginning at \a dest.
///
/// \note Complexity: Performs exactly \a last - \a first assignments.
/// \note Complexity: Performs exactly
/// std::distance(begin(rng), end(rng)) assignments.
///
/// \tparam ExPolicy The type of the execution policy to use (deduced).
/// It describes the manner in which the execution
Expand Down Expand Up @@ -57,14 +58,15 @@ namespace hpx { namespace parallel { inline namespace v1
/// fashion in unspecified threads, and indeterminately sequenced
/// within each thread.
///
/// \returns The \a copy algorithm returns a \a hpx::future<OutIter> if the
/// execution policy is of type
/// \a sequenced_task_policy or
/// \a parallel_task_policy and
/// returns \a OutIter otherwise.
/// The \a copy algorithm returns the output iterator to the
/// element in the destination range, one past the last element
/// copied.
/// \returns The \a copy algorithm returns a
/// \a hpx::future<tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> > if the execution policy is of type
/// \a sequenced_task_policy or \a parallel_task_policy and
/// returns \a tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> otherwise.
/// The \a copy algorithm returns the pair of the input iterator
/// \a last and the output iterator to the element in the
/// destination range, one past the last element copied.
///
template <typename ExPolicy, typename Rng, typename OutIter,
HPX_CONCEPT_REQUIRES_(
Expand All @@ -84,14 +86,15 @@ namespace hpx { namespace parallel { inline namespace v1
hpx::util::begin(rng), hpx::util::end(rng), dest);
}

/// Copies the elements in the range, defined by [first, last), to another
/// Copies the elements in the range \a rng to another
/// range beginning at \a dest. Copies only the elements for which the
/// predicate \a f returns true. The order of the elements that are not
/// removed is preserved.
///
/// \note Complexity: Performs not more than \a last - \a first
/// assignments, exactly \a last - \a first applications of the
/// predicate \a f.
/// \note Complexity: Performs not more than
/// std::distance(begin(rng), end(rng)) assignments,
/// exactly std::distance(begin(rng), end(rng)) applications
/// of the predicate \a f.
///
/// \tparam ExPolicy The type of the execution policy to use (deduced).
/// It describes the manner in which the execution
Expand Down Expand Up @@ -145,14 +148,15 @@ namespace hpx { namespace parallel { inline namespace v1
/// fashion in unspecified threads, and indeterminately sequenced
/// within each thread.
///
/// \returns The \a copy_if algorithm returns a \a hpx::future<OutIter> if the
/// execution policy is of type
/// \a sequenced_task_policy or
/// \a parallel_task_policy and
/// returns \a OutIter otherwise.
/// The \a copy_if algorithm returns the output iterator to the
/// element in the destination range, one past the last element
/// copied.
/// \returns The \a copy_if algorithm returns a
/// \a hpx::future<tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> > if the execution policy is of type
/// \a sequenced_task_policy or \a parallel_task_policy and
/// returns \a tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> otherwise.
/// The \a copy_if algorithm returns the pair of the input iterator
/// \a last and the output iterator to the element in the
/// destination range, one past the last element copied.
///
template <typename ExPolicy, typename Rng, typename OutIter, typename F,
typename Proj = util::projection_identity,
Expand Down
90 changes: 90 additions & 0 deletions hpx/parallel/container_algorithms/move.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) 2017 Bruno Pitrus
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

/// \file parallel/container_algorithms/move.hpp

#if !defined(HPX_PARALLEL_CONTAINER_ALGORITHM_MOVE_26_NOV_2017_1248PM)
#define HPX_PARALLEL_CONTAINER_ALGORITHM_MOVE_26_NOV_2017_1248PM

#include <hpx/config.hpp>
#include <hpx/traits/concepts.hpp>
#include <hpx/traits/is_iterator.hpp>
#include <hpx/traits/is_range.hpp>
#include <hpx/util/range.hpp>
#include <hpx/util/tagged_pair.hpp>

#include <hpx/parallel/algorithms/move.hpp>

#include <type_traits>
#include <utility>

namespace hpx { namespace parallel { inline namespace v1
{
/// Moves the elements in the range \a rng to another range beginning
/// at \a dest. After this operation the elements in the moved-from
/// range will still contain valid values of the appropriate type,
/// but not necessarily the same values as before the move.
///
/// \note Complexity: Performs exactly
/// std::distance(begin(rng), end(rng)) assignments.
///
/// \tparam ExPolicy The type of the execution policy to use (deduced).
/// It describes the manner in which the execution
/// of the algorithm may be parallelized and the manner
/// in which it executes the assignments.
/// \tparam Rng The type of the source range used (deduced).
/// The iterators extracted from this range type must
/// meet the requirements of an input iterator.
/// \tparam OutIter The type of the iterator representing the
/// destination range (deduced).
/// This iterator type must meet the requirements of an
/// output iterator.
///
/// \param policy The execution policy to use for the scheduling of
/// the iterations.
/// \param rng Refers to the sequence of elements the algorithm
/// will be applied to.
/// \param dest Refers to the beginning of the destination range.
///
/// The assignments in the parallel \a copy algorithm invoked with an
/// execution policy object of type \a sequenced_policy
/// execute in sequential order in the calling thread.
///
/// The assignments in the parallel \a copy algorithm invoked with
/// an execution policy object of type \a parallel_policy or
/// \a parallel_task_policy are permitted to execute in an unordered
/// fashion in unspecified threads, and indeterminately sequenced
/// within each thread.
///
/// \returns The \a move algorithm returns a
/// \a hpx::future<tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> > if the execution policy is of type
/// \a sequenced_task_policy or \a parallel_task_policy and
/// returns \a tagged_pair<tag::in(iterator_t<Rng>),
/// tag::out(FwdIter2)> otherwise.
/// The \a move algorithm returns the pair of the input iterator
/// \a last and the output iterator to the element in the
/// destination range, one past the last element moved.
///
template <typename ExPolicy, typename Rng, typename OutIter,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_range<Rng>::value &&
hpx::traits::is_iterator<OutIter>::value)>
typename util::detail::algorithm_result<
ExPolicy,
hpx::util::tagged_pair<
tag::in(typename hpx::traits::range_traits<Rng>::iterator_type),
tag::out(OutIter)
>
>::type
move(ExPolicy && policy, Rng && rng, OutIter dest)
{
return move(std::forward<ExPolicy>(policy),
hpx::util::begin(rng), hpx::util::end(rng), dest);
}
}}}

#endif
1 change: 1 addition & 0 deletions tests/unit/parallel/container_algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(tests
merge_range
min_element_range
minmax_element_range
move_range
none_of_range
partition_range
partition_copy_range
Expand Down
Loading