Skip to content

Commit

Permalink
Fix unsupported arg for tbb deterministic_reduce
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Peskov <[email protected]>
  • Loading branch information
AlexPeskov committed Nov 27, 2020
1 parent cb3bf2d commit 0ca94c5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions inference-engine/include/ie_parallel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ inline int parallel_get_env_threads() {
}
#if IE_THREAD == IE_THREAD_TBB
#define PARTITIONING , tbb::static_partitioner()

// The TBB version less than 2018u1 has no static_partitioner argument for
// tbb::parallel_deterministic_reduce. So will fallback to non deterministic version.
#if (TBB_INTERFACE_VERSION >= 10001)
#define _TBB_REDUCE_FUNC tbb::parallel_deterministic_reduce
#else
#define _TBB_REDUCE_FUNC tbb::parallel_reduce
#endif

#else
#define PARTITIONING
#endif
Expand Down Expand Up @@ -186,7 +195,7 @@ void parallel_sort(I begin, I end, const F& comparator) {
template <typename T0, typename R, typename F>
R parallel_sum(const T0& D0, const R& input, const F& func) {
#if (IE_THREAD == IE_THREAD_TBB || IE_THREAD == IE_THREAD_TBB_AUTO)
return tbb::parallel_deterministic_reduce(
return _TBB_REDUCE_FUNC(
tbb::blocked_range<T0>(0, D0), input,
[&](const tbb::blocked_range<T0>& r, R init) -> R {
R sum = init;
Expand Down Expand Up @@ -218,7 +227,7 @@ R parallel_sum(const T0& D0, const R& input, const F& func) {
template <typename T0, typename T1, typename R, typename F>
R parallel_sum2d(const T0& D0, const T1& D1, const R& input, const F& func) {
#if (IE_THREAD == IE_THREAD_TBB || IE_THREAD == IE_THREAD_TBB_AUTO)
return tbb::parallel_deterministic_reduce(
return _TBB_REDUCE_FUNC(
tbb::blocked_range2d<T0, T1>(0, D0, 0, D1), input,
[&](const tbb::blocked_range2d<T0, T1>& r, R init) -> R {
R sum = init;
Expand Down Expand Up @@ -257,7 +266,7 @@ R parallel_sum2d(const T0& D0, const T1& D1, const R& input, const F& func) {
template <typename T0, typename T1, typename T2, typename R, typename F>
R parallel_sum3d(const T0& D0, const T1& D1, const T2& D2, const R& input, const F& func) {
#if (IE_THREAD == IE_THREAD_TBB || IE_THREAD == IE_THREAD_TBB_AUTO)
return tbb::parallel_deterministic_reduce(
return _TBB_REDUCE_FUNC(
tbb::blocked_range3d<T0, T1, T2>(0, D0, 0, D1, 0, D2), input,
[&](const tbb::blocked_range3d<T0, T1, T2>& r, R init) -> R {
R sum = init;
Expand Down

0 comments on commit 0ca94c5

Please sign in to comment.