[Beignet] [PATCH 2/3] utests: Add const private array initialization test.
Ruiling Song
ruiling.song at intel.com
Wed Dec 3 18:52:10 PST 2014
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
kernels/compiler_private_const.cl | 9 +++++++++
utests/CMakeLists.txt | 1 +
utests/compiler_private_const.cpp | 27 +++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
create mode 100644 kernels/compiler_private_const.cl
create mode 100644 utests/compiler_private_const.cpp
diff --git a/kernels/compiler_private_const.cl b/kernels/compiler_private_const.cl
new file mode 100644
index 0000000..946fb07
--- /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 __private 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 d98c0ec..05f1fcf 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -172,6 +172,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 0000000..d5fa982
--- /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);
+
+
--
1.7.10.4
More information about the Beignet
mailing list