move the "cpu device checking" from supportsFeatures() to queryDeviceInfo()
This commit is contained in:
parent
d5aaea2749
commit
5022bc8c25
@ -155,7 +155,7 @@ namespace cv
|
|||||||
static Context* getContext();
|
static Context* getContext();
|
||||||
static void setContext(Info &oclinfo);
|
static void setContext(Info &oclinfo);
|
||||||
|
|
||||||
enum {CL_DOUBLE, CL_UNIFIED_MEM, CL_CPU};
|
enum {CL_DOUBLE, CL_UNIFIED_MEM};
|
||||||
bool supportsFeature(int ftype);
|
bool supportsFeature(int ftype);
|
||||||
size_t computeUnits();
|
size_t computeUnits();
|
||||||
void* oclContext();
|
void* oclContext();
|
||||||
|
@ -128,7 +128,8 @@ namespace cv
|
|||||||
enum DEVICE_INFO
|
enum DEVICE_INFO
|
||||||
{
|
{
|
||||||
WAVEFRONT_SIZE, //in AMD speak
|
WAVEFRONT_SIZE, //in AMD speak
|
||||||
WARP_SIZE = WAVEFRONT_SIZE //in nvidia speak
|
WARP_SIZE = WAVEFRONT_SIZE, //in nvidia speak
|
||||||
|
IS_CPU_DEVICE //check if the device is CPU
|
||||||
};
|
};
|
||||||
//info should have been pre-allocated
|
//info should have been pre-allocated
|
||||||
void CV_EXPORTS queryDeviceInfo(DEVICE_INFO info_type, void* info);
|
void CV_EXPORTS queryDeviceInfo(DEVICE_INFO info_type, void* info);
|
||||||
|
@ -397,6 +397,15 @@ namespace cv
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case IS_CPU_DEVICE:
|
||||||
|
{
|
||||||
|
cl_device_type devicetype;
|
||||||
|
openCLSafeCall(clGetDeviceInfo(impl->devices[impl->devnum],
|
||||||
|
CL_DEVICE_TYPE, sizeof(cl_device_type),
|
||||||
|
&devicetype, NULL));
|
||||||
|
*(bool*)info = (devicetype == CVCL_DEVICE_TYPE_CPU);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
CV_Error(-1, "Invalid device info type");
|
CV_Error(-1, "Invalid device info type");
|
||||||
break;
|
break;
|
||||||
@ -979,12 +988,6 @@ namespace cv
|
|||||||
return impl->double_support == 1;
|
return impl->double_support == 1;
|
||||||
case CL_UNIFIED_MEM:
|
case CL_UNIFIED_MEM:
|
||||||
return impl->unified_memory == 1;
|
return impl->unified_memory == 1;
|
||||||
case CL_CPU:
|
|
||||||
cl_device_type devicetype;
|
|
||||||
clGetDeviceInfo(impl->devices[impl->devnum],
|
|
||||||
CL_DEVICE_TYPE, sizeof(cl_device_type),
|
|
||||||
&devicetype, NULL);
|
|
||||||
return devicetype == CVCL_DEVICE_TYPE_CPU;
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,9 @@ static void lkSparse_run(oclMat &I, oclMat &J,
|
|||||||
args.push_back( make_pair( sizeof(cl_int), (void *)&iters ));
|
args.push_back( make_pair( sizeof(cl_int), (void *)&iters ));
|
||||||
args.push_back( make_pair( sizeof(cl_char), (void *)&calcErr ));
|
args.push_back( make_pair( sizeof(cl_char), (void *)&calcErr ));
|
||||||
|
|
||||||
if (clCxt->supportsFeature(Context::CL_CPU))
|
bool is_cpu;
|
||||||
|
queryDeviceInfo(IS_CPU_DEVICE, &is_cpu);
|
||||||
|
if (is_cpu)
|
||||||
{
|
{
|
||||||
openCLExecuteKernel(clCxt, &pyrlk, kernelName, globalThreads, localThreads, args, I.oclchannels(), I.depth(), (char*)" -D CPU");
|
openCLExecuteKernel(clCxt, &pyrlk, kernelName, globalThreads, localThreads, args, I.oclchannels(), I.depth(), (char*)" -D CPU");
|
||||||
releaseTexture(ITex);
|
releaseTexture(ITex);
|
||||||
|
Loading…
Reference in New Issue
Block a user