1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H
10 #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H
14 #include <__utility/empty.h>
15 #include <__utility/move.h>
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 # pragma GCC system_header
24 #include <__undef_macros>
26 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
28 // This backend implementation is for testing purposes only and not meant for production use. This will be replaced
29 // by a proper implementation once the PSTL implementation is somewhat stable.
31 _LIBCPP_BEGIN_NAMESPACE_STD
33 namespace __par_backend
{
34 inline namespace __thread_cpu_backend
{
36 template <class _RandomAccessIterator
, class _Fp
>
37 _LIBCPP_HIDE_FROM_ABI optional
<__empty
>
38 __parallel_for(_RandomAccessIterator __first
, _RandomAccessIterator __last
, _Fp __f
) {
43 template <class _Index
, class _UnaryOp
, class _Tp
, class _BinaryOp
, class _Reduce
>
44 _LIBCPP_HIDE_FROM_ABI optional
<_Tp
>
45 __parallel_transform_reduce(_Index __first
, _Index __last
, _UnaryOp
, _Tp __init
, _BinaryOp
, _Reduce __reduce
) {
46 return __reduce(std::move(__first
), std::move(__last
), std::move(__init
));
49 template <class _RandomAccessIterator
, class _Compare
, class _LeafSort
>
50 _LIBCPP_HIDE_FROM_ABI optional
<__empty
> __parallel_stable_sort(
51 _RandomAccessIterator __first
, _RandomAccessIterator __last
, _Compare __comp
, _LeafSort __leaf_sort
) {
52 __leaf_sort(__first
, __last
, __comp
);
56 _LIBCPP_HIDE_FROM_ABI
inline void __cancel_execution() {}
58 template <class _RandomAccessIterator1
,
59 class _RandomAccessIterator2
,
60 class _RandomAccessIterator3
,
63 _LIBCPP_HIDE_FROM_ABI optional
<__empty
> __parallel_merge(
64 _RandomAccessIterator1 __first1
,
65 _RandomAccessIterator1 __last1
,
66 _RandomAccessIterator2 __first2
,
67 _RandomAccessIterator2 __last2
,
68 _RandomAccessIterator3 __outit
,
70 _LeafMerge __leaf_merge
) {
71 __leaf_merge(__first1
, __last1
, __first2
, __last2
, __outit
, __comp
);
75 } // namespace __thread_cpu_backend
76 } // namespace __par_backend
78 _LIBCPP_END_NAMESPACE_STD
80 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
84 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H