diff options
author | Pan Xiuli <xiuli.pan@intel.com> | 2016-07-18 15:06:29 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-07-20 17:35:47 +0800 |
commit | 4c599b9b086cc92ae30d5ffeac190166d76d97ea (patch) | |
tree | 1380d681f2318cdf61f93b7299b724dc0129aa1b /utests/compiler_sub_group_shuffle_xor.cpp | |
parent | b522871956a8dc911a3ceb049d4d4e476a94845a (diff) | |
download | beignet-4c599b9b086cc92ae30d5ffeac190166d76d97ea.tar.gz |
Utest: Add test case for sub_group_shuffle_down/up/xor
V2:Add subgroups extension check.
Signed-off-by: Pan Xiuli <xiuli.pan@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'utests/compiler_sub_group_shuffle_xor.cpp')
-rw-r--r-- | utests/compiler_sub_group_shuffle_xor.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/utests/compiler_sub_group_shuffle_xor.cpp b/utests/compiler_sub_group_shuffle_xor.cpp new file mode 100644 index 00000000..967ec3ed --- /dev/null +++ b/utests/compiler_sub_group_shuffle_xor.cpp @@ -0,0 +1,48 @@ +#include "utest_helper.hpp" + +void compiler_sub_group_shuffle_xor(void) +{ + if(!cl_check_subgroups()) + return; + const size_t n = 32; + const int32_t buf_size = 4 * n + 1; + + // Setup kernel and buffers + OCL_CREATE_KERNEL("compiler_sub_group_shuffle_xor"); + OCL_CREATE_BUFFER(buf[0], 0, buf_size * sizeof(int), NULL); + OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]); + + int c = 3; + OCL_SET_ARG(1, sizeof(int), &c); + + globals[0] = n; + locals[0] = 16; + + OCL_MAP_BUFFER(0); + for (int32_t i = 0; i < buf_size; ++i) + ((int*)buf_data[0])[i] = -1; + OCL_UNMAP_BUFFER(0); + + // Run the kernel on GPU + OCL_NDRANGE(1); + + // Compare + OCL_MAP_BUFFER(0); + int* dst = (int *)buf_data[0]; + int suggroupsize = dst[0]; + OCL_ASSERT(suggroupsize == 8 || suggroupsize == 16); + + dst++; + for (int32_t i = 0; i < (int32_t) n; ++i){ + int round = i / suggroupsize; + int index = i % suggroupsize; + OCL_ASSERT(index == dst[4*i]); + //printf("%d %d %d %d\n", i, dst[4*i+1], dst[4*i+2], dst[4*i+3]); + OCL_ASSERT((round * suggroupsize + (c ^ index)) == dst[4*i+1]); + OCL_ASSERT((round * suggroupsize + (index ^ (suggroupsize - index -1))) == dst[4*i+2]); + OCL_ASSERT((round * suggroupsize + (index ^ (index + 1) % suggroupsize)) == dst[4*i+3]); + } + OCL_UNMAP_BUFFER(0); +} + +MAKE_UTEST_FROM_FUNCTION(compiler_sub_group_shuffle_xor); |