[Beignet] [PATCH 2/2] add test case for null kernel arg of global/constant buffer
Ruiling Song
ruiling.song at intel.com
Wed Jun 12 23:00:26 PDT 2013
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
kernels/null_kernel_arg.cl | 10 ++++++++++
utests/CMakeLists.txt | 1 +
utests/runtime_null_kernel_arg.cpp | 28 ++++++++++++++++++++++++++++
3 files changed, 39 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..e05f42f
--- /dev/null
+++ b/kernels/null_kernel_arg.cl
@@ -0,0 +1,10 @@
+__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 d883cfd..0315e89 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -81,6 +81,7 @@ set (utests_sources
compiler_vector_load_store.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..d655d6f
--- /dev/null
+++ b/utests/runtime_null_kernel_arg.cpp
@@ -0,0 +1,28 @@
+#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