X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=modules%2Fcore%2Fsrc%2Focl.cpp;h=5e18e035ec981a2af00f7a06e05571e39b73a451;hb=4eb16122c0489604bf800be8721c12b582a2a915;hp=9f8489e131bfe788a6f07369e650fe61b9c3d331;hpb=91a8ea5e60ba0656b247e75e9566c91534ca6f76;p=profile%2Fivi%2Fopencv.git diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 9f8489e..5e18e03 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -1453,7 +1453,7 @@ bool useOpenCL() { try { - data->useOpenCL = (int)haveOpenCL() && Device::getDefault().ptr() != NULL; + data->useOpenCL = (int)haveOpenCL() && Device::getDefault().ptr() && Device::getDefault().available(); } catch (...) { @@ -2130,7 +2130,8 @@ const Device& Device::getDefault() { const Context& ctx = Context::getDefault(); int idx = coreTlsData.get()->device; - return ctx.device(idx); + const Device& device = ctx.device(idx); + return device; } ////////////////////////////////////// Context /////////////////////////////////////////////////// @@ -2210,7 +2211,10 @@ static cl_device_id selectOpenCLDevice() std::vector deviceTypes; const char* configuration = getenv("OPENCV_OPENCL_DEVICE"); - if (configuration && !parseOpenCLDeviceConfiguration(std::string(configuration), platform, deviceTypes, deviceName)) + if (configuration && + (strcmp(configuration, "disabled") == 0 || + !parseOpenCLDeviceConfiguration(std::string(configuration), platform, deviceTypes, deviceName) + )) return NULL; bool isID = false; @@ -2339,14 +2343,16 @@ static cl_device_id selectOpenCLDevice() } not_found: - std::cerr << "ERROR: Required OpenCL device not found, check configuration: " << (configuration == NULL ? "" : configuration) << std::endl + if (!configuration) + return NULL; // suppress messages on stderr + + std::cerr << "ERROR: Requested OpenCL device not found, check configuration: " << (configuration == NULL ? "" : configuration) << std::endl << " Platform: " << (platform.length() == 0 ? "any" : platform) << std::endl << " Device types: "; for (size_t t = 0; t < deviceTypes.size(); t++) std::cerr << deviceTypes[t] << " "; std::cerr << std::endl << " Device name: " << (deviceName.length() == 0 ? "any" : deviceName) << std::endl; - CV_Error(CL_INVALID_DEVICE, "Requested OpenCL device is not found"); return NULL; } #endif