diff --git a/include/oneapi/dpl/pstl/onedpl_config.h b/include/oneapi/dpl/pstl/onedpl_config.h index 2ef13c46f83..92c34295bea 100644 --- a/include/oneapi/dpl/pstl/onedpl_config.h +++ b/include/oneapi/dpl/pstl/onedpl_config.h @@ -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) diff --git a/include/oneapi/dpl/pstl/unseq_backend_simd.h b/include/oneapi/dpl/pstl/unseq_backend_simd.h index 7b760ccc67b..909b48c419b 100644 --- a/include/oneapi/dpl/pstl/unseq_backend_simd.h +++ b/include/oneapi/dpl/pstl/unseq_backend_simd.h @@ -248,6 +248,23 @@ __simd_count(_Index __index, _DifferenceType __n, _Pred __pred) noexcept return __count; } +template +_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 _OutputIterator __simd_unique_copy(_InputIterator __first, _DifferenceType __n, _OutputIterator __result,