From 75e133e5418eeff9e1d3ae631aa65f7516041890 Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Thu, 28 Nov 2024 19:02:46 +0100 Subject: [PATCH] [oneDPL][ranges][merge] support size limit for output; + __parallel_merge sycl pattern support --- include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h | 2 +- .../oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h b/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h index b9cd154a044..a6654897420 100644 --- a/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h +++ b/include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h @@ -54,7 +54,7 @@ template , _ExecutionPolicy&& __exec, _Function __f, _Ranges&&... __rngs) { - auto __n = oneapi::dpl::__ranges::__get_first_range_size(__rngs...); + auto __n = std::min({__rngs.size()...}); if (__n > 0) { oneapi::dpl::__par_backend_hetero::__parallel_for(_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec), diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h index 753e32816a0..fa45d0f6db1 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h @@ -142,7 +142,7 @@ struct __parallel_merge_submitter<_IdType, __internal::__optional_kernel_name<_N { const _IdType __n1 = __rng1.size(); const _IdType __n2 = __rng2.size(); - const _IdType __n = __n1 + __n2; + const _IdType __n = std::min<_IdType>(__n1 + __n2, __rng3.size()); assert(__n1 > 0 || __n2 > 0);