Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9d6b2d2
include/oneapi/dpl/pstl/algorithm_impl.h - apply std::invoke for comp…
SergeyKopienko Nov 7, 2025
cbc8eb0
include/oneapi/dpl/pstl/parallel_backend_tbb.h - apply std::invoke fo…
SergeyKopienko Nov 7, 2025
0e9cf13
include/oneapi/dpl/pstl/parallel_backend_utils.h - apply std::invoke …
SergeyKopienko Nov 7, 2025
ddde1d0
include/oneapi/dpl/pstl/parallel_impl.h - apply std::invoke for compa…
SergeyKopienko Nov 7, 2025
c2911c1
include/oneapi/dpl/pstl/unseq_backend_simd.h - apply std::invoke for …
SergeyKopienko Nov 7, 2025
1f9c3a5
include/oneapi/dpl/pstl/utils.h - apply std::invoke for comparators
SergeyKopienko Nov 7, 2025
43ad566
include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - apply std::i…
SergeyKopienko Nov 7, 2025
44e8758
include/oneapi/dpl/pstl/hetero/utils_hetero.h - apply std::invoke for…
SergeyKopienko Nov 7, 2025
68e539b
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge_sort…
SergeyKopienko Nov 7, 2025
c681595
test/support/utils.h - apply std::invoke for comparators
SergeyKopienko Nov 7, 2025
ead1a40
test/general/implementation_details/balanced_path_unit_tests.pass.cpp…
SergeyKopienko Nov 7, 2025
04d6d45
test/general/sycl_iterator/sycl_iterator_sort.pass.cpp - apply std::i…
SergeyKopienko Nov 7, 2025
4a25744
test/parallel_api/algorithm/alg.sorting/alg.set.operations/set_common…
SergeyKopienko Nov 7, 2025
add7f22
test/parallel_api/algorithm/alg.nonmodifying/nth_element.pass.cpp - a…
SergeyKopienko Nov 7, 2025
353e2c3
include/oneapi/dpl/pstl/parallel_impl.h - additional comment
SergeyKopienko Nov 12, 2025
d56df9f
test/parallel_api/algorithm/alg.nonmodifying/nth_element.pass.cpp - r…
SergeyKopienko Nov 12, 2025
8c7a061
test/general/sycl_iterator/sycl_iterator_sort.pass.cpp - revert extra…
SergeyKopienko Nov 12, 2025
fa5e03c
test/general/implementation_details/balanced_path_unit_tests.pass.cpp…
SergeyKopienko Nov 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 36 additions & 29 deletions include/oneapi/dpl/pstl/algorithm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "parallel_backend.h"
#include "parallel_impl.h"
#include "iterator_impl.h"
#include "functional_impl.h" // for oneapi::dpl::identity
#include "functional_impl.h" // for oneapi::dpl::identity, std::invoke

#if _ONEDPL_HETERO_BACKEND
# include "hetero/algorithm_impl_hetero.h" // for __pattern_fill_n, __pattern_generate_n
Expand Down Expand Up @@ -2442,7 +2442,9 @@ __pattern_sort_by_key(_Tag, _ExecutionPolicy&&, _RandomAccessIterator1 __keys_fi

auto __beg = oneapi::dpl::make_zip_iterator(__keys_first, __values_first);
auto __end = __beg + (__keys_last - __keys_first);
auto __cmp_f = [__comp](const auto& __a, const auto& __b) { return __comp(std::get<0>(__a), std::get<0>(__b)); };
auto __cmp_f = [__comp](const auto& __a, const auto& __b) {
return std::invoke(__comp, std::get<0>(__a), std::get<0>(__b));
};

__leaf_sort(__beg, __end, __cmp_f);
}
Expand All @@ -2456,7 +2458,9 @@ __pattern_sort_by_key(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _Ran
{
auto __beg = oneapi::dpl::make_zip_iterator(__keys_first, __values_first);
auto __end = __beg + (__keys_last - __keys_first);
auto __cmp_f = [__comp](const auto& __a, const auto& __b) { return __comp(std::get<0>(__a), std::get<0>(__b)); };
auto __cmp_f = [__comp](const auto& __a, const auto& __b) {
return std::invoke(__comp, std::get<0>(__a), std::get<0>(__b));
};

using __backend_tag = typename __parallel_tag<_IsVector>::__backend_tag;

Expand Down Expand Up @@ -2699,8 +2703,9 @@ __pattern_nth_element(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec
_RandomAccessIterator __x;
do
{
__x = __internal::__pattern_partition(__tag, ::std::forward<_ExecutionPolicy>(__exec), __first + 1, __last,
[&__comp, __first](const _Tp& __x) { return __comp(__x, *__first); });
__x = __internal::__pattern_partition(
__tag, std::forward<_ExecutionPolicy>(__exec), __first + 1, __last,
[&__comp, __first](const _Tp& __x) { return std::invoke(__comp, __x, *__first); });
--__x;
if (__x != __first)
{
Expand All @@ -2715,7 +2720,7 @@ __pattern_nth_element(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec
else if (__x - __nth < 0)
{
// if *x == *nth then we start the new partition at the next index where *x != *nth
while (!__comp(*__nth, *__x) && !__comp(*__x, *__nth) && __x - __nth < 0)
while (!std::invoke(__comp, *__nth, *__x) && !std::invoke(__comp, *__x, *__nth) && __x - __nth < 0)
{
++__x;
}
Expand Down Expand Up @@ -3220,15 +3225,15 @@ __pattern_includes(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _
if (__first1 == __last1 || __last2 - __first2 > __last1 - __first1 ||
// {1}: [**********] or [**********]
// {2}: [***********] [***********]
__comp(*__first2, *__first1) || __comp(*(__last1 - 1), *(__last2 - 1)))
std::invoke(__comp, *__first2, *__first1) || std::invoke(__comp, *(__last1 - 1), *(__last2 - 1)))
return false;

__first1 = ::std::lower_bound(__first1, __last1, *__first2, __comp);
if (__first1 == __last1)
return false;

if (__last2 - __first2 == 1)
return !__comp(*__first1, *__first2) && !__comp(*__first2, *__first1);
return !std::invoke(__comp, *__first1, *__first2) && !std::invoke(__comp, *__first2, *__first1);

return __internal::__except_handler([&]() {
return !__internal::__parallel_or(
Expand All @@ -3240,7 +3245,7 @@ __pattern_includes(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _
//1. moving boundaries to "consume" subsequence of equal elements
auto __is_equal_sorted = [&__comp](_RandomAccessIterator2 __a, _RandomAccessIterator2 __b) -> bool {
//enough one call of __comp due to compared couple belongs to one sorted sequence
return !__comp(*__a, *__b);
return !std::invoke(__comp, *__a, *__b);
};

//1.1 left bound, case "aaa[aaaxyz...]" - searching "x"
Expand All @@ -3260,8 +3265,8 @@ __pattern_includes(__parallel_tag<_IsVector> __tag, _ExecutionPolicy&& __exec, _
//2. testing is __a subsequence of the second range included into the first range
auto __b = ::std::lower_bound(__first1, __last1, *__i, __comp);

assert(!__comp(*(__last1 - 1), *__b));
assert(!__comp(*(__j - 1), *__i));
assert(!std::invoke(__comp, *(__last1 - 1), *__b));
assert(!std::invoke(__comp, *(__j - 1), *__i));
return !::std::includes(__b, __last1, __i, __j, __comp);
});
});
Expand Down Expand Up @@ -3846,9 +3851,10 @@ __brick_is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __las
/* __is_vector = */ ::std::true_type) noexcept
{
using _SizeType = typename std::iterator_traits<_RandomAccessIterator>::difference_type;
return __unseq_backend::__simd_first(
__first, _SizeType(0), __last - __first,
[&__comp](_RandomAccessIterator __it, _SizeType __i) { return __comp(__it[(__i - 1) / 2], __it[__i]); });
return __unseq_backend::__simd_first(__first, _SizeType(0), __last - __first,
[&__comp](_RandomAccessIterator __it, _SizeType __i) {
return std::invoke(__comp, __it[(__i - 1) / 2], __it[__i]);
});
}

template <class _Tag, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare>
Expand All @@ -3868,7 +3874,7 @@ __is_heap_until_local(_RandomAccessIterator __first, _DifferenceType __begin, _D
{
_DifferenceType __i = __begin;
for (; __i < __end; ++__i)
if (__comp(__first[(__i - 1) / 2], __first[__i]))
if (std::invoke(__comp, __first[(__i - 1) / 2], __first[__i]))
break;
return __first + __i;
}
Expand All @@ -3878,9 +3884,10 @@ _RandomAccessIterator
__is_heap_until_local(_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
/* __is_vector = */ ::std::true_type) noexcept
{
return __unseq_backend::__simd_first(
__first, __begin, __end,
[&__comp](_RandomAccessIterator __it, _DifferenceType __i) { return __comp(__it[(__i - 1) / 2], __it[__i]); });
return __unseq_backend::__simd_first(__first, __begin, __end,
[&__comp](_RandomAccessIterator __it, _DifferenceType __i) {
return std::invoke(__comp, __it[(__i - 1) / 2], __it[__i]);
});
}

template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare>
Expand Down Expand Up @@ -3916,7 +3923,7 @@ __brick_is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
/* __is_vector = */ ::std::true_type) noexcept
{
return !__unseq_backend::__simd_or_iter(__first, __last - __first, [__first, &__comp](_RandomAccessIterator __it) {
return __comp(*(__first + (__it - __first - 1) / 2), *__it);
return std::invoke(__comp, *(__first + (__it - __first - 1) / 2), *__it);
});
}

Expand All @@ -3933,10 +3940,10 @@ bool
__is_heap_local(_RandomAccessIterator __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp,
/* __is_vector = */ ::std::true_type) noexcept
{
return !__unseq_backend::__simd_or_iter(__first + __begin, __end - __begin,
[__first, &__comp](_RandomAccessIterator __it) {
return __comp(*(__first + (__it - __first - 1) / 2), *__it);
});
return !__unseq_backend::__simd_or_iter(
__first + __begin, __end - __begin, [__first, &__comp](_RandomAccessIterator __it) {
return std::invoke(__comp, *(__first + (__it - __first - 1) / 2), *__it);
});
}

template <class _Tag, class _ExecutionPolicy, class _RandomAccessIterator, class _Compare>
Expand Down Expand Up @@ -4205,16 +4212,16 @@ __brick_lexicographical_compare(_RandomAccessIterator1 __first1, _RandomAccessIt
auto __n = ::std::min(__last1 - __first1, __last2 - __first2);
::std::pair<_RandomAccessIterator1, _RandomAccessIterator2> __result = __unseq_backend::__simd_first(
__first1, __n, __first2, [__comp](const ref_type1 __x, const ref_type2 __y) mutable {
return __comp(__x, __y) || __comp(__y, __x);
return std::invoke(__comp, __x, __y) || std::invoke(__comp, __y, __x);
});

if (__result.first == __last1 && __result.second != __last2)
{ // if first sequence shorter than second
return !__comp(*__result.second, *__result.first);
return !std::invoke(__comp, *__result.second, *__result.first);
}
else
{ // if second sequence shorter than first or both have the same number of elements
return __comp(*__result.first, *__result.second);
return std::invoke(__comp, *__result.first, *__result.second);
}
}
}
Expand Down Expand Up @@ -4261,7 +4268,7 @@ __pattern_lexicographical_compare(__parallel_tag<_IsVector> __tag, _ExecutionPol
return __internal::__brick_mismatch(
__i, __j, __first2 + (__i - __first1), __first2 + (__j - __first1),
[&__comp](const _RefType1 __x, const _RefType2 __y) {
return !__comp(__x, __y) && !__comp(__y, __x);
return !std::invoke(__comp, __x, __y) && !std::invoke(__comp, __y, __x);
},
_IsVector{})
.first;
Expand All @@ -4270,11 +4277,11 @@ __pattern_lexicographical_compare(__parallel_tag<_IsVector> __tag, _ExecutionPol

if (__result == __last1 && __first2 + (__result - __first1) != __last2)
{ // if first sequence shorter than second
return !__comp(*(__first2 + (__result - __first1)), *__result);
return !std::invoke(__comp, *(__first2 + (__result - __first1)), *__result);
}
else
{ // if second sequence shorter than first or both have the same number of elements
return __comp(*__result, *(__first2 + (__result - __first1)));
return std::invoke(__comp, *__result, *(__first2 + (__result - __first1)));
}
});
}
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 @@ -1415,8 +1415,8 @@ struct __pattern_lexicographical_compare_transform_fn
auto const& __s1_val = __acc1[__gidx];
auto const& __s2_val = __acc2[__gidx];

::std::int32_t __is_s1_val_less = __comp(__s1_val, __s2_val);
::std::int32_t __is_s1_val_greater = __comp(__s2_val, __s1_val);
std::int32_t __is_s1_val_less = std::invoke(__comp, __s1_val, __s2_val);
std::int32_t __is_s1_val_greater = std::invoke(__comp, __s2_val, __s1_val);

// 1 if __s1_val < __s2_val, -1 if __s1_val < __s2_val, 0 if __s1_val == __s2_val
return _ReduceValueType{1 * __is_s1_val_less - 1 * __is_s1_val_greater};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct __subgroup_bubble_sorter
{
auto& __first_item = __storage_acc[j - 1];
auto& __second_item = __storage_acc[j];
if (__comp(__second_item, __first_item))
if (std::invoke(__comp, __second_item, __first_item))
{
using std::swap;
swap(__first_item, __second_item);
Expand Down
10 changes: 5 additions & 5 deletions include/oneapi/dpl/pstl/hetero/utils_hetero.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ struct __pattern_minmax_element_reduce_fn
auto __chosen_for_min = __a;
auto __chosen_for_max = __b;

if (__comp(get<2>(__b), get<2>(__a)))
if (std::invoke(__comp, get<2>(__b), get<2>(__a)))
__chosen_for_min = std::move(__b);
if (__comp(get<3>(__b), get<3>(__a)))
if (std::invoke(__comp, get<3>(__b), get<3>(__a)))
__chosen_for_max = std::move(__a);
return _ReduceValueType{get<0>(__chosen_for_min), get<1>(__chosen_for_max), get<2>(__chosen_for_min),
get<3>(__chosen_for_max)};
Expand All @@ -87,7 +87,7 @@ struct __pattern_min_element_reduce_fn
{
// This operator doesn't track the lowest found index in case of equal min. or max. values. Thus, this operator is
// not commutative.
if (__comp(get<1>(__b), get<1>(__a)))
if (std::invoke(__comp, get<1>(__b), get<1>(__a)))
{
return __b;
}
Expand All @@ -97,8 +97,8 @@ struct __pattern_min_element_reduce_fn
{
// This operator keeps track of the lowest found index in case of equal min. or max. values. Thus, this operator is
// commutative.
bool _is_a_lt_b = __comp(get<1>(__a), get<1>(__b));
bool _is_b_lt_a = __comp(get<1>(__b), get<1>(__a));
bool _is_a_lt_b = std::invoke(__comp, get<1>(__a), get<1>(__b));
bool _is_b_lt_a = std::invoke(__comp, get<1>(__b), get<1>(__a));

if (_is_b_lt_a || (!_is_a_lt_b && get<0>(__b) < get<0>(__a)))
{
Expand Down
5 changes: 3 additions & 2 deletions include/oneapi/dpl/pstl/parallel_backend_tbb.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <cassert>
#include <algorithm>
#include <type_traits>
#include <functional> // for std::invoke

#include "parallel_backend_utils.h"
#include "execution_impl.h"
Expand Down Expand Up @@ -869,12 +870,12 @@ class __merge_func
{
assert(::std::is_sorted(_M_x_beg + _M_xs, _M_x_beg + _M_xs + __kx, _M_comp));
assert(::std::is_sorted(_M_x_beg + _M_ys, _M_x_beg + _M_ys + __ky, _M_comp));
return !_M_comp(*(_M_x_beg + _M_ys), *(_M_x_beg + _M_xs + __kx - 1));
return !std::invoke(_M_comp, *(_M_x_beg + _M_ys), *(_M_x_beg + _M_xs + __kx - 1));
}

assert(::std::is_sorted(_M_z_beg + _M_xs, _M_z_beg + _M_xs + __kx, _M_comp));
assert(::std::is_sorted(_M_z_beg + _M_ys, _M_z_beg + _M_ys + __ky, _M_comp));
return !_M_comp(*(_M_z_beg + _M_zs + __nx), *(_M_z_beg + _M_zs + __kx - 1));
return !std::invoke(_M_comp, *(_M_z_beg + _M_zs + __nx), *(_M_z_beg + _M_zs + __kx - 1));
}
void
move_x_range()
Expand Down
4 changes: 2 additions & 2 deletions include/oneapi/dpl/pstl/parallel_backend_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <cassert>
#include "utils.h"
#include "memory_fwd.h"
#include "functional_impl.h" // for oneapi::dpl::identity
#include "functional_impl.h" // for oneapi::dpl::identity, std::invoke

namespace oneapi
{
Expand Down Expand Up @@ -110,7 +110,7 @@ struct __serial_move_merge
{
for (;;)
{
if (__comp(*__ys, *__xs))
if (std::invoke(__comp, *__ys, *__xs))
{
const auto __i = __zs - __zs_beg;
if (__i < __nx)
Expand Down
6 changes: 4 additions & 2 deletions include/oneapi/dpl/pstl/parallel_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#define _ONEDPL_PARALLEL_IMPL_H

#include <atomic>
#include <functional> // for std::invoke

// This header defines the minimum set of parallel routines required to support Parallel STL,
// implemented on top of Intel(R) Threading Building Blocks (Intel(R) TBB) library

Expand Down Expand Up @@ -51,14 +53,14 @@ __parallel_find(__parallel_tag<_IsVector>, _ExecutionPolicy&& __exec, _Index __f
[__comp, __f, __first, &__extremum](_Index __i, _Index __j) {
// See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of
// why using a shared variable scales fairly well in this situation.
if (__comp(__i - __first, __extremum))
if (std::invoke(__comp, __i - __first, __extremum))
{
_Index __res = __f(__i, __j);
// If not '__last' returned then we found what we want so put this to extremum
if (__res != __j)
{
const _DifferenceType __k = __res - __first;
for (_DifferenceType __old = __extremum; __comp(__k, __old);
for (_DifferenceType __old = __extremum; std::invoke(__comp, __k, __old);
__old = __extremum)
{
__extremum.compare_exchange_weak(__old, __k);
Expand Down
Loading