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