[Beignet] [PATCH 4/4 opencl 1.2] Add the utest case for clGetKernelArgInfo
junyan.he at inbox.com
junyan.he at inbox.com
Sun Jun 8 23:39:06 PDT 2014
From: Junyan He <junyan.he at linux.intel.com>
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
kernels/test_get_arg_info.cl | 8 +++++
utests/CMakeLists.txt | 1 +
utests/get_arg_info.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+)
create mode 100644 kernels/test_get_arg_info.cl
create mode 100644 utests/get_arg_info.cpp
diff --git a/kernels/test_get_arg_info.cl b/kernels/test_get_arg_info.cl
new file mode 100644
index 0000000..b9201a4
--- /dev/null
+++ b/kernels/test_get_arg_info.cl
@@ -0,0 +1,8 @@
+typedef struct _test_arg_struct {
+ int a;
+ int b;
+}test_arg_struct;
+
+kernel void test_get_arg_info(global float const volatile *src, local int *dst, test_arg_struct extra) {
+
+}
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index 698c9ff..02a302f 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -176,6 +176,7 @@ set (utests_sources
compiler_simd_any.cpp
compiler_simd_all.cpp
load_program_from_bin.cpp
+ get_arg_info.cpp
profiling_exec.cpp
enqueue_copy_buf.cpp
enqueue_copy_buf_unaligned.cpp
diff --git a/utests/get_arg_info.cpp b/utests/get_arg_info.cpp
new file mode 100644
index 0000000..c1ea1ef
--- /dev/null
+++ b/utests/get_arg_info.cpp
@@ -0,0 +1,85 @@
+#include <string.h>
+#include "utest_helper.hpp"
+
+void test_get_arg_info(void)
+{
+ int ret;
+ uint32_t ret_val;
+ cl_kernel_arg_type_qualifier type_qual;
+ size_t ret_sz;
+ char name[64];
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("test_get_arg_info");
+
+ //Arg 0
+ ret = clGetKernelArgInfo(kernel, 0, CL_KERNEL_ARG_ADDRESS_QUALIFIER,
+ sizeof(ret_val), &ret_val, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == sizeof(cl_kernel_arg_address_qualifier));
+ OCL_ASSERT(ret_val == CL_KERNEL_ARG_ADDRESS_GLOBAL);
+
+ ret = clGetKernelArgInfo(kernel, 0, CL_KERNEL_ARG_ACCESS_QUALIFIER,
+ sizeof(ret_val), &ret_val, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == sizeof(cl_kernel_arg_access_qualifier));
+ OCL_ASSERT(ret_val == CL_KERNEL_ARG_ACCESS_NONE);
+
+ ret = clGetKernelArgInfo(kernel, 0, CL_KERNEL_ARG_TYPE_NAME,
+ sizeof(name), name, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == strlen("float*") + 1);
+ OCL_ASSERT(!strcmp(name, "float*"));
+
+ ret = clGetKernelArgInfo(kernel, 0, CL_KERNEL_ARG_NAME,
+ sizeof(name), name, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == strlen("src") + 1);
+ OCL_ASSERT(!strcmp(name, "src"));
+
+ ret = clGetKernelArgInfo(kernel, 0, CL_KERNEL_ARG_TYPE_QUALIFIER,
+ sizeof(type_qual), &type_qual, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == sizeof(cl_kernel_arg_type_qualifier));
+ OCL_ASSERT(type_qual == (CL_KERNEL_ARG_TYPE_CONST|CL_KERNEL_ARG_TYPE_VOLATILE));
+
+ //Arg 1
+ ret = clGetKernelArgInfo(kernel, 1, CL_KERNEL_ARG_ADDRESS_QUALIFIER,
+ sizeof(ret_val), &ret_val, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == sizeof(cl_kernel_arg_address_qualifier));
+ OCL_ASSERT(ret_val == CL_KERNEL_ARG_ADDRESS_LOCAL);
+
+ ret = clGetKernelArgInfo(kernel, 1, CL_KERNEL_ARG_ACCESS_QUALIFIER,
+ sizeof(ret_val), &ret_val, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == sizeof(cl_kernel_arg_access_qualifier));
+ OCL_ASSERT(ret_val == CL_KERNEL_ARG_ACCESS_NONE);
+
+ ret = clGetKernelArgInfo(kernel, 1, CL_KERNEL_ARG_TYPE_NAME,
+ sizeof(name), name, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == strlen("int*") + 1);
+ OCL_ASSERT(!strcmp(name, "int*"));
+
+ ret = clGetKernelArgInfo(kernel, 1, CL_KERNEL_ARG_NAME,
+ sizeof(name), name, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == strlen("dst") + 1);
+ OCL_ASSERT(!strcmp(name, "dst"));
+
+ ret = clGetKernelArgInfo(kernel, 1, CL_KERNEL_ARG_TYPE_QUALIFIER,
+ sizeof(type_qual), &type_qual, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == sizeof(cl_kernel_arg_type_qualifier));
+ OCL_ASSERT(type_qual == CL_KERNEL_ARG_TYPE_NONE);
+
+ //Arg 2
+ ret = clGetKernelArgInfo(kernel, 2, CL_KERNEL_ARG_TYPE_NAME,
+ sizeof(name), name, &ret_sz);
+ OCL_ASSERT(ret == CL_SUCCESS);
+ OCL_ASSERT(ret_sz == strlen("test_arg_struct") + 1);
+ OCL_ASSERT(!strcmp(name, "test_arg_struct"));
+}
+
+MAKE_UTEST_FROM_FUNCTION(test_get_arg_info);
--
1.8.3.2
More information about the Beignet
mailing list