summaryrefslogtreecommitdiff
path: root/utests
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2013-10-10 15:13:50 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-10-14 17:33:09 +0800
commitd0c6d8fe26e150ef457b72249aec6a163c841e81 (patch)
tree51fbf084bba1246dfd06e0f56c633842b61438e4 /utests
parent4a8288440cbb47f0a444ae988c56906807943856 (diff)
GBE: Support local variable inside kernel function.
As Clang treat local variable in similar way like global constant, (they are treated as Global variable in each own address space) we refine the previous constant implementation in order to share same code between local variable and global constant. We will allocate an address register for each GlobalVariable (constant or local) through calling newRegister(). In later step, through getRegister() we will get a proper register derived from the allocated address register. Signed-off-by: Ruiling Song <ruiling.song@intel.com> Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Diffstat (limited to 'utests')
-rw-r--r--utests/CMakeLists.txt1
-rw-r--r--utests/compiler_local_slm.cpp30
2 files changed, 28 insertions, 3 deletions
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index a24c4900..daa4d6f5 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -96,6 +96,7 @@ set (utests_sources
compiler_local_memory_barrier.cpp
compiler_local_memory_barrier_wg64.cpp
compiler_local_memory_barrier_2.cpp
+ compiler_local_slm.cpp
compiler_movforphi_undef.cpp
compiler_volatile.cpp
compiler_copy_image1.cpp
diff --git a/utests/compiler_local_slm.cpp b/utests/compiler_local_slm.cpp
index aa9a2fec..48a072fa 100644
--- a/utests/compiler_local_slm.cpp
+++ b/utests/compiler_local_slm.cpp
@@ -2,9 +2,33 @@
void compiler_local_slm(void)
{
- // Setup kernel and buffers
- OCL_CREATE_KERNEL("compiler_local_slm");
+ const size_t n = 32;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_local_slm", "compiler_local_slm");
+ 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] = 16;
+ OCL_NDRANGE(1);
+ OCL_MAP_BUFFER(0);
+ for (uint32_t i = 0; i < n; ++i)
+// std::cout << ((int32_t*)buf_data[0])[i] << std::endl;
+ OCL_ASSERT(((int32_t*)buf_data[0])[i] == (i%16 + 2 + 1+ i/16));
+ OCL_UNMAP_BUFFER(0);
}
+void compiler_local_slm1(void)
+{
+ const size_t n = 2;
+ OCL_CREATE_KERNEL_FROM_FILE("compiler_local_slm", "compiler_local_slm1");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint64_t), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+ globals[0] = 1;
+ locals[0] = 1;
+ OCL_NDRANGE(1);
+ OCL_MAP_BUFFER(0);
+ uint64_t * ptr = (uint64_t*)buf_data[0];
+ OCL_ASSERT((ptr[1] -ptr[0]) == 4);
+ OCL_UNMAP_BUFFER(0);
+}
MAKE_UTEST_FROM_FUNCTION(compiler_local_slm);
-
+MAKE_UTEST_FROM_FUNCTION(compiler_local_slm1);