On 21/09/20 08:19 -0700, Thomas Rodgers wrote:


On Sep 21, 2020, at 7:40 AM, Jonathan Wakely <jwak...@redhat.com> wrote:

On 15/09/20 20:35 -0700, Thomas Rodgers wrote:
From: Thomas Rodgers <trodg...@redhat.com>

From llvm-project/pstl @ 0b2e0e80d96

libstdc++-v3/ChangeLog:

        * include/pstl/algorithm_impl.h: Update file.
        * include/pstl/execution_impl.h: Likewise.
        * include/pstl/glue_algorithm_impl.h: Likewise.
        * include/pstl/glue_memory_impl.h: Likewise.
        * include/pstl/glue_numeric_impl.h: Likewise.
        * include/pstl/memory_impl.h: Likewise.
        * include/pstl/numeric_impl.h: Likewise.
        * include/pstl/parallel_backend.h: Likewise.
        * include/pstl/parallel_backend_serial.h: Likewise.
        * include/pstl/parallel_backend_tbb.h: Likewise.
        * include/pstl/parallel_backend_utils.h: Likewise.
        * include/pstl/pstl_config.h: Likewise.
        * include/pstl/unseq_backend_simd.h: Likewise.
---
libstdc++-v3/include/pstl/algorithm_impl.h    | 181 ++--
libstdc++-v3/include/pstl/execution_impl.h    |   4 +-
.../include/pstl/glue_algorithm_impl.h        | 543 +++++------
libstdc++-v3/include/pstl/glue_memory_impl.h  | 264 ++---
libstdc++-v3/include/pstl/glue_numeric_impl.h |  68 +-
libstdc++-v3/include/pstl/memory_impl.h       |  67 +-
libstdc++-v3/include/pstl/numeric_impl.h      |   8 +-
libstdc++-v3/include/pstl/parallel_backend.h  |   8 +
.../include/pstl/parallel_backend_serial.h    |   8 +-
.../include/pstl/parallel_backend_tbb.h       | 903 +++++++++++++++---
.../include/pstl/parallel_backend_utils.h     | 248 +++--
libstdc++-v3/include/pstl/pstl_config.h       |  24 +-
.../include/pstl/unseq_backend_simd.h         |  39 +-
13 files changed, 1586 insertions(+), 779 deletions(-)

diff --git a/libstdc++-v3/include/pstl/glue_algorithm_impl.h 
b/libstdc++-v3/include/pstl/glue_algorithm_impl.h
index 379de4033ec..d2e30529f78 100644
--- a/libstdc++-v3/include/pstl/glue_algorithm_impl.h
+++ b/libstdc++-v3/include/pstl/glue_algorithm_impl.h
@@ -757,8 +743,7 @@ 
__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, bool>
equal(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 
__last1, _ForwardIterator2 __first2,
     _ForwardIterator2 __last2)
{
-    return std::equal(std::forward<_ExecutionPolicy>(__exec), __first1, 
__last1, __first2, __last2,
-                      __pstl::__internal::__pstl_equal());
+    return equal(std::forward<_ExecutionPolicy>(__exec), __first1, __last1, 
__first2, __last2, std::equal_to<>());

Any idea why this is now called unqualified? I don't think we want ADL
here.

I’m sure it is related to ...

diff --git a/libstdc++-v3/include/pstl/parallel_backend_tbb.h 
b/libstdc++-v3/include/pstl/parallel_backend_tbb.h
index 9c05ade0532..4476486d548 100644
--- a/libstdc++-v3/include/pstl/parallel_backend_tbb.h
+++ b/libstdc++-v3/include/pstl/parallel_backend_tbb.h

This file is full of non-reserved names, like _root and _x_orig and
move_y_range.


The upstream authors not being sufficiently versed in thinking in terms of 
writing things up front to avoid the sort of issues that a stdlib requires of 
the code.

Fixing those upstream might take a while though.

I have already started accumulating a set of patches for upstream which I’ll 
manage as independently of getting this rebase into gcc.

Here's a patch to fix
https://bugs.llvm.org/show_bug.cgi?id=47601
and
https://bugs.llvm.org/show_bug.cgi?id=47601
by essentially rewriting the entire file!


diff --git a/libstdc++-v3/include/pstl/execution_impl.h b/libstdc++-v3/include/pstl/execution_impl.h
index d53fd6ffd32..b3a8030fca3 100644
--- a/libstdc++-v3/include/pstl/execution_impl.h
+++ b/libstdc++-v3/include/pstl/execution_impl.h
@@ -22,45 +22,9 @@ namespace __internal
 
 using namespace __pstl::execution;
 
-/* predicate */
-
-template <typename _Tp>
-std::false_type __lazy_and(_Tp, std::false_type)
-{
-    return std::false_type{};
-};
-
-template <typename _Tp>
-inline _Tp
-__lazy_and(_Tp __a, std::true_type)
-{
-    return __a;
-}
-
-template <typename _Tp>
-std::true_type __lazy_or(_Tp, std::true_type)
-{
-    return std::true_type{};
-};
-
-template <typename _Tp>
-inline _Tp
-__lazy_or(_Tp __a, std::false_type)
-{
-    return __a;
-}
-
 /* iterator */
-template <typename _IteratorType, typename... _OtherIteratorTypes>
-struct __is_random_access_iterator
-{
-    static constexpr bool value = __internal::__is_random_access_iterator<_IteratorType>::value &&
-                                  __internal::__is_random_access_iterator<_OtherIteratorTypes...>::value;
-    typedef std::integral_constant<bool, value> type;
-};
-
 template <typename _IteratorType>
-struct __is_random_access_iterator<_IteratorType>
+struct __is_random_access_iterator
     : std::is_same<typename std::iterator_traits<_IteratorType>::iterator_category, std::random_access_iterator_tag>
 {
 };
@@ -74,86 +38,68 @@ struct __policy_traits
 template <>
 struct __policy_traits<sequenced_policy>
 {
-    typedef std::false_type allow_parallel;
-    typedef std::false_type allow_unsequenced;
-    typedef std::false_type allow_vector;
+    typedef std::false_type __allow_parallel;
+    typedef std::false_type __allow_unsequenced;
+    typedef std::false_type __allow_vector;
 };
 
 template <>
 struct __policy_traits<unsequenced_policy>
 {
-    typedef std::false_type allow_parallel;
-    typedef std::true_type allow_unsequenced;
-    typedef std::true_type allow_vector;
+    typedef std::false_type __allow_parallel;
+    typedef std::true_type __allow_unsequenced;
+    typedef std::true_type __allow_vector;
 };
 
 template <>
 struct __policy_traits<parallel_policy>
 {
-    typedef std::true_type allow_parallel;
-    typedef std::false_type allow_unsequenced;
-    typedef std::false_type allow_vector;
+    typedef std::true_type __allow_parallel;
+    typedef std::false_type __allow_unsequenced;
+    typedef std::false_type __allow_vector;
 };
 
 template <>
 struct __policy_traits<parallel_unsequenced_policy>
 {
-    typedef std::true_type allow_parallel;
-    typedef std::true_type allow_unsequenced;
-    typedef std::true_type allow_vector;
+    typedef std::true_type __allow_parallel;
+    typedef std::true_type __allow_unsequenced;
+    typedef std::true_type __allow_vector;
 };
 
-template <typename _ExecutionPolicy>
-using __collector_t =
-    typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__collector_type;
-
 template <typename _ExecutionPolicy>
 using __allow_vector =
-    typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_vector;
+    typename __internal::__policy_traits<std::decay_t<_ExecutionPolicy>>::__allow_vector;
 
 template <typename _ExecutionPolicy>
 using __allow_unsequenced =
-    typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_unsequenced;
+    typename __internal::__policy_traits<std::decay_t<_ExecutionPolicy>>::__allow_unsequenced;
 
 template <typename _ExecutionPolicy>
 using __allow_parallel =
-    typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_parallel;
+    typename __internal::__policy_traits<std::decay_t<_ExecutionPolicy>>::__allow_parallel;
 
 template <typename _ExecutionPolicy, typename... _IteratorTypes>
-auto
-__is_vectorization_preferred(_ExecutionPolicy&& __exec)
-    -> decltype(__internal::__lazy_and(__exec.__allow_vector(),
-                                       typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
+std::conjunction<__allow_vector<_ExecutionPolicy>, __is_random_access_iterator<_IteratorTypes>...>
+__is_vectorization_preferred(_ExecutionPolicy&&)
 {
-    return __internal::__lazy_and(__exec.__allow_vector(),
-                                  typename __internal::__is_random_access_iterator<_IteratorTypes...>::type());
+    return {};
 }
 
 template <typename _ExecutionPolicy, typename... _IteratorTypes>
-auto
-__is_parallelization_preferred(_ExecutionPolicy&& __exec)
-    -> decltype(__internal::__lazy_and(__exec.__allow_parallel(),
-                                       typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
+std::conjunction<__allow_parallel<_ExecutionPolicy>, __is_random_access_iterator<_IteratorTypes>...>
+__is_parallelization_preferred(_ExecutionPolicy&&)
 {
-    return __internal::__lazy_and(__exec.__allow_parallel(),
-                                  typename __internal::__is_random_access_iterator<_IteratorTypes...>::type());
+    return {};
 }
 
-template <typename policy, typename... _IteratorTypes>
-struct __prefer_unsequenced_tag
-{
-    static constexpr bool value = __internal::__allow_unsequenced<policy>::value &&
-                                  __internal::__is_random_access_iterator<_IteratorTypes...>::value;
-    typedef std::integral_constant<bool, value> type;
-};
+template <typename _Policy, typename... _IteratorTypes>
+using __prefer_unsequenced_tag
+= std::conjunction<__allow_unsequenced<_Policy>, __is_random_access_iterator<_IteratorTypes>...>;
 
-template <typename policy, typename... _IteratorTypes>
-struct __prefer_parallel_tag
-{
-    static constexpr bool value = __internal::__allow_parallel<policy>::value &&
-                                  __internal::__is_random_access_iterator<_IteratorTypes...>::value;
-    typedef std::integral_constant<bool, value> type;
-};
+template <typename _Policy, typename... _IteratorTypes>
+using __prefer_parallel_tag
+= std::conjunction<__allow_parallel<_Policy>, __is_random_access_iterator<_IteratorTypes>...>;
 
 } // namespace __internal
 } // namespace __pstl

Reply via email to