Rewrite queryDeviceInfo interface.

Previously the function may cause some unsafe issue. It is fixed now by introducing a template parameter.
This commit is contained in:
peng xiao
2013-05-09 17:15:26 +08:00
parent 416fb50594
commit bfa0f02303
2 changed files with 45 additions and 61 deletions

View File

@@ -125,16 +125,21 @@ namespace cv
bool CV_EXPORTS support_image2d(Context *clCxt = Context::getContext());
// the enums are used to query device information
// currently only support wavefront size queries
enum DEVICE_INFO
{
WAVEFRONT_SIZE, //in AMD speak
WARP_SIZE = WAVEFRONT_SIZE, //in nvidia speak
IS_CPU_DEVICE //check if the device is CPU
WAVEFRONT_SIZE,
IS_CPU_DEVICE //supports
};
//info should have been pre-allocated
void CV_EXPORTS queryDeviceInfo(DEVICE_INFO info_type, void* info);
template<DEVICE_INFO _it, typename _ty>
_ty queryDeviceInfo(cl_kernel kernel = NULL);
//only these three specializations are implemented at the moment
template<>
int CV_EXPORTS queryDeviceInfo<WAVEFRONT_SIZE, int>(cl_kernel kernel);
template<>
size_t CV_EXPORTS queryDeviceInfo<WAVEFRONT_SIZE, size_t>(cl_kernel kernel);
template<>
bool CV_EXPORTS queryDeviceInfo<IS_CPU_DEVICE, bool>(cl_kernel kernel);
}//namespace ocl
}//namespace cv