From 24ed052cfe04d8db37a9c87ec7ac768785e37ebc Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Tue, 13 Aug 2024 14:23:59 +0200 Subject: [PATCH 01/15] General description of oneDPL parallel range algorithms --- .../elements/oneDPL/source/parallel_api.rst | 4 +++ .../parallel_api/parallel_range_api.rst | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 source/elements/oneDPL/source/parallel_api/parallel_range_api.rst diff --git a/source/elements/oneDPL/source/parallel_api.rst b/source/elements/oneDPL/source/parallel_api.rst index 23002ace82..e045919bdc 100644 --- a/source/elements/oneDPL/source/parallel_api.rst +++ b/source/elements/oneDPL/source/parallel_api.rst @@ -451,5 +451,9 @@ than an element in the range being searched. The elements of ``[start, end)`` must be partitioned with respect to the comparator used. +.. toctree:: + + parallel_api/parallel_range_api.rst + .. _`C++ Standard`: https://isocpp.org/std/the-standard .. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst new file mode 100644 index 0000000000..2675a282ce --- /dev/null +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -0,0 +1,27 @@ +.. SPDX-FileCopyrightText: Contributors to the oneAPI Specification project. +.. +.. SPDX-License-Identifier: CC-BY-4.0 + +Parallel Ranges API +------------------- + +oneDPL provides variations of algorithms that work with ranges defined in the `C++ Standard`_, 6th edition (C++20). +These algorithms execute according to a oneDPL execution policy supplied as the first argument, similarly to other +oneDPL algorithms. + +The oneDPL parallel range algorithms rely on the functionality of C++20 and are not available in the code +compiled for earlier editions of the standard. + +The parallel range algorithms reside in ``namespace oneapi::dpl::ranges``. Same as the range algorithm functions +defined by the `C++ standard` in ``namespace std::ranges``, they cannot be found by argument-dependent name lookup. + +The following differences to the standard C++ range algorithms apply: + +- The execution policy parameter is added. +- Output data sequences are defined as ranges, not iterators. +- Both input and output ranges must support random access. +- For a given algorithm, at least one of the input ranges as well as the output range must be bounded. +- ``for_each`` does not return its function object. + +.. _`C++ Standard`: https://isocpp.org/std/the-standard +.. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html From 1b5c99e199e2e32210b0c3ff3c48b9c073db098f Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 23 Aug 2024 16:19:13 +0200 Subject: [PATCH 02/15] Add whole sequence operations --- .../parallel_api/parallel_range_api.rst | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 2675a282ce..48f5c53b86 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -23,5 +23,59 @@ The following differences to the standard C++ range algorithms apply: - For a given algorithm, at least one of the input ranges as well as the output range must be bounded. - ``for_each`` does not return its function object. +Whole Sequence Operations ++++++++++++++++++++++++++ + +.. code:: cpp + + // Defined in + + namespace oneapi::dpl::ranges { + + // all_of + template , Proj > > Pred> + requires oneapi::dpl::is_execution_policy_v> + && std::ranges::sized_range + bool all_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + + // any_of + template , Proj > > Pred> + requires oneapi::dpl::is_execution_policy_v> + && std::ranges::sized_range + bool any_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + + // none_of + template , Proj > > Pred> + requires oneapi::dpl::is_execution_policy_v> + && std::ranges::sized_range + bool none_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + + // for_each + template , Proj > > Fun> + requires oneapi::dpl::is_execution_policy_v> + && std::ranges::sized_range + borrowed_iterator_t for_each(ExecutionPolicy&& pol, R&& r, Fun f, Proj proj = {}); + + // count + template , Proj>> + requires oneapi::dpl::is_execution_policy_v> + && std::ranges::sized_range + && indirect_binary_predicate, Proj >, const T*> + range_difference_t count(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); + + // count_if + template , Proj > > Pred> + requires oneapi::dpl::is_execution_policy_v> + && std::ranges::sized_range + range_difference_t count_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + + } + .. _`C++ Standard`: https://isocpp.org/std/the-standard .. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html From 3147053db9811075f77608e934a4f84fdcc28c2f Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 23 Aug 2024 16:32:58 +0200 Subject: [PATCH 03/15] Add missing namespaces --- .../parallel_api/parallel_range_api.rst | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 48f5c53b86..b16add536b 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -33,47 +33,47 @@ Whole Sequence Operations namespace oneapi::dpl::ranges { // all_of - template , Proj > > Pred> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range bool all_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // any_of - template , Proj > > Pred> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range bool any_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // none_of - template , Proj > > Pred> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range bool none_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // for_each - template , Proj > > Fun> + template , Proj > > Fun> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range - borrowed_iterator_t for_each(ExecutionPolicy&& pol, R&& r, Fun f, Proj proj = {}); + std::ranges::borrowed_iterator_t for_each(ExecutionPolicy&& pol, R&& r, Fun f, Proj proj = {}); // count - template , Proj>> + template , Proj>> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range - && indirect_binary_predicate, Proj >, const T*> - range_difference_t count(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); + && std::indirect_binary_predicate, Proj >, const T*> + std::ranges::range_difference_t count(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); // count_if - template , Proj > > Pred> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range - range_difference_t count_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + std::ranges::range_difference_t count_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); } From 520e688a73f1b3f6e0679a699b42171e391cac18 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 23 Aug 2024 17:30:11 +0200 Subject: [PATCH 04/15] Format to fit the code block width --- .../parallel_api/parallel_range_api.rst | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index b16add536b..33c9701911 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -33,47 +33,58 @@ Whole Sequence Operations namespace oneapi::dpl::ranges { // all_of - template , Proj > > Pred> - requires oneapi::dpl::is_execution_policy_v> - && std::ranges::sized_range + template , Proj> > Pred> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range bool all_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // any_of - template , Proj > > Pred> - requires oneapi::dpl::is_execution_policy_v> - && std::ranges::sized_range + template , Proj> > Pred> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range bool any_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // none_of - template , Proj > > Pred> - requires oneapi::dpl::is_execution_policy_v> - && std::ranges::sized_range + template , Proj> > Pred> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range bool none_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // for_each - template , Proj > > Fun> - requires oneapi::dpl::is_execution_policy_v> - && std::ranges::sized_range - std::ranges::borrowed_iterator_t for_each(ExecutionPolicy&& pol, R&& r, Fun f, Proj proj = {}); + template , Proj> > Fn> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + std::ranges::borrowed_iterator_t + for_each(ExecutionPolicy&& pol, R&& r, Fn f, Proj proj = {}); // count - template , Proj>> - requires oneapi::dpl::is_execution_policy_v> - && std::ranges::sized_range - && std::indirect_binary_predicate, Proj >, const T*> - std::ranges::range_difference_t count(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && + std::indirect_binary_predicate, Proj>, + const T*> + std::ranges::range_difference_t + count(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); // count_if - template , Proj > > Pred> - requires oneapi::dpl::is_execution_policy_v> - && std::ranges::sized_range - std::ranges::range_difference_t count_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + template , Proj> > Pred> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + std::ranges::range_difference_t + count_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); } From 8e67056d6c627ed4802c33286e7dcc4e13354d71 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 23 Aug 2024 19:01:09 +0200 Subject: [PATCH 05/15] Add element search operations --- .../parallel_api/parallel_range_api.rst | 78 ++++++++++++++++++- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 33c9701911..dc450c6f5f 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -71,9 +71,9 @@ Whole Sequence Operations typename T = std::projected_value_t, Proj>> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range && - std::indirect_binary_predicate, Proj>, - const T*> + std::indirect_binary_predicate< std::ranges::equal_to, + std::projected, Proj>, + const T* > std::ranges::range_difference_t count(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); @@ -88,5 +88,77 @@ Whole Sequence Operations } +Element Search Operations ++++++++++++++++++++++++++ + +.. code:: cpp + + // Defined in + + namespace oneapi::dpl::ranges { + + // find + template , Proj>> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && + std::indirect_binary_predicate< std::ranges::equal_to, + std::projected, Proj>, + const T* > + std::ranges::borrowed_iterator_t + find(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); + + // find_if + template , Proj> > Pred> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + std::ranges::borrowed_iterator_t + find_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + + // find_if_not + template , Proj> > Pred> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + std::ranges::borrowed_iterator_t + find_if_not(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + + // adjacent_find + template , Proj>, + std::projected, Proj> > + Pred = std::ranges::equal_to> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + std::ranges::borrowed_iterator_t + adjacent_find(ExecutionPolicy&& pol, R&& r, Pred pred = {}, Proj proj = {}); + + // min_element + template , Proj> > + Comp = std::ranges::less> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + std::ranges::borrowed_iterator_t + min_element(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + + // max_element + template , Proj> > + Comp = std::ranges::less> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + std::ranges::borrowed_iterator_t + max_element(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + + } + .. _`C++ Standard`: https://isocpp.org/std/the-standard .. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html From 62a8d07bd92faf77e66a1feeccdbed8624dae27d Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 23 Aug 2024 20:01:43 +0200 Subject: [PATCH 06/15] Add missing namespaces --- .../oneDPL/source/parallel_api/parallel_range_api.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index dc450c6f5f..52a99125e9 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -130,8 +130,8 @@ Element Search Operations // adjacent_find template , Proj>, - std::projected, Proj> > + std::indirect_binary_predicate< std::projected, Proj>, + std::projected, Proj> > Pred = std::ranges::equal_to> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range @@ -141,7 +141,7 @@ Element Search Operations // min_element template , Proj> > + std::indirect_strict_weak_order< std::projected, Proj> > Comp = std::ranges::less> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range @@ -151,7 +151,7 @@ Element Search Operations // max_element template , Proj> > + std::indirect_strict_weak_order< std::projected, Proj> > Comp = std::ranges::less> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range From 61c15e4852b3fada668af43b037db2cda71d7776 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 23 Aug 2024 20:03:58 +0200 Subject: [PATCH 07/15] Add search and equal --- .../parallel_api/parallel_range_api.rst | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 52a99125e9..0d5308a48a 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -160,5 +160,50 @@ Element Search Operations } +Sequence Search and Comparison +++++++++++++++++++++++++++++++ + +.. code:: cpp + + // Defined in + + namespace oneapi::dpl::ranges { + + // equal + template + requires oneapi::dpl::is_execution_policy_v> && + (std::ranges::sized_range || std::ranges::sized_range) && + std::indirectly_comparable< std::ranges::iterator_t, std::ranges::iterator_t, + Pred, Proj1, Proj2 > + bool equal(ExecutionPolicy&& pol, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); + + // search + template + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && std::ranges::sized_range && + std::indirectly_comparable< std::ranges::iterator_t, std::ranges::iterator_t, + Pred, Proj1, Proj2 > + std::ranges::borrowed_subrange_t + search(ExecutionPolicy&& pol, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); + + // search_n + template, Proj>> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && + std::indirectly_comparable< std::ranges::iterator_t, const T*, Pred, Proj > + std::ranges::borrowed_subrange_t + search_n(ExecutionPolicy&& pol, R&& r, std::ranges::range_difference_t count, + const T& value, Pred pred = {}, Proj proj = {}); + + } + .. _`C++ Standard`: https://isocpp.org/std/the-standard .. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html From 949162d934a193d002cfcdeeeebccd2346bb8891 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 23 Aug 2024 23:17:45 +0200 Subject: [PATCH 08/15] Add sorting and merge algorithms --- .../parallel_api/parallel_range_api.rst | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 0d5308a48a..9e1595e310 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -31,7 +31,7 @@ Whole Sequence Operations // Defined in namespace oneapi::dpl::ranges { - + // all_of template + + namespace oneapi::dpl::ranges { + + // sort + template + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && std::sortable, Comp, Proj> + std::ranges::borrowed_iterator_t + sort(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + + // stable_sort + template + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && std::sortable, Comp, Proj> + std::ranges::borrowed_iterator_t + stable_sort(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + + // is_sorted + template , Proj> > + Comp = std::ranges::less> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range + bool is_sorted(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + + // merge + template + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && std::ranges::sized_range && + std::ranges::sized_range && + std::mergeable, std::ranges::iterator_t, + std::ranges::iterator_t, Comp, Proj1, Proj2> + std::ranges::merge_result, + std::ranges::borrowed_iterator_t, + std::ranges::borrowed_iterator_t> + merge(R1&& r1, R2&& r2, OutR&& result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + + } + .. _`C++ Standard`: https://isocpp.org/std/the-standard .. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html From 5ac78d114a056e2f689d1780684e0cfa41ed4f34 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Sat, 24 Aug 2024 00:00:22 +0200 Subject: [PATCH 09/15] Add mutating operations --- .../parallel_api/parallel_range_api.rst | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 9e1595e310..85915d7beb 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -232,7 +232,7 @@ Sorting and Merge // is_sorted template , Proj> > Comp = std::ranges::less> requires oneapi::dpl::is_execution_policy_v> && @@ -256,5 +256,66 @@ Sorting and Merge } +Mutating Operations ++++++++++++++++++++ + +.. code:: cpp + + // Defined in + + namespace oneapi::dpl::ranges { + + // copy + template + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && std::ranges::sized_range && + std::indirectly_copyable, std::ranges::iterator_t> + std::ranges::copy_result, + std::ranges::borrowed_iterator_t> + copy(ExecutionPolicy&& pol, R&& r, OutR&& result); + + // copy_if + template , Proj> > Pred> + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && std::ranges::sized_range && + std::indirectly_copyable, std::ranges::iterator_t> + std::ranges::copy_if_result, + std::ranges::borrowed_iterator_t> + copy_if(ExecutionPolicy&& pol, R&& r, OutR&& result, Pred pred, Proj proj = {}); + + // transform (unary) + template + requires oneapi::dpl::is_execution_policy_v> && + std::ranges::sized_range && std::ranges::sized_range && + std::indirectly_writable< std::ranges::iterator_t, + std::indirect_result_t, Proj>> > + std::ranges::unary_transform_result, + std::ranges::borrowed_iterator_t> + transform(ExecutionPolicy&& pol, R&& r, OutR&& result, Fn unary_op, Proj proj = {}); + + // transform (binary) + template + requires oneapi::dpl::is_execution_policy_v> && + (std::ranges::sized_range || std::ranges::sized_range) && + std::ranges::sized_range && + std::indirectly_writable< std::ranges::iterator_t, + std::indirect_result_t, Proj1>, + std::projected, Proj2>> > + std::ranges::binary_transform_result, + std::ranges::borrowed_iterator_t, + std::ranges::borrowed_iterator_t> + transform(ExecutionPolicy&& pol, R1&& r1, R2&& r2, OutR&& result, Fn binary_op, + Proj1 proj1 = {}, Proj2 proj2 = {}); + + } + .. _`C++ Standard`: https://isocpp.org/std/the-standard .. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html From 67e55a6134448902dbcb8b58da4cb1571798c4c2 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Sat, 24 Aug 2024 00:11:59 +0200 Subject: [PATCH 10/15] Separate function names from parameters --- .../parallel_api/parallel_range_api.rst | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 85915d7beb..e33d903efa 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -38,7 +38,7 @@ Whole Sequence Operations std::indirect_unary_predicate< std::projected, Proj> > Pred> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range - bool all_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + bool all_of (ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // any_of template , Proj> > Pred> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range - bool any_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + bool any_of (ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // none_of template , Proj> > Pred> requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range - bool none_of(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + bool none_of (ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // for_each template > && std::ranges::sized_range std::ranges::borrowed_iterator_t - for_each(ExecutionPolicy&& pol, R&& r, Fn f, Proj proj = {}); + for_each (ExecutionPolicy&& pol, R&& r, Fn f, Proj proj = {}); // count template , Proj>, const T* > std::ranges::range_difference_t - count(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); + count (ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); // count_if template > && std::ranges::sized_range std::ranges::range_difference_t - count_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + count_if (ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); } @@ -107,7 +107,7 @@ Element Search Operations std::projected, Proj>, const T* > std::ranges::borrowed_iterator_t - find(ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); + find (ExecutionPolicy&& pol, R&& r, const T& value, Proj proj = {}); // find_if template > && std::ranges::sized_range std::ranges::borrowed_iterator_t - find_if(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + find_if (ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // find_if_not template > && std::ranges::sized_range std::ranges::borrowed_iterator_t - find_if_not(ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); + find_if_not (ExecutionPolicy&& pol, R&& r, Pred pred, Proj proj = {}); // adjacent_find template > && std::ranges::sized_range std::ranges::borrowed_iterator_t - adjacent_find(ExecutionPolicy&& pol, R&& r, Pred pred = {}, Proj proj = {}); + adjacent_find (ExecutionPolicy&& pol, R&& r, Pred pred = {}, Proj proj = {}); // min_element template > && std::ranges::sized_range std::ranges::borrowed_iterator_t - min_element(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + min_element (ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); // max_element template > && std::ranges::sized_range std::ranges::borrowed_iterator_t - max_element(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + max_element (ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); } @@ -177,8 +177,8 @@ Sequence Search and Comparison (std::ranges::sized_range || std::ranges::sized_range) && std::indirectly_comparable< std::ranges::iterator_t, std::ranges::iterator_t, Pred, Proj1, Proj2 > - bool equal(ExecutionPolicy&& pol, R1&& r1, R2&& r2, Pred pred = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); + bool equal (ExecutionPolicy&& pol, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // search template, std::ranges::iterator_t, Pred, Proj1, Proj2 > std::ranges::borrowed_subrange_t - search(ExecutionPolicy&& pol, R1&& r1, R2&& r2, Pred pred = {}, - Proj1 proj1 = {}, Proj2 proj2 = {}); + search (ExecutionPolicy&& pol, R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // search_n template && std::indirectly_comparable< std::ranges::iterator_t, const T*, Pred, Proj > std::ranges::borrowed_subrange_t - search_n(ExecutionPolicy&& pol, R&& r, std::ranges::range_difference_t count, - const T& value, Pred pred = {}, Proj proj = {}); + search_n (ExecutionPolicy&& pol, R&& r, std::ranges::range_difference_t count, + const T& value, Pred pred = {}, Proj proj = {}); } @@ -220,7 +220,7 @@ Sorting and Merge requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range && std::sortable, Comp, Proj> std::ranges::borrowed_iterator_t - sort(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + sort (ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); // stable_sort template > && std::ranges::sized_range && std::sortable, Comp, Proj> std::ranges::borrowed_iterator_t - stable_sort(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + stable_sort (ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); // is_sorted template requires oneapi::dpl::is_execution_policy_v> && std::ranges::sized_range - bool is_sorted(ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); + bool is_sorted (ExecutionPolicy&& pol, R&& r, Comp comp = {}, Proj proj = {}); // merge template , std::ranges::borrowed_iterator_t, std::ranges::borrowed_iterator_t> - merge(R1&& r1, R2&& r2, OutR&& result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); + merge (R1&& r1, R2&& r2, OutR&& result, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); } @@ -273,7 +273,7 @@ Mutating Operations std::indirectly_copyable, std::ranges::iterator_t> std::ranges::copy_result, std::ranges::borrowed_iterator_t> - copy(ExecutionPolicy&& pol, R&& r, OutR&& result); + copy (ExecutionPolicy&& pol, R&& r, OutR&& result); // copy_if template , std::ranges::iterator_t> std::ranges::copy_if_result, std::ranges::borrowed_iterator_t> - copy_if(ExecutionPolicy&& pol, R&& r, OutR&& result, Pred pred, Proj proj = {}); + copy_if (ExecutionPolicy&& pol, R&& r, OutR&& result, Pred pred, Proj proj = {}); // transform (unary) template , Proj>> > std::ranges::unary_transform_result, std::ranges::borrowed_iterator_t> - transform(ExecutionPolicy&& pol, R&& r, OutR&& result, Fn unary_op, Proj proj = {}); + transform (ExecutionPolicy&& pol, R&& r, OutR&& result, Fn unary_op, Proj proj = {}); // transform (binary) template , std::ranges::borrowed_iterator_t, std::ranges::borrowed_iterator_t> - transform(ExecutionPolicy&& pol, R1&& r1, R2&& r2, OutR&& result, Fn binary_op, - Proj1 proj1 = {}, Proj2 proj2 = {}); + transform (ExecutionPolicy&& pol, R1&& r1, R2&& r2, OutR&& result, Fn binary_op, + Proj1 proj1 = {}, Proj2 proj2 = {}); } From c70213e120fb2f09841fe438e7b38fd5d171f3b4 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Fri, 6 Sep 2024 18:48:41 +0200 Subject: [PATCH 11/15] Change the header file to match the standard --- .../oneDPL/source/parallel_api/parallel_range_api.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index e33d903efa..15711dc9c6 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -28,7 +28,7 @@ Whole Sequence Operations .. code:: cpp - // Defined in + // Defined in namespace oneapi::dpl::ranges { @@ -93,7 +93,7 @@ Element Search Operations .. code:: cpp - // Defined in + // Defined in namespace oneapi::dpl::ranges { @@ -165,7 +165,7 @@ Sequence Search and Comparison .. code:: cpp - // Defined in + // Defined in namespace oneapi::dpl::ranges { @@ -210,7 +210,7 @@ Sorting and Merge .. code:: cpp - // Defined in + // Defined in namespace oneapi::dpl::ranges { @@ -261,7 +261,7 @@ Mutating Operations .. code:: cpp - // Defined in + // Defined in namespace oneapi::dpl::ranges { From 7e00eebfbebf943f732f4369874b52f900d926f9 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Mon, 9 Sep 2024 11:53:11 +0200 Subject: [PATCH 12/15] Add a note describing a usual implementation --- .../oneDPL/source/parallel_api/parallel_range_api.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index 15711dc9c6..e8452e1e10 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -10,10 +10,12 @@ These algorithms execute according to a oneDPL execution policy supplied as the oneDPL algorithms. The oneDPL parallel range algorithms rely on the functionality of C++20 and are not available in the code -compiled for earlier editions of the standard. +compiled for earlier editions of the C++ standard. The parallel range algorithms reside in ``namespace oneapi::dpl::ranges``. Same as the range algorithm functions -defined by the `C++ standard` in ``namespace std::ranges``, they cannot be found by argument-dependent name lookup. +defined by the C++ standard in ``namespace std::ranges``, they cannot be found by argument-dependent name lookup +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: From 8e5706f34a33fb92c02c3949286da2319d25504e Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Mon, 9 Sep 2024 16:58:08 +0200 Subject: [PATCH 13/15] Add a note about parallel range algorithms --- source/elements/oneDPL/source/parallel_api.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/elements/oneDPL/source/parallel_api.rst b/source/elements/oneDPL/source/parallel_api.rst index f910212959..c4983ee20f 100644 --- a/source/elements/oneDPL/source/parallel_api.rst +++ b/source/elements/oneDPL/source/parallel_api.rst @@ -10,6 +10,9 @@ including parallel algorithms added in the 6th edition known as C++20. All those algorithms work with *C++ Standard aligned execution policies* and with *device execution policies*. +oneDPL also provides *parallel range algorithms*: variations of C++20 range-based algorithms +that take a oneDPL execution policy. + Additionally, oneDPL provides wrapper functions for `SYCL`_ buffers, special iterators, and a set of non-standard parallel algorithms. From a37c2405c0fcc6d43b37751516bd86fe76b33ba5 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Sat, 21 Sep 2024 21:48:10 +0200 Subject: [PATCH 14/15] Address the review feedback --- .../source/parallel_api/parallel_range_api.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst index e8452e1e10..ff3f348349 100644 --- a/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst +++ b/source/elements/oneDPL/source/parallel_api/parallel_range_api.rst @@ -2,12 +2,12 @@ .. .. SPDX-License-Identifier: CC-BY-4.0 -Parallel Ranges API -------------------- +Parallel Range Algorithms +------------------------- -oneDPL provides variations of algorithms that work with ranges defined in the `C++ Standard`_, 6th edition (C++20). -These algorithms execute according to a oneDPL execution policy supplied as the first argument, similarly to other -oneDPL algorithms. +oneDPL provides variations of algorithms that work with ranges defined in the `C++ Standard`_, 6th edition (C++20) +and newer. These algorithms execute according to a oneDPL execution policy supplied as the first argument, +similarly to other oneDPL algorithms. The oneDPL parallel range algorithms rely on the functionality of C++20 and are not available in the code compiled for earlier editions of the C++ standard. @@ -19,12 +19,16 @@ predefined function objects which static function call operators have the requir The following differences to the standard C++ range algorithms apply: +- Parallel range algorithms cannot be used in constant expressions. - The execution policy parameter is added. - Output data sequences are defined as ranges, not iterators. - Both input and output ranges must support random access. - For a given algorithm, at least one of the input ranges as well as the output range must be bounded. - ``for_each`` does not return its function object. +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). + Whole Sequence Operations +++++++++++++++++++++++++ From 19d7532ee7465c941e8f9a27b065f3aa6aeb5d46 Mon Sep 17 00:00:00 2001 From: Alexey Kukanov Date: Thu, 3 Oct 2024 18:37:50 +0200 Subject: [PATCH 15/15] Add the SPDX tag for contributors' copyright --- source/elements/oneDPL/source/parallel_api.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/source/elements/oneDPL/source/parallel_api.rst b/source/elements/oneDPL/source/parallel_api.rst index c4983ee20f..c0945c9fba 100644 --- a/source/elements/oneDPL/source/parallel_api.rst +++ b/source/elements/oneDPL/source/parallel_api.rst @@ -1,4 +1,5 @@ .. SPDX-FileCopyrightText: 2019-2022 Intel Corporation +.. SPDX-FileCopyrightText: Contributors to the oneAPI Specification project. .. .. SPDX-License-Identifier: CC-BY-4.0