Skip to content

Commit

Permalink
[oneDPL][ranges] + __simd_count for sized output; + _ONEDPL_PRAGMA_SI…
Browse files Browse the repository at this point in the history
…MD_EARLYEXIT_REDUCTION
  • Loading branch information
MikeDvorskiy committed Oct 15, 2024
1 parent 955ef35 commit 69df5b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/oneapi/dpl/pstl/onedpl_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA_SIMD_EARLYEXIT
#elif _ONEDPL_EARLYEXIT_PRESENT
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT _ONEDPL_PRAGMA(omp simd early_exit)
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT_REDUCTION(PRM) _ONEDPL_PRAGMA(omp simd early_exit reduction(PRM))
#else
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT_REDUCTION(PRM)
#endif
#define _ONEDPL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)
Expand Down
17 changes: 17 additions & 0 deletions include/oneapi/dpl/pstl/unseq_backend_simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,23 @@ __simd_count(_Index __index, _DifferenceType __n, _Pred __pred) noexcept
return __count;
}

template <typename _Index, typename _DifferenceType, typename _Bound, typename _Pred>
_DifferenceType
__simd_count(_Index __index, _DifferenceType __n, _Bound __m, _Pred __pred) noexcept
{
_DifferenceType __count = 0;
_ONEDPL_PRAGMA_SIMD_EARLYEXIT_REDUCTION(+ : __count)
for (_DifferenceType __i = 0; __i < __n; ++__i)
{
if(__count >= __m)
break;
if (__pred(*(__index + __i)))
++__count;
}

return __count;
}

template <class _InputIterator, class _DifferenceType, class _OutputIterator, class _BinaryPredicate>
_OutputIterator
__simd_unique_copy(_InputIterator __first, _DifferenceType __n, _OutputIterator __result,
Expand Down

0 comments on commit 69df5b4

Please sign in to comment.