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
e49065b1
Commit
e49065b1
authored
Dec 25, 2013
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/ocl: temporary move device selection from ocl module
parent
0966e5ff
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
2 deletions
+159
-2
ocl.hpp
modules/core/include/opencv2/core/ocl.hpp
+1
-0
ocl.cpp
modules/core/src/ocl.cpp
+0
-0
main.cpp
modules/ocl/perf/main.cpp
+1
-1
perf_precomp.hpp
modules/ocl/perf/perf_precomp.hpp
+2
-0
main.cpp
modules/ocl/test/main.cpp
+1
-1
test_precomp.hpp
modules/ocl/test/test_precomp.hpp
+2
-0
ts.hpp
modules/ts/include/opencv2/ts.hpp
+12
-0
ocl_test.cpp
modules/ts/src/ocl_test.cpp
+140
-0
No files found.
modules/core/include/opencv2/core/ocl.hpp
View file @
e49065b1
...
@@ -210,6 +210,7 @@ public:
...
@@ -210,6 +210,7 @@ public:
Context2
(
const
Context2
&
c
);
Context2
(
const
Context2
&
c
);
Context2
&
operator
=
(
const
Context2
&
c
);
Context2
&
operator
=
(
const
Context2
&
c
);
bool
create
();
bool
create
(
int
dtype
);
bool
create
(
int
dtype
);
size_t
ndevices
()
const
;
size_t
ndevices
()
const
;
const
Device
&
device
(
size_t
idx
)
const
;
const
Device
&
device
(
size_t
idx
)
const
;
...
...
modules/core/src/ocl.cpp
View file @
e49065b1
This diff is collapsed.
Click to expand it.
modules/ocl/perf/main.cpp
View file @
e49065b1
...
@@ -72,5 +72,5 @@ int main(int argc, char ** argv)
...
@@ -72,5 +72,5 @@ int main(int argc, char ** argv)
{
{
::
perf
::
TestBase
::
setModulePerformanceStrategy
(
::
perf
::
PERF_STRATEGY_SIMPLE
);
::
perf
::
TestBase
::
setModulePerformanceStrategy
(
::
perf
::
PERF_STRATEGY_SIMPLE
);
CV_PERF_TEST_MAIN_INTERNALS
(
ocl
,
impls
,
dumpOpenCLDevice
())
CV_PERF_TEST_MAIN_INTERNALS
(
ocl
,
impls
,
::
dumpOpenCLDevice
())
}
}
modules/ocl/perf/perf_precomp.hpp
View file @
e49065b1
...
@@ -59,6 +59,8 @@
...
@@ -59,6 +59,8 @@
# endif
# endif
#endif
#endif
#define CV_BUILD_OCL_MODULE
#include <iomanip>
#include <iomanip>
#include <stdexcept>
#include <stdexcept>
#include <string>
#include <string>
...
...
modules/ocl/test/main.cpp
View file @
e49065b1
...
@@ -76,5 +76,5 @@ void readLoopTimes(int argc, char ** argv)
...
@@ -76,5 +76,5 @@ void readLoopTimes(int argc, char ** argv)
CV_Assert
(
LOOP_TIMES
>
0
);
CV_Assert
(
LOOP_TIMES
>
0
);
}
}
CV_TEST_MAIN
(
"."
,
dumpOpenCLDevice
(),
CV_TEST_MAIN
(
"."
,
::
dumpOpenCLDevice
(),
readLoopTimes
(
argc
,
argv
))
readLoopTimes
(
argc
,
argv
))
modules/ocl/test/test_precomp.hpp
View file @
e49065b1
...
@@ -50,6 +50,8 @@
...
@@ -50,6 +50,8 @@
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
#define CV_BUILD_OCL_MODULE
#include <cmath>
#include <cmath>
#include <cstdio>
#include <cstdio>
#include <iostream>
#include <iostream>
...
...
modules/ts/include/opencv2/ts.hpp
View file @
e49065b1
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
#include "opencv2/core/cvdef.h"
#include "opencv2/core/cvdef.h"
#include <stdarg.h> // for va_list
#include <stdarg.h> // for va_list
#include "cvconfig.h"
#ifdef HAVE_WINRT
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
#endif
...
@@ -548,6 +550,15 @@ CV_EXPORTS void printVersionInfo(bool useStdOut = true);
...
@@ -548,6 +550,15 @@ CV_EXPORTS void printVersionInfo(bool useStdOut = true);
#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_TEST_MAIN(resourcesubdir, ...) \
#define CV_TEST_MAIN(resourcesubdir, ...) \
int main(int argc, char **argv) \
int main(int argc, char **argv) \
{ \
{ \
...
@@ -555,6 +566,7 @@ int main(int argc, char **argv) \
...
@@ -555,6 +566,7 @@ int main(int argc, char **argv) \
::testing::InitGoogleTest(&argc, argv); \
::testing::InitGoogleTest(&argc, argv); \
cvtest::printVersionInfo(); \
cvtest::printVersionInfo(); \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
TEST_DUMP_OCL_INFO \
return RUN_ALL_TESTS(); \
return RUN_ALL_TESTS(); \
}
}
...
...
modules/ts/src/ocl_test.cpp
View file @
e49065b1
...
@@ -52,6 +52,146 @@ using namespace cv;
...
@@ -52,6 +52,146 @@ using namespace cv;
int
test_loop_times
=
1
;
// TODO Read from command line / environment
int
test_loop_times
=
1
;
// TODO Read from command line / environment
#define DUMP_PROPERTY_XML(propertyName, propertyValue) \
do { \
std::stringstream ssName, ssValue;\
ssName << propertyName;\
ssValue << (propertyValue); \
::testing::Test::RecordProperty(ssName.str(), ssValue.str()); \
} while (false)
#define DUMP_MESSAGE_STDOUT(msg) \
do { \
std::cout << msg << std::endl; \
} while (false)
static
std
::
string
bytesToStringRepr
(
size_t
value
)
{
size_t
b
=
value
%
1024
;
value
/=
1024
;
size_t
kb
=
value
%
1024
;
value
/=
1024
;
size_t
mb
=
value
%
1024
;
value
/=
1024
;
size_t
gb
=
value
;
std
::
ostringstream
stream
;
if
(
gb
>
0
)
stream
<<
gb
<<
" GB "
;
if
(
mb
>
0
)
stream
<<
mb
<<
" MB "
;
if
(
kb
>
0
)
stream
<<
kb
<<
" kB "
;
if
(
b
>
0
)
stream
<<
b
<<
" B"
;
return
stream
.
str
();
}
void
dumpOpenCLDevice
()
{
using
namespace
cv
::
ocl
;
try
{
#if 0
Platforms platforms;
getOpenCLPlatforms(platforms);
if (platforms.size() > 0)
{
DUMP_MESSAGE_STDOUT("OpenCL Platforms: ");
for (size_t i = 0; i < platforms.size(); i++)
{
const Platform* platform = platforms.at(i);
DUMP_MESSAGE_STDOUT(" " << platform->name().c_str());
const Devices& devices = platform->devices();
for (size_t j = 0; j < devices.size(); j++)
{
const Device& current_device = *devices.at(j);
const char* deviceTypeStr = current_device.type() == Device::TYPE_CPU
? ("CPU") : (current_device.type() == Device::TYPE_GPU ? "GPU" : "unknown");
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),
"(Platform=" << current_device.getPlatform().name().c_str()
<< ")(Type=" << deviceTypeStr
<< ")(Name=" << current_device.name().c_str()
<< ")(Version=" << current_device.version().c_str() << ")");
}
}
}
else
{
DUMP_MESSAGE_STDOUT("OpenCL is not available");
DUMP_PROPERTY_XML("cv_ocl", "not available");
return;
}
#endif
DUMP_MESSAGE_STDOUT
(
"Current OpenCL device: "
);
const
Device
&
device
=
Device
::
getDefault
();
#if 0
DUMP_MESSAGE_STDOUT(" Platform = "<< device.getPlatform().name());
DUMP_PROPERTY_XML("cv_ocl_current_platformName", device.getPlatform().name());
#endif
const
char
*
deviceTypeStr
=
device
.
type
()
==
Device
::
TYPE_CPU
?
"CPU"
:
(
device
.
type
()
==
Device
::
TYPE_GPU
?
"GPU"
:
"unknown"
);
DUMP_MESSAGE_STDOUT
(
" Type = "
<<
deviceTypeStr
);
DUMP_PROPERTY_XML
(
"cv_ocl_current_deviceType"
,
deviceTypeStr
);
DUMP_MESSAGE_STDOUT
(
" Name = "
<<
device
.
name
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_deviceName"
,
device
.
name
());
#if 0
DUMP_MESSAGE_STDOUT(" Version = " << device.version());
DUMP_PROPERTY_XML("cv_ocl_current_deviceVersion", device.version());
#endif
DUMP_MESSAGE_STDOUT
(
" Compute units = "
<<
device
.
maxComputeUnits
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_maxComputeUnits"
,
device
.
maxComputeUnits
());
DUMP_MESSAGE_STDOUT
(
" Max work group size = "
<<
device
.
maxWorkGroupSize
());
DUMP_PROPERTY_XML
(
"cv_ocl_current_maxWorkGroupSize"
,
device
.
maxWorkGroupSize
());
std
::
string
localMemorySizeStr
=
bytesToStringRepr
(
device
.
localMemSize
());
DUMP_MESSAGE_STDOUT
(
" Local memory size = "
<<
localMemorySizeStr
);
DUMP_PROPERTY_XML
(
"cv_ocl_current_localMemSize"
,
device
.
localMemSize
());
std
::
string
maxMemAllocSizeStr
=
bytesToStringRepr
(
device
.
maxMemAllocSize
());
DUMP_MESSAGE_STDOUT
(
" Max memory allocation size = "
<<
maxMemAllocSizeStr
);
DUMP_PROPERTY_XML
(
"cv_ocl_current_maxMemAllocSize"
,
device
.
maxMemAllocSize
());
#if 0
const char* doubleSupportStr = device.haveDoubleSupport() ? "Yes" : "No";
DUMP_MESSAGE_STDOUT(" Double support = "<< doubleSupportStr);
DUMP_PROPERTY_XML("cv_ocl_current_haveDoubleSupport", device.haveDoubleSupport());
#else
const
char
*
doubleSupportStr
=
device
.
doubleFPConfig
()
>
0
?
"Yes"
:
"No"
;
DUMP_MESSAGE_STDOUT
(
" Double support = "
<<
doubleSupportStr
);
DUMP_PROPERTY_XML
(
"cv_ocl_current_haveDoubleSupport"
,
device
.
doubleFPConfig
()
>
0
);
#endif
const
char
*
isUnifiedMemoryStr
=
device
.
hostUnifiedMemory
()
?
"Yes"
:
"No"
;
DUMP_MESSAGE_STDOUT
(
" Host unified memory = "
<<
isUnifiedMemoryStr
);
DUMP_PROPERTY_XML
(
"cv_ocl_current_hostUnifiedMemory"
,
device
.
hostUnifiedMemory
());
}
catch
(...)
{
DUMP_MESSAGE_STDOUT
(
"Exception. Can't dump OpenCL info"
);
DUMP_MESSAGE_STDOUT
(
"OpenCL device not available"
);
DUMP_PROPERTY_XML
(
"cv_ocl"
,
"not available"
);
}
}
#undef DUMP_MESSAGE_STDOUT
#undef DUMP_PROPERTY_XML
Mat
TestUtils
::
readImage
(
const
String
&
fileName
,
int
flags
)
Mat
TestUtils
::
readImage
(
const
String
&
fileName
,
int
flags
)
{
{
return
cv
::
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
fileName
,
flags
);
return
cv
::
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
fileName
,
flags
);
...
...
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