summaryrefslogtreecommitdiff
path: root/utests
diff options
context:
space:
mode:
authorPan Xiuli <xiuli.pan@intel.com>2015-12-11 13:28:57 +0800
committerYang Rong <rong.r.yang@intel.com>2015-12-14 16:22:13 +0800
commit0b1e6e2faffbc636801464c57be0969ac5cd91ee (patch)
treed7cc39c7a7f3ac9beebf8f43141a2745e4bbbd1b /utests
parent19fc80c432f748bd192d845ee58598352f0d898f (diff)
Utest: Add a bitonic sort test for non-constant extractelement
This test case is for the new added non-constand index extractelement path in llvm_scalarize pass. Signed-off-by: Pan Xiuli <xiuli.pan@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'utests')
-rw-r--r--utests/CMakeLists.txt3
-rw-r--r--utests/compiler_bsort.cpp45
2 files changed, 47 insertions, 1 deletions
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index 74189c62..d846b7b7 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -225,7 +225,8 @@ set (utests_sources
compiler_sub_group_shuffle.cpp
builtin_global_linear_id.cpp
builtin_local_linear_id.cpp
- compiler_mix.cpp)
+ compiler_mix.cpp
+ compiler_bsort.cpp)
if (LLVM_VERSION_NODOT VERSION_GREATER 34)
SET(utests_sources
diff --git a/utests/compiler_bsort.cpp b/utests/compiler_bsort.cpp
new file mode 100644
index 00000000..31607aaf
--- /dev/null
+++ b/utests/compiler_bsort.cpp
@@ -0,0 +1,45 @@
+#include "utest_helper.hpp"
+/*
+ * This test is for non-constant extractelement scalarize
+ * this bitonic sort test will use this path in
+ *
+ * comp = input < shuffle(input, mask1) ^ dir; \
+ * input = shuffle(input, as_uint4(comp + add1)); \
+ *
+ * The origin buff is
+ * {3.0 5.0 4.0 6.0 0.0 7.0 2.0 1.0}
+ * and the expected result is
+ * {0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0}
+ */
+void compiler_bsort(void)
+{
+ const int n = 8;
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_bsort");
+ OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(float), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+ globals[0] = 1;
+ locals[0] = 1;
+
+ OCL_MAP_BUFFER(0);
+ ((float *)(buf_data[0]))[0] = 3.0f;
+ ((float *)(buf_data[0]))[1] = 5.0f;
+ ((float *)(buf_data[0]))[2] = 4.0f;
+ ((float *)(buf_data[0]))[3] = 6.0f;
+ ((float *)(buf_data[0]))[4] = 0.0f;
+ ((float *)(buf_data[0]))[5] = 7.0f;
+ ((float *)(buf_data[0]))[6] = 2.0f;
+ ((float *)(buf_data[0]))[7] = 1.0f;
+ OCL_UNMAP_BUFFER(0);
+
+ OCL_NDRANGE(1);
+
+ OCL_MAP_BUFFER(0);
+ for (int i = 0; i < n; i ++) {
+ OCL_ASSERT(((float *)(buf_data[0]))[i] == (float)i);
+ }
+ OCL_UNMAP_BUFFER(0);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_bsort);