summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2014-12-04 10:52:10 +0800
committerZhigang Gong <zhigang.gong@intel.com>2015-01-12 09:30:35 +0800
commitf7f15de3b206a8e48de94dd4ef8bcd35dff88ee0 (patch)
treefca0c0ed2e368392db0d3f450c4132df69a731b7
parent7c9def15e1b2001fe0c9e562157640fc27bd47a0 (diff)
downloadbeignet-f7f15de3b206a8e48de94dd4ef8bcd35dff88ee0.tar.gz
utests: Add const private array initialization test.
Signed-off-by: Ruiling Song <ruiling.song@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--kernels/compiler_private_const.cl9
-rw-r--r--utests/CMakeLists.txt1
-rw-r--r--utests/compiler_private_const.cpp27
3 files changed, 37 insertions, 0 deletions
diff --git a/kernels/compiler_private_const.cl b/kernels/compiler_private_const.cl
new file mode 100644
index 00000000..7fad369d
--- /dev/null
+++ b/kernels/compiler_private_const.cl
@@ -0,0 +1,9 @@
+constant int x[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+__kernel void
+compiler_private_const( __global int *dst)
+{
+ const int array0[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+ dst[get_global_id(0)] = array0[get_global_id(0)] + x[get_global_id(0)];
+}
+
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index 9fcad7ee..8c42f1ac 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -181,6 +181,7 @@ set (utests_sources
compiler_function_argument3.cpp
compiler_function_qualifiers.cpp
compiler_bool_cross_basic_block.cpp
+ compiler_private_const.cpp
compiler_private_data_overflow.cpp
compiler_getelementptr_bitcast.cpp
compiler_simd_any.cpp
diff --git a/utests/compiler_private_const.cpp b/utests/compiler_private_const.cpp
new file mode 100644
index 00000000..d5fa982e
--- /dev/null
+++ b/utests/compiler_private_const.cpp
@@ -0,0 +1,27 @@
+#include "utest_helper.hpp"
+
+void compiler_private_const(void)
+{
+ const size_t n = 16;
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_private_const");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+ globals[0] = n;
+ locals[0] = n;
+
+
+ // Run the kernel on GPU
+ OCL_NDRANGE(1);
+
+ // Compare
+ OCL_MAP_BUFFER(0);
+ for (size_t i = 0; i < n; ++i)
+ OCL_ASSERT(((int32_t*)buf_data[0])[i] == (int32_t)(i * 2));
+ OCL_UNMAP_BUFFER(0);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_private_const);
+
+