1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
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 _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
11 #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
12 
13 #include <__config>
14 #include <__utility/empty.h>
15 #include <__utility/move.h>
16 #include <cstddef>
17 #include <optional>
18 
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 #  pragma GCC system_header
21 #endif
22 
23 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
24 
25 _LIBCPP_PUSH_MACROS
26 #  include <__undef_macros>
27 
28 _LIBCPP_BEGIN_NAMESPACE_STD
29 
30 namespace __par_backend {
31 inline namespace __serial_cpu_backend {
32 
33 template <class _RandomAccessIterator, class _Fp>
34 _LIBCPP_HIDE_FROM_ABI optional<__empty>
__parallel_for(_RandomAccessIterator __first,_RandomAccessIterator __last,_Fp __f)35 __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
36   __f(__first, __last);
37   return __empty{};
38 }
39 
40 template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
41 _LIBCPP_HIDE_FROM_ABI optional<_Tp>
__parallel_transform_reduce(_Index __first,_Index __last,_UnaryOp,_Tp __init,_BinaryOp,_Reduce __reduce)42 __parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
43   return __reduce(std::move(__first), std::move(__last), std::move(__init));
44 }
45 
46 template <class _RandomAccessIterator, class _Compare, class _LeafSort>
__parallel_stable_sort(_RandomAccessIterator __first,_RandomAccessIterator __last,_Compare __comp,_LeafSort __leaf_sort)47 _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort(
48     _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
49   __leaf_sort(__first, __last, __comp);
50   return __empty{};
51 }
52 
__cancel_execution()53 _LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {}
54 
55 template <class _RandomAccessIterator1,
56           class _RandomAccessIterator2,
57           class _RandomAccessIterator3,
58           class _Compare,
59           class _LeafMerge>
__parallel_merge(_RandomAccessIterator1 __first1,_RandomAccessIterator1 __last1,_RandomAccessIterator2 __first2,_RandomAccessIterator2 __last2,_RandomAccessIterator3 __outit,_Compare __comp,_LeafMerge __leaf_merge)60 _LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge(
61     _RandomAccessIterator1 __first1,
62     _RandomAccessIterator1 __last1,
63     _RandomAccessIterator2 __first2,
64     _RandomAccessIterator2 __last2,
65     _RandomAccessIterator3 __outit,
66     _Compare __comp,
67     _LeafMerge __leaf_merge) {
68   __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
69   return __empty{};
70 }
71 
72 // TODO: Complete this list
73 
74 } // namespace __serial_cpu_backend
75 } // namespace __par_backend
76 
77 _LIBCPP_END_NAMESPACE_STD
78 
79 _LIBCPP_POP_MACROS
80 
81 #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
82 
83 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
84