Added check for fp16 support on OpenCL.
Will show proper message if not found.
Signed-off-by: Debadri Samaddar <s.debadri@samsung.com>
device_id_ = devices[0];
platform_id_ = platform_id_;
+#ifdef ENABLE_FP16
+ // check for fp16 (half) support available on device
+ // getting extensions
+ size_t extension_size;
+ status =
+ clGetDeviceInfo(device_id_, CL_DEVICE_EXTENSIONS, 0, NULL, &extension_size);
+ if (status != CL_SUCCESS) {
+ ml_loge("clGetDeviceInfo returned %d", status);
+ return false;
+ }
+
+ char extensions[extension_size];
+ status = clGetDeviceInfo(device_id_, CL_DEVICE_EXTENSIONS, extension_size,
+ extensions, NULL);
+ if (status != CL_SUCCESS) {
+ ml_loge("clGetDeviceInfo returned %d", status);
+ return false;
+ }
+
+ if (std::string(extensions).find("cl_khr_fp16") == std::string::npos) {
+ ml_loge("fp16 (half) is not supported by device");
+ return false;
+ }
+#endif
+
return true;
}
void LoadOpenCLFunctions(void *libopencl) {
LoadFunction(clGetPlatformIDs);
LoadFunction(clGetDeviceIDs);
+ LoadFunction(clGetDeviceInfo);
LoadFunction(clCreateContext);
LoadFunction(clCreateCommandQueue);
LoadFunction(clCreateBuffer);
PFN_clGetPlatformIDs clGetPlatformIDs;
PFN_clGetDeviceIDs clGetDeviceIDs;
+PFN_clGetDeviceInfo clGetDeviceInfo;
PFN_clCreateContext clCreateContext;
PFN_clCreateCommandQueue clCreateCommandQueue;
PFN_clCreateBuffer clCreateBuffer;
cl_uint /**< num_entries */, cl_device_id * /**< devices */,
cl_uint * /**< num_devices */);
+typedef cl_int(CL_API_CALL *PFN_clGetDeviceInfo)(
+ cl_device_id /**< device */, cl_device_info /**< param_name */,
+ size_t /**< param_value_size */, void * /**< param_value */,
+ size_t * /**< param_value_size_ret */);
+
typedef cl_context(CL_API_CALL *PFN_clCreateContext)(
const cl_context_properties * /**< properties */, cl_uint /**< num_devices */,
const cl_device_id * /**< devices */,
extern PFN_clGetPlatformIDs clGetPlatformIDs;
extern PFN_clGetDeviceIDs clGetDeviceIDs;
+extern PFN_clGetDeviceInfo clGetDeviceInfo;
extern PFN_clCreateContext clCreateContext;
extern PFN_clCreateCommandQueue clCreateCommandQueue;
extern PFN_clCreateBuffer clCreateBuffer;