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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
|
//===----------------------------------------------------------------------===//
//
// 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___PSTL_BACKEND_FWD_H
#define _LIBCPP___PSTL_BACKEND_FWD_H
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
//
// This header declares available PSTL backends and the functions that must be implemented in order for the
// PSTL algorithms to be provided.
//
// Backends often do not implement the full set of functions themselves -- a configuration of the PSTL is
// usually a set of backends "stacked" together which each implement some algorithms under some execution
// policies. It is only necessary for the "stack" of backends to implement all algorithms under all execution
// policies, but a single backend is not required to implement everything on its own.
//
// The signatures used by each backend function are documented below.
//
// Exception handling
// ==================
//
// PSTL backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from
// their implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions
// are turned into a program termination at the front-end level. When a backend returns a disengaged `optional` to the
// frontend, the frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to
// the user.
//
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {
template <class... _Backends>
struct __backend_configuration;
struct __default_backend_tag;
struct __libdispatch_backend_tag;
struct __serial_backend_tag;
struct __std_thread_backend_tag;
#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
using __current_configuration = __backend_configuration<__serial_backend_tag, __default_backend_tag>;
#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
using __current_configuration = __backend_configuration<__std_thread_backend_tag, __default_backend_tag>;
#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
using __current_configuration = __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>;
#else
// ...New vendors can add parallel backends here...
# error "Invalid PSTL backend configuration"
#endif
template <class _Backend, class _ExecutionPolicy>
struct __find_if;
// template <class _Policy, class _ForwardIterator, class _Predicate>
// optional<_ForwardIterator>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __find_if_not;
// template <class _Policy, class _ForwardIterator, class _Predicate>
// optional<_ForwardIterator>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __find;
// template <class _Policy, class _ForwardIterator, class _Tp>
// optional<_ForwardIterator>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __any_of;
// template <class _Policy, class _ForwardIterator, class _Predicate>
// optional<bool>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __all_of;
// template <class _Policy, class _ForwardIterator, class _Predicate>
// optional<bool>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __none_of;
// template <class _Policy, class _ForwardIterator, class _Predicate>
// optional<bool>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __is_partitioned;
// template <class _Policy, class _ForwardIterator, class _Predicate>
// optional<bool>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __for_each;
// template <class _Policy, class _ForwardIterator, class _Function>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Function __func) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __for_each_n;
// template <class _Policy, class _ForwardIterator, class _Size, class _Function>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _Size __size, _Function __func) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __fill;
// template <class _Policy, class _ForwardIterator, class _Tp>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __fill_n;
// template <class _Policy, class _ForwardIterator, class _Size, class _Tp>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _Size __n, _Tp const& __value) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __replace;
// template <class _Policy, class _ForwardIterator, class _Tp>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _Tp const& __old, _Tp const& __new) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __replace_if;
// template <class _Policy, class _ForwardIterator, class _Predicate, class _Tp>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _Predicate __pred, _Tp const& __new_value) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __generate;
// template <class _Policy, class _ForwardIterator, class _Generator>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __generate_n;
// template <class _Policy, class _ForwardIterator, class _Size, class _Generator>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _Size __n, _Generator __gen) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __merge;
// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp>
// optional<_ForwardOutIterator>
// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
// _ForwardIterator2 __first2, _ForwardIterator2 __last2,
// _ForwardOutIterator __result, _Comp __comp) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __stable_sort;
// template <class _Policy, class _RandomAccessIterator, class _Comp>
// optional<__empty>
// operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __sort;
// template <class _Policy, class _RandomAccessIterator, class _Comp>
// optional<__empty>
// operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __transform;
// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation>
// optional<_ForwardOutIterator>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _ForwardOutIterator __result,
// _UnaryOperation __op) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __transform_binary;
// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2,
// class _ForwardOutIterator,
// class _BinaryOperation>
// optional<_ForwardOutIterator>
// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
// _ForwardIterator2 __first2,
// _ForwardOutIterator __result,
// _BinaryOperation __op) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __replace_copy_if;
// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Predicate, class _Tp>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _ForwardOutIterator __out_it,
// _Predicate __pred,
// _Tp const& __new_value) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __replace_copy;
// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Tp>
// optional<__empty>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _ForwardOutIterator __out_it,
// _Tp const& __old_value,
// _Tp const& __new_value) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __move;
// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
// optional<_ForwardOutIterator>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _ForwardOutIterator __out_it) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __copy;
// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
// optional<_ForwardOutIterator>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _ForwardOutIterator __out_it) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __copy_n;
// template <class _Policy, class _ForwardIterator, class _Size, class _ForwardOutIterator>
// optional<_ForwardOutIterator>
// operator()(_Policy&&, _ForwardIterator __first, _Size __n, _ForwardOutIterator __out_it) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __rotate_copy;
// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
// optional<_ForwardOutIterator>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
// _ForwardOutIterator __out_it) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __transform_reduce;
// template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
// optional<_Tp>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _Tp __init,
// _BinaryOperation __reduce,
// _UnaryOperation __transform) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __transform_reduce_binary;
// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2,
// class _Tp, class _BinaryOperation1, class _BinaryOperation2>
// optional<_Tp> operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
// _ForwardIterator2 __first2,
// _Tp __init,
// _BinaryOperation1 __reduce,
// _BinaryOperation2 __transform) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __count_if;
// template <class _Policy, class _ForwardIterator, class _Predicate>
// optional<__iter_diff_t<_ForwardIterator>>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __count;
// template <class _Policy, class _ForwardIterator, class _Tp>
// optional<__iter_diff_t<_ForwardIterator>>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __equal_3leg;
// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
// optional<bool>
// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
// _ForwardIterator2 __first2,
// _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __equal;
// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
// optional<bool>
// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
// _ForwardIterator2 __first2, _ForwardIterator2 __last2,
// _Predicate __pred) const noexcept;
template <class _Backend, class _ExecutionPolicy>
struct __reduce;
// template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation>
// optional<_Tp>
// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
// _Tp __init, _BinaryOperation __op) const noexcept;
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
#endif // _LIBCPP___PSTL_BACKEND_FWD_H
|