[Beignet] [PATCH v2 2/2] utests: add test case for structure argument

Lu Guanqun guanqun.lu at intel.com
Mon Nov 4 21:25:56 PST 2013


Signed-off-by: Lu Guanqun <guanqun.lu at intel.com>
---
 kernels/compiler_function_argument3.cl |   69 ++++++++++++++++++++++++++++++++
 utests/CMakeLists.txt                  |    1 
 utests/compiler_function_argument3.cpp |   45 +++++++++++++++++++++
 3 files changed, 115 insertions(+)
 create mode 100644 kernels/compiler_function_argument3.cl
 create mode 100644 utests/compiler_function_argument3.cpp

diff --git a/kernels/compiler_function_argument3.cl b/kernels/compiler_function_argument3.cl
new file mode 100644
index 0000000..4df2816
--- /dev/null
+++ b/kernels/compiler_function_argument3.cl
@@ -0,0 +1,69 @@
+struct sfloat8 {
+    float a;
+    float b;
+    float c;
+    float d;
+    float e;
+    float f;
+    float g;
+    float h;
+};
+
+
+__kernel void compiler_function_argument3(
+struct sfloat8 f, __global struct sfloat8 *result)
+{
+  result[0].a = f.a;
+  result[0].b = 12.0f;
+  result[0].c = 12.0f;
+  result[0].d = 12.0f;
+  result[0].e = 12.0f;
+  result[0].f = 12.0f;
+  result[0].g = 12.0f;
+  result[0].h = f.a + f.h;
+
+  result[1].a = f.a;
+  result[1].b = 12.0f;
+  result[1].c = 12.0f;
+  result[1].d = 12.0f;
+  result[1].e = 12.0f;
+  result[1].f = 12.0f;
+  result[1].g = 12.0f;
+  result[1].h = f.a + f.h;
+
+  result[2].a = f.a;
+  result[2].b = 12.0f;
+  result[2].c = 12.0f;
+  result[2].d = 12.0f;
+  result[2].e = 12.0f;
+  result[2].f = 12.0f;
+  result[2].g = 12.0f;
+  result[2].h = f.a + f.h;
+
+  result[3].a = f.a;
+  result[3].b = 12.0f;
+  result[3].c = 12.0f;
+  result[3].d = 12.0f;
+  result[3].e = 12.0f;
+  result[3].f = 12.0f;
+  result[3].g = 12.0f;
+  result[3].h = f.a + f.h;
+
+  result[4].a = f.a;
+  result[4].b = 12.0f;
+  result[4].c = 12.0f;
+  result[4].d = 12.0f;
+  result[4].e = 12.0f;
+  result[4].f = 12.0f;
+  result[4].g = 12.0f;
+  result[4].h = f.a + f.h;
+
+  result[5].a = f.a;
+  result[5].b = 12.0f;
+  result[5].c = 12.0f;
+  result[5].d = 12.0f;
+  result[5].e = 12.0f;
+  result[5].f = 12.0f;
+  result[5].g = 12.0f;
+  result[5].h = f.a + f.h;
+}
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index d25621f..2be0c36 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -147,6 +147,7 @@ set (utests_sources
   compiler_long_asr.cpp
   compiler_long_mult.cpp
   compiler_long_cmp.cpp
+  compiler_function_argument3.cpp
   compiler_bool_cross_basic_block.cpp
   load_program_from_bin.cpp
   enqueue_copy_buf.cpp
diff --git a/utests/compiler_function_argument3.cpp b/utests/compiler_function_argument3.cpp
new file mode 100644
index 0000000..e9f5e80
--- /dev/null
+++ b/utests/compiler_function_argument3.cpp
@@ -0,0 +1,45 @@
+#include "utest_helper.hpp"
+
+struct sfloat8 {
+    float a;
+    float b;
+    float c;
+    float d;
+    float e;
+    float f;
+    float g;
+    float h;
+};
+
+void compiler_function_argument3(void)
+{
+  sfloat8 arg6;
+
+  arg6.a = 3.0f;
+  arg6.h = 4.0f;
+
+  // Setup kernel and buffers
+  OCL_CREATE_KERNEL("compiler_function_argument3");
+  OCL_CREATE_BUFFER(buf[0], 0, sizeof(struct sfloat8) * 8, NULL);
+
+  OCL_SET_ARG(0, sizeof(arg6), &arg6);
+  OCL_SET_ARG(1, sizeof(cl_mem), &buf[0]);
+
+  // Run the kernel
+  globals[0] = 1;
+  locals[0] = 1;
+  OCL_NDRANGE(1);
+
+  OCL_MAP_BUFFER(0);
+
+  /* Check results */
+  sfloat8 *dst = (sfloat8*)buf_data[0];
+
+  OCL_ASSERT(dst[0].a == 3.0f);
+  OCL_ASSERT(dst[0].b == 12.0f);
+  OCL_ASSERT(dst[0].h == 7.0f);
+
+  OCL_UNMAP_BUFFER(0);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_function_argument3);



More information about the Beignet mailing list