Skip to content

Commit

Permalink
Allow passing a device-copyable comparator to sort
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Sobolev <[email protected]>
  • Loading branch information
dmitriy-sobolev committed Nov 4, 2024
1 parent bdc037b commit 71fe89c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/oneapi/dpl/pstl/hetero/dpcpp/sycl_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ struct __write_to_id_if_else;
template <typename _ExecutionPolicy, typename _Pred>
struct __early_exit_find_or;

template <typename _Range, typename _Compare>
struct __leaf_sorter;

} // namespace oneapi::dpl::__par_backend_hetero

template <typename _UnaryOp>
Expand Down Expand Up @@ -313,6 +316,13 @@ struct sycl::is_device_copyable<_ONEDPL_SPECIALIZE_FOR(oneapi::dpl::__par_backen
{
};

template <typename _Range, typename _Compare>
struct sycl::is_device_copyable<_ONEDPL_SPECIALIZE_FOR(oneapi::dpl::__par_backend_hetero::__leaf_sorter, _Range,
_Compare)>
: oneapi::dpl::__internal::__are_all_device_copyable<_Range, _Compare>
{
};

namespace oneapi::dpl::unseq_backend
{

Expand Down
9 changes: 9 additions & 0 deletions test/general/implementation_details/device_copyable.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ test_device_copyable()
oneapi::dpl::__par_backend_hetero::__early_exit_find_or<policy_non_device_copyable, noop_device_copyable>>,
"__early_exit_find_or is not device copyable with device copyable types");

static_assert(
sycl::is_device_copyable_v<oneapi::dpl::__par_backend_hetero::__leaf_sorter<noop_device_copyable,
noop_device_copyable>>,
"__leaf_sorter is not device copyable with device copyable types");

//__not_pred
static_assert(sycl::is_device_copyable_v<oneapi::dpl::__internal::__not_pred<noop_device_copyable>>,
"__not_pred is not device copyable with device copyable types");
Expand Down Expand Up @@ -423,6 +428,10 @@ test_non_device_copyable()
noop_non_device_copyable>>,
"__early_exit_find_or is device copyable with non device copyable types");

static_assert(!sycl::is_device_copyable_v<oneapi::dpl::__par_backend_hetero::__leaf_sorter<noop_device_copyable,
noop_non_device_copyable>>,
"__leaf_sorter is device copyable with non device copyable types");

//__not_pred
static_assert(!sycl::is_device_copyable_v<oneapi::dpl::__internal::__not_pred<noop_non_device_copyable>>,
"__not_pred is device copyable with non device copyable types");
Expand Down

0 comments on commit 71fe89c

Please sign in to comment.