diff options
author | Ruiling Song <ruiling.song@intel.com> | 2014-12-04 10:52:10 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-12-04 14:56:26 +0800 |
commit | 9952ef26aa4358af7281d59b873a4a2f52d32c2f (patch) | |
tree | ca55e2c8f3bc948fc4feb84f0ca4ee953a53ad19 | |
parent | 07475bc0b4b6a588cb0326b5f156e6f2e8a888f3 (diff) |
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.cl | 9 | ||||
-rw-r--r-- | utests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | utests/compiler_private_const.cpp | 27 |
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 d98c0ec2..05f1fcfd 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 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); + + |