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
9b1b281c
Commit
9b1b281c
authored
Oct 18, 2017
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9881 from alalek:ocl_timer_simplify
parents
c63b4433
185faf99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
52 deletions
+24
-52
ocl.hpp
modules/core/include/opencv2/core/ocl.hpp
+7
-4
ocl.cpp
modules/core/src/ocl.cpp
+14
-45
ocl4dnn_conv_spatial.cpp
modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp
+3
-3
No files found.
modules/core/include/opencv2/core/ocl.hpp
View file @
9b1b281c
...
...
@@ -742,13 +742,16 @@ public:
~
Timer
();
void
start
();
void
stop
();
float
milliSeconds
();
float
microSeconds
();
float
seconds
();
uint64
durationNS
()
const
;
//< duration in nanoseconds
protected
:
struct
Impl
;
Impl
*
p
;
Impl
*
const
p
;
private
:
Timer
(
const
Timer
&
);
// disabled
Timer
&
operator
=
(
const
Timer
&
);
// disabled
};
CV_EXPORTS
MatAllocator
*
getOpenCLAllocator
();
...
...
modules/core/src/ocl.cpp
View file @
9b1b281c
...
...
@@ -5288,68 +5288,37 @@ struct Timer::Impl
#endif
}
float
microSeconds
()
uint64
durationNS
()
const
{
#ifdef HAVE_OPENCL
return
(
float
)
timer
.
getTimeMicro
(
);
return
(
uint64
)(
timer
.
getTimeSec
()
*
1e9
);
#else
return
0
;
#endif
}
float
milliSeconds
()
{
#ifdef HAVE_OPENCL
return
(
float
)
timer
.
getTimeMilli
();
#else
return
0
;
#endif
}
float
seconds
()
{
#ifdef HAVE_OPENCL
return
(
float
)
timer
.
getTimeSec
();
#else
return
0
;
#endif
}
TickMeter
timer
;
};
Timer
::
Timer
(
const
Queue
&
q
)
{
p
=
new
Impl
(
q
);
}
Timer
::~
Timer
()
{
if
(
p
)
{
delete
p
;
p
=
0
;
}
}
Timer
::
Timer
(
const
Queue
&
q
)
:
p
(
new
Impl
(
q
))
{
}
Timer
::~
Timer
()
{
delete
p
;
}
void
Timer
::
start
()
{
if
(
p
)
p
->
start
();
CV_Assert
(
p
);
p
->
start
();
}
void
Timer
::
stop
()
{
if
(
p
)
p
->
stop
();
CV_Assert
(
p
);
p
->
stop
();
}
float
Timer
::
microSeconds
()
{
return
p
?
p
->
microSeconds
()
:
0
;
}
float
Timer
::
milliSeconds
()
{
return
p
?
p
->
milliSeconds
()
:
0
;
}
float
Timer
::
seconds
()
{
return
p
?
p
->
seconds
()
:
0
;
}
uint64
Timer
::
durationNS
()
const
{
CV_Assert
(
p
);
return
p
->
durationNS
();
}
}}
}}
// namespace
modules/dnn/src/ocl4dnn/src/ocl4dnn_conv_spatial.cpp
View file @
9b1b281c
...
...
@@ -890,7 +890,7 @@ float OCL4DNNConvSpatial<float>::timedConvolve(const UMat &bottom, UMat &top,
return
1e5
;
}
float
elapsedTime
=
timer
.
milliSeconds
()
/
loop_cnt
;
float
elapsedTime
=
timer
.
durationNS
()
*
1e-6
/
loop_cnt
;
#ifdef dbg
double
out_w
=
output_w_
;
double
out_h
=
output_h_
;
...
...
@@ -899,9 +899,9 @@ float OCL4DNNConvSpatial<float>::timedConvolve(const UMat &bottom, UMat &top,
double
k_h
=
kernel_h_
;
double
k_z
=
channels_
;
double
totalFlops
=
((
k_w
*
k_h
*
k_z
-
1
)
*
2
)
*
(
out_w
*
out_h
*
out_z
)
*
num_
;
std
::
cout
<<
"
\t
Estimated Gflops:"
<<
(
(
totalFlops
/
1000
)
/
1000
)
/
1000
std
::
cout
<<
"
\t
Estimated Gflops:"
<<
(
totalFlops
*
1e-9
)
<<
std
::
endl
;
std
::
cout
<<
"
\t
Estimated GFLOPS/S: "
<<
((
(
totalFlops
/
1000
)
/
1000
)
/
1000
)
*
(
1000.0
/
elapsedTime
)
std
::
cout
<<
"
\t
Estimated GFLOPS/S: "
<<
((
totalFlops
*
1e-9
)
*
(
1000.0
/
elapsedTime
)
)
<<
std
::
endl
;
#if 0
std::cout << "Estimated utilization: " <<
...
...
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