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
b28acfc1
Commit
b28acfc1
authored
Oct 10, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add GPU module specific command line arguments
parent
f88be98e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
88 deletions
+114
-88
perf_main.cpp
modules/gpu/perf/perf_main.cpp
+73
-2
utility.cpp
modules/gpu/perf/utility.cpp
+2
-66
utility.hpp
modules/gpu/perf/utility.hpp
+4
-9
ts_perf.hpp
modules/ts/include/opencv2/ts/ts_perf.hpp
+3
-3
ts_perf.cpp
modules/ts/src/ts_perf.cpp
+32
-8
No files found.
modules/gpu/perf/perf_main.cpp
View file @
b28acfc1
#include "perf_precomp.hpp"
#include "perf_precomp.hpp"
CV_PERF_TEST_MAIN
(
gpu
)
namespace
{
\ No newline at end of file
static
void
printOsInfo
()
{
#if defined _WIN32
# if defined _WIN64
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run on OS Windows x64.
\n
[----------]
\n
"
),
fflush
(
stdout
);
# else
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run on OS Windows x32.
\n
[----------]
\n
"
),
fflush
(
stdout
);
# endif
#elif defined linux
# if defined _LP64
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run on OS Linux x64.
\n
[----------]
\n
"
),
fflush
(
stdout
);
# else
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run on OS Linux x32.
\n
[----------]
\n
"
),
fflush
(
stdout
);
# endif
#elif defined __APPLE__
# if defined _LP64
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run on OS Apple x64.
\n
[----------]
\n
"
),
fflush
(
stdout
);
# else
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run on OS Apple x32.
\n
[----------]
\n
"
),
fflush
(
stdout
);
# endif
#endif
}
static
void
printCudaInfo
()
{
printOsInfo
();
#ifndef HAVE_CUDA
printf
(
"[----------]
\n
[ GPU INFO ]
\t
OpenCV was built without CUDA support.
\n
[----------]
\n
"
),
fflush
(
stdout
);
#else
int
driver
;
cudaDriverGetVersion
(
&
driver
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
printf
(
"[ GPU INFO ]
\t
CUDA Driver version: %d.
\n
"
,
driver
),
fflush
(
stdout
);
printf
(
"[ GPU INFO ]
\t
CUDA Runtime version: %d.
\n
"
,
CUDART_VERSION
),
fflush
(
stdout
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
printf
(
"[ GPU INFO ]
\t
GPU module was compiled for the following GPU archs.
\n
"
),
fflush
(
stdout
);
printf
(
"[ BIN ]
\t
%s.
\n
"
,
CUDA_ARCH_BIN
),
fflush
(
stdout
);
printf
(
"[ PTX ]
\t
%s.
\n
"
,
CUDA_ARCH_PTX
),
fflush
(
stdout
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
int
deviceCount
=
cv
::
gpu
::
getCudaEnabledDeviceCount
();
printf
(
"[ GPU INFO ]
\t
CUDA device count:: %d.
\n
"
,
deviceCount
),
fflush
(
stdout
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
for
(
int
i
=
0
;
i
<
deviceCount
;
++
i
)
{
cv
::
gpu
::
DeviceInfo
info
(
i
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
printf
(
"[ DEVICE ]
\t
# %d %s.
\n
"
,
i
,
info
.
name
().
c_str
()),
fflush
(
stdout
);
printf
(
"[ ]
\t
Compute capability: %d.%d
\n
"
,
(
int
)
info
.
majorVersion
(),
(
int
)
info
.
minorVersion
()),
fflush
(
stdout
);
printf
(
"[ ]
\t
Multi Processor Count: %d
\n
"
,
info
.
multiProcessorCount
()),
fflush
(
stdout
);
printf
(
"[ ]
\t
Total memory: %d Mb
\n
"
,
static_cast
<
int
>
(
static_cast
<
int
>
(
info
.
totalMemory
()
/
1024.0
)
/
1024.0
)),
fflush
(
stdout
);
printf
(
"[ ]
\t
Free memory: %d Mb
\n
"
,
static_cast
<
int
>
(
static_cast
<
int
>
(
info
.
freeMemory
()
/
1024.0
)
/
1024.0
)),
fflush
(
stdout
);
if
(
!
info
.
isCompatible
())
printf
(
"[ GPU INFO ]
\t
This device is NOT compatible with current GPU module build
\n
"
);
printf
(
"[----------]
\n
"
),
fflush
(
stdout
);
}
#endif
}
}
CV_PERF_TEST_MAIN
(
gpu
,
printCudaInfo
())
\ No newline at end of file
modules/gpu/perf/utility.cpp
View file @
b28acfc1
...
@@ -188,69 +188,4 @@ void PrintTo(const CvtColorInfo& info, ostream* os)
...
@@ -188,69 +188,4 @@ void PrintTo(const CvtColorInfo& info, ostream* os)
};
};
*
os
<<
str
[
info
.
code
];
*
os
<<
str
[
info
.
code
];
}
}
\ No newline at end of file
void
ts
::
printOsInfo
()
{
#if defined _WIN32
# if defined _WIN64
cout
<<
"OS: Windows x64
\n
"
<<
endl
;
# else
cout
<<
"OS: Windows x32
\n
"
<<
endl
;
# endif
#elif defined linux
# if defined _LP64
cout
<<
"OS: Linux x64
\n
"
<<
endl
;
# else
cout
<<
"OS: Linux x32
\n
"
<<
endl
;
# endif
#elif defined __APPLE__
# if defined _LP64
cout
<<
"OS: Apple x64
\n
"
<<
endl
;
# else
cout
<<
"OS: Apple x32
\n
"
<<
endl
;
# endif
#endif
}
void
ts
::
printCudaInfo
()
{
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
cout
<<
"OpenCV was built without CUDA support
\n
"
<<
endl
;
#else
int
driver
;
cudaDriverGetVersion
(
&
driver
);
cout
<<
"CUDA Driver version: "
<<
driver
<<
'\n'
;
cout
<<
"CUDA Runtime version: "
<<
CUDART_VERSION
<<
'\n'
;
cout
<<
endl
;
cout
<<
"GPU module was compiled for the following GPU archs:"
<<
endl
;
cout
<<
" BIN: "
<<
CUDA_ARCH_BIN
<<
'\n'
;
cout
<<
" PTX: "
<<
CUDA_ARCH_PTX
<<
'\n'
;
cout
<<
endl
;
int
deviceCount
=
getCudaEnabledDeviceCount
();
cout
<<
"CUDA device count: "
<<
deviceCount
<<
'\n'
;
cout
<<
endl
;
for
(
int
i
=
0
;
i
<
deviceCount
;
++
i
)
{
DeviceInfo
info
(
i
);
cout
<<
"Device ["
<<
i
<<
"]
\n
"
;
cout
<<
"
\t
Name: "
<<
info
.
name
()
<<
'\n'
;
cout
<<
"
\t
Compute capability: "
<<
info
.
majorVersion
()
<<
'.'
<<
info
.
minorVersion
()
<<
'\n'
;
cout
<<
"
\t
Multi Processor Count: "
<<
info
.
multiProcessorCount
()
<<
'\n'
;
cout
<<
"
\t
Total memory: "
<<
static_cast
<
int
>
(
static_cast
<
int
>
(
info
.
totalMemory
()
/
1024.0
)
/
1024.0
)
<<
" Mb
\n
"
;
cout
<<
"
\t
Free memory: "
<<
static_cast
<
int
>
(
static_cast
<
int
>
(
info
.
freeMemory
()
/
1024.0
)
/
1024.0
)
<<
" Mb
\n
"
;
if
(
!
info
.
isCompatible
())
cout
<<
"
\t
!!! This device is NOT compatible with current GPU module build
\n
"
;
cout
<<
endl
;
}
#endif
}
modules/gpu/perf/utility.hpp
View file @
b28acfc1
...
@@ -46,21 +46,16 @@ DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, MatCn);
...
@@ -46,21 +46,16 @@ DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, MatCn);
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::sz720p, perf::szSXGA, perf::sz1080p)
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::sz720p, perf::szSXGA, perf::sz1080p)
namespace
ts
{
void
printOsInfo
();
void
printCudaInfo
();
}
#define GPU_SANITY_CHECK(dmat, ...) \
#define GPU_SANITY_CHECK(dmat, ...) \
do
{
\
do
{
\
cv
::
Mat
d
##
dmat
(
dmat
);
\
cv
::
Mat
d
##
dmat
(
dmat
);
\
SANITY_CHECK
(
d
##
dmat
,
##
__VA_ARGS__
);
\
SANITY_CHECK
(
d
##
dmat
,
##
__VA_ARGS__
);
\
}
while
(
0
)
;
}
while
(
0
)
#define CPU_SANITY_CHECK(cmat, ...) \
#define CPU_SANITY_CHECK(cmat, ...) \
do
{
\
do
{
\
SANITY_CHECK
(
cmat
,
##
__VA_ARGS__
);
\
SANITY_CHECK
(
cmat
,
##
__VA_ARGS__
);
\
}
while
(
0
)
;
}
while
(
0
)
#define GPU_SANITY_CHECK_KEYPOINTS(alg, dmat, ...) \
#define GPU_SANITY_CHECK_KEYPOINTS(alg, dmat, ...) \
do
{
\
do
{
\
...
@@ -75,13 +70,13 @@ namespace ts {
...
@@ -75,13 +70,13 @@ namespace ts {
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"-angle-row"
,
__angle
,
##
__VA_ARGS__
);
\
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"-angle-row"
,
__angle
,
##
__VA_ARGS__
);
\
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"octave-row"
,
__octave
,
##
__VA_ARGS__
);
\
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"octave-row"
,
__octave
,
##
__VA_ARGS__
);
\
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"-pt-size-row"
,
__size
,
##
__VA_ARGS__
);
\
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"-pt-size-row"
,
__size
,
##
__VA_ARGS__
);
\
}
while
(
0
)
;
}
while
(
0
)
#define GPU_SANITY_CHECK_RESPONSE(alg, dmat, ...) \
#define GPU_SANITY_CHECK_RESPONSE(alg, dmat, ...) \
do
{
\
do
{
\
cv
::
Mat
d
##
dmat
(
dmat
);
\
cv
::
Mat
d
##
dmat
(
dmat
);
\
cv
::
Mat
__response
=
d
##
dmat
.
row
(
cv
::
gpu
::
alg
##
_GPU
::
RESPONSE_ROW
);
\
cv
::
Mat
__response
=
d
##
dmat
.
row
(
cv
::
gpu
::
alg
##
_GPU
::
RESPONSE_ROW
);
\
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"-response-row"
,
__response
,
##
__VA_ARGS__
);
\
::
perf
::
Regression
::
add
(
this
,
std
::
string
(
#
dmat
)
+
"-response-row"
,
__response
,
##
__VA_ARGS__
);
\
}
while
(
0
)
;
}
while
(
0
)
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__
modules/ts/include/opencv2/ts/ts_perf.hpp
View file @
b28acfc1
...
@@ -206,7 +206,6 @@ private:
...
@@ -206,7 +206,6 @@ private:
#define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__)
#define SANITY_CHECK_MATCHES(array, ...) ::perf::Regression::addMatches(this, #array, array , ## __VA_ARGS__)
#ifdef HAVE_CUDA
#ifdef HAVE_CUDA
//#error "CUDA"
class
CV_EXPORTS
GpuPerf
class
CV_EXPORTS
GpuPerf
{
{
public
:
public
:
...
@@ -215,7 +214,7 @@ public:
...
@@ -215,7 +214,7 @@ public:
# define PERF_RUN_GPU() ::perf::GpuPerf::targetDevice()
# define PERF_RUN_GPU() ::perf::GpuPerf::targetDevice()
#else
#else
# define PERF_RUN_GPU()
# define PERF_RUN_GPU()
false
#endif
#endif
...
@@ -478,9 +477,10 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
...
@@ -478,9 +477,10 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
void fixture##_##name::PerfTestBody()
void fixture##_##name::PerfTestBody()
#define CV_PERF_TEST_MAIN(testsuitname) \
#define CV_PERF_TEST_MAIN(testsuitname
, ...
) \
int main(int argc, char **argv)\
int main(int argc, char **argv)\
{\
{\
__VA_ARGS__;\
::perf::Regression::Init(#testsuitname);\
::perf::Regression::Init(#testsuitname);\
::perf::TestBase::Init(argc, argv);\
::perf::TestBase::Init(argc, argv);\
::testing::InitGoogleTest(&argc, argv);\
::testing::InitGoogleTest(&argc, argv);\
...
...
modules/ts/src/ts_perf.cpp
View file @
b28acfc1
...
@@ -17,18 +17,20 @@ const std::string command_line_keys =
...
@@ -17,18 +17,20 @@ const std::string command_line_keys =
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_seed |809564 |seed for random numbers generator}"
"{ perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
"{ perf_tbb_nthreads |-1 |if TBB is enabled, the number of TBB threads}"
"{ 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)}"
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
"{ perf_log_power_checkpoints | |additional xml logging for power measurement}"
"{ perf_log_power_checkpoints | |additional xml logging for power measurement}"
#else
#else
"{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
"{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
#endif
#endif
"{ perf_max_deviation |1.0 |}"
"{ perf_max_deviation |1.0 |}"
"{ help h | |print help info}"
"{ help h | |print help info}"
#ifdef HAVE_CUDA
#ifdef HAVE_CUDA
"{ perf_run_cpu |false |run GPU performance tests for analogy CPU functions}"
"{ perf_run_cpu |false |run GPU performance tests for analogical CPU functions}"
#endif
"{ perf_cuda_device |0 |run GPU test suite onto specific CUDA capable device}"
"{ perf_cuda_info_only |false |print an information about system and an available CUDA devices and then exit.}"
#endif
;
;
static
double
param_max_outliers
;
static
double
param_max_outliers
;
...
@@ -41,6 +43,7 @@ static int param_tbb_nthreads;
...
@@ -41,6 +43,7 @@ static int param_tbb_nthreads;
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
;
#endif
#endif
#ifdef ANDROID
#ifdef ANDROID
static
int
param_affinity_mask
;
static
int
param_affinity_mask
;
...
@@ -64,6 +67,10 @@ static void setCurrentThreadAffinityMask(int mask)
...
@@ -64,6 +67,10 @@ static void setCurrentThreadAffinityMask(int mask)
#endif
#endif
#ifdef HAVE_CUDA
# include <opencv2/core/gpumat.hpp>
#endif
static
void
randu
(
cv
::
Mat
&
m
)
static
void
randu
(
cv
::
Mat
&
m
)
{
{
const
int
bigValue
=
0x00000FFF
;
const
int
bigValue
=
0x00000FFF
;
...
@@ -617,12 +624,30 @@ void TestBase::Init(int argc, const char* const argv[])
...
@@ -617,12 +624,30 @@ void TestBase::Init(int argc, const char* const argv[])
#endif
#endif
#ifdef HAVE_CUDA
#ifdef HAVE_CUDA
bool
printOnly
=
args
.
has
(
"perf_cuda_info_only"
);
if
(
printOnly
)
exit
(
0
);
param_run_cpu
=
args
.
has
(
"perf_run_cpu"
);
param_run_cpu
=
args
.
has
(
"perf_run_cpu"
);
param_cuda_device
=
std
::
max
(
0
,
std
::
min
(
cv
::
gpu
::
getCudaEnabledDeviceCount
(),
args
.
get
<
int
>
(
"perf_cuda_device"
)));
if
(
param_run_cpu
)
if
(
param_run_cpu
)
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run test suite on CPU.
\n
[----------]
\n
"
),
fflush
(
stdout
);
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run test suite on CPU.
\n
[----------]
\n
"
),
fflush
(
stdout
);
else
else
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run test suite on GPU.
\n
[----------]
\n
"
),
fflush
(
stdout
);
{
cv
::
gpu
::
DeviceInfo
info
(
param_cuda_device
);
if
(
!
info
.
isCompatible
())
{
printf
(
"[----------]
\n
[ FAILURE ]
\t
Device %s is NOT compatible with current GPU module build.
\n
[----------]
\n
"
,
info
.
name
().
c_str
()),
fflush
(
stdout
);
exit
(
-
1
);
}
cv
::
gpu
::
setDevice
(
param_cuda_device
);
printf
(
"[----------]
\n
[ GPU INFO ]
\t
Run test suite on %s GPU.
\n
[----------]
\n
"
,
info
.
name
().
c_str
()),
fflush
(
stdout
);
}
#endif
#endif
if
(
!
args
.
check
())
if
(
!
args
.
check
())
...
@@ -1212,7 +1237,6 @@ bool perf::GpuPerf::targetDevice()
...
@@ -1212,7 +1237,6 @@ bool perf::GpuPerf::targetDevice()
}
}
#endif
#endif
/*****************************************************************************************\
/*****************************************************************************************\
* ::perf::PrintTo
* ::perf::PrintTo
\*****************************************************************************************/
\*****************************************************************************************/
...
...
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