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
d9ab3149
Commit
d9ab3149
authored
Sep 08, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ocl: profiling queue
parent
6a5298a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
3 deletions
+69
-3
ocl.hpp
modules/core/include/opencv2/core/ocl.hpp
+5
-1
ocl.cpp
modules/core/src/ocl.cpp
+64
-2
No files found.
modules/core/include/opencv2/core/ocl.hpp
View file @
d9ab3149
...
...
@@ -333,8 +333,12 @@ public:
void
*
ptr
()
const
;
static
Queue
&
getDefault
();
/// @brief Returns OpenCL command queue with enable profiling mode support
const
Queue
&
getProfilingQueue
()
const
;
struct
Impl
;
friend
struct
Impl
;
inline
Impl
*
getImpl
()
const
{
return
p
;
}
protected
:
struct
Impl
;
Impl
*
p
;
};
...
...
modules/core/src/ocl.cpp
View file @
d9ab3149
...
...
@@ -1840,9 +1840,35 @@ void initializeContextFromHandle(Context& ctx, void* platform, void* _context, v
struct
Queue
::
Impl
{
Impl
(
const
Context
&
c
,
const
Device
&
d
)
inline
void
__init
(
)
{
refcount
=
1
;
handle
=
0
;
isProfilingQueue_
=
false
;
}
Impl
(
cl_command_queue
q
)
{
__init
();
handle
=
q
;
cl_command_queue_properties
props
=
0
;
cl_int
result
=
clGetCommandQueueInfo
(
handle
,
CL_QUEUE_PROPERTIES
,
sizeof
(
cl_command_queue_properties
),
&
props
,
NULL
);
CV_Assert
(
result
&&
"clGetCommandQueueInfo(CL_QUEUE_PROPERTIES)"
);
isProfilingQueue_
=
!!
(
props
&
CL_QUEUE_PROFILING_ENABLE
);
}
Impl
(
cl_command_queue
q
,
bool
isProfilingQueue
)
{
__init
();
handle
=
q
;
isProfilingQueue_
=
isProfilingQueue
;
}
Impl
(
const
Context
&
c
,
const
Device
&
d
,
bool
withProfiling
=
false
)
{
__init
();
const
Context
*
pc
=
&
c
;
cl_context
ch
=
(
cl_context
)
pc
->
ptr
();
if
(
!
ch
)
...
...
@@ -1854,8 +1880,10 @@ struct Queue::Impl
if
(
!
dh
)
dh
=
(
cl_device_id
)
pc
->
device
(
0
).
ptr
();
cl_int
retval
=
0
;
handle
=
clCreateCommandQueue
(
ch
,
dh
,
0
,
&
retval
);
cl_command_queue_properties
props
=
withProfiling
?
CL_QUEUE_PROFILING_ENABLE
:
0
;
handle
=
clCreateCommandQueue
(
ch
,
dh
,
props
,
&
retval
);
CV_OclDbgAssert
(
retval
==
CL_SUCCESS
);
isProfilingQueue_
=
withProfiling
;
}
~
Impl
()
...
...
@@ -1873,9 +1901,37 @@ struct Queue::Impl
}
}
const
cv
::
ocl
::
Queue
&
getProfilingQueue
(
const
cv
::
ocl
::
Queue
&
self
)
{
if
(
isProfilingQueue_
)
return
self
;
if
(
profiling_queue_
.
ptr
())
return
profiling_queue_
;
cl_context
ctx
=
0
;
CV_Assert
(
CL_SUCCESS
==
clGetCommandQueueInfo
(
handle
,
CL_QUEUE_CONTEXT
,
sizeof
(
cl_context
),
&
ctx
,
NULL
));
cl_device_id
device
=
0
;
CV_Assert
(
CL_SUCCESS
==
clGetCommandQueueInfo
(
handle
,
CL_QUEUE_DEVICE
,
sizeof
(
cl_device_id
),
&
device
,
NULL
));
cl_int
result
=
CL_SUCCESS
;
cl_command_queue_properties
props
=
CL_QUEUE_PROFILING_ENABLE
;
cl_command_queue
q
=
clCreateCommandQueue
(
ctx
,
device
,
props
,
&
result
);
CV_Assert
(
result
==
CL_SUCCESS
&&
"clCreateCommandQueue(with CL_QUEUE_PROFILING_ENABLE)"
);
Queue
queue
;
queue
.
p
=
new
Impl
(
q
,
true
);
profiling_queue_
=
queue
;
return
profiling_queue_
;
}
IMPLEMENT_REFCOUNTABLE
();
cl_command_queue
handle
;
bool
isProfilingQueue_
;
cv
::
ocl
::
Queue
profiling_queue_
;
};
Queue
::
Queue
()
...
...
@@ -1929,6 +1985,12 @@ void Queue::finish()
}
}
const
Queue
&
Queue
::
getProfilingQueue
()
const
{
CV_Assert
(
p
);
return
p
->
getProfilingQueue
(
*
this
);
}
void
*
Queue
::
ptr
()
const
{
return
p
?
p
->
handle
:
0
;
...
...
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