From: Lu Guanqun Date: Mon, 25 Mar 2013 03:29:31 +0000 (+0800) Subject: enhance clGetDeviceInfo() API to return the length of string fields X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2490a59efb40cd47ccde9e56a063172857776626;p=contrib%2Fbeignet.git enhance clGetDeviceInfo() API to return the length of string fields Signed-off-by: Lu Guanqun Reviewed-by: Zhigang Gong --- diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 4fc7939..4543921 100644 --- a/src/cl_device_id.c +++ b/src/cl_device_id.c @@ -146,6 +146,12 @@ cl_get_device_ids(cl_platform_id platform, memcpy(param_value, device->FIELD, device->JOIN(FIELD,_sz)); \ return CL_SUCCESS; +#define GET_STRING_FIELD_SIZE(CASE,FIELD) \ + case JOIN(CL_DEVICE_,CASE): \ + if (param_value_size_ret != NULL) \ + *param_value_size_ret = device->JOIN(FIELD,_sz); \ + return CL_SUCCESS; + LOCAL cl_int cl_get_device_info(cl_device_id device, cl_device_info param_name, @@ -157,8 +163,17 @@ cl_get_device_info(cl_device_id device, device != &intel_ivb_gt2_device && device != &intel_hsw_device)) return CL_INVALID_DEVICE; - if (UNLIKELY(param_value == NULL)) - return CL_INVALID_VALUE; + + if (param_value == NULL) { + switch (param_name) { + GET_STRING_FIELD_SIZE(NAME, name) + GET_STRING_FIELD_SIZE(VENDOR, vendor) + GET_STRING_FIELD_SIZE(VERSION, version) + GET_STRING_FIELD_SIZE(PROFILE, profile) + GET_STRING_FIELD_SIZE(OPENCL_C_VERSION, opencl_c_version) + default: return CL_INVALID_VALUE; + } + } /* Find the correct parameter */ switch (param_name) {