66 Parallel Algorithms
77-------------------
88
9- The parallel algorithms are defined in the ``<oneapi/dpl/algorithm> `` header,
10- in ``namespace oneapi::dpl ``.
9+ oneDPL parallel algorithms are function templates analogous to the algorithms with execution policies defined
10+ in the `C++ Standard `_, 5th and 6th editions (C++17/20), as well as additional non-standard function templates.
11+
12+ oneDPL parallel algorithms reside in ``namespace oneapi::dpl ``.
13+ Standard-aligned algorithms are defined in the ``<oneapi/dpl/algorithm> ``, ``<oneapi/dpl/numeric> ``,
14+ and ``<oneapi/dpl/memory> `` header files, aligned with how the `C++ Standard `_ places the respective functions
15+ into the standard header files.
16+
17+ The parallel algorithms execute according to a oneDPL execution policy supplied as the first argument.
18+
19+ Where applicable, oneDPL supports
20+ `list initialization of value parameters <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2248r8.html >`_
21+ of the algorithms, as in the working draft of the next C++ standard edition (C++26).
22+
23+ Additional Algorithms
24+ +++++++++++++++++++++
25+
26+ In addition to the standard-aligned parallel algorithms, oneDPL provides the following algorithm functions.
27+
28+ For compatibility with the previous versions of the specification, besides their indicated header files
29+ all these algorithms are defined in ``<oneapi/dpl/algorithm> ``. [*Note *: This may be deprecated in the future. -- *end note *]
1130
1231.. code :: cpp
1332
33+ // Defined in <oneapi/dpl/numeric>
1434 template<typename Policy, typename InputKeyIt, typename InputValueIt,
1535 typename OutputValueIt,
1636 typename T = typename std::iterator_traits<InputValueIt>::value_type,
@@ -42,6 +62,7 @@ provided to combine the elements of the value subsequences.
4262
4363.. code :: cpp
4464
65+ // Defined in <oneapi/dpl/numeric>
4566 template<typename Policy, typename InputKeyIt, typename InputValueIt,
4667 typename OutputValueIt,
4768 typename BinaryPredcate =
@@ -69,6 +90,7 @@ no binary operator is provided to combine the elements of the value subsequences
6990
7091.. code :: cpp
7192
93+ // Defined in <oneapi/dpl/numeric>
7294 template<typename Policy, typename InputKeyIt, typename InputValueIt,
7395 typename OutputKeyIt, typename OutputValueIt,
7496 typename BinaryPredcate =
@@ -98,6 +120,7 @@ combine the values in each subsequence identified if a binary operator is not pr
98120
99121.. code :: cpp
100122
123+ // Defined in <oneapi/dpl/algorithm>
101124 template<typename Policy, typename InputIt1, typename InputIt2, typename OutputIt,
102125 typename Comparator =
103126 std::less<typename std::iterator_traits<InputIt>::value_type>>
@@ -109,18 +132,17 @@ combine the values in each subsequence identified if a binary operator is not pr
109132
110133 ``oneapi::dpl::binary_search `` performs a binary search over the data in ``[start, end) ``
111134for each value in ``[value_first, value_last) ``. If the value exists in the data searched then
112- the corresponding element in ``[result, result + distance(value_first, value_last)) `` is set to
135+ the corresponding element in ``[result, result + std:: distance(value_first, value_last)) `` is set to
113136true, otherwise it is set to false.
114137
115- If no comparator is provided, ``operator< `` is used to determine when the search value is less
116- than an element in the range being searched.
117-
118- The elements of ``[start, end) `` must be partitioned with respect to the comparator used. For all
138+ The elements of ``[start, end) `` must be partitioned with respect to the comparator used,
139+ or with respect to ``std::less `` if no comparator is provided. For all
119140elements ``e `` in ``[start, end) `` and a given search value ``v `` in ``[value_first, value_last) ``,
120141``comp(e, v) `` implies ``!comp(v, e) ``.
121142
122143.. code :: cpp
123144
145+ // Defined in <oneapi/dpl/algorithm>
124146 template<typename Policy, typename InputIt1, typename InputIt2, typename OutputIt,
125147 typename Comparator =
126148 std::less<typename std::iterator_traits<InputIt>::value_type>>
@@ -134,15 +156,14 @@ elements ``e`` in ``[start, end)`` and a given search value ``v`` in ``[value_fi
134156each value in ``[value_first, value_last) `` to find the lowest index at which the search value
135157could be inserted in ``[start, end) `` without violating the ordering defined by the comparator
136158provided. That lowest index is then assigned to the corresponding element in
137- ``[result, result + distance(value_first, value_last)) ``.
159+ ``[result, result + std:: distance(value_first, value_last)) ``.
138160
139- If no comparator is provided, ``operator< `` is used to determine when the search value is less
140- than an element in the range being searched.
141-
142- The elements of ``[start, end) `` must be partitioned with respect to the comparator used.
161+ The elements of ``[start, end) `` must be partitioned with respect to the comparator used,
162+ or with respect to ``std::less `` if no comparator is provided.
143163
144164.. code :: cpp
145165
166+ // Defined in <oneapi/dpl/algorithm>
146167 template<typename Policy, typename InputIt1, typename InputIt2, typename OutputIt,
147168 typename Comparator =
148169 std::less<typename std::iterator_traits<InputIt>::value_type>>
@@ -156,15 +177,14 @@ The elements of ``[start, end)`` must be partitioned with respect to the compara
156177for each value in ``[value_first, value_last) `` to find the highest index at which the search
157178value could be inserted in ``[start, end) `` without violating the ordering defined by the
158179comparator provided. That highest index is then assigned to the corresponding element in
159- ``[result, result + distance(value_first, value_last)) ``.
160-
161- If no comparator is provided, ``operator< `` is used to determine when the search value is less
162- than an element in the range being searched.
180+ ``[result, result + std::distance(value_first, value_last)) ``.
163181
164- The elements of ``[start, end) `` must be partitioned with respect to the comparator used.
182+ The elements of ``[start, end) `` must be partitioned with respect to the comparator used,
183+ or with respect to ``std::less `` if no comparator is provided.
165184
166185.. code :: cpp
167186
187+ // Defined in <oneapi/dpl/algorithm>
168188 template <typename Policy, typename InputIt, typename OutputIt, typename UnaryOp,
169189 typename UnaryPredicate>
170190 OutputIt
@@ -196,6 +216,7 @@ satisfy a given predicate, and stores the result to the output. Depending on the
196216
197217.. code :: cpp
198218
219+ // Defined in <oneapi/dpl/algorithm>
199220 template<typename Policy, typename KeyIt, typename ValueIt,
200221 typename Comparator = std::less<typename std::iterator_traits<KeyIt>::value_type>>
201222 void
@@ -223,6 +244,7 @@ as defined by the `C++ Standard`_.
223244
224245.. code :: cpp
225246
247+ // Defined in <oneapi/dpl/algorithm>
226248 template<typename Policy, typename KeyIt, typename ValueIt,
227249 typename Comparator = std::less<typename std::iterator_traits<KeyIt>::value_type>>
228250 void
@@ -250,6 +272,7 @@ as defined by the `C++ Standard`_.
250272
251273.. code :: cpp
252274
275+ // Defined in <oneapi/dpl/numeric>
253276 template <typename Policy, typename InputIt, typename Size, typename ValueType,
254277 typename OutputIt>
255278 OutputIt
0 commit comments