From 453ae4df90f5ffc473873d4f9e7101937af42347 Mon Sep 17 00:00:00 2001 From: Sergey Kopienko Date: Mon, 3 Jun 2024 09:15:14 +0200 Subject: [PATCH] [oneDPL] Remove `_IsMoveConstructible` from `__pattern_sort` impls + add preconditions checks into sorting algorithms (#1599) --- include/oneapi/dpl/pstl/algorithm_fwd.h | 8 +++----- include/oneapi/dpl/pstl/algorithm_impl.h | 9 ++++----- include/oneapi/dpl/pstl/glue_algorithm_impl.h | 4 +--- include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h | 4 ++-- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/oneapi/dpl/pstl/algorithm_fwd.h b/include/oneapi/dpl/pstl/algorithm_fwd.h index c41dc6d1199..a462c7f1584 100644 --- a/include/oneapi/dpl/pstl/algorithm_fwd.h +++ b/include/oneapi/dpl/pstl/algorithm_fwd.h @@ -741,15 +741,13 @@ __pattern_partition_copy(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomA // sort //------------------------------------------------------------------------ -template +template void -__pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, - _IsMoveConstructible) noexcept; +__pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare) noexcept; template void -__pattern_sort(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare, - /*is_move_constructible=*/::std::true_type); +__pattern_sort(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare); //------------------------------------------------------------------------ // stable_sort diff --git a/include/oneapi/dpl/pstl/algorithm_impl.h b/include/oneapi/dpl/pstl/algorithm_impl.h index 13d1e9c41b7..5b7220bbef6 100644 --- a/include/oneapi/dpl/pstl/algorithm_impl.h +++ b/include/oneapi/dpl/pstl/algorithm_impl.h @@ -2392,10 +2392,10 @@ __pattern_partition_copy(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _ // sort //------------------------------------------------------------------------ -template +template void -__pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, - _IsMoveConstructible) noexcept +__pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, + _Compare __comp) noexcept { static_assert(__is_serial_tag_v<_Tag> || __is_parallel_forward_tag_v<_Tag>); @@ -2405,8 +2405,7 @@ __pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator __first, _RandomA template void __pattern_sort(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _RandomAccessIterator __first, - _RandomAccessIterator __last, _Compare __comp, - /*is_move_constructible=*/::std::true_type) + _RandomAccessIterator __last, _Compare __comp) { using __backend_tag = typename __parallel_tag<_IsVector>::__backend_tag; diff --git a/include/oneapi/dpl/pstl/glue_algorithm_impl.h b/include/oneapi/dpl/pstl/glue_algorithm_impl.h index 0d17726cc24..8207808ebb3 100644 --- a/include/oneapi/dpl/pstl/glue_algorithm_impl.h +++ b/include/oneapi/dpl/pstl/glue_algorithm_impl.h @@ -664,10 +664,8 @@ sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIter { const auto __dispatch_tag = oneapi::dpl::__internal::__select_backend(__exec, __first); - typedef typename ::std::iterator_traits<_RandomAccessIterator>::value_type _InputType; - oneapi::dpl::__internal::__pattern_sort(__dispatch_tag, ::std::forward<_ExecutionPolicy>(__exec), __first, __last, - __comp, typename ::std::is_move_constructible<_InputType>::type()); + __comp); } template diff --git a/include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h b/include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h index d52385ad5c6..766b599361f 100644 --- a/include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h +++ b/include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h @@ -1264,7 +1264,7 @@ __stable_sort_with_projection(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __ex template void __pattern_sort(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&& __exec, _Iterator __first, _Iterator __last, - _Compare __comp, /*is_move_constructible=*/::std::true_type) + _Compare __comp) { __stable_sort_with_projection(__tag, ::std::forward<_ExecutionPolicy>(__exec), __first, __last, __comp, oneapi::dpl::identity{}); @@ -1511,7 +1511,7 @@ __pattern_partial_sort_copy(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&& __pattern_sort( __tag, __par_backend_hetero::make_wrapped_policy<__partial_sort_1>(::std::forward<_ExecutionPolicy>(__exec)), - __out_first, __out_end, __comp, ::std::true_type{}); + __out_first, __out_end, __comp); return __out_end; }