|
|
|
@ -80,6 +80,7 @@ |
|
|
|
|
4. HAVE_GCD - system wide, used automatically (APPLE only) |
|
|
|
|
5. WINRT - system wide, used automatically (Windows RT only) |
|
|
|
|
6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11) |
|
|
|
|
7. HAVE_PTHREADS_PF - pthreads if available |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#if defined HAVE_TBB |
|
|
|
@ -125,14 +126,14 @@ |
|
|
|
|
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency" |
|
|
|
|
#elif defined HAVE_CONCURRENCY |
|
|
|
|
# define CV_PARALLEL_FRAMEWORK "ms-concurrency" |
|
|
|
|
#elif defined HAVE_PTHREADS |
|
|
|
|
#elif defined HAVE_PTHREADS_PF |
|
|
|
|
# define CV_PARALLEL_FRAMEWORK "pthreads" |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
|
ParallelLoopBody::~ParallelLoopBody() {} |
|
|
|
|
#if defined HAVE_PTHREADS && HAVE_PTHREADS |
|
|
|
|
#ifdef HAVE_PTHREADS_PF |
|
|
|
|
void parallel_for_pthreads(const cv::Range& range, const cv::ParallelLoopBody& body, double nstripes); |
|
|
|
|
size_t parallel_pthreads_get_threads_num(); |
|
|
|
|
void parallel_pthreads_set_threads_num(int num); |
|
|
|
@ -306,7 +307,7 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body, |
|
|
|
|
Concurrency::CurrentScheduler::Detach(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#elif defined HAVE_PTHREADS |
|
|
|
|
#elif defined HAVE_PTHREADS_PF |
|
|
|
|
|
|
|
|
|
parallel_for_pthreads(range, body, nstripes); |
|
|
|
|
|
|
|
|
@ -365,7 +366,7 @@ int cv::getNumThreads(void) |
|
|
|
|
? Concurrency::CurrentScheduler::Get()->GetNumberOfVirtualProcessors() |
|
|
|
|
: pplScheduler->GetNumberOfVirtualProcessors()); |
|
|
|
|
|
|
|
|
|
#elif defined HAVE_PTHREADS |
|
|
|
|
#elif defined HAVE_PTHREADS_PF |
|
|
|
|
|
|
|
|
|
return parallel_pthreads_get_threads_num(); |
|
|
|
|
|
|
|
|
@ -426,7 +427,7 @@ void cv::setNumThreads( int threads ) |
|
|
|
|
Concurrency::MaxConcurrency, threads-1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#elif defined HAVE_PTHREADS |
|
|
|
|
#elif defined HAVE_PTHREADS_PF |
|
|
|
|
|
|
|
|
|
parallel_pthreads_set_threads_num(threads); |
|
|
|
|
|
|
|
|
@ -452,6 +453,8 @@ int cv::getThreadNum(void) |
|
|
|
|
return 0; |
|
|
|
|
#elif defined HAVE_CONCURRENCY |
|
|
|
|
return std::max(0, (int)Concurrency::Context::VirtualProcessorId()); // zero for master thread, unique number for others but not necessary 1,2,3,...
|
|
|
|
|
#elif defined HAVE_PTHREADS_PF |
|
|
|
|
return (int)(size_t)(void*)pthread_self(); // no zero-based indexing
|
|
|
|
|
#else |
|
|
|
|
return 0; |
|
|
|
|
#endif |
|
|
|
|