utests: add test case for structure argument
authorLu Guanqun <guanqun.lu@intel.com>
Tue, 5 Nov 2013 05:55:27 +0000 (13:55 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Wed, 6 Nov 2013 03:06:06 +0000 (11:06 +0800)
Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
kernels/compiler_function_argument3.cl [new file with mode: 0644]
utests/CMakeLists.txt
utests/compiler_function_argument3.cpp [new file with mode: 0644]

diff --git a/kernels/compiler_function_argument3.cl b/kernels/compiler_function_argument3.cl
new file mode 100644 (file)
index 0000000..4df2816
--- /dev/null
@@ -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;
+}
index d25621f..2be0c36 100644 (file)
@@ -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 (file)
index 0000000..e9f5e80
--- /dev/null
@@ -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);