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
0ebabe17
Commit
0ebabe17
authored
Aug 10, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix flag processing for nested regions in cv::parallel_for_()
parent
87c27a07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
8 deletions
+34
-8
parallel.cpp
modules/core/src/parallel.cpp
+34
-8
No files found.
modules/core/src/parallel.cpp
View file @
0ebabe17
...
...
@@ -363,6 +363,10 @@ static SchedPtr pplScheduler;
/* ================================ parallel_for_ ================================ */
#ifdef CV_PARALLEL_FRAMEWORK
static
void
parallel_for_impl
(
const
cv
::
Range
&
range
,
const
cv
::
ParallelLoopBody
&
body
,
double
nstripes
);
// forward declaration
#endif
void
cv
::
parallel_for_
(
const
cv
::
Range
&
range
,
const
cv
::
ParallelLoopBody
&
body
,
double
nstripes
)
{
#ifdef OPENCV_TRACE
...
...
@@ -377,10 +381,35 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
return
;
#ifdef CV_PARALLEL_FRAMEWORK
static
volatile
int
flagNestedParallelFor
=
0
;
bool
isNotNestedRegion
=
flagNestedParallelFor
==
0
;
if
(
isNotNestedRegion
)
isNotNestedRegion
=
CV_XADD
(
&
flagNestedParallelFor
,
1
)
==
0
;
if
(
isNotNestedRegion
)
{
try
{
parallel_for_impl
(
range
,
body
,
nstripes
);
flagNestedParallelFor
=
0
;
}
catch
(...)
{
flagNestedParallelFor
=
0
;
throw
;
}
}
else
// nested parallel_for_() calls are not parallelized
#endif // CV_PARALLEL_FRAMEWORK
{
(
void
)
nstripes
;
body
(
range
);
}
}
static
int
flagNestedParallelFor
=
0
;
bool
isNotNesterParallelFor
=
CV_XADD
(
&
flagNestedParallelFor
,
1
)
==
0
;
if
(
numThreads
!=
0
&&
isNotNesterParallelFor
)
#ifdef CV_PARALLEL_FRAMEWORK
static
void
parallel_for_impl
(
const
cv
::
Range
&
range
,
const
cv
::
ParallelLoopBody
&
body
,
double
nstripes
)
{
if
((
numThreads
<
0
||
numThreads
>
1
)
&&
range
.
end
-
range
.
start
>
1
)
{
ParallelLoopBodyWrapperContext
ctx
(
body
,
range
,
nstripes
);
ProxyLoopBody
pbody
(
ctx
);
...
...
@@ -388,7 +417,6 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
if
(
stripeRange
.
end
-
stripeRange
.
start
==
1
)
{
body
(
range
);
flagNestedParallelFor
=
0
;
return
;
}
...
...
@@ -444,16 +472,14 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
#error You have hacked and compiling with unsupported parallel framework
#endif
flagNestedParallelFor
=
0
;
}
else
#endif // CV_PARALLEL_FRAMEWORK
{
(
void
)
nstripes
;
body
(
range
);
}
}
#endif // CV_PARALLEL_FRAMEWORK
int
cv
::
getNumThreads
(
void
)
{
...
...
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