From 71fe89cca85b93915153c7e82ed3aa65c948c876 Mon Sep 17 00:00:00 2001 From: Dmitriy Sobolev Date: Mon, 4 Nov 2024 14:21:33 -0600 Subject: [PATCH 1/3] Allow passing a device-copyable comparator to sort Signed-off-by: Dmitriy Sobolev --- include/oneapi/dpl/pstl/hetero/dpcpp/sycl_traits.h | 10 ++++++++++ .../implementation_details/device_copyable.pass.cpp | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_traits.h b/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_traits.h index f498a58750..2d0e88fd34 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_traits.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_traits.h @@ -257,6 +257,9 @@ struct __write_to_id_if_else; template struct __early_exit_find_or; +template +struct __leaf_sorter; + } // namespace oneapi::dpl::__par_backend_hetero template @@ -313,6 +316,13 @@ struct sycl::is_device_copyable<_ONEDPL_SPECIALIZE_FOR(oneapi::dpl::__par_backen { }; +template +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 { diff --git a/test/general/implementation_details/device_copyable.pass.cpp b/test/general/implementation_details/device_copyable.pass.cpp index 8b137cc33e..1a537c2863 100644 --- a/test/general/implementation_details/device_copyable.pass.cpp +++ b/test/general/implementation_details/device_copyable.pass.cpp @@ -190,6 +190,11 @@ test_device_copyable() oneapi::dpl::__par_backend_hetero::__early_exit_find_or>, "__early_exit_find_or is not device copyable with device copyable types"); + static_assert( + sycl::is_device_copyable_v>, + "__leaf_sorter is not device copyable with device copyable types"); + //__not_pred static_assert(sycl::is_device_copyable_v>, "__not_pred is not device copyable with device copyable types"); @@ -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>, + "__leaf_sorter is device copyable with non device copyable types"); + //__not_pred static_assert(!sycl::is_device_copyable_v>, "__not_pred is device copyable with non device copyable types"); From 1fa74380b05573bfab24bc7f586915da426fe794 Mon Sep 17 00:00:00 2001 From: Dmitriy Sobolev Date: Tue, 5 Nov 2024 07:50:31 -0600 Subject: [PATCH 2/3] Add sycl_traits.h Signed-off-by: Dmitriy Sobolev --- .../dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge_sort.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge_sort.h b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge_sort.h index db55edc37d..0765f8ef7b 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge_sort.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge_sort.h @@ -24,6 +24,7 @@ #include // std::decay_t, std::integral_constant #include "sycl_defs.h" // __dpl_sycl::__local_accessor, __dpl_sycl::__group_barrier +#include "sycl_traits.h" // SYCL traits specialization for some oneDPL types. #include "../../utils.h" // __dpl_bit_floor, __dpl_bit_ceil #include "../../utils_ranges.h" // __difference_t #include "parallel_backend_sycl_merge.h" // __find_start_point, __serial_merge From af9577cbd31f2eec3061d2fe1502d15e2044a8db Mon Sep 17 00:00:00 2001 From: Dmitriy Sobolev Date: Tue, 5 Nov 2024 11:07:41 -0600 Subject: [PATCH 3/3] More comments for device_copyable test Signed-off-by: Dmitriy Sobolev --- test/general/implementation_details/device_copyable.pass.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/general/implementation_details/device_copyable.pass.cpp b/test/general/implementation_details/device_copyable.pass.cpp index 1a537c2863..9b1b09e8c2 100644 --- a/test/general/implementation_details/device_copyable.pass.cpp +++ b/test/general/implementation_details/device_copyable.pass.cpp @@ -190,6 +190,10 @@ test_device_copyable() oneapi::dpl::__par_backend_hetero::__early_exit_find_or>, "__early_exit_find_or is not device copyable with device copyable types"); + // __leaf_sorter + // Note that the use of noop_device_copyable/noop_non_device_copyable is valid in this context because + // sycl::is_device_copyable specialization for __leaf_sorter does not require instantiation of + // __leaf_sorter with the provided types. See [temp.inst]/1 of C++17 spec for the details. static_assert( sycl::is_device_copyable_v>, @@ -428,6 +432,7 @@ test_non_device_copyable() noop_non_device_copyable>>, "__early_exit_find_or is device copyable with non device copyable types"); + // __leaf_sorter static_assert(!sycl::is_device_copyable_v>, "__leaf_sorter is device copyable with non device copyable types");