move the "cpu device checking" from supportsFeatures() to queryDeviceInfo()

This commit is contained in:
yao 2013-04-05 09:17:14 +08:00
parent d5aaea2749
commit 5022bc8c25
4 changed files with 16 additions and 10 deletions

View File

@ -155,7 +155,7 @@ namespace cv
static Context* getContext();
static void setContext(Info &oclinfo);
enum {CL_DOUBLE, CL_UNIFIED_MEM, CL_CPU};
enum {CL_DOUBLE, CL_UNIFIED_MEM};
bool supportsFeature(int ftype);
size_t computeUnits();
void* oclContext();

View File

@ -127,8 +127,9 @@ namespace cv
// currently only support wavefront size queries
enum DEVICE_INFO
{
WAVEFRONT_SIZE, //in AMD speak
WARP_SIZE = WAVEFRONT_SIZE //in nvidia speak
WAVEFRONT_SIZE, //in AMD speak
WARP_SIZE = WAVEFRONT_SIZE, //in nvidia speak
IS_CPU_DEVICE //check if the device is CPU
};
//info should have been pre-allocated
void CV_EXPORTS queryDeviceInfo(DEVICE_INFO info_type, void* info);

View File

@ -397,6 +397,15 @@ namespace cv
}
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:
CV_Error(-1, "Invalid device info type");
break;
@ -979,12 +988,6 @@ namespace cv
return impl->double_support == 1;
case CL_UNIFIED_MEM:
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:
return false;
}

View File

@ -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_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");
releaseTexture(ITex);