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
c3881ede
Commit
c3881ede
authored
Oct 15, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor thread management in performance tests
parent
aedf5640
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
18 deletions
+25
-18
ts_perf.cpp
modules/ts/src/ts_perf.cpp
+25
-18
No files found.
modules/ts/src/ts_perf.cpp
View file @
c3881ede
...
@@ -15,7 +15,7 @@ const std::string command_line_keys =
...
@@ -15,7 +15,7 @@ const std::string command_line_keys =
"{ perf_min_samples |10 |minimal required numer of samples}"
"{ perf_min_samples |10 |minimal required numer of samples}"
"{ perf_force_samples |100 |force set maximum number of samples for all tests}"
"{ perf_force_samples |100 |force set maximum number of samples for all tests}"
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_t
bb_nthreads |-1 |if TBB is enabled, the number of TBB threads
}"
"{ perf_t
hreads |-1 |the number of worker threads, if parallel execution is enabled
}"
"{ perf_write_sanity | |allow to create new records for sanity checks}"
"{ perf_write_sanity | |allow to create new records for sanity checks}"
#ifdef ANDROID
#ifdef ANDROID
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
...
@@ -39,18 +39,18 @@ static unsigned int param_min_samples;
...
@@ -39,18 +39,18 @@ static unsigned int param_min_samples;
static
unsigned
int
param_force_samples
;
static
unsigned
int
param_force_samples
;
static
uint64
param_seed
;
static
uint64
param_seed
;
static
double
param_time_limit
;
static
double
param_time_limit
;
static
int
param_t
bb_nt
hreads
;
static
int
param_threads
;
static
bool
param_write_sanity
;
static
bool
param_write_sanity
;
#ifdef HAVE_CUDA
#ifdef HAVE_CUDA
static
bool
param_run_cpu
;
static
bool
param_run_cpu
;
static
int
param_cuda_device
;
static
int
param_cuda_device
;
#endif
#endif
#ifdef ANDROID
#ifdef ANDROID
static
int
param_affinity_mask
;
static
int
param_affinity_mask
;
static
bool
log_power_checkpoints
;
static
bool
log_power_checkpoints
;
#include <sys/syscall.h>
#include <sys/syscall.h>
#include <pthread.h>
#include <pthread.h>
static
void
setCurrentThreadAffinityMask
(
int
mask
)
static
void
setCurrentThreadAffinityMask
(
int
mask
)
...
@@ -64,13 +64,25 @@ static void setCurrentThreadAffinityMask(int mask)
...
@@ -64,13 +64,25 @@ static void setCurrentThreadAffinityMask(int mask)
LOGE
(
"Error in the syscall setaffinity: mask=%d=0x%x err=%d=0x%x"
,
mask
,
mask
,
err
,
err
);
LOGE
(
"Error in the syscall setaffinity: mask=%d=0x%x err=%d=0x%x"
,
mask
,
mask
,
err
,
err
);
}
}
}
}
#endif
#endif
#ifdef HAVE_CUDA
#ifdef HAVE_CUDA
# include <opencv2/core/gpumat.hpp>
# include <opencv2/core/gpumat.hpp>
#endif
#endif
namespace
{
class
PerfEnvironment
:
public
::
testing
::
Environment
{
public
:
void
TearDown
()
{
cv
::
setNumThreads
(
-
1
);
}
};
}
// namespace
static
void
randu
(
cv
::
Mat
&
m
)
static
void
randu
(
cv
::
Mat
&
m
)
{
{
const
int
bigValue
=
0x00000FFF
;
const
int
bigValue
=
0x00000FFF
;
...
@@ -635,6 +647,8 @@ void TestBase::Init(int argc, const char* const argv[])
...
@@ -635,6 +647,8 @@ void TestBase::Init(int argc, const char* const argv[])
return
;
return
;
}
}
::
testing
::
AddGlobalTestEnvironment
(
new
PerfEnvironment
);
param_max_outliers
=
std
::
min
(
100.
,
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_max_outliers"
)));
param_max_outliers
=
std
::
min
(
100.
,
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_max_outliers"
)));
param_min_samples
=
std
::
max
(
1u
,
args
.
get
<
unsigned
int
>
(
"perf_min_samples"
));
param_min_samples
=
std
::
max
(
1u
,
args
.
get
<
unsigned
int
>
(
"perf_min_samples"
));
param_max_deviation
=
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_max_deviation"
));
param_max_deviation
=
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_max_deviation"
));
...
@@ -642,7 +656,7 @@ void TestBase::Init(int argc, const char* const argv[])
...
@@ -642,7 +656,7 @@ void TestBase::Init(int argc, const char* const argv[])
param_time_limit
=
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_time_limit"
));
param_time_limit
=
std
::
max
(
0.
,
args
.
get
<
double
>
(
"perf_time_limit"
));
param_force_samples
=
args
.
get
<
unsigned
int
>
(
"perf_force_samples"
);
param_force_samples
=
args
.
get
<
unsigned
int
>
(
"perf_force_samples"
);
param_write_sanity
=
args
.
has
(
"perf_write_sanity"
);
param_write_sanity
=
args
.
has
(
"perf_write_sanity"
);
param_t
bb_nthreads
=
args
.
get
<
int
>
(
"perf_tbb_n
threads"
);
param_t
hreads
=
args
.
get
<
int
>
(
"perf_
threads"
);
#ifdef ANDROID
#ifdef ANDROID
param_affinity_mask
=
args
.
get
<
int
>
(
"perf_affinity_mask"
);
param_affinity_mask
=
args
.
get
<
int
>
(
"perf_affinity_mask"
);
log_power_checkpoints
=
args
.
has
(
"perf_log_power_checkpoints"
);
log_power_checkpoints
=
args
.
has
(
"perf_log_power_checkpoints"
);
...
@@ -1039,16 +1053,14 @@ void TestBase::SetUp()
...
@@ -1039,16 +1053,14 @@ void TestBase::SetUp()
{
{
cv
::
theRNG
().
state
=
param_seed
;
// this rng should generate same numbers for each run
cv
::
theRNG
().
state
=
param_seed
;
// this rng should generate same numbers for each run
#ifdef HAVE_TBB
if
(
param_threads
>=
0
)
if
(
param_tbb_nthreads
>
0
)
{
cv
::
setNumThreads
(
param_threads
);
p_tbb_initializer
.
release
();
p_tbb_initializer
=
new
tbb
::
task_scheduler_init
(
param_tbb_nthreads
);
}
#endif
#ifdef ANDROID
#ifdef ANDROID
if
(
param_affinity_mask
)
if
(
param_affinity_mask
)
setCurrentThreadAffinityMask
(
param_affinity_mask
);
setCurrentThreadAffinityMask
(
param_affinity_mask
);
#endif
#endif
verified
=
false
;
verified
=
false
;
lastTime
=
0
;
lastTime
=
0
;
totalTime
=
0
;
totalTime
=
0
;
...
@@ -1167,12 +1179,7 @@ TestBase::_declareHelper& TestBase::_declareHelper::time(double timeLimitSecs)
...
@@ -1167,12 +1179,7 @@ TestBase::_declareHelper& TestBase::_declareHelper::time(double timeLimitSecs)
TestBase
::
_declareHelper
&
TestBase
::
_declareHelper
::
tbb_threads
(
int
n
)
TestBase
::
_declareHelper
&
TestBase
::
_declareHelper
::
tbb_threads
(
int
n
)
{
{
#ifdef HAVE_TBB
cv
::
setNumThreads
(
n
);
test
->
p_tbb_initializer
.
release
();
if
(
n
>
0
)
test
->
p_tbb_initializer
=
new
tbb
::
task_scheduler_init
(
n
);
#endif
(
void
)
n
;
return
*
this
;
return
*
this
;
}
}
...
...
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