@@ -2180,6 +2180,41 @@ __pattern_reduce_by_segment(__hetero_tag<_BackendTag> __tag, _ExecutionPolicy&&
2180
2180
__out_keys.all_view (), __out_values.all_view (), __binary_pred, __binary_op);
2181
2181
}
2182
2182
2183
+ template <typename _BackendTag, typename _Policy, typename _InputIterator1, typename _InputIterator2,
2184
+ typename _OutputIterator, typename _T, typename _BinaryPredicate, typename _Operator, typename _Inclusive>
2185
+ _OutputIterator
2186
+ __pattern_scan_by_segment (__hetero_tag<_BackendTag>, _Policy&& __policy, _InputIterator1 __first1,
2187
+ _InputIterator1 __last1, _InputIterator2 __first2, _OutputIterator __result, _T __init,
2188
+ _BinaryPredicate __binary_pred, _Operator __binary_op, _Inclusive)
2189
+ {
2190
+ const auto __n = std::distance (__first1, __last1);
2191
+
2192
+ // Check for empty element ranges
2193
+ if (__n <= 0 )
2194
+ return __result;
2195
+
2196
+ namespace __bknd = oneapi::dpl::__par_backend_hetero;
2197
+
2198
+ auto __keep_keys = oneapi::dpl::__ranges::__get_sycl_range<__bknd::access_mode::read, _InputIterator1>();
2199
+ auto __key_buf = __keep_keys (__first1, __last1);
2200
+ auto __keep_values = oneapi::dpl::__ranges::__get_sycl_range<__bknd::access_mode::read, _InputIterator2>();
2201
+ auto __value_buf = __keep_values (__first2, __first2 + __n);
2202
+ auto __keep_value_outputs =
2203
+ oneapi::dpl::__ranges::__get_sycl_range<__bknd::access_mode::read_write, _OutputIterator>();
2204
+ auto __value_output_buf = __keep_value_outputs (__result, __result + __n);
2205
+ using _IterValueType = typename std::iterator_traits<_InputIterator2>::value_type;
2206
+
2207
+ // Currently, this pattern requires a known identity for the binary operator.
2208
+ static_assert (unseq_backend::__has_known_identity<_Operator, _IterValueType>::value,
2209
+ " Calls to __pattern_scan_by_segment require a known identity for the provided binary operator" );
2210
+ constexpr _IterValueType __identity = unseq_backend::__known_identity<_Operator, _IterValueType>;
2211
+
2212
+ __bknd::__parallel_scan_by_segment<_Inclusive::value>(
2213
+ _BackendTag{}, std::forward<_Policy>(__policy), __key_buf.all_view (), __value_buf.all_view (),
2214
+ __value_output_buf.all_view (), __binary_pred, __binary_op, __init, __identity);
2215
+ return __result + __n;
2216
+ }
2217
+
2183
2218
} // namespace __internal
2184
2219
} // namespace dpl
2185
2220
} // namespace oneapi
0 commit comments