[Beignet] [PATCH] cl: fix clGetKernelWorkGroupInfo on CL 1.2
EdB
edb+piglit at sigluy.net
Sun Nov 30 07:08:27 PST 2014
---
tests/cl/api/get-kernel-work-group-info.c | 159 +++++++++++++++++++++++++-----
1 file changed, 132 insertions(+), 27 deletions(-)
diff --git a/tests/cl/api/get-kernel-work-group-info.c b/tests/cl/api/get-kernel-work-group-info.c
index a38cdf0..ea899ca 100644
--- a/tests/cl/api/get-kernel-work-group-info.c
+++ b/tests/cl/api/get-kernel-work-group-info.c
@@ -49,6 +49,52 @@ PIGLIT_CL_API_TEST_CONFIG_BEGIN
PIGLIT_CL_API_TEST_CONFIG_END
+static bool
+test(cl_kernel kernel,
+ cl_device_id device,
+ cl_kernel_work_group_info param_name,
+ cl_int expected_error,
+ enum piglit_result* result) {
+
+ cl_int errNo;
+ size_t param_value_size;
+ void* param_value;
+
+ errNo = clGetKernelWorkGroupInfo(kernel,
+ device,
+ param_name,
+ 0,
+ NULL,
+ ¶m_value_size);
+ if(!piglit_cl_check_error(errNo, expected_error)) {
+ fprintf(stderr,
+ "Failed (error code: %s): Get size of %s.",
+ piglit_cl_get_error_name(errNo),
+ piglit_cl_get_enum_name(param_name));
+ piglit_merge_result(result, PIGLIT_FAIL);
+ return false;
+ }
+
+ param_value = malloc(param_value_size);
+ errNo = clGetKernelWorkGroupInfo(kernel,
+ device,
+ param_name,
+ param_value_size,
+ param_value,
+ NULL);
+ if(!piglit_cl_check_error(errNo, expected_error)) {
+ fprintf(stderr,
+ "Failed (error code: %s): Get value of %s.",
+ piglit_cl_get_error_name(errNo),
+ piglit_cl_get_enum_name(param_name));
+ piglit_merge_result(result, PIGLIT_FAIL);
+ return false;
+ }
+
+ free(param_value);
+
+ return true;
+}
enum piglit_result
piglit_cl_test(const int argc,
@@ -62,6 +108,7 @@ piglit_cl_test(const int argc,
cl_int errNo;
cl_kernel kernel;
cl_uint* dev_count_ptr;
+ cl_device_type* dev_type;
size_t param_value_size;
void* param_value;
@@ -81,45 +128,102 @@ piglit_cl_test(const int argc,
return PIGLIT_FAIL;
}
+ dev_type = piglit_cl_get_device_info(env->device_id, CL_DEVICE_TYPE);
+
/*** Normal usage ***/
for(i = 0; i < num_kernel_work_group_infos; i++) {
printf("%s ", piglit_cl_get_enum_name(kernel_work_group_infos[i]));
- errNo = clGetKernelWorkGroupInfo(kernel,
- env->device_id,
- kernel_work_group_infos[i],
- 0,
- NULL,
- ¶m_value_size);
- if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
- fprintf(stderr,
- "Failed (error code: %s): Get size of %s.\n",
- piglit_cl_get_error_name(errNo),
- piglit_cl_get_enum_name(kernel_work_group_infos[i]));
- piglit_merge_result(&result, PIGLIT_FAIL);
+#if defined(CL_VERSION_1_2)
+ /*
+ * CL_KERNEL_GLOBAL_WORK_SIZE can only return CL_SUCCESS
+ * for device == CL_DEVICE_TYPE_CUSTOM or built-in in kernel
+ * so we can't expect CL_SUCCESS. Test it later.
+ */
+ if (kernel_work_group_infos[i] == CL_KERNEL_GLOBAL_WORK_SIZE &&
+ *dev_type != CL_DEVICE_TYPE_CUSTOM) {
+ printf("skipped: device is not of CL_DEVICE_TYPE_CUSTOM type\n");
continue;
}
+#endif
- param_value = malloc(param_value_size);
- errNo = clGetKernelWorkGroupInfo(kernel,
- env->device_id,
- kernel_work_group_infos[i],
- param_value_size,
- param_value,
- NULL);
- if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
- fprintf(stderr,
- "Failed (error code: %s): Get value of %s.\n",
- piglit_cl_get_error_name(errNo),
- piglit_cl_get_enum_name(kernel_work_group_infos[i]));
- piglit_merge_result(&result, PIGLIT_FAIL);
- }
+ test(kernel, env->device_id, kernel_work_group_infos[i],
+ CL_SUCCESS, &result);
//TODO: output returned values
printf("\n");
- free(param_value);
}
+#if defined(CL_VERSION_1_2)
+ if(env->version >= 12) {
+ /*
+ * Extra test for CL_KERNEL_GLOBAL_WORK_SIZE
+ */
+
+ char* kernel_name;
+ cl_program builtin_prog;
+ cl_kernel builtin_kernel;
+
+ /*** Normal usage ***/
+
+ //test with built-in
+ kernel_name = piglit_cl_get_device_info(env->device_id,
+ CL_DEVICE_BUILT_IN_KERNELS);
+ if (kernel_name) {
+ kernel_name[strcspn(kernel_name, ";")] = '\0';
+
+ builtin_prog = clCreateProgramWithBuiltInKernels(env->context->cl_ctx,
+ 1, &env->device_id,
+ kernel_name,
+ &errNo);
+ if (errNo == CL_SUCCESS)
+ builtin_kernel = clCreateKernel(builtin_prog, kernel_name, &errNo);
+
+ if (errNo == CL_SUCCESS) {
+ test(builtin_kernel, env->device_id, CL_KERNEL_GLOBAL_WORK_SIZE,
+ CL_SUCCESS, &result);
+
+ clReleaseKernel(builtin_kernel);
+ clReleaseProgram(builtin_prog);
+ } else {
+ clReleaseProgram(builtin_prog);
+
+ fprintf(stderr,
+ "Warn (error code: %s): error while creating built-in kernel test.\n",
+ piglit_cl_get_error_name(errNo));
+ piglit_merge_result(&result, PIGLIT_WARN);
+ }
+
+ free(kernel_name);
+ }
+
+ //test with custom device
+ if (*dev_type == CL_DEVICE_TYPE_CUSTOM)
+ test(kernel, env->device_id, CL_KERNEL_GLOBAL_WORK_SIZE,
+ CL_SUCCESS, &result);
+
+
+ /*** Errors ***/
+
+ /*
+ * If device is not a custom device or kernel is not a built-in kernel,
+ * clGetKernelArgInfo returns the error
+ * CL_INVALID_VALUE.
+ */
+ if (*dev_type != CL_DEVICE_TYPE_CUSTOM)
+ if (!test(kernel, env->device_id, CL_KERNEL_GLOBAL_WORK_SIZE,
+ CL_INVALID_VALUE, &result))
+ fprintf(stderr,
+ " Trigger CL_INVALID_VALUE if device is not a custom device.\n");
+
+ if (!test(kernel, env->device_id, CL_KERNEL_GLOBAL_WORK_SIZE,
+ CL_INVALID_VALUE, &result))
+ fprintf(stderr,
+ " Trigger CL_INVALID_VALUE if kernel is not a built-in kernel.\n");
+
+ }
+#endif
+
/*** Errors ***/
/*
@@ -141,6 +245,7 @@ piglit_cl_test(const int argc,
piglit_merge_result(&result, PIGLIT_FAIL);
}
+ param_value = ¶m_value_size;
errNo = clGetKernelWorkGroupInfo(kernel,
env->device_id,
CL_KERNEL_WORK_GROUP_SIZE,
--
2.2.0
More information about the Beignet
mailing list