[libcxx-commits] [PATCH] D149686: [libc++][PSTL] Add more specialized backend customization points

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 10 08:45:15 PDT 2023


ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

I think this is an excellent start. Then we can clean up some stuff, improve comments and move all the existing algorithms to this approach.

It turns out that once we get to the CPU backend, we basically do what the original PSTL did -- we're really just adding an additional layer of customizability on top for backends where the par/non-par split might not make sense. LGTM w/ green CI and comments addressed.



================
Comment at: libcxx/include/__algorithm/pstl_backend.h:45-46
+
+template <class>
+void __pstl_for_each_n();
+
----------------
Let's move this to `pstl_for_each.h`, it seems to belong there more than here. We can also add `// declaration needed for the frontend dispatch below`.


================
Comment at: libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h:35
+template <class _ExecutionPolicy, class _ForwardIterator, class _Functor>
+void __pstl_for_each(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Functor __func) {
+  if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
----------------
`_HIDE_FROM_ABI`


================
Comment at: libcxx/include/__algorithm/pstl_for_each.h:57
+        if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) {
+          std::for_each(__policy, std::move(__first), __first + __size, std::move(__func));
+        } else {
----------------
Nit but I don't think you can `move(__first)` here since you are then using `__first + __size`.


================
Comment at: libcxx/include/__type_traits/is_execution_policy.h:47
+_LIBCPP_HIDE_FROM_ABI auto
+__remove_parallel_policy(const _ExecutionPolicy& = _ExecutionPolicy{execution::__disable_user_instantiations_tag{}});
+
----------------
`// TODO: Remove default argument once algorithms are using the new backend dispatching`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149686/new/

https://reviews.llvm.org/D149686



More information about the libcxx-commits mailing list