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