summaryrefslogtreecommitdiff
path: root/utests/builtin_sub_group_size.cpp
diff options
context:
space:
mode:
authorPan Xiuli <xiuli.pan@intel.com>2016-05-12 09:13:26 +0800
committerYang Rong <rong.r.yang@intel.com>2016-06-13 17:02:16 +0800
commitb37871995fab6601936460d17180cccb7a5b0dee (patch)
treef7ba10fc6752755b2f615038119124935ce5d8d1 /utests/builtin_sub_group_size.cpp
parenta2dd4f9bdc55026c9667db8b2d44a9dd529785e7 (diff)
downloadbeignet-b37871995fab6601936460d17180cccb7a5b0dee.tar.gz
Utest: Add subgroup work item test cases
Signed-off-by: Pan Xiuli <xiuli.pan@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'utests/builtin_sub_group_size.cpp')
-rw-r--r--utests/builtin_sub_group_size.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/utests/builtin_sub_group_size.cpp b/utests/builtin_sub_group_size.cpp
new file mode 100644
index 00000000..1dc24edb
--- /dev/null
+++ b/utests/builtin_sub_group_size.cpp
@@ -0,0 +1,61 @@
+/*
+According to the OpenCL cl_intel_subgroups.
+Now define local and global size as following:
+ globals[0] = 4;
+ globals[1] = 9;
+ globals[2] = 16;
+ locals[0] = 2;
+ locals[1] = 3;
+ locals[2] = 4;
+*/
+
+#define udebug 0
+#include "utest_helper.hpp"
+static void builtin_sub_group_size(void)
+{
+
+ // Setup kernel and buffers
+ size_t dim, i,local_sz = 1,buf_len = 1;
+ OCL_CREATE_KERNEL("builtin_sub_group_size");
+ size_t max_sub_sz;
+
+
+ OCL_CREATE_BUFFER(buf[0], CL_MEM_READ_WRITE, sizeof(int)*576, NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+
+ for( dim=1; dim <= 3; dim++ )
+ {
+ buf_len = 1;
+ local_sz = 1;
+ for(i=1; i <= dim; i++)
+ {
+ locals[i - 1] = i + 1;
+ globals[i - 1] = (i + 1) * (i + 1);
+ buf_len *= ((i + 1) * (i + 1));
+ local_sz *= i + 1;
+ }
+ for(i = dim+1; i <= 3; i++)
+ {
+ globals[i - 1] = 0;
+ locals[i - 1] = 0;
+ }
+
+ OCL_CALL(clGetKernelSubGroupInfoKHR,kernel,device,CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR,sizeof(size_t)*dim,locals,sizeof(size_t),&max_sub_sz,NULL);
+ // Run the kernel
+ OCL_NDRANGE( dim );
+ clFinish(queue);
+
+ OCL_MAP_BUFFER(0);
+
+ for( i = 0; i < buf_len; i++) {
+ size_t expect_sz = (i % local_sz) < (local_sz / max_sub_sz * max_sub_sz) ? max_sub_sz : (local_sz % max_sub_sz);
+#if udebug
+ printf("%zu get %d, expect %zu\n",i, ((uint32_t*)buf_data[0])[i], expect_sz);
+#endif
+ OCL_ASSERT( ((uint32_t*)buf_data[0])[i] == expect_sz);
+ }
+ OCL_UNMAP_BUFFER(0);
+ }
+}
+
+MAKE_UTEST_FROM_FUNCTION(builtin_sub_group_size);