From 15f08855cf84fb18b5e5117d44c00f6bf201a543 Mon Sep 17 00:00:00 2001 From: Yang Rong Date: Mon, 21 Oct 2013 15:20:41 +0800 Subject: [PATCH] Add a test for vector argument deallocate assert. V2: Add result compare. Signed-off-by: Yang Rong Reviewed-by: Ruiling Song --- kernels/compiler_function_argument2.cl | 12 +++++++ utests/CMakeLists.txt | 1 + utests/compiler_function_argument2.cpp | 57 ++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 kernels/compiler_function_argument2.cl create mode 100644 utests/compiler_function_argument2.cpp diff --git a/kernels/compiler_function_argument2.cl b/kernels/compiler_function_argument2.cl new file mode 100644 index 0000000..24e5795 --- /dev/null +++ b/kernels/compiler_function_argument2.cl @@ -0,0 +1,12 @@ +__kernel void compiler_function_argument2( +char8 c, uchar8 uc, short8 s, ushort8 us, int8 i, uint8 ui, float8 f, +__global float8 *result) +{ + result[0] = convert_float8(c); + result[1] = convert_float8(uc); + result[2] = convert_float8(s); + result[3] = convert_float8(us); + result[4] = convert_float8(i); + result[5] = convert_float8(ui); + result[6] = f; +} diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 373f449..37240fe 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -41,6 +41,7 @@ set (utests_sources compiler_fill_image_3d_2.cpp compiler_function_argument0.cpp compiler_function_argument1.cpp + compiler_function_argument2.cpp compiler_function_argument.cpp compiler_function_constant0.cpp compiler_function_constant1.cpp diff --git a/utests/compiler_function_argument2.cpp b/utests/compiler_function_argument2.cpp new file mode 100644 index 0000000..c352a9e --- /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); -- 2.7.4