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
f90e41d5
Commit
f90e41d5
authored
Jan 22, 2014
by
Konstantin Matskevich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dumpinfo
parent
494f7e36
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
16 deletions
+148
-16
ocl.hpp
modules/core/include/opencv2/core/ocl.hpp
+21
-0
ocl.cpp
modules/core/src/ocl.cpp
+107
-0
ts_perf.hpp
modules/ts/include/opencv2/ts/ts_perf.hpp
+10
-0
ocl_test.cpp
modules/ts/src/ocl_test.cpp
+10
-16
No files found.
modules/core/include/opencv2/core/ocl.hpp
View file @
f90e41d5
...
@@ -59,6 +59,7 @@ class CV_EXPORTS Kernel;
...
@@ -59,6 +59,7 @@ class CV_EXPORTS Kernel;
class
CV_EXPORTS
Program
;
class
CV_EXPORTS
Program
;
class
CV_EXPORTS
ProgramSource2
;
class
CV_EXPORTS
ProgramSource2
;
class
CV_EXPORTS
Queue
;
class
CV_EXPORTS
Queue
;
class
CV_EXPORTS
PlatformInform
;
class
CV_EXPORTS
Device
class
CV_EXPORTS
Device
{
{
...
@@ -84,6 +85,7 @@ public:
...
@@ -84,6 +85,7 @@ public:
String
name
()
const
;
String
name
()
const
;
String
extensions
()
const
;
String
extensions
()
const
;
String
version
()
const
;
String
vendor
()
const
;
String
vendor
()
const
;
String
OpenCL_C_Version
()
const
;
String
OpenCL_C_Version
()
const
;
String
OpenCLVersion
()
const
;
String
OpenCLVersion
()
const
;
...
@@ -549,9 +551,28 @@ protected:
...
@@ -549,9 +551,28 @@ protected:
Impl
*
p
;
Impl
*
p
;
};
};
class
CV_EXPORTS
PlatformInform
{
public
:
PlatformInform
();
explicit
PlatformInform
(
void
*
id
);
~
PlatformInform
();
String
name
()
const
;
String
vendor
()
const
;
String
version
()
const
;
int
deviceNumber
()
const
;
void
getDevice
(
Device
&
device
,
int
d
)
const
;
protected
:
struct
Impl
;
Impl
*
p
;
};
CV_EXPORTS
const
char
*
convertTypeStr
(
int
sdepth
,
int
ddepth
,
int
cn
,
char
*
buf
);
CV_EXPORTS
const
char
*
convertTypeStr
(
int
sdepth
,
int
ddepth
,
int
cn
,
char
*
buf
);
CV_EXPORTS
const
char
*
typeToStr
(
int
t
);
CV_EXPORTS
const
char
*
typeToStr
(
int
t
);
CV_EXPORTS
const
char
*
memopTypeToStr
(
int
t
);
CV_EXPORTS
const
char
*
memopTypeToStr
(
int
t
);
CV_EXPORTS
void
getPlatfomsInfo
(
std
::
vector
<
PlatformInform
>&
platform_info
);
}}
}}
...
...
modules/core/src/ocl.cpp
View file @
f90e41d5
...
@@ -1693,6 +1693,9 @@ String Device::name() const
...
@@ -1693,6 +1693,9 @@ String Device::name() const
String
Device
::
extensions
()
const
String
Device
::
extensions
()
const
{
return
p
?
p
->
getStrProp
(
CL_DEVICE_EXTENSIONS
)
:
String
();
}
{
return
p
?
p
->
getStrProp
(
CL_DEVICE_EXTENSIONS
)
:
String
();
}
String
Device
::
version
()
const
{
return
p
?
p
->
getStrProp
(
CL_DEVICE_VERSION
)
:
String
();
}
String
Device
::
vendor
()
const
String
Device
::
vendor
()
const
{
return
p
?
p
->
getStrProp
(
CL_DEVICE_VENDOR
)
:
String
();
}
{
return
p
?
p
->
getStrProp
(
CL_DEVICE_VENDOR
)
:
String
();
}
...
@@ -3621,6 +3624,110 @@ MatAllocator* getOpenCLAllocator()
...
@@ -3621,6 +3624,110 @@ MatAllocator* getOpenCLAllocator()
return
&
allocator
;
return
&
allocator
;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static
void
getDevices
(
std
::
vector
<
cl_device_id
>&
devices
,
cl_platform_id
&
platform
)
{
cl_int
status
=
CL_SUCCESS
;
cl_uint
numDevices
=
0
;
status
=
clGetDeviceIDs
(
platform
,
(
cl_device_type
)
Device
::
TYPE_ALL
,
0
,
NULL
,
&
numDevices
);
CV_Assert
(
status
==
CL_SUCCESS
);
if
(
numDevices
==
0
)
return
;
devices
.
resize
((
size_t
)
numDevices
);
status
=
clGetDeviceIDs
(
platform
,
(
cl_device_type
)
Device
::
TYPE_ALL
,
numDevices
,
&
devices
[
0
],
&
numDevices
);
CV_Assert
(
status
==
CL_SUCCESS
);
devices
.
resize
(
numDevices
);
}
struct
PlatformInform
::
Impl
{
Impl
(
void
*
id
)
{
handle
=
*
(
cl_platform_id
*
)
id
;
getDevices
(
devices
,
handle
);
}
String
getStrProp
(
cl_device_info
prop
)
const
{
char
buf
[
1024
];
size_t
sz
=
0
;
return
clGetPlatformInfo
(
handle
,
prop
,
sizeof
(
buf
)
-
16
,
buf
,
&
sz
)
>=
0
&&
sz
<
sizeof
(
buf
)
?
String
(
buf
)
:
String
();
}
IMPLEMENT_REFCOUNTABLE
();
std
::
vector
<
cl_device_id
>
devices
;
cl_platform_id
handle
;
};
PlatformInform
::
PlatformInform
()
{
p
=
0
;
}
PlatformInform
::
PlatformInform
(
void
*
platform_id
)
{
p
=
new
Impl
(
platform_id
);
}
PlatformInform
::~
PlatformInform
()
{
if
(
p
)
p
->
release
();
}
int
PlatformInform
::
deviceNumber
()
const
{
return
p
?
(
int
)
p
->
devices
.
size
()
:
0
;
}
void
PlatformInform
::
getDevice
(
Device
&
device
,
int
d
)
const
{
CV_Assert
(
d
<
(
int
)
p
->
devices
.
size
()
);
if
(
p
)
device
.
set
(
p
->
devices
[
d
]);
}
String
PlatformInform
::
name
()
const
{
return
p
?
p
->
getStrProp
(
CL_PLATFORM_NAME
)
:
String
();
}
String
PlatformInform
::
vendor
()
const
{
return
p
?
p
->
getStrProp
(
CL_PLATFORM_VENDOR
)
:
String
();
}
String
PlatformInform
::
version
()
const
{
return
p
?
p
->
getStrProp
(
CL_PLATFORM_VERSION
)
:
String
();
}
static
void
getPlatforms
(
std
::
vector
<
cl_platform_id
>&
platforms
)
{
cl_int
status
=
CL_SUCCESS
;
cl_uint
numPlatforms
=
0
;
status
=
clGetPlatformIDs
(
0
,
NULL
,
&
numPlatforms
);
CV_Assert
(
status
==
CL_SUCCESS
);
if
(
numPlatforms
==
0
)
return
;
platforms
.
resize
((
size_t
)
numPlatforms
);
status
=
clGetPlatformIDs
(
numPlatforms
,
&
platforms
[
0
],
&
numPlatforms
);
CV_Assert
(
status
==
CL_SUCCESS
);
platforms
.
resize
(
numPlatforms
);
}
void
getPlatfomsInfo
(
std
::
vector
<
PlatformInform
>&
platformsInfo
)
{
std
::
vector
<
cl_platform_id
>
platforms
;
getPlatforms
(
platforms
);
for
(
size_t
i
=
0
;
i
<
platforms
.
size
();
i
++
)
{
platformsInfo
.
push_back
(
PlatformInform
((
void
*
)
&
platforms
[
i
])
);
}
}
const
char
*
typeToStr
(
int
t
)
const
char
*
typeToStr
(
int
t
)
{
{
static
const
char
*
tab
[]
=
static
const
char
*
tab
[]
=
...
...
modules/ts/include/opencv2/ts/ts_perf.hpp
View file @
f90e41d5
...
@@ -509,6 +509,15 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
...
@@ -509,6 +509,15 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
#endif
#endif
#endif
#endif
#if defined(HAVE_OPENCL) && !defined(CV_BUILD_OCL_MODULE)
namespace
cvtest
{
namespace
ocl
{
void
dumpOpenCLDevice
();
}}
#define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice();
#else
#define TEST_DUMP_OCL_INFO
#endif
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
::perf::Regression::Init(#modulename); \
::perf::Regression::Init(#modulename); \
::perf::TestBase::Init(std::vector<std::string>(impls, impls + sizeof impls / sizeof *impls), \
::perf::TestBase::Init(std::vector<std::string>(impls, impls + sizeof impls / sizeof *impls), \
...
@@ -518,6 +527,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
...
@@ -518,6 +527,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
::testing::Test::RecordProperty("cv_module_name", #modulename); \
::testing::Test::RecordProperty("cv_module_name", #modulename); \
::perf::TestBase::RecordRunParameters(); \
::perf::TestBase::RecordRunParameters(); \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
TEST_DUMP_OCL_INFO \
return RUN_ALL_TESTS();
return RUN_ALL_TESTS();
// impls must be an array, not a pointer; "plain" should always be one of the implementations
// impls must be an array, not a pointer; "plain" should always be one of the implementations
...
...
modules/ts/src/ocl_test.cpp
View file @
f90e41d5
...
@@ -98,28 +98,25 @@ void dumpOpenCLDevice()
...
@@ -98,28 +98,25 @@ void dumpOpenCLDevice()
using
namespace
cv
::
ocl
;
using
namespace
cv
::
ocl
;
try
try
{
{
#if 0
std
::
vector
<
PlatformInform
>
platforms
;
Platforms platforms;
cv
::
ocl
::
getPlatfomsInfo
(
platforms
);
getOpenCLPlatforms(platforms);
if
(
platforms
.
size
()
>
0
)
if
(
platforms
.
size
()
>
0
)
{
{
DUMP_MESSAGE_STDOUT
(
"OpenCL Platforms: "
);
DUMP_MESSAGE_STDOUT
(
"OpenCL Platforms: "
);
for
(
size_t
i
=
0
;
i
<
platforms
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
platforms
.
size
();
i
++
)
{
{
const Platform
* platform = platforms.at(i)
;
const
Platform
Inform
*
platform
=
&
platforms
[
i
]
;
DUMP_MESSAGE_STDOUT
(
" "
<<
platform
->
name
().
c_str
());
DUMP_MESSAGE_STDOUT
(
" "
<<
platform
->
name
().
c_str
());
const Devices& devices = platform->devices()
;
Device
current_device
;
for (
size_t j = 0; j < devices.size
(); j++)
for
(
int
j
=
0
;
j
<
platform
->
deviceNumber
();
j
++
)
{
{
const Device& current_device = *devices.at(
j);
platform
->
getDevice
(
current_device
,
j
);
const
char
*
deviceTypeStr
=
current_device
.
type
()
==
Device
::
TYPE_CPU
const
char
*
deviceTypeStr
=
current_device
.
type
()
==
Device
::
TYPE_CPU
?
(
"CPU"
)
:
(
current_device
.
type
()
==
Device
::
TYPE_GPU
?
"GPU"
:
"unknown"
);
?
(
"CPU"
)
:
(
current_device
.
type
()
==
Device
::
TYPE_GPU
?
"GPU"
:
"unknown"
);
DUMP_MESSAGE_STDOUT
(
" "
<<
deviceTypeStr
<<
": "
<<
current_device
.
name
().
c_str
()
<<
" ("
<<
current_device
.
version
().
c_str
()
<<
")"
);
DUMP_MESSAGE_STDOUT
(
" "
<<
deviceTypeStr
<<
": "
<<
current_device
.
name
().
c_str
()
<<
" ("
<<
current_device
.
version
().
c_str
()
<<
")"
);
DUMP_PROPERTY_XML(cv::format("cv_ocl_platform_%d_device_%d", (int)i, (int)j),
DUMP_PROPERTY_XML
(
cv
::
format
(
"cv_ocl_platform_%d_device_%d"
,
(
int
)
i
,
(
int
)
j
),
"(Platform=" << current_device.getPlatform().name().c_str()
cv
::
format
(
"(Platform=%sType=%sName=%sVersion=%s"
,
<< ")(Type=" << deviceTypeStr
platform
->
name
().
c_str
(),
deviceTypeStr
,
current_device
.
name
().
c_str
(),
current_device
.
version
().
c_str
())
);
<< ")(Name=" << current_device.name().c_str()
<< ")(Version=" << current_device.version().c_str() << ")");
}
}
}
}
}
}
...
@@ -129,10 +126,9 @@ void dumpOpenCLDevice()
...
@@ -129,10 +126,9 @@ void dumpOpenCLDevice()
DUMP_PROPERTY_XML
(
"cv_ocl"
,
"not available"
);
DUMP_PROPERTY_XML
(
"cv_ocl"
,
"not available"
);
return
;
return
;
}
}
#endif
DUMP_MESSAGE_STDOUT
(
"Current OpenCL device: "
);
const
Device
&
device
=
Device
::
getDefault
();
const
Device
&
device
=
Device
::
getDefault
();
DUMP_MESSAGE_STDOUT
(
"Current OpenCL device: "
);
#if 0
#if 0
DUMP_MESSAGE_STDOUT(" Platform = "<< device.getPlatform().name());
DUMP_MESSAGE_STDOUT(" Platform = "<< device.getPlatform().name());
...
@@ -147,10 +143,8 @@ void dumpOpenCLDevice()
...
@@ -147,10 +143,8 @@ void dumpOpenCLDevice()
DUMP_MESSAGE_STDOUT
(
" Name = "
<<
device
.
name
());
DUMP_MESSAGE_STDOUT
(
" Name = "
<<
device
.
name
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_deviceName"
,
device
.
name
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_deviceName"
,
device
.
name
());
#if 0
DUMP_MESSAGE_STDOUT
(
" Version = "
<<
device
.
version
());
DUMP_MESSAGE_STDOUT
(
" Version = "
<<
device
.
version
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_deviceVersion"
,
device
.
version
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_deviceVersion"
,
device
.
version
());
#endif
DUMP_MESSAGE_STDOUT
(
" Compute units = "
<<
device
.
maxComputeUnits
());
DUMP_MESSAGE_STDOUT
(
" Compute units = "
<<
device
.
maxComputeUnits
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_maxComputeUnits"
,
device
.
maxComputeUnits
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_maxComputeUnits"
,
device
.
maxComputeUnits
());
...
...
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