diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 8ebb0064a9..7780364f1c 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -2037,16 +2037,25 @@ struct Context::Impl 0 }; - cl_uint i, nd0 = 0, nd = 0; + cl_uint nd0 = 0; int dtype = dtype0 & 15; - CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, 0, 0, &nd0)); + cl_int status = clGetDeviceIDs(pl, dtype, 0, NULL, &nd0); + if (status != CL_DEVICE_NOT_FOUND) // Not an error if platform has no devices + { + CV_OCL_DBG_CHECK_RESULT(status, + cv::format("clGetDeviceIDs(platform=%p, device_type=%d, num_entries=0, devices=NULL, numDevices=%p)", pl, dtype, &nd0).c_str()); + } + + if (nd0 == 0) + return; AutoBuffer dlistbuf(nd0*2+1); cl_device_id* dlist = (cl_device_id*)dlistbuf.data(); cl_device_id* dlist_new = dlist + nd0; CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, nd0, dlist, &nd0)); - String name0; + cl_uint i, nd = 0; + String name0; for(i = 0; i < nd0; i++) { Device d(dlist[i]); @@ -5944,7 +5953,12 @@ void convertFromImage(void* cl_mem_image, UMat& dst) static void getDevices(std::vector& devices, cl_platform_id platform) { cl_uint numDevices = 0; - CV_OCL_DBG_CHECK(clGetDeviceIDs(platform, (cl_device_type)Device::TYPE_ALL, 0, NULL, &numDevices)); + cl_int status = clGetDeviceIDs(platform, (cl_device_type)Device::TYPE_ALL, 0, NULL, &numDevices); + if (status != CL_DEVICE_NOT_FOUND) // Not an error if platform has no devices + { + CV_OCL_DBG_CHECK_RESULT(status, + cv::format("clGetDeviceIDs(platform, Device::TYPE_ALL, num_entries=0, devices=NULL, numDevices=%p)", &numDevices).c_str()); + } if (numDevices == 0) {