summaryrefslogtreecommitdiff
path: root/utests/compiler_function_argument2.cpp
diff options
context:
space:
mode:
authorYang Rong <rong.r.yang@intel.com>2013-10-21 15:20:41 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2013-10-22 14:16:52 +0800
commit15f08855cf84fb18b5e5117d44c00f6bf201a543 (patch)
tree6717276d92716282d69a498d366236f8fe8a83aa /utests/compiler_function_argument2.cpp
parentfeeee7c74b1972e7f882e0cccccb324f67b833eb (diff)
downloadbeignet-15f08855cf84fb18b5e5117d44c00f6bf201a543.tar.gz
Add a test for vector argument deallocate assert.
V2: Add result compare. Signed-off-by: Yang Rong <rong.r.yang@intel.com> Reviewed-by: Ruiling Song <ruiling.song@intel.com>
Diffstat (limited to 'utests/compiler_function_argument2.cpp')
-rw-r--r--utests/compiler_function_argument2.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/utests/compiler_function_argument2.cpp b/utests/compiler_function_argument2.cpp
new file mode 100644
index 00000000..c352a9eb
--- /dev/null
+++ b/utests/compiler_function_argument2.cpp
@@ -0,0 +1,57 @@
+#include "utest_helper.hpp"
+
+#define VECSIZE 8
+void compiler_function_argument2(void)
+{
+ char arg0[8] = { 0 };
+ unsigned char arg1[8] = { 0 };
+ short arg2[8] = { 0 };
+ unsigned short arg3[8] = { 0 };
+ int arg4[8] = { 0 };
+ unsigned int arg5[8] = { 0 };
+ float arg6[8] = { 0 };
+
+ for (uint32_t i = 0; i < 8; ++i) {
+ arg0[i] = rand();
+ arg1[i] = rand();
+ arg2[i] = rand();
+ arg3[i] = rand();
+ arg4[i] = rand();
+ arg5[i] = rand();
+ arg6[i] = rand();
+ }
+
+ // Setup kernel and buffers
+ OCL_CREATE_KERNEL("compiler_function_argument2");
+ OCL_CREATE_BUFFER(buf[0], 0, sizeof(float) * 8 * 8, NULL);
+ OCL_SET_ARG(0, sizeof(arg0), arg0);
+ OCL_SET_ARG(1, sizeof(arg1), arg1);
+ OCL_SET_ARG(2, sizeof(arg2), arg2);
+ OCL_SET_ARG(3, sizeof(arg3), arg3);
+ OCL_SET_ARG(4, sizeof(arg4), arg4);
+ OCL_SET_ARG(5, sizeof(arg5), arg5);
+ OCL_SET_ARG(6, sizeof(arg6), arg6);
+ OCL_SET_ARG(7, sizeof(cl_mem), &buf[0]);
+
+ // Run the kernel
+ globals[0] = 1;
+ locals[0] = 1;
+ OCL_NDRANGE(1);
+ OCL_MAP_BUFFER(0);
+
+ /* Check results */
+ float *dst = (float*)buf_data[0];
+
+ for (uint32_t i = 0; i < 8; ++i) {
+ OCL_ASSERT((float)arg0[i] == dst[0*8 + i]);
+ OCL_ASSERT((float)arg1[i] == dst[1*8 + i]);
+ OCL_ASSERT((float)arg2[i] == dst[2*8 + i]);
+ OCL_ASSERT((float)arg3[i] == dst[3*8 + i]);
+ OCL_ASSERT((float)arg4[i] == dst[4*8 + i]);
+ OCL_ASSERT((float)arg5[i] == dst[5*8 + i]);
+ OCL_ASSERT((float)arg6[i] == dst[6*8 + i]);
+ }
+ OCL_UNMAP_BUFFER(0);
+}
+
+MAKE_UTEST_FROM_FUNCTION(compiler_function_argument2);