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
ddca4704
Commit
ddca4704
authored
Aug 16, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated gpu accuracy tests
added posibility to specify device on which tests will be executed
parent
cfdeb503
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
212 additions
and
70 deletions
+212
-70
main.cpp
modules/gpu/test/main.cpp
+62
-31
precomp.hpp
modules/gpu/test/precomp.hpp
+1
-0
utility.cpp
modules/gpu/test/utility.cpp
+134
-33
utility.hpp
modules/gpu/test/utility.hpp
+15
-6
No files found.
modules/gpu/test/main.cpp
View file @
ddca4704
...
...
@@ -49,35 +49,39 @@ using namespace cv::gpu;
using
namespace
cvtest
;
using
namespace
testing
;
void
print
_i
nfo
()
void
print
I
nfo
()
{
printf
(
"
\n
"
);
#if defined _WIN32
# if defined _WIN64
puts
(
"OS: Windows 64"
);
puts
(
"OS: Windows
x
64"
);
# else
puts
(
"OS: Windows 32"
);
puts
(
"OS: Windows
x
32"
);
# endif
#elif defined linux
# if defined _LP64
puts
(
"OS: Linux 64"
);
puts
(
"OS: Linux
x
64"
);
# else
puts
(
"OS: Linux 32"
);
puts
(
"OS: Linux
x
32"
);
# endif
#elif defined __APPLE__
# if defined _LP64
puts
(
"OS: Apple 64"
);
puts
(
"OS: Apple
x
64"
);
# else
puts
(
"OS: Apple 32"
);
puts
(
"OS: Apple
x
32"
);
# endif
#endif
int
deviceCount
=
getCudaEnabledDeviceCount
();
int
driver
;
cudaDriverGetVersion
(
&
driver
);
printf
(
"CUDA Driver version: %d
\n
"
,
driver
);
printf
(
"CUDA Runtime version: %d
\n
"
,
CUDART_VERSION
);
puts
(
"GPU module was compiled for the following GPU archs:"
);
printf
(
" BIN: %s
\n
"
,
CUDA_ARCH_BIN
);
printf
(
" PTX: %s
\n\n
"
,
CUDA_ARCH_PTX
);
int
deviceCount
=
getCudaEnabledDeviceCount
();
printf
(
"CUDA device count: %d
\n\n
"
,
deviceCount
);
for
(
int
i
=
0
;
i
<
deviceCount
;
++
i
)
...
...
@@ -87,17 +91,13 @@ void print_info()
printf
(
"Device %d:
\n
"
,
i
);
printf
(
" Name: %s
\n
"
,
info
.
name
().
c_str
());
printf
(
" Compute capability version: %d.%d
\n
"
,
info
.
majorVersion
(),
info
.
minorVersion
());
printf
(
" Multi Processor Count: %d
\n
"
,
info
.
multiProcessorCount
());
printf
(
" Total memory: %d Mb
\n
"
,
static_cast
<
int
>
(
static_cast
<
int
>
(
info
.
totalMemory
()
/
1024.0
)
/
1024.0
));
printf
(
" Free memory: %d Mb
\n
"
,
static_cast
<
int
>
(
static_cast
<
int
>
(
info
.
freeMemory
()
/
1024.0
)
/
1024.0
));
if
(
info
.
isCompatible
())
puts
(
" This device is compatible with current GPU module build
\n
"
);
else
puts
(
" This device is NOT compatible with current GPU module build
\n
"
);
if
(
!
info
.
isCompatible
())
puts
(
" !!! This device is NOT compatible with current GPU module build
\n
"
);
printf
(
"
\n
"
);
}
puts
(
"GPU module was compiled for the following GPU archs:"
);
printf
(
" BIN: %s
\n
"
,
CUDA_ARCH_BIN
);
printf
(
" PTX: %s
\n\n
"
,
CUDA_ARCH_PTX
);
}
enum
OutputLevel
...
...
@@ -111,25 +111,56 @@ extern OutputLevel nvidiaTestOutputLevel;
int
main
(
int
argc
,
char
**
argv
)
{
TS
::
ptr
()
->
init
(
"gpu"
);
InitGoogleTest
(
&
argc
,
argv
);
const
char
*
keys
=
"{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"
;
try
{
CommandLineParser
parser
(
argc
,
(
const
char
**
)
argv
,
"{ print_info_only | print_info_only | false | Print information about system and exit }"
"{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }"
"{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"
);
printInfo
();
if
(
parser
.
get
<
bool
>
(
"print_info_only"
))
return
0
;
int
device
=
parser
.
get
<
int
>
(
"device"
);
if
(
device
<
0
)
{
DeviceManager
::
instance
().
loadAll
();
std
::
cout
<<
"Run tests on all supported devices
\n
"
<<
std
::
endl
;
}
else
{
DeviceManager
::
instance
().
load
(
device
);
std
::
cout
<<
"Run tests on device "
<<
device
<<
'\n'
<<
std
::
endl
;
}
CommandLineParser
parser
(
argc
,
(
const
char
**
)
argv
,
keys
);
string
outputLevel
=
parser
.
get
<
string
>
(
"nvtest_output_level"
);
string
outputLevel
=
parser
.
get
<
string
>
(
"nvtest_output_level"
,
"none"
);
if
(
outputLevel
==
"none"
)
nvidiaTestOutputLevel
=
OutputLevelNone
;
else
if
(
outputLevel
==
"compact"
)
nvidiaTestOutputLevel
=
OutputLevelCompact
;
else
if
(
outputLevel
==
"full"
)
nvidiaTestOutputLevel
=
OutputLevelFull
;
if
(
outputLevel
==
"none"
)
nvidiaTestOutputLevel
=
OutputLevelNone
;
else
if
(
outputLevel
==
"compact"
)
nvidiaTestOutputLevel
=
OutputLevelCompact
;
else
if
(
outputLevel
==
"full"
)
nvidiaTestOutputLevel
=
OutputLevelFull
;
TS
::
ptr
()
->
init
(
"gpu"
);
InitGoogleTest
(
&
argc
,
argv
);
print_info
();
return
RUN_ALL_TESTS
();
}
catch
(
const
exception
&
e
)
{
cerr
<<
e
.
what
()
<<
endl
;
return
-
1
;
}
catch
(...)
{
cerr
<<
"Unknown error"
<<
endl
;
return
-
1
;
}
return
RUN_ALL_TESTS
()
;
return
0
;
}
#else // HAVE_CUDA
...
...
modules/gpu/test/precomp.hpp
View file @
ddca4704
...
...
@@ -56,6 +56,7 @@
#include <limits>
#include <algorithm>
#include <iterator>
#include <stdexcept>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
...
...
modules/gpu/test/utility.cpp
View file @
ddca4704
...
...
@@ -46,6 +46,7 @@ using namespace cv;
using
namespace
cv
::
gpu
;
using
namespace
cvtest
;
using
namespace
testing
;
using
namespace
testing
::
internal
;
//////////////////////////////////////////////////////////////////////
// random generators
...
...
@@ -108,12 +109,12 @@ GpuMat loadMat(const Mat& m, bool useRoi)
//////////////////////////////////////////////////////////////////////
// Image load
Mat
readImage
(
const
string
&
fileName
,
int
flags
)
Mat
readImage
(
const
st
d
::
st
ring
&
fileName
,
int
flags
)
{
return
imread
(
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
)
+
fileName
,
flags
);
return
imread
(
TS
::
ptr
()
->
get_data_path
(
)
+
fileName
,
flags
);
}
Mat
readImageType
(
const
string
&
fname
,
int
type
)
Mat
readImageType
(
const
st
d
::
st
ring
&
fname
,
int
type
)
{
Mat
src
=
readImage
(
fname
,
CV_MAT_CN
(
type
)
==
1
?
IMREAD_GRAYSCALE
:
IMREAD_COLOR
);
if
(
CV_MAT_CN
(
type
)
==
4
)
...
...
@@ -134,50 +135,150 @@ bool supportFeature(const DeviceInfo& info, FeatureSet feature)
return
TargetArchs
::
builtWith
(
feature
)
&&
info
.
supports
(
feature
);
}
const
vector
<
DeviceInfo
>&
devices
()
DeviceManager
&
DeviceManager
::
instance
()
{
static
vector
<
DeviceInfo
>
devs
;
static
bool
first
=
true
;
static
DeviceManager
obj
;
return
obj
;
}
if
(
first
)
{
int
deviceCount
=
getCudaEnabledDeviceCount
();
void
DeviceManager
::
load
(
int
i
)
{
devices_
.
clear
();
devices_
.
reserve
(
1
);
devs
.
reserve
(
deviceCount
)
;
ostringstream
msg
;
for
(
int
i
=
0
;
i
<
deviceCount
;
++
i
)
{
DeviceInfo
info
(
i
);
if
(
info
.
isCompatible
())
devs
.
push_back
(
info
);
}
if
(
i
<
0
||
i
>=
getCudaEnabledDeviceCount
())
{
msg
<<
"Incorrect device number - "
<<
i
;
throw
runtime_error
(
msg
.
str
());
}
DeviceInfo
info
(
i
);
first
=
false
;
if
(
!
info
.
isCompatible
())
{
msg
<<
"Device "
<<
i
<<
" ["
<<
info
.
name
()
<<
"] is NOT compatible with current GPU module build"
;
throw
runtime_error
(
msg
.
str
());
}
return
devs
;
devices_
.
push_back
(
info
)
;
}
v
ector
<
DeviceInfo
>
devices
(
FeatureSet
feature
)
v
oid
DeviceManager
::
loadAll
(
)
{
const
vector
<
DeviceInfo
>&
d
=
devices
();
int
deviceCount
=
getCudaEnabledDeviceCount
();
vector
<
DeviceInfo
>
devs_filtered
;
devices_
.
clear
();
devices_
.
reserve
(
deviceCount
);
if
(
TargetArchs
::
builtWith
(
feature
)
)
for
(
int
i
=
0
;
i
<
deviceCount
;
++
i
)
{
devs_filtered
.
reserve
(
d
.
size
());
for
(
size_t
i
=
0
,
size
=
d
.
size
();
i
<
size
;
++
i
)
DeviceInfo
info
(
i
);
if
(
info
.
isCompatible
())
{
const
DeviceInfo
&
info
=
d
[
i
];
if
(
info
.
supports
(
feature
))
devs_filtered
.
push_back
(
info
);
devices_
.
push_back
(
info
);
}
}
}
return
devs_filtered
;
class
DevicesGenerator
:
public
ParamGeneratorInterface
<
DeviceInfo
>
{
public
:
~
DevicesGenerator
();
ParamIteratorInterface
<
DeviceInfo
>*
Begin
()
const
;
ParamIteratorInterface
<
DeviceInfo
>*
End
()
const
;
private
:
class
Iterator
:
public
ParamIteratorInterface
<
DeviceInfo
>
{
public
:
Iterator
(
const
ParamGeneratorInterface
<
DeviceInfo
>*
base
,
vector
<
DeviceInfo
>::
const_iterator
iterator
);
virtual
~
Iterator
();
virtual
const
ParamGeneratorInterface
<
DeviceInfo
>*
BaseGenerator
()
const
;
virtual
void
Advance
();
virtual
ParamIteratorInterface
<
DeviceInfo
>*
Clone
()
const
;
virtual
const
DeviceInfo
*
Current
()
const
;
virtual
bool
Equals
(
const
ParamIteratorInterface
<
DeviceInfo
>&
other
)
const
;
private
:
Iterator
(
const
Iterator
&
other
);
const
ParamGeneratorInterface
<
DeviceInfo
>*
const
base_
;
vector
<
DeviceInfo
>::
const_iterator
iterator_
;
mutable
DeviceInfo
value_
;
};
};
DevicesGenerator
::~
DevicesGenerator
()
{
}
ParamIteratorInterface
<
DeviceInfo
>*
DevicesGenerator
::
Begin
()
const
{
return
new
Iterator
(
this
,
DeviceManager
::
instance
().
values
().
begin
());
}
ParamIteratorInterface
<
DeviceInfo
>*
DevicesGenerator
::
End
()
const
{
return
new
Iterator
(
this
,
DeviceManager
::
instance
().
values
().
end
());
}
DevicesGenerator
::
Iterator
::
Iterator
(
const
ParamGeneratorInterface
<
DeviceInfo
>*
base
,
vector
<
DeviceInfo
>::
const_iterator
iterator
)
:
base_
(
base
),
iterator_
(
iterator
)
{
}
DevicesGenerator
::
Iterator
::~
Iterator
()
{
}
const
ParamGeneratorInterface
<
DeviceInfo
>*
DevicesGenerator
::
Iterator
::
BaseGenerator
()
const
{
return
base_
;
}
void
DevicesGenerator
::
Iterator
::
Advance
()
{
++
iterator_
;
}
ParamIteratorInterface
<
DeviceInfo
>*
DevicesGenerator
::
Iterator
::
Clone
()
const
{
return
new
Iterator
(
*
this
);
}
const
DeviceInfo
*
DevicesGenerator
::
Iterator
::
Current
()
const
{
value_
=
*
iterator_
;
return
&
value_
;
}
bool
DevicesGenerator
::
Iterator
::
Equals
(
const
ParamIteratorInterface
<
DeviceInfo
>&
other
)
const
{
GTEST_CHECK_
(
BaseGenerator
()
==
other
.
BaseGenerator
())
<<
"The program attempted to compare iterators "
<<
"from different generators."
<<
endl
;
return
iterator_
==
CheckedDowncastToActualType
<
const
Iterator
>
(
&
other
)
->
iterator_
;
}
DevicesGenerator
::
Iterator
::
Iterator
(
const
Iterator
&
other
)
:
ParamIteratorInterface
<
DeviceInfo
>
(),
base_
(
other
.
base_
),
iterator_
(
other
.
iterator_
)
{
}
ParamGenerator
<
DeviceInfo
>
DevicesGenerator_
()
{
return
ParamGenerator
<
DeviceInfo
>
(
new
DevicesGenerator
);
}
//////////////////////////////////////////////////////////////////////
...
...
@@ -250,7 +351,7 @@ void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minL
namespace
{
template
<
typename
T
,
typename
OutT
>
string
printMatValImpl
(
const
Mat
&
m
,
Point
p
)
template
<
typename
T
,
typename
OutT
>
st
d
::
st
ring
printMatValImpl
(
const
Mat
&
m
,
Point
p
)
{
const
int
cn
=
m
.
channels
();
...
...
@@ -269,9 +370,9 @@ namespace
return
ostr
.
str
();
}
string
printMatVal
(
const
Mat
&
m
,
Point
p
)
st
d
::
st
ring
printMatVal
(
const
Mat
&
m
,
Point
p
)
{
typedef
string
(
*
func_t
)(
const
Mat
&
m
,
Point
p
);
typedef
st
d
::
st
ring
(
*
func_t
)(
const
Mat
&
m
,
Point
p
);
static
const
func_t
funcs
[]
=
{
...
...
modules/gpu/test/utility.hpp
View file @
ddca4704
...
...
@@ -80,14 +80,23 @@ cv::Mat readImageType(const std::string& fname, int type);
//! return true if device supports specified feature and gpu module was built with support the feature.
bool
supportFeature
(
const
cv
::
gpu
::
DeviceInfo
&
info
,
cv
::
gpu
::
FeatureSet
feature
);
//! return all devices compatible with current gpu module build.
const
std
::
vector
<
cv
::
gpu
::
DeviceInfo
>&
devices
();
class
DeviceManager
{
public
:
static
DeviceManager
&
instance
();
void
load
(
int
i
);
void
loadAll
();
const
std
::
vector
<
cv
::
gpu
::
DeviceInfo
>&
values
()
const
{
return
devices_
;
}
private
:
std
::
vector
<
cv
::
gpu
::
DeviceInfo
>
devices_
;
};
//! return all devices compatible with current gpu module build which support specified feature.
std
::
vector
<
cv
::
gpu
::
DeviceInfo
>
devices
(
cv
::
gpu
::
FeatureSet
feature
);
testing
::
internal
::
ParamGenerator
<
cv
::
gpu
::
DeviceInfo
>
DevicesGenerator_
();
#define ALL_DEVICES testing::ValuesIn(devices())
#define DEVICES(feature) testing::ValuesIn(devices(feature))
#define ALL_DEVICES DevicesGenerator_()
//////////////////////////////////////////////////////////////////////
// Additional assertion
...
...
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