@@ -9,8 +9,7 @@ Execution Policies
9
9
C++ Standard Aligned Execution Policies
10
10
+++++++++++++++++++++++++++++++++++++++
11
11
12
- oneDPL has the set of execution policies and related utilities that are semantically aligned
13
- with the `C++ Standard `_, 6th edition (C++20):
12
+ oneDPL has the set of execution policies semantically aligned with the `C++ Standard `_, 6th edition (C++20):
14
13
15
14
.. code :: cpp
16
15
@@ -30,17 +29,16 @@ with the `C++ Standard`_, 6th edition (C++20):
30
29
inline constexpr parallel_unsequenced_policy par_unseq { /*unspecified*/ };
31
30
inline constexpr unsequenced_policy unseq { /*unspecified*/ };
32
31
33
- template <class T>
34
- struct is_execution_policy;
35
-
36
- template <class T>
37
- inline constexpr bool is_execution_policy_v = oneapi::dpl::execution::is_execution_policy<T>::value;
38
32
}
39
33
}
40
34
}
41
35
42
36
See "Execution policies" in the `C++ Standard `_ for more information.
43
37
38
+ .. note ::
39
+ The ``std::is_execution_policy `` type trait resolves to ``std::false_type `` for oneDPL execution policies.
40
+ Implementations and programs should instead use the :ref: `oneDPL type trait <exec-policy-type-trait >`.
41
+
44
42
Device Execution Policy
45
43
+++++++++++++++++++++++
46
44
@@ -180,5 +178,54 @@ as the template argument, otherwise unspecified.
180
178
Return a policy object constructed from ``policy ``, with a new kernel name provided as the template
181
179
argument. If no policy object is provided, the new policy is constructed from ``dpcpp_default ``.
182
180
181
+ .. _exec-policy-type-trait :
182
+
183
+ Execution Policy Type Trait
184
+ +++++++++++++++++++++++++++
185
+
186
+ oneDPL provides type trait utilities to detect its execution policy types at compile time for the purpose of
187
+ function overload resolution:
188
+
189
+ .. code :: cpp
190
+
191
+ // Defined in <oneapi/dpl/execution>
192
+
193
+ namespace oneapi {
194
+ namespace dpl {
195
+
196
+ template <class T>
197
+ struct is_execution_policy { /*see below*/ };
198
+
199
+ template <class T>
200
+ inline constexpr bool is_execution_policy_v = oneapi::dpl::is_execution_policy<T>::value;
201
+
202
+ namespace execution {
203
+
204
+ template <class T>
205
+ struct is_execution_policy { /*see below*/ };
206
+
207
+ template <class T>
208
+ inline constexpr bool is_execution_policy_v = oneapi::dpl::execution::is_execution_policy<T>::value;
209
+
210
+ }
211
+ }
212
+ }
213
+
214
+ ``oneapi::dpl::is_execution_policy `` and ``oneapi::dpl::execution::is_execution_policy `` must be treated
215
+ as name aliases to the same class template. It is unspecified, which namespace contains the class template
216
+ definition and its specializations.
217
+
218
+ .. note ::
219
+ The ``oneapi::dpl::execution::is_execution_policy `` class originated in the oneDPL specification version 1.0,
220
+ while ``oneapi::dpl::is_execution_policy `` has been added later to better align with the C++ standard.
221
+
222
+ For new code, use of the type trait utilities in ``namespace oneapi::dpl `` is highly recommended. Those
223
+ in ``namespace oneapi::dpl::execution `` are provided for backward compatibility and may be deprecated in the future.
224
+
225
+ ``is_execution_policy<T> `` must have the characteristics of ``std::true_type `` if ``T `` is one of the above specified or
226
+ implementation-defined oneDPL execution policy types, otherwise it must have the characteristics of ``std::false_type ``.
227
+ Following the C++ Standard, ``is_execution_policy<T> `` does not automatically strip references and cv-qualifiers from
228
+ its template argument. [*Note *: Use it with ``std::decay_t<T> `` or similar type transformation utilities. -- *end note *]
229
+
183
230
.. _`C++ Standard` : https://isocpp.org/std/the-standard
184
231
.. _`SYCL` : https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html
0 commit comments