Skip to content

Commit

Permalink
Address review comment
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Michel <matthew.michel@intel.com>
  • Loading branch information
mmichel11 committed Dec 6, 2024
1 parent 18efe04 commit 6a6d9a5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl.h
Original file line number Diff line number Diff line change
Expand Up @@ -830,29 +830,30 @@ struct __gen_red_by_seg_scan_input
using _KeyType = oneapi::dpl::__internal::__value_t<decltype(__in_keys)>;
using _ValueType = oneapi::dpl::__internal::__value_t<decltype(__in_vals)>;
const _KeyType& __current_key = __in_keys[__id];
const _ValueType& __current_val = __in_vals[__id];
// Ordering the most common condition first has yielded the best results.
if (__id > 0 && __id < __n - 1)
{
const _KeyType& __prev_key = __in_keys[__id - 1];
const _KeyType& __next_key = __in_keys[__id + 1];
const std::size_t __new_seg_mask = !__binary_pred(__prev_key, __current_key);
return oneapi::dpl::__internal::make_tuple(
oneapi::dpl::__internal::make_tuple(__new_seg_mask, _ValueType{__in_vals[__id]}),
oneapi::dpl::__internal::make_tuple(__new_seg_mask, __current_val),
!__binary_pred(__current_key, __next_key), __next_key, __current_key);
}
else if (__id == __n - 1)
{
const _KeyType& __prev_key = __in_keys[__id - 1];
const std::size_t __new_seg_mask = !__binary_pred(__prev_key, __current_key);
return oneapi::dpl::__internal::make_tuple(
oneapi::dpl::__internal::make_tuple(__new_seg_mask, _ValueType{__in_vals[__id]}), true, __current_key,
oneapi::dpl::__internal::make_tuple(__new_seg_mask, __current_val), true, __current_key,
__current_key); // Passing __current_key as the next key for the last element is a placeholder
}
else // __id == 0
{
const _KeyType& __next_key = __in_keys[__id + 1];
return oneapi::dpl::__internal::make_tuple(
oneapi::dpl::__internal::make_tuple(std::size_t{0}, _ValueType{__in_vals[__id]}),
oneapi::dpl::__internal::make_tuple(std::size_t{0}, __current_val),
!__binary_pred(__current_key, __next_key), __next_key, __current_key);
}
}
Expand Down

0 comments on commit 6a6d9a5

Please sign in to comment.