diff --git a/inference-engine/include/ie_parallel.hpp b/inference-engine/include/ie_parallel.hpp index 67286f3e165efb..bc33c92e01266a 100644 --- a/inference-engine/include/ie_parallel.hpp +++ b/inference-engine/include/ie_parallel.hpp @@ -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 @@ -186,7 +195,7 @@ void parallel_sort(I begin, I end, const F& comparator) { template 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(0, D0), input, [&](const tbb::blocked_range& r, R init) -> R { R sum = init; @@ -218,7 +227,7 @@ R parallel_sum(const T0& D0, const R& input, const F& func) { template 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(0, D0, 0, D1), input, [&](const tbb::blocked_range2d& r, R init) -> R { R sum = init; @@ -257,7 +266,7 @@ R parallel_sum2d(const T0& D0, const T1& D1, const R& input, const F& func) { template 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(0, D0, 0, D1, 0, D2), input, [&](const tbb::blocked_range3d& r, R init) -> R { R sum = init;