Commit 16adbda4 authored by Alexander Alekhin's avatar Alexander Alekhin

ocl: added OpenCL device selection via OPENCV_OPENCL_DEVICE environment variable

parent dd9ff587
......@@ -51,6 +51,8 @@ const char * impls[] =
#endif
};
using namespace cv::ocl;
int main(int argc, char ** argv)
{
const char * keys =
......@@ -59,6 +61,8 @@ int main(int argc, char ** argv)
"{ p | platform | -1 | set platform id }"
"{ d | device | 0 | set device id }";
if (getenv("OPENCV_OPENCL_DEVICE") == NULL) // TODO Remove this after buildbot updates
{
CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help"))
{
......@@ -91,10 +95,15 @@ int main(int argc, char ** argv)
}
cv::ocl::setDevice(devicesInfo[device]);
}
const DeviceInfo& deviceInfo = cv::ocl::Context::getContext()->getDeviceInfo();
cout << "Device type:" << type << endl
<< "Platform name:" << devicesInfo[device]->platform->platformName << endl
<< "Device name:" << devicesInfo[device]->deviceName << endl;
cout << "Device type: " << (deviceInfo.deviceType == CVCL_DEVICE_TYPE_CPU ?
"CPU" :
(deviceInfo.deviceType == CVCL_DEVICE_TYPE_GPU ? "GPU" : "unknown")) << endl
<< "Platform name: " << deviceInfo.platform->platformName << endl
<< "Device name: " << deviceInfo.deviceName << endl;
CV_PERF_TEST_MAIN_INTERNALS(ocl, impls)
}
This diff is collapsed.
......@@ -83,6 +83,8 @@ int main(int argc, char **argv)
"{ p | platform | -1 | set platform id }"
"{ d | device | 0 | set device id }";
if (getenv("OPENCV_OPENCL_DEVICE") == NULL) // TODO Remove this after buildbot updates
{
CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help"))
{
......@@ -118,10 +120,15 @@ int main(int argc, char **argv)
}
cv::ocl::setDevice(devicesInfo[device]);
}
const DeviceInfo& deviceInfo = cv::ocl::Context::getContext()->getDeviceInfo();
cout << "Device type: " << type << endl
<< "Platform name: " << devicesInfo[device]->platform->platformName << endl
<< "Device name: " << devicesInfo[device]->deviceName << endl;
cout << "Device type: " << (deviceInfo.deviceType == CVCL_DEVICE_TYPE_CPU ?
"CPU" :
(deviceInfo.deviceType == CVCL_DEVICE_TYPE_GPU ? "GPU" : "unknown")) << endl
<< "Platform name: " << deviceInfo.platform->platformName << endl
<< "Device name: " << deviceInfo.deviceName << endl;
return RUN_ALL_TESTS();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment