mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 19:24:07 +08:00
Simplify OpenCL info dumping code:
* Reduce code nesting * Drop redundant .c_str() calls
This commit is contained in:
parent
53139e6ebe
commit
6d5b900324
@ -64,33 +64,30 @@ static void dumpOpenCLInformation()
|
|||||||
|
|
||||||
std::vector<PlatformInfo> platforms;
|
std::vector<PlatformInfo> platforms;
|
||||||
cv::ocl::getPlatfomsInfo(platforms);
|
cv::ocl::getPlatfomsInfo(platforms);
|
||||||
if (platforms.size() > 0)
|
if (platforms.empty())
|
||||||
{
|
|
||||||
DUMP_MESSAGE_STDOUT("OpenCL Platforms: ");
|
|
||||||
for (size_t i = 0; i < platforms.size(); i++)
|
|
||||||
{
|
|
||||||
const PlatformInfo* platform = &platforms[i];
|
|
||||||
DUMP_MESSAGE_STDOUT(" " << platform->name().c_str());
|
|
||||||
Device current_device;
|
|
||||||
for (int j = 0; j < platform->deviceNumber(); j++)
|
|
||||||
{
|
|
||||||
platform->getDevice(current_device, j);
|
|
||||||
const char* deviceTypeStr = current_device.type() == Device::TYPE_CPU
|
|
||||||
? ("CPU") : (current_device.type() == Device::TYPE_GPU ? current_device.hostUnifiedMemory() ? "iGPU" : "dGPU" : "unknown");
|
|
||||||
DUMP_MESSAGE_STDOUT( " " << deviceTypeStr << ": " << current_device.name().c_str() << " (" << current_device.version().c_str() << ")");
|
|
||||||
DUMP_CONFIG_PROPERTY( cv::format("cv_ocl_platform_%d_device_%d", (int)i, (int)j ),
|
|
||||||
cv::format("(Platform=%s)(Type=%s)(Name=%s)(Version=%s)",
|
|
||||||
platform->name().c_str(), deviceTypeStr, current_device.name().c_str(), current_device.version().c_str()) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
DUMP_MESSAGE_STDOUT("OpenCL is not available");
|
DUMP_MESSAGE_STDOUT("OpenCL is not available");
|
||||||
DUMP_CONFIG_PROPERTY("cv_ocl", "not available");
|
DUMP_CONFIG_PROPERTY("cv_ocl", "not available");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DUMP_MESSAGE_STDOUT("OpenCL Platforms: ");
|
||||||
|
for (size_t i = 0; i < platforms.size(); i++)
|
||||||
|
{
|
||||||
|
const PlatformInfo* platform = &platforms[i];
|
||||||
|
DUMP_MESSAGE_STDOUT(" " << platform->name());
|
||||||
|
Device current_device;
|
||||||
|
for (int j = 0; j < platform->deviceNumber(); j++)
|
||||||
|
{
|
||||||
|
platform->getDevice(current_device, j);
|
||||||
|
const char* deviceTypeStr = (current_device.type() == Device::TYPE_CPU) ? "CPU" :
|
||||||
|
(current_device.type() == Device::TYPE_GPU ? current_device.hostUnifiedMemory() ? "iGPU" : "dGPU" : "unknown");
|
||||||
|
DUMP_MESSAGE_STDOUT( " " << deviceTypeStr << ": " << current_device.name() << " (" << current_device.version() << ")");
|
||||||
|
DUMP_CONFIG_PROPERTY( cv::format("cv_ocl_platform_%d_device_%d", (int)i, j ),
|
||||||
|
cv::format("(Platform=%s)(Type=%s)(Name=%s)(Version=%s)",
|
||||||
|
platform->name().c_str(), deviceTypeStr, current_device.name().c_str(), current_device.version().c_str()) );
|
||||||
|
}
|
||||||
|
}
|
||||||
const Device& device = Device::getDefault();
|
const Device& device = Device::getDefault();
|
||||||
if (!device.available())
|
if (!device.available())
|
||||||
CV_Error(Error::OpenCLInitError, "OpenCL device is not available");
|
CV_Error(Error::OpenCLInitError, "OpenCL device is not available");
|
||||||
@ -102,8 +99,8 @@ static void dumpOpenCLInformation()
|
|||||||
DUMP_CONFIG_PROPERTY("cv_ocl_current_platformName", device.getPlatform().name());
|
DUMP_CONFIG_PROPERTY("cv_ocl_current_platformName", device.getPlatform().name());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* deviceTypeStr = device.type() == Device::TYPE_CPU
|
const char* deviceTypeStr = (device.type() == Device::TYPE_CPU) ? "CPU" :
|
||||||
? ("CPU") : (device.type() == Device::TYPE_GPU ? device.hostUnifiedMemory() ? "iGPU" : "dGPU" : "unknown");
|
(device.type() == Device::TYPE_GPU ? device.hostUnifiedMemory() ? "iGPU" : "dGPU" : "unknown");
|
||||||
DUMP_MESSAGE_STDOUT(" Type = " << deviceTypeStr);
|
DUMP_MESSAGE_STDOUT(" Type = " << deviceTypeStr);
|
||||||
DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceType", deviceTypeStr);
|
DUMP_CONFIG_PROPERTY("cv_ocl_current_deviceType", deviceTypeStr);
|
||||||
|
|
||||||
@ -156,7 +153,7 @@ static void dumpOpenCLInformation()
|
|||||||
}
|
}
|
||||||
pos = pos2 + 1;
|
pos = pos2 + 1;
|
||||||
}
|
}
|
||||||
DUMP_CONFIG_PROPERTY("cv_ocl_current_extensions", extensionsStr.c_str());
|
DUMP_CONFIG_PROPERTY("cv_ocl_current_extensions", extensionsStr);
|
||||||
|
|
||||||
const char* haveAmdBlasStr = haveAmdBlas() ? "Yes" : "No";
|
const char* haveAmdBlasStr = haveAmdBlas() ? "Yes" : "No";
|
||||||
DUMP_MESSAGE_STDOUT(" Has AMD Blas = " << haveAmdBlasStr);
|
DUMP_MESSAGE_STDOUT(" Has AMD Blas = " << haveAmdBlasStr);
|
||||||
|
Loading…
Reference in New Issue
Block a user