Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements of __parallel_find_or + __device_backend_tag #1617

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0ad4456
include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - new predicat…
SergeyKopienko Jun 7, 2024
b95e518
include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - implementati…
SergeyKopienko Jun 7, 2024
f2a0344
include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - implementati…
SergeyKopienko Jun 7, 2024
d1bd118
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - remove…
SergeyKopienko Jun 10, 2024
e958b10
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - remove…
SergeyKopienko Jun 7, 2024
77642ab
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - remove…
SergeyKopienko Jun 7, 2024
86c9ac0
Apply GitHUB clang fromat
SergeyKopienko Jun 10, 2024
e96f6ca
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - fix se…
SergeyKopienko Jun 10, 2024
a707cb1
include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - fix review c…
SergeyKopienko Jun 10, 2024
b078d7f
include/oneapi/dpl/pstl/hetero/dpcpp/unseq_backend_sycl.h - fix error…
SergeyKopienko Jun 10, 2024
d04610b
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - fix re…
SergeyKopienko Jun 10, 2024
d9e7b4d
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - remove…
SergeyKopienko Jun 11, 2024
91f3de3
Revert "include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - fix …
SergeyKopienko Jun 11, 2024
d0dbb93
Revert "Apply GitHUB clang fromat"
SergeyKopienko Jun 11, 2024
dec2a04
Revert "include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - impl…
SergeyKopienko Jun 11, 2024
c50af52
Revert "include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - impl…
SergeyKopienko Jun 11, 2024
d851105
Revert "include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h - new …
SergeyKopienko Jun 11, 2024
c074778
Revert "include/oneapi/dpl/pstl/hetero/dpcpp/unseq_backend_sycl.h - f…
SergeyKopienko Jun 11, 2024
b92fce3
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - fix re…
SergeyKopienko Jun 13, 2024
7ea5ba6
Fix review comment: rename __parallel_find_or to __parallel_find_firs…
SergeyKopienko Jun 13, 2024
b9c26a8
Fix review comment: rename __parallel_find_or to __parallel_find_firs…
SergeyKopienko Jun 13, 2024
225d5f6
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - remove…
SergeyKopienko Jun 13, 2024
d20a4cd
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - restor…
SergeyKopienko Jun 13, 2024
9a69cc1
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - fix re…
SergeyKopienko Jun 13, 2024
30fb5a6
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - simpli…
SergeyKopienko Jun 14, 2024
aa94007
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - rename…
SergeyKopienko Jun 14, 2024
63eb820
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - rewrit…
SergeyKopienko Jun 14, 2024
d2581b2
include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h - run pr…
SergeyKopienko Jun 14, 2024
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
17 changes: 8 additions & 9 deletions include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,9 @@ __pattern_adjacent_find(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _I

// TODO: in case of conflicting names
// __par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__or_policy_wrapper>()
bool result = __par_backend_hetero::__parallel_find_or(
_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec),
_Predicate{adjacent_find_fn<_BinaryPredicate>{__predicate}}, __par_backend_hetero::__parallel_or_tag{},
bool result = __par_backend_hetero::__parallel_find_any(
_BackendTag{}, std::forward<_ExecutionPolicy>(__exec),
_Predicate{adjacent_find_fn<_BinaryPredicate>{__predicate}},
oneapi::dpl::__ranges::make_zip_view(__buf1.all_view(), __buf2.all_view()));

// inverted conditional because of
Expand Down Expand Up @@ -659,11 +659,11 @@ __pattern_any_of(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _Iterator
auto __keep = oneapi::dpl::__ranges::__get_sycl_range<__par_backend_hetero::access_mode::read, _Iterator>();
auto __buf = __keep(__first, __last);

return oneapi::dpl::__par_backend_hetero::__parallel_find_or(
return oneapi::dpl::__par_backend_hetero::__parallel_find_any(
_BackendTag{},
__par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__or_policy_wrapper>(
::std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, __par_backend_hetero::__parallel_or_tag{}, __buf.all_view());
std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, __buf.all_view());
}

//------------------------------------------------------------------------
Expand All @@ -687,9 +687,8 @@ __pattern_equal(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _Iterator1

// TODO: in case of conflicting names
// __par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__or_policy_wrapper>()
return !__par_backend_hetero::__parallel_find_or(
_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec), _Predicate{equal_predicate<_Pred>{__pred}},
__par_backend_hetero::__parallel_or_tag{},
return !__par_backend_hetero::__parallel_find_any(
_BackendTag{}, std::forward<_ExecutionPolicy>(__exec), _Predicate{equal_predicate<_Pred>{__pred}},
oneapi::dpl::__ranges::make_zip_view(__buf1.all_view(), __buf2.all_view()));
}

Expand Down
72 changes: 43 additions & 29 deletions include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ __pattern_equal(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _Range1&&

// TODO: in case of conflicting names
// __par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__or_policy_wrapper>()
return !oneapi::dpl::__par_backend_hetero::__parallel_find_or(
_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec), _Predicate{equal_predicate<_Pred>{__pred}},
oneapi::dpl::__par_backend_hetero::__parallel_or_tag{},
return !oneapi::dpl::__par_backend_hetero::__parallel_find_any(
_BackendTag{}, std::forward<_ExecutionPolicy>(__exec), _Predicate{equal_predicate<_Pred>{__pred}},
oneapi::dpl::__ranges::zip_view(::std::forward<_Range1>(__rng1), ::std::forward<_Range2>(__rng2)));
}

Expand All @@ -126,10 +125,10 @@ __pattern_find_if(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _Range&&
using _Predicate = oneapi::dpl::unseq_backend::single_match_pred<_ExecutionPolicy, _Pred>;
using _TagType = oneapi::dpl::__par_backend_hetero::__parallel_find_forward_tag<_Range>;

return oneapi::dpl::__par_backend_hetero::__parallel_find_or(
return oneapi::dpl::__par_backend_hetero::__parallel_find_first(
_BackendTag{},
__par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__find_policy_wrapper>(
::std::forward<_ExecutionPolicy>(__exec)),
std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, _TagType{}, ::std::forward<_Range>(__rng));
}

Expand All @@ -156,10 +155,10 @@ __pattern_find_end(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&& __exec, _
using _Predicate = unseq_backend::multiple_match_pred<_ExecutionPolicy, _Pred>;
using _TagType = __par_backend_hetero::__parallel_find_backward_tag<_Range1>;

return oneapi::dpl::__par_backend_hetero::__parallel_find_or(
return oneapi::dpl::__par_backend_hetero::__parallel_find_first(
_BackendTag{},
__par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__find_policy_wrapper>(
::std::forward<_ExecutionPolicy>(__exec)),
std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, _TagType{}, ::std::forward<_Range1>(__rng1), ::std::forward<_Range2>(__rng2));
}

Expand All @@ -180,11 +179,11 @@ __pattern_find_first_of(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _R
using _TagType = oneapi::dpl::__par_backend_hetero::__parallel_find_forward_tag<_Range1>;

//TODO: To check whether it makes sense to iterate over the second sequence in case of __rng1.size() < __rng2.size()
return oneapi::dpl::__par_backend_hetero::__parallel_find_or(
return oneapi::dpl::__par_backend_hetero::__parallel_find_first(
_BackendTag{},
__par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__find_policy_wrapper>(
::std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, _TagType{}, ::std::forward<_Range1>(__rng1), ::std::forward<_Range2>(__rng2));
std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, _TagType{}, std::forward<_Range1>(__rng1), ::std::forward<_Range2>(__rng2));
}

//------------------------------------------------------------------------
Expand All @@ -199,11 +198,11 @@ __pattern_any_of(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _Range&&
return false;

using _Predicate = oneapi::dpl::unseq_backend::single_match_pred<_ExecutionPolicy, _Pred>;
return oneapi::dpl::__par_backend_hetero::__parallel_find_or(
return oneapi::dpl::__par_backend_hetero::__parallel_find_any(
_BackendTag{},
__par_backend_hetero::make_wrapped_policy<oneapi::dpl::__par_backend_hetero::__or_policy_wrapper>(
::std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, oneapi::dpl::__par_backend_hetero::__parallel_or_tag{}, ::std::forward<_Range>(__rng));
std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, std::forward<_Range>(__rng));
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -237,11 +236,11 @@ __pattern_search(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&& __exec, _Ra
using _Predicate = unseq_backend::multiple_match_pred<_ExecutionPolicy, _Pred>;
using _TagType = oneapi::dpl::__par_backend_hetero::__parallel_find_forward_tag<_Range1>;

return oneapi::dpl::__par_backend_hetero::__parallel_find_or(
return oneapi::dpl::__par_backend_hetero::__parallel_find_first(
_BackendTag{},
oneapi::dpl::__par_backend_hetero::make_wrapped_policy<
oneapi::dpl::__par_backend_hetero::__find_policy_wrapper>(::std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, _TagType{}, ::std::forward<_Range1>(__rng1), ::std::forward<_Range2>(__rng2));
oneapi::dpl::__par_backend_hetero::__find_policy_wrapper>(std::forward<_ExecutionPolicy>(__exec)),
_Predicate{__pred}, _TagType{}, std::forward<_Range1>(__rng1), std::forward<_Range2>(__rng2));
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -292,22 +291,37 @@ __pattern_adjacent_find(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _R

using _Predicate =
oneapi::dpl::unseq_backend::single_match_pred<_ExecutionPolicy, adjacent_find_fn<_BinaryPredicate>>;
using _TagType = ::std::conditional_t<__is__or_semantic(), oneapi::dpl::__par_backend_hetero::__parallel_or_tag,
oneapi::dpl::__par_backend_hetero::__parallel_find_forward_tag<_Range>>;

auto __rng1 = __rng | oneapi::dpl::experimental::ranges::views::take(__rng.size() - 1);
auto __rng2 = __rng | oneapi::dpl::experimental::ranges::views::drop(1);

// TODO: in case of conflicting names
// __par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__or_policy_wrapper>()
auto result = oneapi::dpl::__par_backend_hetero::__parallel_find_or(
_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec),
_Predicate{adjacent_find_fn<_BinaryPredicate>{__predicate}}, _TagType{},
oneapi::dpl::__ranges::zip_view(__rng1, __rng2));

// inverted conditional because of
// reorder_predicate in glue_algorithm_impl.h
return return_value(result, __rng.size(), __is__or_semantic);
if constexpr (__is__or_semantic())
{
// TODO: in case of conflicting names
// __par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__or_policy_wrapper>()
auto result = oneapi::dpl::__par_backend_hetero::__parallel_find_any(
_BackendTag{}, std::forward<_ExecutionPolicy>(__exec),
_Predicate{adjacent_find_fn<_BinaryPredicate>{__predicate}},
oneapi::dpl::__ranges::zip_view(__rng1, __rng2));

// inverted conditional because of
// reorder_predicate in glue_algorithm_impl.h
return return_value(result, __rng.size(), __is__or_semantic);
}
else
{
using _TagType = oneapi::dpl::__par_backend_hetero::__parallel_find_forward_tag<_Range>;

// TODO: in case of conflicting names
// __par_backend_hetero::make_wrapped_policy<__par_backend_hetero::__or_policy_wrapper>()
auto result = oneapi::dpl::__par_backend_hetero::__parallel_find_first(
_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec),
_Predicate{adjacent_find_fn<_BinaryPredicate>{__predicate}}, _TagType{},
oneapi::dpl::__ranges::zip_view(__rng1, __rng2));

// inverted conditional because of
// reorder_predicate in glue_algorithm_impl.h
return return_value(result, __rng.size(), __is__or_semantic);
}
}

template <typename _BackendTag, typename _ExecutionPolicy, typename _Range, typename _Predicate>
Expand Down
Loading
Loading