[Beignet] [PATCH 2/4] Runtime: fixed one missing case for clGetKernelWorkGroupInfo.
Zhigang Gong
zhigang.gong at intel.com
Sun Nov 24 21:11:07 PST 2013
CL_KERNEL_PRIVATE_MEM_SIZE is not implemented, this patch fix
this issue and can pass the piglit test case.
Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
src/cl_command_queue_gen7.c | 2 +-
src/cl_device_id.c | 54 +++++++++++++++++++++----------------------
src/cl_kernel.c | 2 ++
src/cl_kernel.h | 1 +
4 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/src/cl_command_queue_gen7.c b/src/cl_command_queue_gen7.c
index 9faaafa..923a881 100644
--- a/src/cl_command_queue_gen7.c
+++ b/src/cl_command_queue_gen7.c
@@ -236,7 +236,7 @@ cl_bind_stack(cl_gpgpu gpgpu, cl_kernel ker)
{
cl_context ctx = ker->program->ctx;
cl_device_id device = ctx->device;
- const int32_t per_lane_stack_sz = gbe_kernel_get_stack_size(ker->opaque);
+ const int32_t per_lane_stack_sz = ker->stack_size;
const int32_t value = GBE_CURBE_EXTRA_ARGUMENT;
const int32_t sub_value = GBE_STACK_BUFFER;
const int32_t offset = gbe_kernel_get_curbe_offset(ker->opaque, value, sub_value);
diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index 1124d30..871cda3 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -259,17 +259,19 @@ cl_device_get_version(cl_device_id device, cl_int *ver)
}
#undef DECL_FIELD
-#define DECL_FIELD(CASE,FIELD) \
- case JOIN(CL_KERNEL_,CASE): \
- if (param_value_size < sizeof(((cl_device_id)NULL)->FIELD)) \
- return CL_INVALID_VALUE; \
- if (param_value_size_ret != NULL) \
- *param_value_size_ret = sizeof(((cl_device_id)NULL)->FIELD);\
- memcpy(param_value, \
- &device->FIELD, \
- sizeof(((cl_device_id)NULL)->FIELD)); \
+#define _DECL_FIELD(FIELD) \
+ if (param_value && param_value_size < sizeof(FIELD)) \
+ return CL_INVALID_VALUE; \
+ if (param_value_size_ret != NULL) \
+ *param_value_size_ret = sizeof(FIELD); \
+ if (param_value) \
+ memcpy(param_value, &FIELD, sizeof(FIELD)); \
return CL_SUCCESS;
+#define DECL_FIELD(CASE,FIELD) \
+ case JOIN(CL_KERNEL_,CASE): \
+ _DECL_FIELD(FIELD)
+
#include "cl_kernel.h"
LOCAL cl_int
cl_get_kernel_workgroup_info(cl_kernel kernel,
@@ -279,31 +281,27 @@ cl_get_kernel_workgroup_info(cl_kernel kernel,
void* param_value,
size_t* param_value_size_ret)
{
+ int err = CL_SUCCESS;
if (UNLIKELY(device != &intel_ivb_gt1_device &&
device != &intel_ivb_gt2_device))
return CL_INVALID_DEVICE;
- if (UNLIKELY(param_value == NULL))
- return CL_INVALID_VALUE;
+ CHECK_KERNEL(kernel);
switch (param_name) {
- DECL_FIELD(WORK_GROUP_SIZE, wg_sz)
- DECL_FIELD(PREFERRED_WORK_GROUP_SIZE_MULTIPLE, preferred_wg_sz_mul)
+ DECL_FIELD(WORK_GROUP_SIZE, device->wg_sz)
+ DECL_FIELD(PREFERRED_WORK_GROUP_SIZE_MULTIPLE, device->preferred_wg_sz_mul)
case CL_KERNEL_LOCAL_MEM_SIZE:
- if (param_value_size < sizeof(cl_ulong))
- return CL_INVALID_VALUE;
- if (param_value_size_ret != NULL)
- *param_value_size_ret = sizeof(cl_ulong);
- *(cl_ulong*)param_value = gbe_kernel_get_slm_size(kernel->opaque) + kernel->local_mem_sz;
- return CL_SUCCESS;
- case CL_KERNEL_COMPILE_WORK_GROUP_SIZE:
- if (param_value_size < sizeof(kernel->compile_wg_sz))
- return CL_INVALID_VALUE;
- if (param_value_size_ret != NULL)
- *param_value_size_ret = sizeof(kernel->compile_wg_sz);
- memcpy(param_value, kernel->compile_wg_sz, sizeof(kernel->compile_wg_sz));
- return CL_SUCCESS;
-
- default: return CL_INVALID_VALUE;
+ {
+ size_t local_mem_sz = gbe_kernel_get_slm_size(kernel->opaque) + kernel->local_mem_sz;
+ _DECL_FIELD(local_mem_sz)
+ }
+ DECL_FIELD(COMPILE_WORK_GROUP_SIZE, kernel->compile_wg_sz)
+ DECL_FIELD(PRIVATE_MEM_SIZE, kernel->stack_size)
+ default:
+ return CL_INVALID_VALUE;
};
+
+error:
+ return err;
}
diff --git a/src/cl_kernel.c b/src/cl_kernel.c
index 9a2a737..1869eba 100644
--- a/src/cl_kernel.c
+++ b/src/cl_kernel.c
@@ -231,6 +231,7 @@ cl_kernel_setup(cl_kernel k, gbe_kernel opaque)
if (k->sampler_sz > 0)
gbe_kernel_get_sampler_data(k->opaque, k->samplers);
gbe_kernel_get_compile_wg_size(k->opaque, k->compile_wg_sz);
+ k->stack_size = gbe_kernel_get_stack_size(k->opaque);
/* Get image data & size */
k->image_sz = gbe_kernel_get_image_size(k->opaque);
assert(k->sampler_sz <= GEN_MAX_SURFACES);
@@ -265,6 +266,7 @@ cl_kernel_dup(cl_kernel from)
to->sampler_sz = from->sampler_sz;
to->image_sz = from->image_sz;
memcpy(to->compile_wg_sz, from->compile_wg_sz, sizeof(from->compile_wg_sz));
+ to->stack_size = from->stack_size;
if (to->sampler_sz)
memcpy(to->samplers, from->samplers, to->sampler_sz * sizeof(uint32_t));
if (to->image_sz) {
diff --git a/src/cl_kernel.h b/src/cl_kernel.h
index 608ed8e..6524a69 100644
--- a/src/cl_kernel.h
+++ b/src/cl_kernel.h
@@ -59,6 +59,7 @@ struct _cl_kernel {
cl_ulong local_mem_sz; /* local memory size specified in kernel args. */
size_t compile_wg_sz[3]; /* Required workgroup size by __attribute__((reqd_work_gro
up_size(X, Y, Z))) qualifier.*/
+ size_t stack_size; /* stack size per work item. */
cl_argument *args; /* To track argument setting */
uint32_t arg_n:31; /* Number of arguments */
uint32_t ref_its_program:1; /* True only for the user kernel (created by clCreateKernel) */
--
1.7.9.5
More information about the Beignet
mailing list