Skip to content

Commit 69df5b4

Browse files
committed
[oneDPL][ranges] + __simd_count for sized output; + _ONEDPL_PRAGMA_SIMD_EARLYEXIT_REDUCTION
1 parent 955ef35 commit 69df5b4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

include/oneapi/dpl/pstl/onedpl_config.h

+2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@
158158
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT _PSTL_PRAGMA_SIMD_EARLYEXIT
159159
#elif _ONEDPL_EARLYEXIT_PRESENT
160160
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT _ONEDPL_PRAGMA(omp simd early_exit)
161+
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT_REDUCTION(PRM) _ONEDPL_PRAGMA(omp simd early_exit reduction(PRM))
161162
#else
162163
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT
164+
# define _ONEDPL_PRAGMA_SIMD_EARLYEXIT_REDUCTION(PRM)
163165
#endif
164166
165167
#define _ONEDPL_MONOTONIC_PRESENT (__INTEL_COMPILER >= 1800)

include/oneapi/dpl/pstl/unseq_backend_simd.h

+17
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,23 @@ __simd_count(_Index __index, _DifferenceType __n, _Pred __pred) noexcept
248248
return __count;
249249
}
250250

251+
template <typename _Index, typename _DifferenceType, typename _Bound, typename _Pred>
252+
_DifferenceType
253+
__simd_count(_Index __index, _DifferenceType __n, _Bound __m, _Pred __pred) noexcept
254+
{
255+
_DifferenceType __count = 0;
256+
_ONEDPL_PRAGMA_SIMD_EARLYEXIT_REDUCTION(+ : __count)
257+
for (_DifferenceType __i = 0; __i < __n; ++__i)
258+
{
259+
if(__count >= __m)
260+
break;
261+
if (__pred(*(__index + __i)))
262+
++__count;
263+
}
264+
265+
return __count;
266+
}
267+
251268
template <class _InputIterator, class _DifferenceType, class _OutputIterator, class _BinaryPredicate>
252269
_OutputIterator
253270
__simd_unique_copy(_InputIterator __first, _DifferenceType __n, _OutputIterator __result,

0 commit comments

Comments
 (0)