diff options
author | Junyan He <junyan.he@intel.com> | 2016-10-08 16:47:53 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-12-15 17:57:46 +0800 |
commit | 4f5771149ea942ff7d7e685f75b90a07bfd83ad1 (patch) | |
tree | d7b61ca76d5e4e5772287be98fbd2366b97c8799 /src | |
parent | 0315d21b662b6c55d1483013eb9e845e150d6f29 (diff) |
Modify clGetKernelInfo using cl_get_info_helper.
Signed-off-by: Junyan He <junyan.he@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cl_api.c | 35 | ||||
-rw-r--r-- | src/cl_api_kernel.c | 51 | ||||
-rw-r--r-- | src/cl_api_platform_id.c | 12 |
3 files changed, 55 insertions, 43 deletions
diff --git a/src/cl_api.c b/src/cl_api.c index 7c262e64..2d399c30 100644 --- a/src/cl_api.c +++ b/src/cl_api.c @@ -1725,41 +1725,6 @@ error: } cl_int -clGetKernelInfo(cl_kernel kernel, - cl_kernel_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) -{ - cl_int err; - - CHECK_KERNEL(kernel); - - if (param_name == CL_KERNEL_CONTEXT) { - FILL_GETINFO_RET (cl_context, 1, &kernel->program->ctx, CL_SUCCESS); - } else if (param_name == CL_KERNEL_PROGRAM) { - FILL_GETINFO_RET (cl_program, 1, &kernel->program, CL_SUCCESS); - } else if (param_name == CL_KERNEL_NUM_ARGS) { - cl_uint n = kernel->arg_n; - FILL_GETINFO_RET (cl_uint, 1, &n, CL_SUCCESS); - } else if (param_name == CL_KERNEL_REFERENCE_COUNT) { - cl_int ref = CL_OBJECT_GET_REF(kernel); - FILL_GETINFO_RET (cl_int, 1, &ref, CL_SUCCESS); - } else if (param_name == CL_KERNEL_FUNCTION_NAME) { - const char * n = cl_kernel_get_name(kernel); - FILL_GETINFO_RET (cl_char, strlen(n)+1, n, CL_SUCCESS); - } else if (param_name == CL_KERNEL_ATTRIBUTES) { - const char * n = cl_kernel_get_attributes(kernel); - FILL_GETINFO_RET (cl_char, strlen(n)+1, n, CL_SUCCESS); - } else { - return CL_INVALID_VALUE; - } - -error: - return err; -} - -cl_int clGetKernelWorkGroupInfo(cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, diff --git a/src/cl_api_kernel.c b/src/cl_api_kernel.c index 70140b23..723152f7 100644 --- a/src/cl_api_kernel.c +++ b/src/cl_api_kernel.c @@ -28,6 +28,53 @@ #include <string.h> cl_int +clGetKernelInfo(cl_kernel kernel, + cl_kernel_info param_name, + size_t param_value_size, + void *param_value, + size_t *param_value_size_ret) +{ + const void *src_ptr = NULL; + size_t src_size = 0; + const char *str = NULL; + cl_int ref; + cl_uint n; + + if (!CL_OBJECT_IS_KERNEL(kernel)) { + return CL_INVALID_KERNEL; + } + + if (param_name == CL_KERNEL_CONTEXT) { + src_ptr = &kernel->program->ctx; + src_size = sizeof(cl_context); + } else if (param_name == CL_KERNEL_PROGRAM) { + src_ptr = &kernel->program; + src_size = sizeof(cl_program); + } else if (param_name == CL_KERNEL_NUM_ARGS) { + n = kernel->arg_n; + src_ptr = &n; + src_size = sizeof(cl_uint); + } else if (param_name == CL_KERNEL_REFERENCE_COUNT) { + ref = CL_OBJECT_GET_REF(kernel); + src_ptr = &ref; + src_size = sizeof(cl_int); + } else if (param_name == CL_KERNEL_FUNCTION_NAME) { + str = cl_kernel_get_name(kernel); + src_ptr = str; + src_size = strlen(str) + 1; + } else if (param_name == CL_KERNEL_ATTRIBUTES) { + str = cl_kernel_get_attributes(kernel); + src_ptr = str; + src_size = strlen(str) + 1; + } else { + return CL_INVALID_VALUE; + } + + return cl_get_info_helper(src_ptr, src_size, + param_value, param_value_size, param_value_size_ret); +} + +cl_int clEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, @@ -127,8 +174,8 @@ clEnqueueNDRangeKernel(cl_command_queue command_queue, if (realGroupSize % 8 != 0 && warn_no_good_localsize) { warn_no_good_localsize = 0; DEBUGP(DL_WARNING, "unable to find good values for local_work_size[i], please provide\n" - " local_work_size[] explicitly, you can find good values with\n" - " trial-and-error method."); + " local_work_size[] explicitly, you can find good values with\n" + " trial-and-error method."); } } } diff --git a/src/cl_api_platform_id.c b/src/cl_api_platform_id.c index 656dea33..10d88947 100644 --- a/src/cl_api_platform_id.c +++ b/src/cl_api_platform_id.c @@ -26,7 +26,7 @@ clGetPlatformInfo(cl_platform_id platform, void *param_value, size_t *param_value_size_ret) { - void *src_ptr = NULL; + const void *src_ptr = NULL; size_t src_size = 0; if (!CL_OBJECT_IS_PLATFORM(platform)) { @@ -39,22 +39,22 @@ clGetPlatformInfo(cl_platform_id platform, } if (param_name == CL_PLATFORM_PROFILE) { - src_ptr = (void *)platform->profile; + src_ptr = platform->profile; src_size = platform->profile_sz; } else if (param_name == CL_PLATFORM_VERSION) { - src_ptr = (void *)platform->version; + src_ptr = platform->version; src_size = platform->version_sz; } else if (param_name == CL_PLATFORM_NAME) { - src_ptr = (void *)platform->name; + src_ptr = platform->name; src_size = platform->name_sz; } else if (param_name == CL_PLATFORM_VENDOR) { - src_ptr = (void *)platform->vendor; + src_ptr = platform->vendor; src_size = platform->vendor_sz; } else if (param_name == CL_PLATFORM_EXTENSIONS) { src_ptr = platform->extensions; src_size = platform->extensions_sz; } else if (param_name == CL_PLATFORM_ICD_SUFFIX_KHR) { - src_ptr = (void *)platform->icd_suffix_khr; + src_ptr = platform->icd_suffix_khr; src_size = platform->icd_suffix_khr_sz; } else { return CL_INVALID_VALUE; |