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
23288b7c
Commit
23288b7c
authored
Oct 07, 2019
by
Nikita Shulga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use atomic operations to modify flagNestedParallelFor
This ensures uniform behavior on any C++11 compliant compiler
parent
626bfbf3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
parallel.cpp
modules/core/src/parallel.cpp
+9
-5
No files found.
modules/core/src/parallel.cpp
View file @
23288b7c
...
@@ -134,6 +134,10 @@
...
@@ -134,6 +134,10 @@
# define CV_PARALLEL_FRAMEWORK "pthreads"
# define CV_PARALLEL_FRAMEWORK "pthreads"
#endif
#endif
#ifdef CV_PARALLEL_FRAMEWORK
#include <atomic>
#endif
#include "parallel_impl.hpp"
#include "parallel_impl.hpp"
#include "opencv2/core/detail/exception_ptr.hpp" // CV__EXCEPTION_PTR = 1 if std::exception_ptr is available
#include "opencv2/core/detail/exception_ptr.hpp" // CV__EXCEPTION_PTR = 1 if std::exception_ptr is available
...
@@ -487,20 +491,20 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
...
@@ -487,20 +491,20 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
return
;
return
;
#ifdef CV_PARALLEL_FRAMEWORK
#ifdef CV_PARALLEL_FRAMEWORK
static
volatile
int
flagNestedParallelFor
=
0
;
static
std
::
atomic
<
bool
>
flagNestedParallelFor
(
false
)
;
bool
isNotNestedRegion
=
flagNestedParallelFor
==
0
;
bool
isNotNestedRegion
=
!
flagNestedParallelFor
.
load
()
;
if
(
isNotNestedRegion
)
if
(
isNotNestedRegion
)
isNotNestedRegion
=
CV_XADD
(
&
flagNestedParallelFor
,
1
)
==
0
;
isNotNestedRegion
=
!
flagNestedParallelFor
.
exchange
(
true
)
;
if
(
isNotNestedRegion
)
if
(
isNotNestedRegion
)
{
{
try
try
{
{
parallel_for_impl
(
range
,
body
,
nstripes
);
parallel_for_impl
(
range
,
body
,
nstripes
);
flagNestedParallelFor
=
0
;
flagNestedParallelFor
=
false
;
}
}
catch
(...)
catch
(...)
{
{
flagNestedParallelFor
=
0
;
flagNestedParallelFor
=
false
;
throw
;
throw
;
}
}
}
}
...
...
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