Skip to content

Commit 3d0dc2d

Browse files
committed
Make __parallel_copy_if blocking instead of returning a future
1 parent 36e41f0 commit 3d0dc2d

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

include/oneapi/dpl/pstl/hetero/algorithm_impl_hetero.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,22 +918,19 @@ _Iterator2
918918
__pattern_copy_if(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _Iterator1 __first, _Iterator1 __last,
919919
_Iterator2 __result_first, _Predicate __pred)
920920
{
921-
using _It1DifferenceType = typename ::std::iterator_traits<_Iterator1>::difference_type;
922-
923921
if (__first == __last)
924922
return __result_first;
925923

926-
_It1DifferenceType __n = __last - __first;
924+
typename std::iterator_traits<_Iterator1>::difference_type __n = __last - __first;
927925

928926
auto __keep1 = oneapi::dpl::__ranges::__get_sycl_range<__par_backend_hetero::access_mode::read, _Iterator1>();
929927
auto __buf1 = __keep1(__first, __last);
930928
auto __keep2 = oneapi::dpl::__ranges::__get_sycl_range<__par_backend_hetero::access_mode::write, _Iterator2>();
931929
auto __buf2 = __keep2(__result_first, __result_first + __n);
932930

933-
auto __res = __par_backend_hetero::__parallel_copy_if(_BackendTag{}, ::std::forward<_ExecutionPolicy>(__exec),
934-
__buf1.all_view(), __buf2.all_view(), __n, __n, __pred);
931+
std::size_t __num_copied = __par_backend_hetero::__parallel_copy_if(
932+
_BackendTag{}, std::forward<_ExecutionPolicy>(__exec), __buf1.all_view(), __buf2.all_view(), __n, __n, __pred);
935933

936-
::std::size_t __num_copied = __res.get(); //is a blocking call
937934
return __result_first + __num_copied;
938935
}
939936

include/oneapi/dpl/pstl/hetero/algorithm_ranges_impl_hetero.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,12 +659,10 @@ __pattern_copy_if(__hetero_tag<_BackendTag>, _ExecutionPolicy&& __exec, _Range1&
659659
if (__n == 0 || __m == 0)
660660
return 0;
661661

662-
auto __res = oneapi::dpl::__par_backend_hetero::__parallel_copy_if(
662+
return oneapi::dpl::__par_backend_hetero::__parallel_copy_if(
663663
_BackendTag{}, std::forward<_ExecutionPolicy>(__exec),
664664
oneapi::dpl::__ranges::__get_subscription_view(std::forward<_Range1>(__rng1)),
665665
oneapi::dpl::__ranges::__get_subscription_view(std::forward<_Range2>(__rng2)), __n, __m, __pred, __assign);
666-
667-
return __res.get(); //is a blocking call
668666
}
669667

670668
#if _ONEDPL_CPP20_RANGES_PRESENT

include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ __parallel_partition_copy(oneapi::dpl::__internal::__device_backend_tag, _Execut
889889

890890
template <typename _ExecutionPolicy, typename _InRng, typename _OutRng, typename _Size, typename _Pred,
891891
typename _Assign = oneapi::dpl::__internal::__pstl_assign>
892-
__future<sycl::event, __result_and_scratch_storage<_Size>>
892+
_Size
893893
__parallel_copy_if(oneapi::dpl::__internal::__device_backend_tag, _ExecutionPolicy&& __exec, _InRng&& __in_rng,
894894
_OutRng&& __out_rng, _Size __n, _Size __m, _Pred __pred, _Assign __assign = _Assign{})
895895
// TODO: __parallel_copy_if should return two stop positions
@@ -919,7 +919,8 @@ __parallel_copy_if(oneapi::dpl::__internal::__device_backend_tag, _ExecutionPoli
919919
__scan_copy_single_wg_kernel<_CustomName>>;
920920
return __par_backend_hetero::__parallel_copy_if_static_single_group_submitter<_Size, _KernelName>()(
921921
__q_local, std::forward<_InRng>(__in_rng), std::forward<_OutRng>(__out_rng), __n, __m, __pred, __assign,
922-
static_cast<std::uint16_t>(__n_uniform), static_cast<std::uint16_t>(std::min(__n_uniform, __max_wg_size)));
922+
static_cast<std::uint16_t>(__n_uniform), static_cast<std::uint16_t>(std::min(__n_uniform, __max_wg_size)))
923+
.get();
923924
}
924925
else if (oneapi::dpl::__par_backend_hetero::__is_gpu_with_reduce_then_scan_sg_sz(__q_local))
925926
{
@@ -929,7 +930,7 @@ __parallel_copy_if(oneapi::dpl::__internal::__device_backend_tag, _ExecutionPoli
929930
return __parallel_reduce_then_scan_copy<_CustomName>(__q_local, std::forward<_InRng>(__in_rng),
930931
std::forward<_OutRng>(__out_rng), __n,
931932
_GenMask{__pred, {}}, _WriteOp{__assign},
932-
/*_IsUniquePattern=*/std::false_type{});
933+
/*_IsUniquePattern=*/std::false_type{}).get();
933934
}
934935
else
935936
{
@@ -940,7 +941,7 @@ __parallel_copy_if(oneapi::dpl::__internal::__device_backend_tag, _ExecutionPoli
940941

941942
return __parallel_scan_copy<_CustomName>(__q_local, std::forward<_InRng>(__in_rng),
942943
std::forward<_OutRng>(__out_rng), __n, _CreateOp{__pred},
943-
_CopyOp{_ReduceOp{}, __assign});
944+
_CopyOp{_ReduceOp{}, __assign}).get();
944945
}
945946
}
946947

@@ -2230,8 +2231,7 @@ __parallel_reduce_by_segment_fallback(oneapi::dpl::__internal::__device_backend_
22302231
oneapi::dpl::__internal::__device_backend_tag{},
22312232
oneapi::dpl::__par_backend_hetero::make_wrapped_policy<__assign_key1_wrapper>(__exec), __view1, __view2, __n,
22322233
__n, __internal::__parallel_reduce_by_segment_fallback_fn1<_BinaryPredicate>{__binary_pred, __wgroup_size},
2233-
unseq_backend::__brick_assign_key_position{})
2234-
.get();
2234+
unseq_backend::__brick_assign_key_position{});
22352235

22362236
//reduce by segment
22372237
oneapi::dpl::__par_backend_hetero::__parallel_for(
@@ -2269,8 +2269,7 @@ __parallel_reduce_by_segment_fallback(oneapi::dpl::__internal::__device_backend_
22692269
oneapi::dpl::__par_backend_hetero::make_wrapped_policy<__assign_key2_wrapper>(__exec), __view3, __view4,
22702270
__view3.size(), __view3.size(),
22712271
__internal::__parallel_reduce_by_segment_fallback_fn2<_BinaryPredicate>{__binary_pred},
2272-
unseq_backend::__brick_assign_key_position{})
2273-
.get();
2272+
unseq_backend::__brick_assign_key_position{});
22742273

22752274
//reduce by segment
22762275
oneapi::dpl::__par_backend_hetero::__parallel_for(

0 commit comments

Comments
 (0)