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 4 commits
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
4 changes: 2 additions & 2 deletions include/oneapi/dpl/pstl/algorithm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3882,7 +3882,7 @@ _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
#if _ONEDPL_IS_ONE_OR_EMPTY(_PSTL_UDR_PRESENT) || _ONEDPL_UDR_PRESENT
return __unseq_backend::__simd_min_element(__first, __last - __first, __comp);
#else
return ::std::min_element(__first, __last, __comp);
Expand Down Expand Up @@ -3949,7 +3949,7 @@ ::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)
#if _ONEDPL_IS_ONE_OR_EMPTY(_PSTL_UDR_PRESENT) || _ONEDPL_UDR_PRESENT
return __unseq_backend::__simd_minmax_element(__first, __last - __first, __comp);
#else
return ::std::minmax_element(__first, __last, __comp);
Expand Down
2 changes: 1 addition & 1 deletion include/oneapi/dpl/pstl/numeric_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ __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 _ONEDPL_IS_ONE_OR_EMPTY(_PSTL_UDS_PRESENT) || _ONEDPL_UDS_PRESENT
if (_Inclusive() || !oneapi::dpl::__internal::__iterators_possibly_equal(__first, __result))
{
return __unseq_backend::__simd_scan(__first, __last - __first, __result, __unary_op, __init, __binary_op,
Expand Down
13 changes: 13 additions & 0 deletions include/oneapi/dpl/pstl/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
# include <cstring> // memcpy
#endif

#define _ONEDPL_IS_EMPTY_STRING(_X) ((0-_X-1)==1 && (_X-0)!=-2)
#define _ONEDPL_IS_ONE(_X) ((_X-1)==0)

// This macro is needed because there are two ways that input defines are used:
//
// 1. A feature X is enabled if the macro X is defined as 1 and disabled if
// the macro X is defined as 0
// 2. A feature X is enabled if the macro X is defined with no value (i.e.,
// an empty macro) and disabled if the macro is undefined
//
// We want to catch both cases in a single macro
#define _ONEDPL_IS_ONE_OR_EMPTY(_X) (_ONEDPL_IS_EMPTY_STRING(_X) || _ONEDPL_IS_ONE(_X))

namespace oneapi
{
namespace dpl
Expand Down
Loading