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
f57630d9
Commit
f57630d9
authored
Jan 30, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10691 from alalek:parallel_for_2018
parents
cb66f82c
c49d5d52
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
9 deletions
+51
-9
utility.hpp
modules/core/include/opencv2/core/utility.hpp
+2
-0
parallel.cpp
modules/core/src/parallel.cpp
+30
-8
parallel_impl.cpp
modules/core/src/parallel_impl.cpp
+0
-0
parallel_impl.hpp
modules/core/src/parallel_impl.hpp
+17
-0
parallel_pthreads.cpp
modules/core/src/parallel_pthreads.cpp
+0
-0
ts_perf.cpp
modules/ts/src/ts_perf.cpp
+2
-1
No files found.
modules/core/include/opencv2/core/utility.hpp
View file @
f57630d9
...
...
@@ -233,6 +233,8 @@ CV_EXPORTS_W int getNumThreads();
/** @brief Returns the index of the currently executed thread within the current parallel region. Always
returns 0 if called outside of parallel region.
@deprecated Current implementation doesn't corresponding to this documentation.
The exact meaning of the return value depends on the threading framework used by OpenCV library:
- `TBB` - Unsupported with current 4.1 TBB release. Maybe will be supported in future.
- `OpenMP` - The thread number, within the current team, of the calling thread.
...
...
modules/core/src/parallel.cpp
View file @
f57630d9
...
...
@@ -42,6 +42,7 @@
#include "precomp.hpp"
#include <opencv2/core/utils/configuration.private.hpp>
#include <opencv2/core/utils/trace.private.hpp>
#if defined _WIN32 || defined WINCE
...
...
@@ -125,19 +126,15 @@
# define CV_PARALLEL_FRAMEWORK "pthreads"
#endif
#include "parallel_impl.hpp"
using
namespace
cv
;
namespace
cv
{
ParallelLoopBody
::~
ParallelLoopBody
()
{}
#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
);
#endif
}
namespace
{
#ifdef CV_PARALLEL_FRAMEWORK
...
...
@@ -558,10 +555,35 @@ int cv::getNumThreads(void)
#endif
}
void
cv
::
setNumThreads
(
int
threads
)
namespace
cv
{
unsigned
defaultNumberOfThreads
()
{
#ifdef __ANDROID__
// many modern phones/tables have 4-core CPUs. Let's use no more
// than 2 threads by default not to overheat the devices
const
unsigned
int
default_number_of_threads
=
2
;
#else
const
unsigned
int
default_number_of_threads
=
(
unsigned
int
)
std
::
max
(
1
,
cv
::
getNumberOfCPUs
());
#endif
unsigned
result
=
default_number_of_threads
;
static
int
config_num_threads
=
(
int
)
utils
::
getConfigurationParameterSizeT
(
"OPENCV_FOR_THREADS_NUM"
,
0
);
if
(
config_num_threads
)
{
result
=
(
unsigned
)
std
::
max
(
1
,
config_num_threads
);
//do we need upper limit of threads number?
}
return
result
;
}
}
void
cv
::
setNumThreads
(
int
threads_
)
{
(
void
)
threads
;
(
void
)
threads
_
;
#ifdef CV_PARALLEL_FRAMEWORK
int
threads
=
(
threads_
<
0
)
?
defaultNumberOfThreads
()
:
(
unsigned
)
threads_
;
numThreads
=
threads
;
#endif
...
...
modules/core/src/parallel_impl.cpp
0 → 100644
View file @
f57630d9
This diff is collapsed.
Click to expand it.
modules/core/src/parallel_impl.hpp
0 → 100644
View file @
f57630d9
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef OPENCV_CORE_PARALLEL_IMPL_HPP
#define OPENCV_CORE_PARALLEL_IMPL_HPP
namespace
cv
{
unsigned
defaultNumberOfThreads
();
void
parallel_for_pthreads
(
const
Range
&
range
,
const
ParallelLoopBody
&
body
,
double
nstripes
);
size_t
parallel_pthreads_get_threads_num
();
void
parallel_pthreads_set_threads_num
(
int
num
);
}
#endif // OPENCV_CORE_PARALLEL_IMPL_HPP
modules/core/src/parallel_pthreads.cpp
deleted
100644 → 0
View file @
cb66f82c
This diff is collapsed.
Click to expand it.
modules/ts/src/ts_perf.cpp
View file @
f57630d9
...
...
@@ -1693,9 +1693,10 @@ void TestBase::validateMetrics()
{
double
mean
=
metrics
.
mean
*
1000.0
f
/
metrics
.
frequency
;
double
median
=
metrics
.
median
*
1000.0
f
/
metrics
.
frequency
;
double
min_value
=
metrics
.
min
*
1000.0
f
/
metrics
.
frequency
;
double
stddev
=
metrics
.
stddev
*
1000.0
f
/
metrics
.
frequency
;
double
percents
=
stddev
/
mean
*
100.
f
;
printf
(
"[ PERFSTAT ] (samples
= %d, mean = %.2f, median = %.2f, stddev = %.2f (%.1f%%))
\n
"
,
(
int
)
metrics
.
samples
,
mean
,
median
,
stddev
,
percents
);
printf
(
"[ PERFSTAT ] (samples
=%d mean=%.2f median=%.2f min=%.2f stddev=%.2f (%.1f%%))
\n
"
,
(
int
)
metrics
.
samples
,
mean
,
median
,
min_value
,
stddev
,
percents
);
}
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