[Beignet] [PATCH V2 2/2] add test case for null kernel arg of global/constant buffer

Ruiling Song ruiling.song at intel.com
Fri Jun 14 01:32:54 PDT 2013


Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
 kernels/null_kernel_arg.cl         |    9 +++++++++
 utests/CMakeLists.txt              |    1 +
 utests/runtime_null_kernel_arg.cpp |   27 +++++++++++++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 kernels/null_kernel_arg.cl
 create mode 100644 utests/runtime_null_kernel_arg.cpp

diff --git a/kernels/null_kernel_arg.cl b/kernels/null_kernel_arg.cl
new file mode 100644
index 0000000..68a4280
--- /dev/null
+++ b/kernels/null_kernel_arg.cl
@@ -0,0 +1,9 @@
+__kernel void
+null_kernel_arg(__global unsigned int *dst, __global unsigned int * mask_global, __constant unsigned int* mask_const)
+{
+  if(dst && mask_global==0 && mask_const == NULL)
+  {
+    uint idx = (uint)get_global_id(0);
+    dst[idx] = idx;
+  }
+}
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index 81ff5d8..8946fbe 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -82,6 +82,7 @@ set (utests_sources
   compiler_cl_finish.cpp
   buildin_work_dim.cpp
   runtime_createcontext.cpp
+  runtime_null_kernel_arg.cpp
   utest_assert.cpp
   utest.cpp
   utest_file_map.cpp
diff --git a/utests/runtime_null_kernel_arg.cpp b/utests/runtime_null_kernel_arg.cpp
new file mode 100644
index 0000000..447e345
--- /dev/null
+++ b/utests/runtime_null_kernel_arg.cpp
@@ -0,0 +1,27 @@
+#include "utest_helper.hpp"
+
+void runtime_null_kernel_arg(void)
+{
+  const size_t n = 32;
+
+  // Setup kernel and buffers
+  OCL_CREATE_KERNEL("null_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_mem), NULL);
+  OCL_SET_ARG(2, sizeof(cl_mem), NULL);
+
+    // 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)
+    OCL_ASSERT(((uint32_t*)buf_data[0])[i] == i);
+  OCL_UNMAP_BUFFER(0);
+}
+
+
+MAKE_UTEST_FROM_FUNCTION(runtime_null_kernel_arg);
-- 
1.7.9.5



More information about the Beignet mailing list