diff options
author | Pan Xiuli <xiuli.pan@intel.com> | 2016-05-12 09:09:50 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-06-13 17:02:09 +0800 |
commit | aa3ee67c825fbef5f68b31345c060c981bf35ad3 (patch) | |
tree | ef90a2bf68fc6545e0e82611b2b1ffe923d1a3a8 /src/cl_device_id.c | |
parent | da7eff067fd81fcb99025b2548d18fcb79beee7b (diff) |
Runtime: Add API clGetKernelSubGroupInfoKHR for subgroup extension
Signed-off-by: Pan Xiuli <xiuli.pan@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_device_id.c')
-rw-r--r-- | src/cl_device_id.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 00d014bb..66666ea7 100644 --- a/src/cl_device_id.c +++ b/src/cl_device_id.c @@ -27,6 +27,7 @@ #include "cl_thread.h" #include "CL/cl.h" #include "CL/cl_ext.h" +#include "CL/cl_intel.h" #include "cl_gbe_loader.h" #include "cl_alloc.h" @@ -1088,3 +1089,85 @@ error: return err; } +LOCAL cl_int +cl_get_kernel_subgroup_info(cl_kernel kernel, + cl_device_id device, + cl_kernel_work_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) +{ + int err = CL_SUCCESS; + if(device != NULL) + if (kernel->program->ctx->device != device) + return CL_INVALID_DEVICE; + + CHECK_KERNEL(kernel); + switch (param_name) { + case CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR: + { + int i, dim = 0; + size_t local_sz = 1; + if (param_value && param_value_size < sizeof(size_t)) + return CL_INVALID_VALUE; + if (param_value_size_ret != NULL) + *param_value_size_ret = sizeof(size_t); + switch (input_value_size) + { + case sizeof(size_t)*1: + case sizeof(size_t)*2: + case sizeof(size_t)*3: + dim = input_value_size/sizeof(size_t); + break; + default: return CL_INVALID_VALUE; + } + if (input_value == NULL ) + return CL_INVALID_VALUE; + for(i = 0; i < dim; i++) + local_sz *= ((size_t*)input_value)[i]; + if (param_value) { + size_t simd_sz = cl_kernel_get_simd_width(kernel); + size_t sub_group_size = local_sz >= simd_sz? simd_sz : local_sz; + *(size_t*)param_value = sub_group_size; + return CL_SUCCESS; + } + break; + } + case CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR: + { + int i, dim = 0; + size_t local_sz = 1; + if (param_value && param_value_size < sizeof(size_t)) + return CL_INVALID_VALUE; + if (param_value_size_ret != NULL) + *param_value_size_ret = sizeof(size_t); + switch (input_value_size) + { + case sizeof(size_t)*1: + case sizeof(size_t)*2: + case sizeof(size_t)*3: + dim = input_value_size/sizeof(size_t); + break; + default: return CL_INVALID_VALUE; + } + if (input_value == NULL ) + return CL_INVALID_VALUE; + for(i = 0; i < dim; i++) + local_sz *= ((size_t*)input_value)[i]; + if (param_value) { + size_t simd_sz = cl_kernel_get_simd_width(kernel); + size_t sub_group_num = (local_sz + simd_sz - 1) / simd_sz; + *(size_t*)param_value = sub_group_num; + return CL_SUCCESS; + } + break; + } + default: + return CL_INVALID_VALUE; + }; + +error: + return err; +} |