summaryrefslogtreecommitdiff
path: root/pstl
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2021-03-02 16:53:07 -0500
committerLouis Dionne <ldionne.2@gmail.com>2021-03-03 11:32:14 -0500
commit053146a690774f8955893fbb995ae176eb2e00a7 (patch)
tree132f0f81fbf272dd056a23164bf750ef0d177a47 /pstl
parent6eb1a087aac0fec5ef49224c17d07ce3a1bad2f9 (diff)
downloadllvm-053146a690774f8955893fbb995ae176eb2e00a7.tar.gz
[pstl] Fix broken policy_traits and clean up unused code
https://llvm.org/PR47602 https://llvm.org/PR47601 Differential Revision: https://reviews.llvm.org/D97808
Diffstat (limited to 'pstl')
-rw-r--r--pstl/include/pstl/internal/execution_impl.h103
1 files changed, 21 insertions, 82 deletions
diff --git a/pstl/include/pstl/internal/execution_impl.h b/pstl/include/pstl/internal/execution_impl.h
index af3b0836c30e..99e80818cbba 100644
--- a/pstl/include/pstl/internal/execution_impl.h
+++ b/pstl/include/pstl/internal/execution_impl.h
@@ -25,50 +25,13 @@ 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>
- : std::is_same<typename std::iterator_traits<_IteratorType>::iterator_category, std::random_access_iterator_tag>
+struct __is_random_access_iterator
+ : std::is_same<typename std::iterator_traits<_IteratorType>::iterator_category,
+ std::random_access_iterator_tag>
{
};
-/* policy */
template <typename Policy>
struct __policy_traits
{
@@ -77,40 +40,36 @@ 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;
@@ -123,41 +82,21 @@ using __allow_parallel =
typename __internal::__policy_traits<typename std::decay<_ExecutionPolicy>::type>::__allow_parallel;
template <typename _ExecutionPolicy, typename... _IteratorTypes>
-auto
+typename std::conjunction<__allow_vector<_ExecutionPolicy>,
+ __is_random_access_iterator<_IteratorTypes>...>::type
__is_vectorization_preferred(_ExecutionPolicy&& __exec)
- -> decltype(__internal::__lazy_and(__exec.__allow_vector(),
- typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
{
- return __internal::__lazy_and(__exec.__allow_vector(),
- typename __internal::__is_random_access_iterator<_IteratorTypes...>::type());
+ return {};
}
template <typename _ExecutionPolicy, typename... _IteratorTypes>
-auto
+typename std::conjunction<__allow_parallel<_ExecutionPolicy>,
+ __is_random_access_iterator<_IteratorTypes>...>::type
__is_parallelization_preferred(_ExecutionPolicy&& __exec)
- -> decltype(__internal::__lazy_and(__exec.__allow_parallel(),
- typename __internal::__is_random_access_iterator<_IteratorTypes...>::type()))
{
- 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>
-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;
-};
-
} // namespace __internal
} // namespace __pstl