[libcxx-commits] [libcxx] [libc++][PSTL] Introduce cpu traits (PR #88134)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 12 12:22:33 PDT 2024
================
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H
+#define _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace __pstl {
+
+// __cpu_traits
+//
+// This traits class encapsulates the basis operations for a CPU-based implementation of the PSTL.
+// All the operations in the PSTL can be implemented from these basis operations, so a pure CPU backend
+// only needs to customize these traits in order to get an implementation of the whole PSTL.
+//
+// Basis operations
+// ================
+//
+// template <class _RandomAccessIterator, class _Functor>
+// optional<__empty> __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func);
+// - __func must take a subrange of [__first, __last) that should be executed in serial
+//
+// template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction>
+// optional<_Tp> __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp,
+// _Reduction);
+//
+// template <class _RandomAccessIterator1,
+// class _RandomAccessIterator2,
+// class _RandomAccessIterator3,
+// class _Compare,
+// class _LeafMerge>
+// optional<_RandomAccessIterator3> __parallel_merge(_RandomAccessIterator1 __first1,
+// _RandomAccessIterator1 __last1,
+// _RandomAccessIterator2 __first2,
+// _RandomAccessIterator2 __last2,
+// _RandomAccessIterator3 __outit,
+// _Compare __comp,
+// _LeafMerge __leaf_merge);
+//
+// template <class _RandomAccessIterator, class _Comp, class _LeafSort>
+// optional<__empty> __parallel_stable_sort(_RandomAccessIterator __first,
+// _RandomAccessIterator __last,
+// _Comp __comp,
+// _LeafSort __leaf_sort);
+//
+// void __cancel_execution();
+// Cancel the execution of other jobs - they aren't needed anymore. This is not a binding request,
+// some backends may not actually be able to cancel jobs.
+//
+// constexpr size_t __lane_size;
----------------
philnik777 wrote:
Maybe add a TODO somewhere to merge this with `__native_vector_size` from `__algorithm/simd_utils.h`?
https://github.com/llvm/llvm-project/pull/88134
More information about the libcxx-commits
mailing list