summaryrefslogtreecommitdiff
path: root/utests/compiler_global_constant_2.cpp
diff options
context:
space:
mode:
authorHomer Hsing <homer.xing@intel.com>2013-05-02 11:12:20 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-05-02 12:57:00 +0800
commit63e60ed2686b22c1a098ffec7f533a7e95f2c773 (patch)
treecd2a947973b007b811d3717f82bdfe6500f1e35a /utests/compiler_global_constant_2.cpp
parentd0f10c38843b1f8f1e3a688b86a4139661816583 (diff)
downloadbeignet-63e60ed2686b22c1a098ffec7f533a7e95f2c773.tar.gz
test cases for global constant arrays
version 4 Signed-off-by: Homer Hsing <homer.xing@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'utests/compiler_global_constant_2.cpp')
-rw-r--r--utests/compiler_global_constant_2.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/utests/compiler_global_constant_2.cpp b/utests/compiler_global_constant_2.cpp
new file mode 100644
index 00000000..56fccb57
--- /dev/null
+++ b/utests/compiler_global_constant_2.cpp
@@ -0,0 +1,30 @@
+#include "utest_helper.hpp"
+
+void compiler_global_constant_2(void)
+{
+ const size_t n = 2048;
+ const uint32_t e = 34, r = 77;
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_global_constant_2");
+ 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(uint32_t), &e);
+ OCL_SET_ARG(2, sizeof(uint32_t), &r);
+
+ // Run the kernel
+ globals[0] = n;
+ locals[0] = 16;
+ OCL_NDRANGE(1);
+
+ unsigned int m[3] = {0x15b,0x25b,0x35b};
+ unsigned int t[5] = {0x45b,0x55b,0x65b,0x75b,0x85b};
+
+ // Check results
+ OCL_MAP_BUFFER(0);
+ for (uint32_t i = 0; i < n; ++i)
+ OCL_ASSERT(((uint32_t *)buf_data[0])[i] == m[i%3] + t[i%5] + e + r);
+ OCL_UNMAP_BUFFER(0);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_global_constant_2);