aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxxcuda11/include/execution
blob: 56facc87379ef1c06ac7442e08cc5bd6ce090c71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_EXECUTION
#define _LIBCPP_EXECUTION

/*
namespace std::execution {
  struct sequenced_policy;
  struct parallel_policy;
  struct parallel_unsequenced_policy;
  struct unsequenced_policy; // since C++20

  inline constexpr sequenced_policy seq = implementation-defined;
  inline constexpr parallel_policy par = implementation-defined;
  inline constexpr parallel_unsequenced_policy par_unseq = implementation-defined;
  inline constexpr unsequenced_policy unseq = implementation-defined; // since C++20
}

namespace std {
  template <class T>
  struct is_execution_policy;

  template <class T>
  inline constexpr bool is_execution_policy_v;
}
*/

#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/is_same.h>
#include <__type_traits/remove_cvref.h>
#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#  pragma GCC system_header
#endif

#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17

_LIBCPP_BEGIN_NAMESPACE_STD

namespace execution {
struct sequenced_policy {
  _LIBCPP_HIDE_FROM_ABI constexpr explicit sequenced_policy(__disable_user_instantiations_tag) {}
  sequenced_policy(const sequenced_policy&)            = delete;
  sequenced_policy& operator=(const sequenced_policy&) = delete;
};

inline constexpr sequenced_policy seq{__disable_user_instantiations_tag{}};

struct parallel_policy {
  _LIBCPP_HIDE_FROM_ABI constexpr explicit parallel_policy(__disable_user_instantiations_tag) {}
  parallel_policy(const parallel_policy&)            = delete;
  parallel_policy& operator=(const parallel_policy&) = delete;
};

inline constexpr parallel_policy par{__disable_user_instantiations_tag{}};

struct parallel_unsequenced_policy {
  _LIBCPP_HIDE_FROM_ABI constexpr explicit parallel_unsequenced_policy(__disable_user_instantiations_tag) {}
  parallel_unsequenced_policy(const parallel_unsequenced_policy&)            = delete;
  parallel_unsequenced_policy& operator=(const parallel_unsequenced_policy&) = delete;
};

inline constexpr parallel_unsequenced_policy par_unseq{__disable_user_instantiations_tag{}};

struct __unsequenced_policy {
  _LIBCPP_HIDE_FROM_ABI constexpr explicit __unsequenced_policy(__disable_user_instantiations_tag) {}
  __unsequenced_policy(const __unsequenced_policy&)            = delete;
  __unsequenced_policy& operator=(const __unsequenced_policy&) = delete;
};

constexpr __unsequenced_policy __unseq{__disable_user_instantiations_tag{}};

#  if _LIBCPP_STD_VER >= 20

struct unsequenced_policy {
  _LIBCPP_HIDE_FROM_ABI constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {}
  unsequenced_policy(const unsequenced_policy&)            = delete;
  unsequenced_policy& operator=(const unsequenced_policy&) = delete;
};

inline constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}};

#  endif // _LIBCPP_STD_VER >= 20

} // namespace execution

template <>
inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true;

template <>
inline constexpr bool is_execution_policy_v<execution::parallel_policy> = true;

template <>
inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_policy> = true;

template <>
inline constexpr bool is_execution_policy_v<execution::__unsequenced_policy> = true;

template <>
inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_policy> = true;

template <>
inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_unsequenced_policy> = true;

template <>
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::__unsequenced_policy> = true;

template <>
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::parallel_unsequenced_policy> = true;

#  if _LIBCPP_STD_VER >= 20
template <>
inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true;

template <>
inline constexpr bool __is_unsequenced_execution_policy_impl<execution::unsequenced_policy> = true;

#  endif

template <class _Tp>
struct is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {};

template <class _ExecutionPolicy>
_LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) {
  if constexpr (is_same_v<_ExecutionPolicy, execution::parallel_policy>) {
    return execution::sequenced_policy(execution::__disable_user_instantiations_tag{});
  } else if constexpr (is_same_v<_ExecutionPolicy, execution::parallel_unsequenced_policy>) {
    return execution::__unsequenced_policy{execution::__disable_user_instantiations_tag{}};
  }
}

_LIBCPP_END_NAMESPACE_STD

#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17

#endif // _LIBCPP_EXECUTION