Skip to content

[oneDPL] Add more copying mutating parallel range algorithms #635

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
30 changes: 28 additions & 2 deletions source/elements/oneDPL/source/parallel_api/parallel_range_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defined by the C++ standard in ``namespace std::ranges``, they cannot be found b
and cannot be called with explicitly specified template arguments. [*Note*: A typical implementation uses
predefined function objects which static function call operators have the required signatures. -- *end note*]

The following differences to the standard C++ range algorithms apply:
The following differences to the standard C++ serial range algorithms apply:

- Parallel range algorithms cannot be used in constant expressions.
- The oneDPL execution policy parameter is added.
Expand All @@ -32,7 +32,10 @@ The following differences to the standard C++ range algorithms apply:
- For algorithms with bounded output ranges, processing may not need to go over all the input data.
In that case, the returned value contains iterators pointing to the positions past the last elements
processed according to the algorithm semantics.
- ``for_each`` does not return its function object.
- The return type of ``reverse_copy`` is ``std::ranges::in_in_out_result``
rather than ``std::ranges::reverse_copy_result``.
The semantics of the returned value are as specified in
`P3709R2 <https://isocpp.org/files/papers/P3709R2.html>`_.

Except for these differences, the signatures of parallel range algorithms correspond to the working draft
of the next edition of the C++ standard (C++26).
Expand Down Expand Up @@ -429,6 +432,17 @@ Copying Mutating Operations
std::ranges::borrowed_iterator_t<OutR>>
move (ExecutionPolicy&& pol, R&& r, OutR&& result);

// reverse_copy
template <typename ExecutionPolicy, std::ranges::random_access_range R,
std::ranges::random_access_range OutR>
requires oneapi::dpl::is_execution_policy_v<std::remove_cvref_t<ExecutionPolicy>> &&
std::ranges::sized_range<R> && std::ranges::sized_range<OutR> &&
std::indirectly_copyable<std::ranges::iterator_t<R>, std::ranges::iterator_t<OutR>>
std::ranges::in_in_out_result<std::ranges::borrowed_iterator_t<R>,
std::ranges::borrowed_iterator_t<R>,
std::ranges::borrowed_iterator_t<OutR>>
reverse_copy (ExecutionPolicy&& pol, R&& r, OutR&& result);

// transform (unary)
template <typename ExecutionPolicy, std::ranges::random_access_range R,
std::ranges::random_access_range OutR, std::copy_constructible Fn,
Expand Down Expand Up @@ -458,6 +472,18 @@ Copying Mutating Operations
transform (ExecutionPolicy&& pol, R1&& r1, R2&& r2, OutR&& result, Fn binary_op,
Proj1 proj1 = {}, Proj2 proj2 = {});

// unique_copy
template <typename ExecutionPolicy, std::ranges::random_access_range R,
std::ranges::random_access_range OutR, typename Proj = std::identity,
std::indirect_equivalence_relation<std::projected<std::ranges::iterator_t<R>, Proj>>
Comp = std::ranges::equal_to>
requires oneapi::dpl::is_execution_policy_v<std::remove_cvref_t<ExecutionPolicy>> &&
std::ranges::sized_range<R> && std::ranges::sized_range<OutR> &&
std::indirectly_copyable<std::ranges::iterator_t<R>, std::ranges::iterator_t<OutR>>
std::ranges::unique_copy_result<std::ranges::borrowed_iterator_t<R>,
std::ranges::borrowed_iterator_t<OutR>>
unique_copy (ExecutionPolicy&& pol, R&& r, OutR&& result, Comp comp = {}, Proj proj = {});

}

In-place Mutating Operations
Expand Down
Loading