summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2014-11-06 15:44:49 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-11-06 15:16:07 +0800
commit56aaa7ed21b653d39216caeafb7559fba20e86a8 (patch)
treeb201a7e14cc61c8bd10fe895c19f74ceb3656bd4
parent8b41bb61600aa725fa2c67b15845971e8e6dc465 (diff)
utests: add a test to trigger cl_float3 bug in clSetKernelArg.
Signed-off-by: Ruiling Song <ruiling.song@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--kernels/set_kernel_arg.cl20
-rw-r--r--utests/CMakeLists.txt1
-rw-r--r--utests/runtime_set_kernel_arg.cpp30
3 files changed, 51 insertions, 0 deletions
diff --git a/kernels/set_kernel_arg.cl b/kernels/set_kernel_arg.cl
new file mode 100644
index 00000000..71cf521a
--- /dev/null
+++ b/kernels/set_kernel_arg.cl
@@ -0,0 +1,20 @@
+__kernel void
+set_kernel_arg(__global unsigned int *dst, float3 src)
+{
+ size_t gid = get_global_id(0);
+
+ switch (gid%3)
+ {
+ case 0:
+ dst[gid] = src.x;
+ break;
+ case 1:
+ dst[gid] = src.y;
+ break;
+ case 2:
+ dst[gid] = src.z;
+ break;
+ default:
+ break;
+ }
+}
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index 30623b37..b0225466 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -155,6 +155,7 @@ set (utests_sources
builtin_convert_sat.cpp
sub_buffer.cpp
runtime_createcontext.cpp
+ runtime_set_kernel_arg.cpp
runtime_null_kernel_arg.cpp
runtime_event.cpp
runtime_barrier_list.cpp
diff --git a/utests/runtime_set_kernel_arg.cpp b/utests/runtime_set_kernel_arg.cpp
new file mode 100644
index 00000000..d58c77e4
--- /dev/null
+++ b/utests/runtime_set_kernel_arg.cpp
@@ -0,0 +1,30 @@
+#include "utest_helper.hpp"
+
+void runtime_set_kernel_arg(void)
+{
+ const size_t n = 16;
+
+ cl_float3 src;
+ src.s[0] = 1; src.s[1] =2; src.s[2] = 3;
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("set_kernel_arg");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+ OCL_SET_ARG(1, sizeof(cl_float3), &src);
+
+ // Run the kernel
+ globals[0] = n;
+ locals[0] = 16;
+ OCL_NDRANGE(1);
+ OCL_MAP_BUFFER(0);
+
+ // Check results
+ for (uint32_t i = 0; i < n; ++i) {
+// printf("%d %d\n",i, ((uint32_t*)buf_data[0])[i]);
+ OCL_ASSERT(((uint32_t*)buf_data[0])[i] == src.s[i%3]);
+ }
+ OCL_UNMAP_BUFFER(0);
+}
+
+MAKE_UTEST_FROM_FUNCTION(runtime_set_kernel_arg);