extending openCL info dump

This commit is contained in:
Konstantin Matskevich 2013-11-06 12:17:06 +04:00
parent be37d99567
commit 5304e9f259
2 changed files with 57 additions and 16 deletions

View File

@ -39,7 +39,7 @@
//
//M*/
#if !defined(DUMP_INFO_STDOUT) && !defined(DUMP_INFO_XML)
#if !defined(DUMP_INFO_STDOUT) && !defined(DUMP_INFO_XML) && !defined(DUMP_DEVICES_INFO_STDOUT) && !defined(DUMP_DEVICES_INFO_XML)
#error Invalid usage
#endif
@ -51,6 +51,14 @@
#define DUMP_INFO_XML(...)
#endif
#if !defined(DUMP_DEVICES_INFO_STDOUT)
#define DUMP_DEVICES_INFO_STDOUT(...)
#endif
#if !defined(DUMP_DEVICES_INFO_XML)
#define DUMP_DEVICES_INFO_XML(...)
#endif
#include <sstream>
static std::string bytesToStringRepr(size_t value)
@ -85,43 +93,64 @@ static void dumpOpenCLDevice()
using namespace cv::ocl;
try
{
cv::ocl::PlatformsInfo platforms;
cv::ocl::getOpenCLPlatforms(platforms);
DUMP_INFO_STDOUT("OpenCL Platforms","");
DUMP_INFO_XML("OpenCL Platforms","");
const char* deviceTypeStr;
for(unsigned int i=0; i < platforms.size(); i++)
{
DUMP_INFO_STDOUT(" ", platforms.at(i)->platformName);
DUMP_INFO_XML("", platforms.at(i)->platformName);
cv::ocl::DevicesInfo devices;
cv::ocl::getOpenCLDevices(devices);
for(unsigned int j=0; j < devices.size(); j++)
{
deviceTypeStr = devices.at(j)->deviceType == CVCL_DEVICE_TYPE_CPU
? ("CPU") : (devices.at(j)->deviceType == CVCL_DEVICE_TYPE_GPU ? "GPU" : "unknown");
DUMP_DEVICES_INFO_STDOUT(deviceTypeStr, j, devices.at(j)->deviceName, devices.at(j)->deviceVersion);
DUMP_DEVICES_INFO_XML(deviceTypeStr, j, devices.at(j)->deviceName, devices.at(j)->deviceVersion);
}
}
DUMP_INFO_STDOUT("Current OpenCL device","");
DUMP_INFO_XML("Current OpenCL device","");
const cv::ocl::DeviceInfo& deviceInfo = cv::ocl::Context::getContext()->getDeviceInfo();
const char* deviceTypeStr = deviceInfo.deviceType == CVCL_DEVICE_TYPE_CPU
? "CPU" :
(deviceInfo.deviceType == CVCL_DEVICE_TYPE_GPU ? "GPU" : "unknown");
DUMP_INFO_STDOUT("Device type", deviceTypeStr);
DUMP_INFO_XML("cv_ocl_deviceType", deviceTypeStr);
DUMP_INFO_STDOUT("Platform name", deviceInfo.platform->platformName);
DUMP_INFO_STDOUT(" Platform", deviceInfo.platform->platformName);
DUMP_INFO_XML("cv_ocl_platformName", deviceInfo.platform->platformName);
DUMP_INFO_STDOUT("Device name", deviceInfo.deviceName);
deviceTypeStr = deviceInfo.deviceType == CVCL_DEVICE_TYPE_CPU
? "CPU" : (deviceInfo.deviceType == CVCL_DEVICE_TYPE_GPU ? "GPU" : "unknown");
DUMP_INFO_STDOUT(" Type", deviceTypeStr);
DUMP_INFO_XML("cv_ocl_deviceType", deviceTypeStr);
DUMP_INFO_STDOUT(" Name", deviceInfo.deviceName);
DUMP_INFO_XML("cv_ocl_deviceName", deviceInfo.deviceName);
DUMP_INFO_STDOUT("Device version", deviceInfo.deviceVersion);
DUMP_INFO_STDOUT(" Version", deviceInfo.deviceVersion);
DUMP_INFO_XML("cv_ocl_deviceVersion", deviceInfo.deviceVersion);
DUMP_INFO_STDOUT("Compute units", deviceInfo.maxComputeUnits);
DUMP_INFO_STDOUT(" Compute units", deviceInfo.maxComputeUnits);
DUMP_INFO_XML("cv_ocl_maxComputeUnits", deviceInfo.maxComputeUnits);
DUMP_INFO_STDOUT("Max work group size", deviceInfo.maxWorkGroupSize);
DUMP_INFO_STDOUT(" Max work group size", deviceInfo.maxWorkGroupSize);
DUMP_INFO_XML("cv_ocl_maxWorkGroupSize", deviceInfo.maxWorkGroupSize);
std::string localMemorySizeStr = bytesToStringRepr(deviceInfo.localMemorySize);
DUMP_INFO_STDOUT("Local memory size", localMemorySizeStr.c_str());
DUMP_INFO_STDOUT(" Local memory size", localMemorySizeStr.c_str());
DUMP_INFO_XML("cv_ocl_localMemorySize", deviceInfo.localMemorySize);
std::string maxMemAllocSizeStr = bytesToStringRepr(deviceInfo.maxMemAllocSize);
DUMP_INFO_STDOUT("Max memory allocation size", maxMemAllocSizeStr.c_str());
DUMP_INFO_STDOUT(" Max memory allocation size", maxMemAllocSizeStr.c_str());
DUMP_INFO_XML("cv_ocl_maxMemAllocSize", deviceInfo.maxMemAllocSize);
const char* doubleSupportStr = deviceInfo.haveDoubleSupport ? "Yes" : "No";
DUMP_INFO_STDOUT("Double support", doubleSupportStr);
DUMP_INFO_STDOUT(" Double support", doubleSupportStr);
DUMP_INFO_XML("cv_ocl_haveDoubleSupport", deviceInfo.haveDoubleSupport);
const char* isUnifiedMemoryStr = deviceInfo.isUnifiedMemory ? "Yes" : "No";
DUMP_INFO_STDOUT("Unified memory", isUnifiedMemoryStr);
DUMP_INFO_STDOUT(" Unified memory", isUnifiedMemoryStr);
DUMP_INFO_XML("cv_ocl_isUnifiedMemory", deviceInfo.isUnifiedMemory);
}
catch (...)

View File

@ -53,6 +53,18 @@
::testing::Test::RecordProperty((propertyXMLName), ss.str()); \
} while (false)
#define DUMP_DEVICES_INFO_STDOUT(deviceType, deviceIndex, deviceName, deviceVersion) \
do { \
std::cout << " " << (deviceType) << " " << (deviceIndex) << " : " << (deviceName) << " : " << deviceVersion << std::endl; \
} while (false)
#define DUMP_DEVICES_INFO_XML(deviceType, deviceIndex, deviceName, deviceVersion) \
do { \
std::stringstream ss; \
ss << ":" << deviceIndex << ":" << deviceName << ":" << deviceVersion; \
::testing::Test::RecordProperty((deviceType), ss.str()); \
} while (false)
#include "opencv2/ocl/private/opencl_dumpinfo.hpp"
static const char * impls[] =