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
ab8f578f
Commit
ab8f578f
authored
Jan 25, 2011
by
Alexey Spizhevoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added error handling into GPU perf. tests
parent
6f91a29e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
9 deletions
+42
-9
performance.cpp
samples/gpu/performance/performance.cpp
+30
-8
performance.h
samples/gpu/performance/performance.h
+11
-0
tests.cpp
samples/gpu/performance/tests.cpp
+1
-1
No files found.
samples/gpu/performance/performance.cpp
View file @
ab8f578f
...
...
@@ -12,7 +12,7 @@ void TestSystem::run()
(
*
it
)
->
run
();
cout
<<
setiosflags
(
ios_base
::
left
);
cout
<<
" "
<<
setw
(
10
)
<<
"CPU, ms"
<<
setw
(
10
)
<<
"GPU, ms"
cout
<<
TAB
<<
setw
(
10
)
<<
"CPU, ms"
<<
setw
(
10
)
<<
"GPU, ms"
<<
setw
(
10
)
<<
"SPEEDUP"
<<
"DESCRIPTION
\n
"
;
cout
<<
resetiosflags
(
ios_base
::
left
);
...
...
@@ -21,8 +21,23 @@ void TestSystem::run()
for
(;
it
!=
tests_
.
end
();
++
it
)
{
cout
<<
endl
<<
(
*
it
)
->
name
()
<<
":
\n
"
;
(
*
it
)
->
run
();
flush_subtest_data
();
try
{
(
*
it
)
->
run
();
flush_subtest_data
();
}
catch
(
const
cv
::
Exception
&
e
)
{
cout
<<
TAB
<<
"error"
;
switch
(
e
.
code
)
{
case
CV_StsNoMem
:
cout
<<
": out of memory"
;
break
;
}
if
(
!
description_
.
str
().
empty
())
cout
<<
" ["
<<
description_
.
str
()
<<
"]"
;
cout
<<
endl
;
reset_subtest_data
();
}
}
cout
<<
setiosflags
(
ios_base
::
fixed
|
ios_base
::
left
);
...
...
@@ -39,13 +54,11 @@ void TestSystem::flush_subtest_data()
int
cpu_time
=
static_cast
<
int
>
(
cpu_elapsed_
/
getTickFrequency
()
*
1000.0
);
int
gpu_time
=
static_cast
<
int
>
(
gpu_elapsed_
/
getTickFrequency
()
*
1000.0
);
cpu_elapsed_
=
0
;
gpu_elapsed_
=
0
;
double
speedup
=
static_cast
<
double
>
(
cpu_time
)
/
std
::
max
(
1
,
gpu_time
);
speedup_total_
+=
speedup
;
cout
<<
" "
<<
setiosflags
(
ios_base
::
fixed
|
ios_base
::
left
);
cout
<<
TAB
<<
setiosflags
(
ios_base
::
fixed
|
ios_base
::
left
);
stringstream
stream
;
stream
<<
cpu_time
;
...
...
@@ -60,12 +73,11 @@ void TestSystem::flush_subtest_data()
cout
<<
setw
(
10
)
<<
stream
.
str
();
cout
<<
description_
.
str
();
description_
.
str
(
""
);
cout
<<
resetiosflags
(
ios_base
::
fixed
|
ios_base
::
left
)
<<
endl
;
can_flush_
=
false
;
num_subtests_called_
++
;
reset_subtest_data
();
}
...
...
@@ -77,8 +89,17 @@ void gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high)
}
int
CV_CDECL
cvErrorCallback
(
int
/*status*/
,
const
char
*
/*func_name*/
,
const
char
*
/*err_msg*/
,
const
char
*
/*file_name*/
,
int
/*line*/
,
void
*
/*userdata*/
)
{
return
0
;
}
int
main
()
{
redirectError
(
cvErrorCallback
);
TestSystem
::
instance
()
->
run
();
return
0
;
}
\ No newline at end of file
samples/gpu/performance/performance.h
View file @
ab8f578f
...
...
@@ -7,6 +7,8 @@
#include <string>
#include <opencv2/core/core.hpp>
#define TAB " "
class
Runnable
{
public
:
...
...
@@ -31,6 +33,7 @@ public:
}
void
addInit
(
Runnable
*
init
)
{
inits_
.
push_back
(
init
);
}
void
addTest
(
Runnable
*
test
)
{
tests_
.
push_back
(
test
);
}
void
run
();
...
...
@@ -66,6 +69,14 @@ private:
void
flush_subtest_data
();
void
reset_subtest_data
()
{
cpu_elapsed_
=
0
;
gpu_elapsed_
=
0
;
description_
.
str
(
""
);
can_flush_
=
false
;
}
std
::
vector
<
Runnable
*>
inits_
;
std
::
vector
<
Runnable
*>
tests_
;
...
...
samples/gpu/performance/tests.cpp
View file @
ab8f578f
...
...
@@ -107,7 +107,7 @@ TEST(dft)
Mat
src
,
dst
;
gpu
::
GpuMat
d_src
,
d_dst
;
for
(
int
size
=
1000
;
size
<=
4
000
;
size
*=
2
)
for
(
int
size
=
1000
;
size
<=
8
000
;
size
*=
2
)
{
SUBTEST
<<
"size "
<<
size
<<
", 32FC2, complex-to-complex"
;
...
...
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