summaryrefslogtreecommitdiff
path: root/utests/compiler_group_size.cpp
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2013-05-31 15:58:31 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-05-31 16:49:58 +0800
commit52db44a48e31df3e6782eaa40c98629205658f69 (patch)
tree1e386df7aa10e5972b67c250c71815d8793bdc92 /utests/compiler_group_size.cpp
parent5be70c1b008a264886fcccdd6cef04582d5a1982 (diff)
downloadbeignet-52db44a48e31df3e6782eaa40c98629205658f69.tar.gz
Add test case for group size
Signed-off-by: Ruiling Song <ruiling.song@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'utests/compiler_group_size.cpp')
-rw-r--r--utests/compiler_group_size.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/utests/compiler_group_size.cpp b/utests/compiler_group_size.cpp
new file mode 100644
index 00000000..6d59aedd
--- /dev/null
+++ b/utests/compiler_group_size.cpp
@@ -0,0 +1,86 @@
+#include "utest_helper.hpp"
+
+void compiler_group_size1(void)
+{
+ const size_t n = 7*32*17;
+
+ int group_size[] = {7, 17, 32};
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_group_size");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+
+ for(int i = 0; i < 3; i++) {
+ // Run the kernel
+ globals[0] = n;
+ locals[0] = group_size[i];
+ OCL_NDRANGE(1);
+ OCL_MAP_BUFFER(0);
+
+ // Check results
+ for (uint32_t i = 0; i < n; ++i)
+ OCL_ASSERT(((uint32_t*)buf_data[0])[i] == i);
+ OCL_UNMAP_BUFFER(0);
+ }
+}
+
+void compiler_group_size2(void)
+{
+ const uint32_t n = 4*17*8;
+ int size_x[] = {2, 4, 17};
+ int size_y[] = {2, 4, 4};
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_group_size");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+
+ for(int i = 0; i < 3; i++) {
+ // Run the kernel
+ globals[0] = 4*17;
+ globals[1] = 8;
+ locals[0] = size_x[i];
+ locals[1] = size_y[i];
+ OCL_NDRANGE(2);
+ OCL_MAP_BUFFER(0);
+
+ // Check results
+ for (uint32_t i = 0; i < n; ++i)
+ OCL_ASSERT(((uint32_t*)buf_data[0])[i] == i);
+ OCL_UNMAP_BUFFER(0);
+ }
+}
+
+void compiler_group_size3(void)
+{
+ const uint32_t n = 4*17*8*4;
+ int size_x[] = {2, 4, 17};
+ int size_y[] = {2, 4, 4};
+ int size_z[] = {2, 1, 2};
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_group_size");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+
+ for(int i = 0; i < 3; i++) {
+ // Run the kernel
+ globals[0] = 4*17;
+ globals[1] = 8;
+ globals[2] = 4;
+ locals[0] = size_x[i];
+ locals[1] = size_y[i];
+ locals[2] = size_z[i];
+ OCL_NDRANGE(3);
+ OCL_MAP_BUFFER(0);
+
+ // Check results
+ for (uint32_t i = 0; i < n; ++i)
+ OCL_ASSERT(((uint32_t*)buf_data[0])[i] == i);
+ OCL_UNMAP_BUFFER(0);
+ }
+}
+MAKE_UTEST_FROM_FUNCTION(compiler_group_size1);
+MAKE_UTEST_FROM_FUNCTION(compiler_group_size2);
+MAKE_UTEST_FROM_FUNCTION(compiler_group_size3);
+