@@ -9,8 +9,7 @@ Execution Policies
99C++ Standard Aligned Execution Policies
1010+++++++++++++++++++++++++++++++++++++++
1111
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):
1413
1514.. code :: cpp
1615
@@ -30,17 +29,16 @@ with the `C++ Standard`_, 6th edition (C++20):
3029 inline constexpr parallel_unsequenced_policy par_unseq { /*unspecified*/ };
3130 inline constexpr unsequenced_policy unseq { /*unspecified*/ };
3231
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;
3832 }
3933 }
4034 }
4135
4236 See "Execution policies" in the `C++ Standard `_ for more information.
4337
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+
4442Device Execution Policy
4543+++++++++++++++++++++++
4644
@@ -180,5 +178,54 @@ as the template argument, otherwise unspecified.
180178 Return a policy object constructed from ``policy ``, with a new kernel name provided as the template
181179argument. If no policy object is provided, the new policy is constructed from ``dpcpp_default ``.
182180
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+
183230.. _`C++ Standard` : https://isocpp.org/std/the-standard
184231.. _`SYCL` : https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html
0 commit comments