@@ -298,6 +298,12 @@ namespace
298
298
{
299
299
this ->ParallelLoopBodyWrapper ::operator ()(cv::Range (range.begin (), range.end ()));
300
300
}
301
+
302
+ void operator ()() const // run parallel job
303
+ {
304
+ cv::Range stripeRange = this ->stripeRange ();
305
+ tbb::parallel_for (tbb::blocked_range<int >(stripeRange.start , stripeRange.end ), *this );
306
+ }
301
307
};
302
308
#elif defined HAVE_CSTRIPES || defined HAVE_OPENMP
303
309
typedef ParallelLoopBodyWrapper ProxyLoopBody;
@@ -328,7 +334,11 @@ namespace
328
334
static int numThreads = -1 ;
329
335
330
336
#if defined HAVE_TBB
331
- static tbb::task_scheduler_init tbbScheduler (tbb::task_scheduler_init::deferred);
337
+ #if TBB_INTERFACE_VERSION >= 8000
338
+ static tbb::task_arena tbbArena (tbb::task_arena::automatic);
339
+ #else
340
+ static tbb::task_scheduler_init tbbScheduler (tbb::task_scheduler_init::deferred);
341
+ #endif
332
342
#elif defined HAVE_CSTRIPES
333
343
// nothing for C=
334
344
#elif defined HAVE_OPENMP
@@ -424,7 +434,11 @@ static void parallel_for_impl(const cv::Range& range, const cv::ParallelLoopBody
424
434
425
435
#if defined HAVE_TBB
426
436
427
- tbb::parallel_for (tbb::blocked_range<int >(stripeRange.start , stripeRange.end ), pbody);
437
+ #if TBB_INTERFACE_VERSION >= 8000
438
+ tbbArena.execute (pbody);
439
+ #else
440
+ pbody ();
441
+ #endif
428
442
429
443
#elif defined HAVE_CSTRIPES
430
444
@@ -494,9 +508,17 @@ int cv::getNumThreads(void)
494
508
495
509
#if defined HAVE_TBB
496
510
511
+ #if TBB_INTERFACE_VERSION >= 9100
512
+ return tbbArena.max_concurrency ();
513
+ #elif TBB_INTERFACE_VERSION >= 8000
514
+ return numThreads > 0
515
+ ? numThreads
516
+ : tbb::task_scheduler_init::default_num_threads ();
517
+ #else
497
518
return tbbScheduler.is_active ()
498
519
? numThreads
499
520
: tbb::task_scheduler_init::default_num_threads ();
521
+ #endif
500
522
501
523
#elif defined HAVE_CSTRIPES
502
524
@@ -545,8 +567,13 @@ void cv::setNumThreads( int threads )
545
567
546
568
#ifdef HAVE_TBB
547
569
570
+ #if TBB_INTERFACE_VERSION >= 8000
571
+ if (tbbArena.is_active ()) tbbArena.terminate ();
572
+ if (threads > 0 ) tbbArena.initialize (threads);
573
+ #else
548
574
if (tbbScheduler.is_active ()) tbbScheduler.terminate ();
549
575
if (threads > 0 ) tbbScheduler.initialize (threads);
576
+ #endif
550
577
551
578
#elif defined HAVE_CSTRIPES
552
579
0 commit comments