8 #include <opencv2/core.hpp>
9 #include <opencv2/core/ocl.hpp>
11 #ifndef DUMP_CONFIG_PROPERTY
12 #define DUMP_CONFIG_PROPERTY(...)
15 #ifndef DUMP_MESSAGE_STDOUT
16 #define DUMP_MESSAGE_STDOUT(...) do { std::cout << __VA_ARGS__ << std::endl; } while (false)
24 size_t b =
value % 1024;
27 size_t kb =
value % 1024;
30 size_t mb =
value % 1024;
38 stream << gb <<
" GB ";
40 stream << mb <<
" MB ";
42 stream << kb <<
" KB ";
47 if (s[s.
size() - 1] ==
' ')
78 DUMP_MESSAGE_STDOUT(
"OpenCL is disabled");
79 DUMP_CONFIG_PROPERTY(
"cv_ocl",
"disabled");
85 if (platforms.
empty())
87 DUMP_MESSAGE_STDOUT(
"OpenCL is not available");
88 DUMP_CONFIG_PROPERTY(
"cv_ocl",
"not available");
92 DUMP_MESSAGE_STDOUT(
"OpenCL Platforms: ");
93 for (
size_t i = 0; i < platforms.
size(); i++)
96 DUMP_MESSAGE_STDOUT(
" " << platform->
name());
101 String deviceTypeStr = getDeviceTypeString(current_device);
102 DUMP_MESSAGE_STDOUT(
" " << deviceTypeStr <<
": " << current_device.
name() <<
" (" << current_device.
version() <<
")");
103 DUMP_CONFIG_PROPERTY(
cv::format(
"cv_ocl_platform_%d_device_%d", (
int)i, j ),
104 cv::format(
"(Platform=%s)(Type=%s)(Name=%s)(Version=%s)",
112 DUMP_MESSAGE_STDOUT(
"Current OpenCL device: ");
114 String deviceTypeStr = getDeviceTypeString(device);
115 DUMP_MESSAGE_STDOUT(
" Type = " << deviceTypeStr);
116 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_deviceType", deviceTypeStr);
118 DUMP_MESSAGE_STDOUT(
" Name = " << device.
name());
119 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_deviceName", device.
name());
121 DUMP_MESSAGE_STDOUT(
" Version = " << device.
version());
122 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_deviceVersion", device.
version());
124 DUMP_MESSAGE_STDOUT(
" Driver version = " << device.
driverVersion());
125 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_driverVersion", device.
driverVersion());
127 DUMP_MESSAGE_STDOUT(
" Address bits = " << device.
addressBits());
128 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_addressBits", device.
addressBits());
131 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_maxComputeUnits", device.
maxComputeUnits());
133 DUMP_MESSAGE_STDOUT(
" Max work group size = " << device.
maxWorkGroupSize());
134 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_maxWorkGroupSize", device.
maxWorkGroupSize());
137 DUMP_MESSAGE_STDOUT(
" Local memory size = " << localMemorySizeStr);
138 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_localMemSize", device.
localMemSize());
141 DUMP_MESSAGE_STDOUT(
" Max memory allocation size = " << maxMemAllocSizeStr);
142 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_maxMemAllocSize", device.
maxMemAllocSize());
144 const char* doubleSupportStr = device.
hasFP64() ?
"Yes" :
"No";
145 DUMP_MESSAGE_STDOUT(
" Double support = " << doubleSupportStr);
146 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_haveDoubleSupport", device.
hasFP64());
148 const char* halfSupportStr = device.
hasFP16() ?
"Yes" :
"No";
149 DUMP_MESSAGE_STDOUT(
" Half support = " << halfSupportStr);
150 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_haveHalfSupport", device.
hasFP16());
153 DUMP_MESSAGE_STDOUT(
" Host unified memory = " << isUnifiedMemoryStr);
154 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_hostUnifiedMemory", device.
hostUnifiedMemory());
156 DUMP_MESSAGE_STDOUT(
" Device extensions:");
159 while (
pos < extensionsStr.
size())
161 size_t pos2 = extensionsStr.
find(
' ',
pos);
162 if (pos2 == String::npos)
163 pos2 = extensionsStr.
size();
167 DUMP_MESSAGE_STDOUT(
" " << extensionName);
171 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_extensions", extensionsStr);
173 const char* haveAmdBlasStr =
haveAmdBlas() ?
"Yes" :
"No";
174 DUMP_MESSAGE_STDOUT(
" Has AMD Blas = " << haveAmdBlasStr);
175 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_AmdBlas",
haveAmdBlas());
177 const char* haveAmdFftStr =
haveAmdFft() ?
"Yes" :
"No";
178 DUMP_MESSAGE_STDOUT(
" Has AMD Fft = " << haveAmdFftStr);
179 DUMP_CONFIG_PROPERTY(
"cv_ocl_current_AmdFft",
haveAmdFft());
205 DUMP_MESSAGE_STDOUT(
"Exception. Can't dump OpenCL info");
206 DUMP_MESSAGE_STDOUT(
"OpenCL device not available");
207 DUMP_CONFIG_PROPERTY(
"cv_ocl",
"not available");
210 #undef DUMP_MESSAGE_STDOUT
211 #undef DUMP_CONFIG_PROPERTY
CV_WRAP int addressBits() const
CV_WRAP size_t maxMemAllocSize() const
CV_WRAP int preferredVectorWidthInt() const
CV_WRAP String driverVersion() const
CV_WRAP String extensions() const
CV_WRAP bool available() const
CV_WRAP size_t maxWorkGroupSize() const
CV_WRAP int preferredVectorWidthDouble() const
CV_WRAP int maxComputeUnits() const
@ TYPE_CPU
Definition: ocl.hpp:88
@ TYPE_GPU
Definition: ocl.hpp:89
CV_WRAP String version() const
CV_WRAP bool hasFP16() const
true if 'cl_khr_fp16' extension is available
static CV_WRAP const Device & getDefault()
CV_WRAP int preferredVectorWidthLong() const
CV_WRAP bool hostUnifiedMemory() const
CV_WRAP int preferredVectorWidthFloat() const
CV_WRAP bool hasFP64() const
true if 'cl_khr_fp64' extension is available
CV_WRAP int preferredVectorWidthShort() const
CV_WRAP size_t localMemSize() const
CV_WRAP int preferredVectorWidthChar() const
CV_WRAP String name() const
CV_WRAP int preferredVectorWidthHalf() const
std::string String
Definition: cvstd.hpp:151
int CvScalar value
Definition: core_c.h:720
CvMemStoragePos * pos
Definition: core_c.h:1573
CV_EXPORTS_W bool haveAmdBlas()
CV_EXPORTS_W bool haveOpenCL()
CV_EXPORTS_W bool haveAmdFft()
CV_EXPORTS void getPlatfomsInfo(std::vector< PlatformInfo > &platform_info)
CV_EXPORTS_W bool useOpenCL()
#define CV_Error(code, msg)
Call the error handler.
Definition: base.hpp:320
CV_EXPORTS String format(const char *fmt,...) CV_FORMAT_PRINTF(1
Returns a text string formatted using the printf-like expression.
@ OpenCLInitError
OpenCL initialization error.
Definition: base.hpp:122
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441
static void dumpOpenCLInformation()
Definition: opencl_info.hpp:70