Skip to content

Commit caec240

Browse files
committed
Use single size type in __pattern_bounded_copy_if
1 parent 09de756 commit caec240

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

include/oneapi/dpl/pstl/algorithm_fwd.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,11 @@ _RandomAccessIterator2
489489
__pattern_copy_if(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomAccessIterator1, _RandomAccessIterator1,
490490
_RandomAccessIterator2, _UnaryPredicate);
491491

492-
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2,
493-
class _UnaryPredicate>
492+
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator1, class _DifferenceType,
493+
class _RandomAccessIterator2, class _UnaryPredicate>
494494
std::pair<_RandomAccessIterator1, _RandomAccessIterator2>
495495
__pattern_bounded_copy_if(__parallel_tag<_IsVector>, _ExecutionPolicy&&, _RandomAccessIterator1,
496-
typename std::iterator_traits<_RandomAccessIterator1>::difference_type,
497-
_RandomAccessIterator2,
498-
typename std::iterator_traits<_RandomAccessIterator2>::difference_type, _UnaryPredicate);
496+
_DifferenceType, _RandomAccessIterator2, _DifferenceType, _UnaryPredicate);
499497

500498
//------------------------------------------------------------------------
501499
// count

include/oneapi/dpl/pstl/algorithm_impl.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ __parallel_selective_copy(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec,
13651365
__stop_in = __i + __stop; // Since there is only one such position, there is no data race
13661366
}
13671367
},
1368-
[&__stop_out](auto __total) { // Apex
1368+
[&__stop_out](_DifferenceType __total) { // Apex
13691369
if (__total < __stop_out) // Output size is bigger than needed
13701370
__stop_out = __total;
13711371
});
@@ -1401,17 +1401,13 @@ __pattern_copy_if(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _R
14011401
return __internal::__brick_copy_if(__first, __last, __result, __pred, _IsVector{});
14021402
}
14031403

1404-
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator1, class _RandomAccessIterator2,
1405-
class _UnaryPredicate>
1404+
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator1, class _DifferenceType,
1405+
class _RandomAccessIterator2, class _UnaryPredicate>
14061406
std::pair<_RandomAccessIterator1, _RandomAccessIterator2>
14071407
__pattern_bounded_copy_if(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _RandomAccessIterator1 __first,
1408-
typename std::iterator_traits<_RandomAccessIterator1>::difference_type __n,
1409-
_RandomAccessIterator2 __result,
1410-
typename std::iterator_traits<_RandomAccessIterator2>::difference_type __n_out,
1408+
_DifferenceType __n, _RandomAccessIterator2 __result, _DifferenceType __n_out,
14111409
_UnaryPredicate __pred)
14121410
{
1413-
using _DifferenceType = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;
1414-
14151411
return __parallel_selective_copy(
14161412
__tag, std::forward<_ExecutionPolicy>(__exec), __first, __n, __result, _DifferenceType{__n_out},
14171413
[&__pred](_RandomAccessIterator1 __it, _DifferenceType __idx) { return __pred(__it[__idx]); });

include/oneapi/dpl/pstl/algorithm_ranges_impl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,11 @@ std::ranges::copy_if_result<std::ranges::borrowed_iterator_t<_InRange>, std::ran
544544
__pattern_copy_if_ranges(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _InRange&& __in_r,
545545
_OutRange&& __out_r, _Pred __pred, _Proj __proj)
546546
{
547+
using _Size = oneapi::dpl::__ranges::__common_size_t<_InRange, _OutRange>;
547548
auto __first_in = std::ranges::begin(__in_r);
548549
auto __first_out = std::ranges::begin(__out_r);
549-
auto __sz_in = std::ranges::size(__in_r);
550-
auto __sz_out = std::ranges::size(__out_r);
550+
_Size __sz_in = std::ranges::size(__in_r);
551+
_Size __sz_out = std::ranges::size(__out_r);
551552

552553
// TODO: test if redirecting to "regular" copy_if for sufficient output performs better
553554
if (__sz_in > 0 && __sz_out > 0)

0 commit comments

Comments
 (0)