1 | // -*- C++ -*- |
2 | //===-- execution_defs.h --------------------------------------------------===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _PSTL_EXECUTION_POLICY_DEFS_H |
11 | #define _PSTL_EXECUTION_POLICY_DEFS_H |
12 | |
13 | #include <type_traits> |
14 | |
15 | namespace __pstl |
16 | { |
17 | namespace execution |
18 | { |
19 | inline namespace v1 |
20 | { |
21 | |
22 | // 2.4, Sequential execution policy |
23 | class sequenced_policy |
24 | { |
25 | }; |
26 | |
27 | // 2.5, Parallel execution policy |
28 | class parallel_policy |
29 | { |
30 | }; |
31 | |
32 | // 2.6, Parallel+Vector execution policy |
33 | class parallel_unsequenced_policy |
34 | { |
35 | }; |
36 | |
37 | class unsequenced_policy |
38 | { |
39 | }; |
40 | |
41 | // 2.8, Execution policy objects |
42 | _GLIBCXX17_INLINE constexpr sequenced_policy seq{}; |
43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; |
44 | _GLIBCXX17_INLINE constexpr parallel_unsequenced_policy par_unseq{}; |
45 | _GLIBCXX17_INLINE constexpr unsequenced_policy unseq{}; |
46 | |
47 | // 2.3, Execution policy type trait |
48 | template <class _Tp> |
49 | struct is_execution_policy : std::false_type |
50 | { |
51 | }; |
52 | |
53 | template <> |
54 | struct is_execution_policy<__pstl::execution::sequenced_policy> : std::true_type |
55 | { |
56 | }; |
57 | template <> |
58 | struct is_execution_policy<__pstl::execution::parallel_policy> : std::true_type |
59 | { |
60 | }; |
61 | template <> |
62 | struct is_execution_policy<__pstl::execution::parallel_unsequenced_policy> : std::true_type |
63 | { |
64 | }; |
65 | template <> |
66 | struct is_execution_policy<__pstl::execution::unsequenced_policy> : std::true_type |
67 | { |
68 | }; |
69 | |
70 | #if defined (_PSTL_CPP14_VARIABLE_TEMPLATES_PRESENT) |
71 | template <class _Tp> |
72 | constexpr bool is_execution_policy_v = __pstl::execution::is_execution_policy<_Tp>::value; |
73 | #endif |
74 | |
75 | } // namespace v1 |
76 | } // namespace execution |
77 | |
78 | namespace __internal |
79 | { |
80 | template <class _ExecPolicy, class _Tp> |
81 | #if _GLIBCXX_RELEASE >= 9 |
82 | using __enable_if_execution_policy = |
83 | typename std::enable_if<__pstl::execution::is_execution_policy<std::__remove_cvref_t<_ExecPolicy>>::value, |
84 | _Tp>::type; |
85 | #else |
86 | using __enable_if_execution_policy = |
87 | typename std::enable_if<__pstl::execution::is_execution_policy<typename std::decay<_ExecPolicy>::type>::value, |
88 | _Tp>::type; |
89 | #endif |
90 | |
91 | template <class _IsVector> |
92 | struct __serial_tag; |
93 | template <class _IsVector> |
94 | struct __parallel_tag; |
95 | |
96 | } // namespace __internal |
97 | |
98 | } // namespace __pstl |
99 | |
100 | #endif /* _PSTL_EXECUTION_POLICY_DEFS_H */ |
101 | |