Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change usage of _PSTL_UD[R/S]_PRESENT macros #1551

Merged
merged 7 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions include/oneapi/dpl/pstl/algorithm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3882,11 +3882,17 @@ _RandomAccessIterator
__brick_min_element(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
/* __is_vector = */ ::std::true_type) noexcept
{
#if (_PSTL_UDR_PRESENT || _ONEDPL_UDR_PRESENT)
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved
return __unseq_backend::__simd_min_element(__first, __last - __first, __comp);
#else
return ::std::min_element(__first, __last, __comp);
// On some platforms, _PSTL_UDR_PRESENT is defined but empty
#if (_PSTL_UDR_PRESENT + 0)
constexpr bool __use_simd_min_element = _PSTL_UDR_PRESENT;
#else // _ONEDPL_UDR_PRESENT should always be defined
constexpr bool __use_simd_min_element = _ONEDPL_UDR_PRESENT;
#endif

if constexpr (__use_simd_min_element)
return __unseq_backend::__simd_min_element(__first, __last - __first, __comp);
else
return ::std::min_element(__first, __last, __comp);
}

template <class _Tag, typename _ExecutionPolicy, typename _ForwardIterator, typename _Compare>
Expand Down Expand Up @@ -3949,11 +3955,17 @@ ::std::pair<_RandomAccessIterator, _RandomAccessIterator>
__brick_minmax_element(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
/* __is_vector = */ ::std::true_type) noexcept
{
#if (_PSTL_UDR_PRESENT || _ONEDPL_UDR_PRESENT)
return __unseq_backend::__simd_minmax_element(__first, __last - __first, __comp);
#else
return ::std::minmax_element(__first, __last, __comp);
// On some platforms, _PSTL_UDR_PRESENT is defined but empty
#if (_PSTL_UDR_PRESENT + 0)
constexpr bool __use_simd_minmax_element = _PSTL_UDR_PRESENT;
#else // _ONEDPL_UDR_PRESENT should always be defined
constexpr bool __use_simd_minmax_element = _ONEDPL_UDR_PRESENT;
#endif

if constexpr (__use_simd_minmax_element)
return __unseq_backend::__simd_minmax_element(__first, __last - __first, __comp);
else
return ::std::minmax_element(__first, __last, __comp);
}

template <class _Tag, typename _ExecutionPolicy, typename _ForwardIterator, typename _Compare>
Expand Down
18 changes: 13 additions & 5 deletions include/oneapi/dpl/pstl/numeric_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,21 @@ __brick_transform_scan(_RandomAccessIterator __first, _RandomAccessIterator __la
_UnaryOperation __unary_op, _Tp __init, _BinaryOperation __binary_op, _Inclusive,
/*is_vector=*/::std::true_type) noexcept
{
#if (_PSTL_UDS_PRESENT || _ONEDPL_UDS_PRESENT)
if (_Inclusive() || !oneapi::dpl::__internal::__iterators_possibly_equal(__first, __result))
// On some platforms, _PSTL_UDS_PRESENT is defined but empty
#if (_PSTL_UDS_PRESENT + 0)
constexpr bool __use_simd_scan = _PSTL_UDS_PRESENT;
#else // _ONEDPL_UDS_PRESENT should always be defined
constexpr bool __use_simd_scan = _ONEDPL_UDS_PRESENT;
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

if constexpr (__use_simd_scan)
{
return __unseq_backend::__simd_scan(__first, __last - __first, __result, __unary_op, __init, __binary_op,
_Inclusive());
if (_Inclusive() || !oneapi::dpl::__internal::__iterators_possibly_equal(__first, __result))
{
return __unseq_backend::__simd_scan(__first, __last - __first, __result, __unary_op, __init, __binary_op,
_Inclusive());
}
}
#endif
// We need to call serial brick here to call function for inclusive and exclusive scan that depends on _Inclusive() value
return __internal::__brick_transform_scan(__first, __last, __result, __unary_op, __init, __binary_op, _Inclusive(),
/*is_vector=*/::std::false_type());
Expand Down
Loading