Skip to content

Commit

Permalink
[oneDPL] Remove _IsMoveConstructible from __pattern_sort impls + …
Browse files Browse the repository at this point in the history
…add preconditions checks into sorting algorithms (#1599)
  • Loading branch information
SergeyKopienko authored Jun 3, 2024
1 parent 481272b commit 453ae4d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
8 changes: 3 additions & 5 deletions include/oneapi/dpl/pstl/algorithm_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,13 @@ __pattern_partition_copy(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomA
// sort
//------------------------------------------------------------------------

template <class _Tag, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsMoveConstructible>
template <class _Tag, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare>
void
__pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare,
_IsMoveConstructible) noexcept;
__pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare) noexcept;

template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare>
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
Expand Down
9 changes: 4 additions & 5 deletions include/oneapi/dpl/pstl/algorithm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2392,10 +2392,10 @@ __pattern_partition_copy(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _
// sort
//------------------------------------------------------------------------

template <class _Tag, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare, class _IsMoveConstructible>
template <class _Tag, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare>
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>);

Expand All @@ -2405,8 +2405,7 @@ __pattern_sort(_Tag, _ExecutionPolicy&&, _RandomAccessIterator __first, _RandomA
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare>
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;

Expand Down
4 changes: 1 addition & 3 deletions include/oneapi/dpl/pstl/glue_algorithm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class _ExecutionPolicy, class _RandomAccessIterator>
Expand Down
4 changes: 2 additions & 2 deletions include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ __stable_sort_with_projection(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __ex
template <typename _BackendTag, typename _ExecutionPolicy, typename _Iterator, typename _Compare>
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{});
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 453ae4d

Please sign in to comment.