[Beignet] [PATCH] runtime: fix a conformance bug in cl_get_kernel_arg_info.

Weng, Chuanbo chuanbo.weng at intel.com
Wed Mar 18 01:28:34 PDT 2015


This patch could fix the API/ get_kernel_arg_info fail case in Khronos OpenCL 1.2 conformance test.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Zhigang Gong
Sent: Wednesday, March 18, 2015 15:08
To: beignet at lists.freedesktop.org
Cc: Gong, Zhigang
Subject: [Beignet] [PATCH] runtime: fix a conformance bug in cl_get_kernel_arg_info.

Accordying to OpenCL 1.2 Rev 17:
"CL_KERNEL_ARG_TYPE_CONST is returned if the argument is a pointer and the referenced type is declared with the restrict or const qualifier. For example, a kernel argument declared as global int const *x returns CL_KERNEL_ARG_TYPE_CONST but a kernel argument declared as global int * const x does not."

So only need to return CL_KERNEL_ARG_TYPE_CONST for pointer arguments.

Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
 src/cl_kernel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/cl_kernel.c b/src/cl_kernel.c index 331d250..28d88b6 100644
--- a/src/cl_kernel.c
+++ b/src/cl_kernel.c
@@ -221,6 +221,7 @@ cl_get_kernel_arg_info(cl_kernel k, cl_uint arg_index, cl_kernel_arg_info param_
   assert(k != NULL);
   void *ret_info = interp_kernel_get_arg_info(k->opaque, arg_index,
                            param_name - CL_KERNEL_ARG_ADDRESS_QUALIFIER);
+  uint32_t arg_type = interp_kernel_get_arg_type(k->opaque, arg_index);
   int str_len = 0;
   cl_kernel_arg_type_qualifier type_qual = CL_KERNEL_ARG_TYPE_NONE;
 
@@ -281,7 +282,10 @@ cl_get_kernel_arg_info(cl_kernel k, cl_uint arg_index, cl_kernel_arg_info param_
     if (param_value_size_ret)
       *param_value_size_ret = sizeof(cl_kernel_arg_type_qualifier);
     if (!param_value) return CL_SUCCESS;
-    if (strstr((char*)ret_info, "const"))
+    if (strstr((char*)ret_info, "const") &&
+         (arg_type == GBE_ARG_GLOBAL_PTR   ||
+          arg_type == GBE_ARG_CONSTANT_PTR ||
+          arg_type == GBE_ARG_LOCAL_PTR))
       type_qual = type_qual | CL_KERNEL_ARG_TYPE_CONST;
     if (strstr((char*)ret_info, "volatile"))
       type_qual = type_qual | CL_KERNEL_ARG_TYPE_VOLATILE;
--
1.9.1

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list