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
16adbda4
Commit
16adbda4
authored
Sep 30, 2013
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ocl: added OpenCL device selection via OPENCV_OPENCL_DEVICE environment variable
parent
dd9ff587
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
60 deletions
+76
-60
main.cpp
modules/ocl/perf/main.cpp
+37
-28
cl_context.cpp
modules/ocl/src/cl_context.cpp
+0
-0
main.cpp
modules/ocl/test/main.cpp
+39
-32
No files found.
modules/ocl/perf/main.cpp
View file @
16adbda4
...
...
@@ -51,6 +51,8 @@ const char * impls[] =
#endif
};
using
namespace
cv
::
ocl
;
int
main
(
int
argc
,
char
**
argv
)
{
const
char
*
keys
=
...
...
@@ -59,42 +61,49 @@ int main(int argc, char ** argv)
"{ p | platform | -1 | set platform id }"
"{ d | device | 0 | set device id }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
if
(
getenv
(
"OPENCV_OPENCL_DEVICE"
)
==
NULL
)
// TODO Remove this after buildbot updates
{
cout
<<
"Available options besides google test option:"
<<
endl
;
cmd
.
printParams
();
return
0
;
}
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
{
cout
<<
"Available options besides google test option:"
<<
endl
;
cmd
.
printParams
();
return
0
;
}
string
type
=
cmd
.
get
<
string
>
(
"type"
);
int
pid
=
cmd
.
get
<
int
>
(
"platform"
);
int
device
=
cmd
.
get
<
int
>
(
"device"
);
string
type
=
cmd
.
get
<
string
>
(
"type"
);
int
pid
=
cmd
.
get
<
int
>
(
"platform"
);
int
device
=
cmd
.
get
<
int
>
(
"device"
);
int
flag
=
type
==
"cpu"
?
cv
::
ocl
::
CVCL_DEVICE_TYPE_CPU
:
cv
::
ocl
::
CVCL_DEVICE_TYPE_GPU
;
int
flag
=
type
==
"cpu"
?
cv
::
ocl
::
CVCL_DEVICE_TYPE_CPU
:
cv
::
ocl
::
CVCL_DEVICE_TYPE_GPU
;
cv
::
ocl
::
PlatformsInfo
platformsInfo
;
cv
::
ocl
::
getOpenCLPlatforms
(
platformsInfo
);
if
(
pid
>=
(
int
)
platformsInfo
.
size
())
{
std
::
cout
<<
"platform is invalid
\n
"
;
return
1
;
}
cv
::
ocl
::
PlatformsInfo
platformsInfo
;
cv
::
ocl
::
getOpenCLPlatforms
(
platformsInfo
);
if
(
pid
>=
(
int
)
platformsInfo
.
size
())
{
std
::
cout
<<
"platform is invalid
\n
"
;
return
1
;
}
cv
::
ocl
::
DevicesInfo
devicesInfo
;
int
devnums
=
cv
::
ocl
::
getOpenCLDevices
(
devicesInfo
,
flag
,
(
pid
<
0
)
?
NULL
:
platformsInfo
[
pid
]);
if
(
device
<
0
||
device
>=
devnums
)
{
std
::
cout
<<
"device/platform invalid
\n
"
;
return
1
;
cv
::
ocl
::
DevicesInfo
devicesInfo
;
int
devnums
=
cv
::
ocl
::
getOpenCLDevices
(
devicesInfo
,
flag
,
(
pid
<
0
)
?
NULL
:
platformsInfo
[
pid
]);
if
(
device
<
0
||
device
>=
devnums
)
{
std
::
cout
<<
"device/platform invalid
\n
"
;
return
1
;
}
cv
::
ocl
::
setDevice
(
devicesInfo
[
device
]);
}
c
v
::
ocl
::
setDevice
(
devicesInfo
[
device
]
);
c
onst
DeviceInfo
&
deviceInfo
=
cv
::
ocl
::
Context
::
getContext
()
->
getDeviceInfo
(
);
cout
<<
"Device type:"
<<
type
<<
endl
<<
"Platform name:"
<<
devicesInfo
[
device
]
->
platform
->
platformName
<<
endl
<<
"Device name:"
<<
devicesInfo
[
device
]
->
deviceName
<<
endl
;
cout
<<
"Device type: "
<<
(
deviceInfo
.
deviceType
==
CVCL_DEVICE_TYPE_CPU
?
"CPU"
:
(
deviceInfo
.
deviceType
==
CVCL_DEVICE_TYPE_GPU
?
"GPU"
:
"unknown"
))
<<
endl
<<
"Platform name: "
<<
deviceInfo
.
platform
->
platformName
<<
endl
<<
"Device name: "
<<
deviceInfo
.
deviceName
<<
endl
;
CV_PERF_TEST_MAIN_INTERNALS
(
ocl
,
impls
)
}
modules/ocl/src/cl_context.cpp
View file @
16adbda4
This diff is collapsed.
Click to expand it.
modules/ocl/test/main.cpp
View file @
16adbda4
...
...
@@ -83,45 +83,52 @@ int main(int argc, char **argv)
"{ p | platform | -1 | set platform id }"
"{ d | device | 0 | set device id }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
if
(
getenv
(
"OPENCV_OPENCL_DEVICE"
)
==
NULL
)
// TODO Remove this after buildbot updates
{
cout
<<
"Available options besides google test option:"
<<
endl
;
cmd
.
printParams
();
return
0
;
}
string
type
=
cmd
.
get
<
string
>
(
"type"
);
int
pid
=
cmd
.
get
<
int
>
(
"platform"
);
int
device
=
cmd
.
get
<
int
>
(
"device"
);
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
{
cout
<<
"Available options besides google test option:"
<<
endl
;
cmd
.
printParams
();
return
0
;
}
string
type
=
cmd
.
get
<
string
>
(
"type"
);
int
pid
=
cmd
.
get
<
int
>
(
"platform"
);
int
device
=
cmd
.
get
<
int
>
(
"device"
);
print_info
();
int
flag
=
CVCL_DEVICE_TYPE_GPU
;
if
(
type
==
"cpu"
)
{
flag
=
CVCL_DEVICE_TYPE_CPU
;
}
print_info
();
int
flag
=
CVCL_DEVICE_TYPE_GPU
;
if
(
type
==
"cpu"
)
{
flag
=
CVCL_DEVICE_TYPE_CPU
;
}
cv
::
ocl
::
PlatformsInfo
platformsInfo
;
cv
::
ocl
::
getOpenCLPlatforms
(
platformsInfo
);
if
(
pid
>=
(
int
)
platformsInfo
.
size
())
{
std
::
cout
<<
"platform is invalid
\n
"
;
return
1
;
}
cv
::
ocl
::
PlatformsInfo
platformsInfo
;
cv
::
ocl
::
getOpenCLPlatforms
(
platformsInfo
);
if
(
pid
>=
(
int
)
platformsInfo
.
size
())
{
std
::
cout
<<
"platform is invalid
\n
"
;
return
1
;
}
cv
::
ocl
::
DevicesInfo
devicesInfo
;
int
devnums
=
cv
::
ocl
::
getOpenCLDevices
(
devicesInfo
,
flag
,
(
pid
<
0
)
?
NULL
:
platformsInfo
[
pid
]);
if
(
device
<
0
||
device
>=
devnums
)
{
std
::
cout
<<
"device/platform invalid
\n
"
;
return
1
;
cv
::
ocl
::
DevicesInfo
devicesInfo
;
int
devnums
=
cv
::
ocl
::
getOpenCLDevices
(
devicesInfo
,
flag
,
(
pid
<
0
)
?
NULL
:
platformsInfo
[
pid
]);
if
(
device
<
0
||
device
>=
devnums
)
{
std
::
cout
<<
"device/platform invalid
\n
"
;
return
1
;
}
cv
::
ocl
::
setDevice
(
devicesInfo
[
device
]);
}
c
v
::
ocl
::
setDevice
(
devicesInfo
[
device
]
);
c
onst
DeviceInfo
&
deviceInfo
=
cv
::
ocl
::
Context
::
getContext
()
->
getDeviceInfo
(
);
cout
<<
"Device type: "
<<
type
<<
endl
<<
"Platform name: "
<<
devicesInfo
[
device
]
->
platform
->
platformName
<<
endl
<<
"Device name: "
<<
devicesInfo
[
device
]
->
deviceName
<<
endl
;
cout
<<
"Device type: "
<<
(
deviceInfo
.
deviceType
==
CVCL_DEVICE_TYPE_CPU
?
"CPU"
:
(
deviceInfo
.
deviceType
==
CVCL_DEVICE_TYPE_GPU
?
"GPU"
:
"unknown"
))
<<
endl
<<
"Platform name: "
<<
deviceInfo
.
platform
->
platformName
<<
endl
<<
"Device name: "
<<
deviceInfo
.
deviceName
<<
endl
;
return
RUN_ALL_TESTS
();
}
...
...
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