From e9edfd1c54335947297ed03a6eb21a72ff827986 Mon Sep 17 00:00:00 2001 From: Konstantin Matskevich Date: Wed, 6 Nov 2013 16:03:58 +0400 Subject: [PATCH] update --- .../opencv2/ocl/private/opencl_dumpinfo.hpp | 88 ++++++++----------- modules/ocl/perf/main.cpp | 23 ++--- modules/ocl/test/main.cpp | 12 +-- 3 files changed, 53 insertions(+), 70 deletions(-) diff --git a/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp b/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp index 942fdf453..a1b5300cf 100644 --- a/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp +++ b/modules/ocl/include/opencv2/ocl/private/opencl_dumpinfo.hpp @@ -39,24 +39,16 @@ // //M*/ -#if !defined(DUMP_INFO_STDOUT) && !defined(DUMP_INFO_XML) && !defined(DUMP_DEVICES_INFO_STDOUT) && !defined(DUMP_DEVICES_INFO_XML) +#if !defined(DUMP_MESSAGE_STDOUT) && !defined(DUMP_PROPERTY_XML) #error Invalid usage #endif -#if !defined(DUMP_INFO_STDOUT) -#define DUMP_INFO_STDOUT(...) +#if !defined(DUMP_PROPERTY_XML) +#define DUMP_PROPERTY_XML(...) #endif -#if !defined(DUMP_INFO_XML) -#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(...) +#if !defined(DUMP_MESSAGE_STDOUT) +#define DUMP_MESSAGE_STDOUT(...) #endif #include @@ -95,70 +87,68 @@ static void dumpOpenCLDevice() { cv::ocl::PlatformsInfo platforms; cv::ocl::getOpenCLPlatforms(platforms); - DUMP_INFO_STDOUT("OpenCL Platforms",""); - DUMP_INFO_XML("OpenCL Platforms",""); + DUMP_MESSAGE_STDOUT("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); + DUMP_MESSAGE_STDOUT(" " << platforms.at(i)->platformName); + const cv::ocl::DevicesInfo& devices = platforms.at(i)->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); + const cv::ocl::DeviceInfo& current_device = *devices.at(j); + deviceTypeStr = current_device.deviceType == CVCL_DEVICE_TYPE_CPU + ? ("CPU") : (current_device.deviceType == CVCL_DEVICE_TYPE_GPU ? "GPU" : "unknown"); + DUMP_MESSAGE_STDOUT( " " << deviceTypeStr << " : " << current_device.deviceName << " : " << current_device.deviceVersion ); + DUMP_PROPERTY_XML("cv_ocl_platform_"<< i<<"_device_"<getDeviceInfo(); - DUMP_INFO_STDOUT(" Platform", deviceInfo.platform->platformName); - DUMP_INFO_XML("cv_ocl_platformName", deviceInfo.platform->platformName); + DUMP_MESSAGE_STDOUT(" Platform = "<< deviceInfo.platform->platformName); + DUMP_PROPERTY_XML("cv_ocl_current_platformName", deviceInfo.platform->platformName); 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_MESSAGE_STDOUT(" Type = "<< deviceTypeStr); + DUMP_PROPERTY_XML("cv_ocl_current_deviceType", deviceTypeStr); - DUMP_INFO_STDOUT(" Name", deviceInfo.deviceName); - DUMP_INFO_XML("cv_ocl_deviceName", deviceInfo.deviceName); + DUMP_MESSAGE_STDOUT(" Name = "<< deviceInfo.deviceName); + DUMP_PROPERTY_XML("cv_ocl_current_deviceName", deviceInfo.deviceName); - DUMP_INFO_STDOUT(" Version", deviceInfo.deviceVersion); - DUMP_INFO_XML("cv_ocl_deviceVersion", deviceInfo.deviceVersion); + DUMP_MESSAGE_STDOUT(" Version = " << deviceInfo.deviceVersion); + DUMP_PROPERTY_XML("cv_ocl_current_deviceVersion", deviceInfo.deviceVersion); - DUMP_INFO_STDOUT(" Compute units", deviceInfo.maxComputeUnits); - DUMP_INFO_XML("cv_ocl_maxComputeUnits", deviceInfo.maxComputeUnits); + DUMP_MESSAGE_STDOUT(" Compute units = "<< deviceInfo.maxComputeUnits); + DUMP_PROPERTY_XML("cv_ocl_current_maxComputeUnits", deviceInfo.maxComputeUnits); - DUMP_INFO_STDOUT(" Max work group size", deviceInfo.maxWorkGroupSize); - DUMP_INFO_XML("cv_ocl_maxWorkGroupSize", deviceInfo.maxWorkGroupSize); + DUMP_MESSAGE_STDOUT(" Max work group size = "<< deviceInfo.maxWorkGroupSize); + DUMP_PROPERTY_XML("cv_ocl_current_maxWorkGroupSize", deviceInfo.maxWorkGroupSize); std::string localMemorySizeStr = bytesToStringRepr(deviceInfo.localMemorySize); - DUMP_INFO_STDOUT(" Local memory size", localMemorySizeStr.c_str()); - DUMP_INFO_XML("cv_ocl_localMemorySize", deviceInfo.localMemorySize); + DUMP_MESSAGE_STDOUT(" Local memory size = "<< localMemorySizeStr.c_str()); + DUMP_PROPERTY_XML("cv_ocl_current_localMemorySize", deviceInfo.localMemorySize); std::string maxMemAllocSizeStr = bytesToStringRepr(deviceInfo.maxMemAllocSize); - DUMP_INFO_STDOUT(" Max memory allocation size", maxMemAllocSizeStr.c_str()); - DUMP_INFO_XML("cv_ocl_maxMemAllocSize", deviceInfo.maxMemAllocSize); + DUMP_MESSAGE_STDOUT(" Max memory allocation size = "<< maxMemAllocSizeStr.c_str()); + DUMP_PROPERTY_XML("cv_ocl_current_maxMemAllocSize", deviceInfo.maxMemAllocSize); const char* doubleSupportStr = deviceInfo.haveDoubleSupport ? "Yes" : "No"; - DUMP_INFO_STDOUT(" Double support", doubleSupportStr); - DUMP_INFO_XML("cv_ocl_haveDoubleSupport", deviceInfo.haveDoubleSupport); + DUMP_MESSAGE_STDOUT(" Double support = "<< doubleSupportStr); + DUMP_PROPERTY_XML("cv_ocl_current_haveDoubleSupport", deviceInfo.haveDoubleSupport); const char* isUnifiedMemoryStr = deviceInfo.isUnifiedMemory ? "Yes" : "No"; - DUMP_INFO_STDOUT(" Unified memory", isUnifiedMemoryStr); - DUMP_INFO_XML("cv_ocl_isUnifiedMemory", deviceInfo.isUnifiedMemory); + DUMP_MESSAGE_STDOUT(" Unified memory = "<< isUnifiedMemoryStr); + DUMP_PROPERTY_XML("cv_ocl_current_isUnifiedMemory", deviceInfo.isUnifiedMemory); } catch (...) { - DUMP_INFO_STDOUT("OpenCL device", "not available"); - DUMP_INFO_XML("cv_ocl", "not available"); + DUMP_MESSAGE_STDOUT("OpenCL device not available"); + DUMP_PROPERTY_XML("cv_ocl", "not available"); } } -#undef DUMP_INFO_STDOUT -#undef DUMP_INFO_XML +#undef DUMP_MESSAGE_STDOUT +#undef DUMP_PROPERTY_XML diff --git a/modules/ocl/perf/main.cpp b/modules/ocl/perf/main.cpp index a5e238683..5a67d1cbf 100644 --- a/modules/ocl/perf/main.cpp +++ b/modules/ocl/perf/main.cpp @@ -42,28 +42,19 @@ #include "perf_precomp.hpp" -#define DUMP_INFO_STDOUT(propertyDisplayName, propertyValue) \ +#define DUMP_PROPERTY_XML(propertyName, propertyValue) \ do { \ - std::cout << (propertyDisplayName) << ": " << (propertyValue) << std::endl; \ + std::stringstream ssName, ssValue;\ + ssName << propertyName;\ + ssValue << propertyValue; \ + ::testing::Test::RecordProperty(ssName.str(), ssValue.str()); \ } while (false) -#define DUMP_INFO_XML(propertyXMLName, propertyValue) \ +#define DUMP_MESSAGE_STDOUT(msg) \ do { \ - std::stringstream ss; ss << propertyValue; \ - ::testing::Test::RecordProperty((propertyXMLName), ss.str()); \ + std::cout << msg << std::endl; \ } 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" diff --git a/modules/ocl/test/main.cpp b/modules/ocl/test/main.cpp index d76fa8483..992aeb8bb 100644 --- a/modules/ocl/test/main.cpp +++ b/modules/ocl/test/main.cpp @@ -42,15 +42,17 @@ #include "test_precomp.hpp" -#define DUMP_INFO_STDOUT(propertyDisplayName, propertyValue) \ +#define DUMP_PROPERTY_XML(propertyName, propertyValue) \ do { \ - std::cout << (propertyDisplayName) << ": " << (propertyValue) << std::endl; \ + std::stringstream ssName, ssValue;\ + ssName << propertyName;\ + ssValue << propertyValue; \ + ::testing::Test::RecordProperty(ssName.str(), ssValue.str()); \ } while (false) -#define DUMP_INFO_XML(propertyXMLName, propertyValue) \ +#define DUMP_MESSAGE_STDOUT(msg) \ do { \ - std::stringstream ss; ss << propertyValue; \ - ::testing::Test::RecordProperty((propertyXMLName), ss.str()); \ + std::cout << msg << std::endl; \ } while (false) #include "opencv2/ocl/private/opencl_dumpinfo.hpp"