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
0c19a07b
Commit
0c19a07b
authored
Mar 26, 2013
by
peng xiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a function to query ocl device info
Currently the function only supports wavefront size query
parent
f7b40cdc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
util.hpp
modules/ocl/include/opencv2/ocl/private/util.hpp
+10
-0
initialization.cpp
modules/ocl/src/initialization.cpp
+40
-0
No files found.
modules/ocl/include/opencv2/ocl/private/util.hpp
View file @
0c19a07b
...
...
@@ -123,6 +123,16 @@ namespace cv
// returns whether the current context supports image2d_t format or not
bool
CV_EXPORTS
support_image2d
(
Context
*
clCxt
=
Context
::
getContext
());
// the enums are used to query device information
// currently only support wavefront size queries
enum
DEVICE_INFO
{
WAVEFRONT_SIZE
,
//in AMD speak
WARP_SIZE
=
WAVEFRONT_SIZE
//in nvidia speak
};
//info should have been pre-allocated
void
CV_EXPORTS
queryDeviceInfo
(
DEVICE_INFO
info_type
,
void
*
info
);
}
//namespace ocl
}
//namespace cv
...
...
modules/ocl/src/initialization.cpp
View file @
0c19a07b
...
...
@@ -353,6 +353,46 @@ namespace cv
{
return
&
(
Context
::
getContext
()
->
impl
->
clCmdQueue
);
}
void
queryDeviceInfo
(
DEVICE_INFO
info_type
,
void
*
info
)
{
static
Info
::
Impl
*
impl
=
Context
::
getContext
()
->
impl
;
switch
(
info_type
)
{
case
WAVEFRONT_SIZE
:
{
#ifndef CL_DEVICE_WAVEFRONT_WIDTH_AMD
openCLSafeCall
(
clGetDeviceInfo
(
Context
::
getContext
()
->
impl
->
devices
[
0
],
CL_DEVICE_WAVEFRONT_WIDTH_AMD
,
sizeof
(
size_t
),
info
,
0
));
#else
const
int
EXT_LEN
=
4096
+
1
;
char
extends_set
[
EXT_LEN
];
size_t
extends_size
;
openCLSafeCall
(
clGetDeviceInfo
(
impl
->
devices
[
impl
->
devnum
],
CL_DEVICE_EXTENSIONS
,
EXT_LEN
,
(
void
*
)
extends_set
,
&
extends_size
));
extends_set
[
EXT_LEN
-
1
]
=
0
;
if
(
std
::
string
(
extends_set
).
find
(
"cl_nv_device_attribute_query"
)
!=
std
::
string
::
npos
)
{
openCLSafeCall
(
clGetDeviceInfo
(
Context
::
getContext
()
->
impl
->
devices
[
0
],
CL_DEVICE_WARP_SIZE_NV
,
sizeof
(
size_t
),
info
,
0
));
}
else
{
// if no way left for us to query the warp size, we can get it from kernel group info
static
const
char
*
_kernel_string
=
"__kernel void test_func() {}"
;
cl_kernel
kernel
;
kernel
=
openCLGetKernelFromSource
(
Context
::
getContext
(),
&
_kernel_string
,
"test_func"
);
openCLSafeCall
(
clGetKernelWorkGroupInfo
(
kernel
,
impl
->
devices
[
impl
->
devnum
],
CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE
,
sizeof
(
size_t
),
info
,
NULL
));
}
#endif
}
break
;
default
:
CV_Error
(
-
1
,
"Invalid device info type"
);
break
;
}
}
void
openCLReadBuffer
(
Context
*
clCxt
,
cl_mem
dst_buffer
,
void
*
host_buffer
,
size_t
size
)
{
cl_int
status
;
...
...
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