2323
2424#include < cuda/std/__concepts/concept_macros.h>
2525#include < cuda/std/__execution/env.h>
26+ #include < cuda/std/__execution/policy.h>
2627#include < cuda/std/__type_traits/is_convertible.h>
28+ #include < cuda/std/__type_traits/is_execution_policy.h>
2729
2830#include < cuda/experimental/__execution/prologue.cuh>
2931
30- namespace cuda ::experimental
32+ namespace cuda ::experimental::execution
3133{
32- namespace execution
33- {
34- struct sequenced_policy ;
35- struct parallel_policy ;
36- struct parallel_unsequenced_policy ;
37- struct unsequenced_policy ;
38- struct any_execution_policy ;
39- } // namespace execution
40-
41- // execution policy type trait
42- template <class _Ty >
43- inline constexpr bool is_execution_policy_v = false ;
44-
45- template <>
46- inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true ;
47-
48- template <>
49- inline constexpr bool is_execution_policy_v<execution::parallel_policy> = true ;
50-
51- template <>
52- inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_policy> = true ;
53-
54- template <>
55- inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true ;
5634
57- template <>
58- inline constexpr bool is_execution_policy_v<execution::any_execution_policy> = true ;
59-
60- template <class _Ty >
61- struct is_execution_policy : ::cuda::std::bool_constant<is_execution_policy_v<_Ty>>
62- {};
63-
64- namespace execution
65- {
66- enum class __execution_policy
67- {
68- invalid_execution_policy,
69- sequenced,
70- parallel,
71- parallel_unsequenced,
72- unsequenced,
73- };
74-
75- template <__execution_policy _Policy>
76- struct __policy ;
35+ using ::cuda::std::execution::__execution_policy;
36+ using ::cuda::std::execution::par;
37+ using ::cuda::std::execution::par_unseq;
38+ using ::cuda::std::execution::seq;
39+ using ::cuda::std::execution::unseq;
7740
7841struct any_execution_policy
7942{
@@ -83,8 +46,8 @@ struct any_execution_policy
8346 _CCCL_HIDE_FROM_ABI any_execution_policy () = default;
8447
8548 template <__execution_policy _Policy>
86- _CCCL_HOST_API constexpr any_execution_policy (__policy<_Policy> __pol ) noexcept
87- : value(__pol )
49+ _CCCL_HOST_API constexpr any_execution_policy (::cuda::std::execution:: __policy<_Policy>) noexcept
50+ : value(_Policy )
8851 {}
8952
9053 _CCCL_HOST_API constexpr operator __execution_policy () const noexcept
@@ -97,37 +60,38 @@ struct any_execution_policy
9760 return value;
9861 }
9962
100- __execution_policy value = __execution_policy::invalid_execution_policy;
101- };
102-
103- template <__execution_policy _Policy>
104- struct _CCCL_DECLSPEC_EMPTY_BASES __policy : ::cuda::std::integral_constant<__execution_policy, _Policy>
105- {};
106-
107- struct sequenced_policy : __policy<__execution_policy::sequenced>
108- {};
109-
110- struct parallel_policy : __policy<__execution_policy::parallel>
111- {};
112-
113- struct parallel_unsequenced_policy : __policy<__execution_policy::parallel_unsequenced>
114- {};
63+ template <__execution_policy _Policy>
64+ [[nodiscard]] _CCCL_HOST_API friend constexpr bool
65+ operator ==(const any_execution_policy& pol, const ::cuda::std::execution::__policy<_Policy>&) noexcept
66+ {
67+ return pol.value == _Policy;
68+ }
11569
116- struct unsequenced_policy : __policy<__execution_policy::unsequenced>
117- {};
70+ #if _CCCL_STD_VER <= 2017
71+ template <__execution_policy _Policy>
72+ [[nodiscard]] _CCCL_HOST_API friend constexpr bool
73+ operator ==(const ::cuda::std::execution::__policy<_Policy>&, const any_execution_policy& pol) noexcept
74+ {
75+ return pol.value == _Policy;
76+ }
11877
119- _CCCL_GLOBAL_CONSTANT sequenced_policy seq{};
120- _CCCL_GLOBAL_CONSTANT parallel_policy par{};
121- _CCCL_GLOBAL_CONSTANT parallel_unsequenced_policy par_unseq{};
122- _CCCL_GLOBAL_CONSTANT unsequenced_policy unseq{};
78+ template <__execution_policy _Policy>
79+ [[nodiscard]] _CCCL_HOST_API friend constexpr bool
80+ operator !=(const any_execution_policy& pol, const ::cuda::std::execution::__policy<_Policy>&) noexcept
81+ {
82+ return pol.value != _Policy;
83+ }
12384
124- template <__execution_policy _Policy>
125- inline constexpr bool __is_parallel_execution_policy =
126- _Policy == __execution_policy::parallel || _Policy == __execution_policy::parallel_unsequenced;
85+ template <__execution_policy _Policy>
86+ [[nodiscard]] _CCCL_HOST_API friend constexpr bool
87+ operator !=(const ::cuda::std::execution::__policy<_Policy>&, const any_execution_policy& pol)
88+ {
89+ return pol.value != _Policy;
90+ }
91+ #endif // _CCCL_STD_VER <= 2017
12792
128- template <__execution_policy _Policy>
129- inline constexpr bool __is_unsequenced_execution_policy =
130- _Policy == __execution_policy::unsequenced || _Policy == __execution_policy::parallel_unsequenced;
93+ __execution_policy value = __execution_policy::__invalid_execution_policy;
94+ };
13195
13296struct get_execution_policy_t ;
13397
@@ -161,8 +125,14 @@ struct get_execution_policy_t
161125
162126_CCCL_GLOBAL_CONSTANT get_execution_policy_t get_execution_policy{};
163127
164- } // namespace execution
165- } // namespace cuda::experimental
128+ } // namespace cuda::experimental::execution
129+
130+ _CCCL_BEGIN_NAMESPACE_CUDA_STD
131+
132+ template <>
133+ inline constexpr bool is_execution_policy_v<::cuda::experimental::execution::any_execution_policy> = true ;
134+
135+ _CCCL_END_NAMESPACE_CUDA_STD
166136
167137#include < cuda/experimental/__execution/epilogue.cuh>
168138
0 commit comments