Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
9683f93a
Commit
9683f93a
authored
Mar 19, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3840 from MSOpenTech:concurrency-contrib
parents
9997e6d3
d1a81710
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
parallel.cpp
modules/core/src/parallel.cpp
+28
-5
No files found.
modules/core/src/parallel.cpp
View file @
9683f93a
...
...
@@ -69,7 +69,7 @@
#define HAVE_GCD
#endif
#if defined _MSC_VER && _MSC_VER >= 1600
&& !defined(WINRT)
#if defined _MSC_VER && _MSC_VER >= 1600
#define HAVE_CONCURRENCY
#endif
...
...
@@ -78,7 +78,8 @@
2. HAVE_CSTRIPES - 3rdparty library, should be explicitly enabled
3. HAVE_OPENMP - integrated to compiler, should be explicitly enabled
4. HAVE_GCD - system wide, used automatically (APPLE only)
5. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11)
5. WINRT - system wide, used automatically (Windows RT only)
6. HAVE_CONCURRENCY - part of runtime, used automatically (Windows only - MSVS 10, MSVS 11)
*/
#if defined HAVE_TBB
...
...
@@ -105,6 +106,8 @@
#elif defined HAVE_GCD
#include <dispatch/dispatch.h>
#include <pthread.h>
#elif defined WINRT
#include <ppltasks.h>
#elif defined HAVE_CONCURRENCY
#include <ppl.h>
#endif
...
...
@@ -118,6 +121,8 @@
# define CV_PARALLEL_FRAMEWORK "openmp"
#elif defined HAVE_GCD
# define CV_PARALLEL_FRAMEWORK "gcd"
#elif defined WINRT
# define CV_PARALLEL_FRAMEWORK "winrt-concurrency"
#elif defined HAVE_CONCURRENCY
# define CV_PARALLEL_FRAMEWORK "ms-concurrency"
#endif
...
...
@@ -179,7 +184,7 @@ namespace
ProxyLoopBody
*
ptr_body
=
static_cast
<
ProxyLoopBody
*>
(
context
);
(
*
ptr_body
)(
cv
::
Range
((
int
)
index
,
(
int
)
index
+
1
));
}
#elif defined HAVE_CONCURRENCY
#elif defined
WINRT || defined
HAVE_CONCURRENCY
class
ProxyLoopBody
:
public
ParallelLoopBodyWrapper
{
public
:
...
...
@@ -206,7 +211,10 @@ static tbb::task_scheduler_init tbbScheduler(tbb::task_scheduler_init::deferred)
static
int
numThreadsMax
=
omp_get_max_threads
();
#elif defined HAVE_GCD
// nothing for GCD
#elif defined WINRT
// nothing for WINRT
#elif defined HAVE_CONCURRENCY
class
SchedPtr
{
Concurrency
::
Scheduler
*
sched_
;
...
...
@@ -224,6 +232,7 @@ public:
~
SchedPtr
()
{
*
this
=
0
;
}
};
static
SchedPtr
pplScheduler
;
#endif
#endif // CV_PARALLEL_FRAMEWORK
...
...
@@ -272,6 +281,10 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
dispatch_queue_t
concurrent_queue
=
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
);
dispatch_apply_f
(
stripeRange
.
end
-
stripeRange
.
start
,
concurrent_queue
,
&
pbody
,
block_function
);
#elif defined WINRT
Concurrency
::
parallel_for
(
stripeRange
.
start
,
stripeRange
.
end
,
pbody
);
#elif defined HAVE_CONCURRENCY
if
(
!
pplScheduler
||
pplScheduler
->
Id
()
==
Concurrency
::
CurrentScheduler
::
Id
())
...
...
@@ -330,11 +343,15 @@ int cv::getNumThreads(void)
return
512
;
// the GCD thread pool limit
#elif defined WINRT
return
0
;
#elif defined HAVE_CONCURRENCY
return
1
+
(
pplScheduler
==
0
?
Concurrency
::
CurrentScheduler
::
Get
()
->
GetNumberOfVirtualProcessors
()
:
pplScheduler
->
GetNumberOfVirtualProcessors
());
?
Concurrency
::
CurrentScheduler
::
Get
()
->
GetNumberOfVirtualProcessors
()
:
pplScheduler
->
GetNumberOfVirtualProcessors
());
#else
...
...
@@ -371,6 +388,10 @@ void cv::setNumThreads( int threads )
// unsupported
// there is only private dispatch_queue_set_width() and only for desktop
#elif defined WINRT
return
;
#elif defined HAVE_CONCURRENCY
if
(
threads
<=
0
)
...
...
@@ -407,6 +428,8 @@ int cv::getThreadNum(void)
return
omp_get_thread_num
();
#elif defined HAVE_GCD
return
(
int
)(
size_t
)(
void
*
)
pthread_self
();
// no zero-based indexing
#elif defined WINRT
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,...
#else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment