| 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___PSTL_CPU_ALGOS_CPU_TRAITS_H |
| 10 |
#define _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H |
| 11 |
|
| 12 |
#include <__config> |
| 13 |
#include <cstddef> |
| 14 |
|
| 15 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 |
# pragma GCC system_header |
| 17 |
#endif |
| 18 |
|
| 19 |
_LIBCPP_PUSH_MACROS |
| 20 |
#include <__undef_macros> |
| 21 |
|
| 22 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 23 |
namespace __pstl { |
| 24 |
|
| 25 |
// __cpu_traits |
| 26 |
// |
| 27 |
// This traits class encapsulates the basis operations for a CPU-based implementation of the PSTL. |
| 28 |
// All the operations in the PSTL can be implemented from these basis operations, so a pure CPU backend |
| 29 |
// only needs to customize these traits in order to get an implementation of the whole PSTL. |
| 30 |
// |
| 31 |
// Basis operations |
| 32 |
// ================ |
| 33 |
// |
| 34 |
// template <class _RandomAccessIterator, class _Functor> |
| 35 |
// optional<__empty> __for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func); |
| 36 |
// - __func must take a subrange of [__first, __last) that should be executed in serial |
| 37 |
// |
| 38 |
// template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction> |
| 39 |
// optional<_Tp> __transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction); |
| 40 |
// |
| 41 |
// template <class _RandomAccessIterator1, |
| 42 |
// class _RandomAccessIterator2, |
| 43 |
// class _RandomAccessIterator3, |
| 44 |
// class _Compare, |
| 45 |
// class _LeafMerge> |
| 46 |
// optional<_RandomAccessIterator3> __merge(_RandomAccessIterator1 __first1, |
| 47 |
// _RandomAccessIterator1 __last1, |
| 48 |
// _RandomAccessIterator2 __first2, |
| 49 |
// _RandomAccessIterator2 __last2, |
| 50 |
// _RandomAccessIterator3 __outit, |
| 51 |
// _Compare __comp, |
| 52 |
// _LeafMerge __leaf_merge); |
| 53 |
// |
| 54 |
// template <class _RandomAccessIterator, class _Comp, class _LeafSort> |
| 55 |
// optional<__empty> __stable_sort(_RandomAccessIterator __first, |
| 56 |
// _RandomAccessIterator __last, |
| 57 |
// _Comp __comp, |
| 58 |
// _LeafSort __leaf_sort); |
| 59 |
// |
| 60 |
// void __cancel_execution(); |
| 61 |
// Cancel the execution of other jobs - they aren't needed anymore. This is not a binding request, |
| 62 |
// some backends may not actually be able to cancel jobs. |
| 63 |
// |
| 64 |
// constexpr size_t __lane_size; |
| 65 |
// Size of SIMD lanes. |
| 66 |
// TODO: Merge this with __native_vector_size from __algorithm/simd_utils.h |
| 67 |
// |
| 68 |
// |
| 69 |
// Exception handling |
| 70 |
// ================== |
| 71 |
// |
| 72 |
// CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their |
| 73 |
// implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are |
| 74 |
// turned into a program termination at the front-end level. When a backend returns a disengaged `optional` to the |
| 75 |
// frontend, the frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to |
| 76 |
// the user. |
| 77 |
|
| 78 |
template <class _Backend> |
| 79 |
struct __cpu_traits; |
| 80 |
|
| 81 |
} // namespace __pstl |
| 82 |
_LIBCPP_END_NAMESPACE_STD |
| 83 |
|
| 84 |
_LIBCPP_POP_MACROS |
| 85 |
|
| 86 |
#endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H |