8080 4. HAVE_GCD - system wide, used automatically (APPLE only)
8181 5. WINRT - system wide, used automatically (Windows RT only)
8282 6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11)
83+ 7. HAVE_PTHREADS_PF - pthreads if available
8384*/
8485
8586#if defined HAVE_TBB
125126# define CV_PARALLEL_FRAMEWORK " winrt-concurrency"
126127#elif defined HAVE_CONCURRENCY
127128# define CV_PARALLEL_FRAMEWORK " ms-concurrency"
128- #elif defined HAVE_PTHREADS
129+ #elif defined HAVE_PTHREADS_PF
129130# define CV_PARALLEL_FRAMEWORK " pthreads"
130131#endif
131132
132133namespace cv
133134{
134135 ParallelLoopBody::~ParallelLoopBody () {}
136+ #ifdef HAVE_PTHREADS_PF
137+ void parallel_for_pthreads (const cv::Range& range, const cv::ParallelLoopBody& body, double nstripes);
138+ size_t parallel_pthreads_get_threads_num ();
139+ void parallel_pthreads_set_threads_num (int num);
140+ #endif
135141}
136142
143+
137144namespace
138145{
139146#ifdef CV_PARALLEL_FRAMEWORK
@@ -300,8 +307,8 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
300307 Concurrency::CurrentScheduler::Detach ();
301308 }
302309
303- #elif defined HAVE_PTHREADS
304- void parallel_for_pthreads ( const Range& range, const ParallelLoopBody& body, double nstripes);
310+ #elif defined HAVE_PTHREADS_PF
311+
305312 parallel_for_pthreads (range, body, nstripes);
306313
307314#else
@@ -359,9 +366,7 @@ int cv::getNumThreads(void)
359366 ? Concurrency::CurrentScheduler::Get ()->GetNumberOfVirtualProcessors ()
360367 : pplScheduler->GetNumberOfVirtualProcessors ());
361368
362- #elif defined HAVE_PTHREADS
363-
364- size_t parallel_pthreads_get_threads_num ();
369+ #elif defined HAVE_PTHREADS_PF
365370
366371 return parallel_pthreads_get_threads_num ();
367372
@@ -422,9 +427,7 @@ void cv::setNumThreads( int threads )
422427 Concurrency::MaxConcurrency, threads-1 ));
423428 }
424429
425- #elif defined HAVE_PTHREADS
426-
427- void parallel_pthreads_set_threads_num (int num);
430+ #elif defined HAVE_PTHREADS_PF
428431
429432 parallel_pthreads_set_threads_num (threads);
430433
@@ -450,6 +453,8 @@ int cv::getThreadNum(void)
450453 return 0 ;
451454#elif defined HAVE_CONCURRENCY
452455 return std::max (0 , (int )Concurrency::Context::VirtualProcessorId ()); // zero for master thread, unique number for others but not necessary 1,2,3,...
456+ #elif defined HAVE_PTHREADS_PF
457+ return (int )(size_t )(void *)pthread_self (); // no zero-based indexing
453458#else
454459 return 0 ;
455460#endif
0 commit comments