[Piglit] [PATCH] fix CL_KERNEL_GLOBAL_WORK_SIZE bug.

xionghu.luo at intel.com xionghu.luo at intel.com
Tue Sep 16 15:05:12 PDT 2014


From: Luo <xionghu.luo at intel.com>

the option  CL_KERNEL_GLOBAL_WORK_SIZE for clGetKernelWorkGroupInfo
should call built in kernel or custom device according to the spec,
this patch calls the built in kernel to query the GLOBAL_WOR_SIZ.

Signed-off-by: Luo <xionghu.luo at intel.com>
---
 tests/cl/api/get-kernel-work-group-info.c |   40 ++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/tests/cl/api/get-kernel-work-group-info.c b/tests/cl/api/get-kernel-work-group-info.c
index 47d09da..2b2c7ba 100644
--- a/tests/cl/api/get-kernel-work-group-info.c
+++ b/tests/cl/api/get-kernel-work-group-info.c
@@ -60,6 +60,7 @@ piglit_cl_test(const int argc,
 
 	int i;
 	cl_int errNo;
+	cl_program built_in_prog;
 	cl_kernel kernel;
 
 	size_t param_value_size;
@@ -70,15 +71,47 @@ piglit_cl_test(const int argc,
 	const cl_kernel_work_group_info* kernel_work_group_infos =
 		PIGLIT_CL_ENUM_ARRAY(cl_kernel_work_group_info);
 
-	kernel = clCreateKernel(env->program,
-	                        "dummy_kernel",
-	                        &errNo);
+	char* built_in_kernel_names;
+	char* kernel_name;
+	size_t built_in_kernels_size;
+	size_t ret_sz;
+
+	errNo = clGetDeviceInfo(env->device_id, CL_DEVICE_BUILT_IN_KERNELS, 0, 0, &built_in_kernels_size);
+	if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+		fprintf(stderr,
+		        "Failed (error code: %s): Get Device Info.\n",
+		        piglit_cl_get_error_name(errNo));
+		return PIGLIT_FAIL;
+	}
+
+	built_in_kernel_names = (char* )malloc(built_in_kernels_size * sizeof(char) );
+
+	errNo = clGetDeviceInfo(env->device_id, CL_DEVICE_BUILT_IN_KERNELS, built_in_kernels_size, (void*)built_in_kernel_names, &ret_sz);
+	if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+		fprintf(stderr,
+		        "Failed (error code: %s): Get Device Info.\n",
+		        piglit_cl_get_error_name(errNo));
+		return PIGLIT_FAIL;
+	}
+
+	built_in_prog = clCreateProgramWithBuiltInKernels(env->context->cl_ctx, 1, &env->device_id, built_in_kernel_names, &errNo);
+	if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
+		fprintf(stderr,
+		        "Failed (error code: %s): Create BuiltIn Program.\n",
+		        piglit_cl_get_error_name(errNo));
+		return PIGLIT_FAIL;
+	}
+
+	kernel_name = strtok(built_in_kernel_names, ";");
+
+	kernel = clCreateKernel(built_in_prog, kernel_name,  &errNo);
 	if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
 		fprintf(stderr,
 		        "Failed (error code: %s): Create kernel.\n",
 		        piglit_cl_get_error_name(errNo));
 		return PIGLIT_FAIL;
 	}
+	free(built_in_kernel_names);
 
 	/*** Normal usage ***/
 	for(i = 0; i < num_kernel_work_group_infos; i++) {
@@ -188,6 +221,7 @@ piglit_cl_test(const int argc,
 	}
 
 	clReleaseKernel(kernel);
+	clReleaseProgram(built_in_prog);
 
 	return result;
 }
-- 
1.7.9.5



More information about the Piglit mailing list