utest: do not check the padding componenet for 3-component vector data types

Submitted by Guo Yejun on July 24, 2016, 11:04 p.m.

Details

Message ID 1469401466-5465-1-git-send-email-yejun.guo@intel.com
State New
Headers show
Series "utest: do not check the padding componenet for 3-component vector data types" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Guo Yejun July 24, 2016, 11:04 p.m.
Per OPenCL 1.2 spec 6.1.5: For 3-component vector data types, the
size of the data type is 4 * sizeof(component). The spec does not
explicitly say what the padding componenet will be, it should be
implementation-dependent, so, do not check the padding componenet
in the unit test.

Signed-off-by: Guo Yejun <yejun.guo@intel.com>
---
 utests/compiler_abs.cpp      | 18 +++++++++++++++++-
 utests/compiler_abs_diff.cpp | 17 ++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/utests/compiler_abs.cpp b/utests/compiler_abs.cpp
index 3f477a8..49b381d 100644
--- a/utests/compiler_abs.cpp
+++ b/utests/compiler_abs.cpp
@@ -119,6 +119,18 @@  template <typename T, typename U> static void dump_data (T* src, U* dst, int n)
     }
 }
 
+template <typename T>
+static void check_result(T* actual, T* expected)
+{
+    OCL_ASSERT(*actual == *expected);
+}
+
+template <typename T, int N>
+static void check_result(cl_vec<T, N>* actual, cl_vec<T, N>* expected)
+{
+    OCL_ASSERT(!memcmp(actual, expected, sizeof(T)*N));
+}
+
 template <typename T, typename U> static void compiler_abs_with_type(void)
 {
     const size_t n = 16;
@@ -160,7 +172,11 @@  template <typename T, typename U> static void compiler_abs_with_type(void)
 
 //      dump_data(cpu_src, cpu_dst, n);
 
-        OCL_ASSERT(!memcmp(buf_data[1], cpu_dst, sizeof(T) * n));
+        U* actual = (U*)buf_data[1];
+        U* expected = cpu_dst;
+        for (size_t i = 0; i < n; ++i)
+            check_result(&actual[i], &expected[i]);
+
         OCL_UNMAP_BUFFER(1);
         OCL_UNMAP_BUFFER(0);
     }
diff --git a/utests/compiler_abs_diff.cpp b/utests/compiler_abs_diff.cpp
index 15a1f90..1df7d47 100644
--- a/utests/compiler_abs_diff.cpp
+++ b/utests/compiler_abs_diff.cpp
@@ -127,6 +127,18 @@  template <typename T, typename U> static void dump_data (T* x, T* y, U* diff, in
     }
 }
 
+template <typename T>
+static void check_result(T* actual, T* expected)
+{
+    OCL_ASSERT(*actual == *expected);
+}
+
+template <typename T, int N>
+static void check_result(cl_vec<T, N>* actual, cl_vec<T, N>* expected)
+{
+    OCL_ASSERT(!memcmp(actual, expected, sizeof(T)*N));
+}
+
 template <typename T, typename U> static void compiler_abs_diff_with_type(void)
 {
     const size_t n = 16;
@@ -174,7 +186,10 @@  template <typename T, typename U> static void compiler_abs_diff_with_type(void)
 
 //      dump_data(cpu_x, cpu_y, cpu_diff, n);
 
-        OCL_ASSERT(!memcmp(buf_data[2], cpu_diff, sizeof(T) * n));
+        U* actual = (U*)buf_data[2];
+        U* expected = cpu_diff;
+        for (size_t i = 0; i < n; ++i)
+            check_result(&actual[i], &expected[i]);
 
         OCL_UNMAP_BUFFER(0);
         OCL_UNMAP_BUFFER(1);