• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H
10 #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H
11 
12 #include <__config>
13 
14 /*
15 
16   // _Functor takes a subrange for [__first, __last) that should be executed in serial
17   template <class _RandomAccessIterator, class _Functor>
18   optional<__empty> __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func);
19 
20   template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction>
21   optional<_Tp>
22   __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction);
23 
24   // Cancel the execution of other jobs - they aren't needed anymore
25   void __cancel_execution();
26 
27   template <class _RandomAccessIterator1,
28             class _RandomAccessIterator2,
29             class _RandomAccessIterator3,
30             class _Compare,
31             class _LeafMerge>
32   optional<void> __parallel_merge(
33       _RandomAccessIterator1 __first1,
34       _RandomAccessIterator1 __last1,
35       _RandomAccessIterator2 __first2,
36       _RandomAccessIterator2 __last2,
37       _RandomAccessIterator3 __outit,
38       _Compare __comp,
39       _LeafMerge __leaf_merge);
40 
41   template <class _RandomAccessIterator, class _Comp, class _LeafSort>
42   void __parallel_stable_sort(_RandomAccessIterator __first,
43                               _RandomAccessIterator __last,
44                               _Comp __comp,
45                               _LeafSort __leaf_sort);
46 
47   TODO: Document the parallel backend
48 
49 Exception handling
50 ==================
51 
52 CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their
53 implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned
54 into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the
55 frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user.
56 */
57 
58 #include <__algorithm/pstl_backends/cpu_backends/any_of.h>
59 #include <__algorithm/pstl_backends/cpu_backends/backend.h>
60 #include <__algorithm/pstl_backends/cpu_backends/fill.h>
61 #include <__algorithm/pstl_backends/cpu_backends/find_if.h>
62 #include <__algorithm/pstl_backends/cpu_backends/for_each.h>
63 #include <__algorithm/pstl_backends/cpu_backends/merge.h>
64 #include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
65 #include <__algorithm/pstl_backends/cpu_backends/transform.h>
66 #include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
67 
68 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H
69