[Beignet] [PATCH 3/3] Add vector argument test case.

Zhigang Gong zhigang.gong at linux.intel.com
Thu May 16 22:58:04 PDT 2013


LGTM. Thanks.

On Thu, May 16, 2013 at 12:36:35PM +0800, Yang Rong wrote:
> 
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
>  kernels/compiler_function_argument2.cl |    6 ++++++
>  utests/CMakeLists.txt                  |    1 +
>  utests/compiler_function_argument2.cpp |   26 ++++++++++++++++++++++++++
>  3 files changed, 33 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..0985dbd
> --- /dev/null
> +++ b/kernels/compiler_function_argument2.cl
> @@ -0,0 +1,6 @@
> +__kernel void
> +compiler_function_argument2(__global int *dst, int4 value)
> +{
> +  int id = (int)get_global_id(0);
> +  dst[id] = value.w;
> +}
> diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
> index 45732c8..1444732 100644
> --- a/utests/CMakeLists.txt
> +++ b/utests/CMakeLists.txt
> @@ -32,6 +32,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..1e398a9
> --- /dev/null
> +++ b/utests/compiler_function_argument2.cpp
> @@ -0,0 +1,26 @@
> +#include "utest_helper.hpp"
> +
> +struct int4 {int x,y,z,w;};
> +void compiler_function_argument2(void)
> +{
> +  const size_t n = 2048;
> +  const int4 value = {31, 32, 33, 34};
> +
> +  // Setup kernel and buffers
> +  OCL_CREATE_KERNEL("compiler_function_argument2");
> +  OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(uint32_t), NULL);
> +  OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
> +  OCL_SET_ARG(1, sizeof(int4), &value);
> +
> +  // Run the kernel
> +  globals[0] = n;
> +  locals[0] = 16;
> +  OCL_NDRANGE(1);
> +  OCL_MAP_BUFFER(0);
> +
> +  // Check results
> +  for (uint32_t i = 0; i < n; ++i)
> +    OCL_ASSERT(((int*)buf_data[0])[i] == value.w);
> +}
> +
> +MAKE_UTEST_FROM_FUNCTION(compiler_function_argument2);
> -- 
> 1.7.9.5
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list