[Beignet] [PATCH] utest: Add test case for build-in function get_work_dim

Zhigang Gong zhigang.gong at linux.intel.com
Tue Jun 4 19:58:38 PDT 2013


Pushed, thanks.
On Tue, Jun 04, 2013 at 05:34:30PM +0800, Yi Sun wrote:
> v2: Refine the case, verifying the result of function get_work_dim.
> 
> v3: Since the 16 work group size limitation is fixed, re-side the global size and local size with 1.
> 
> Signed-off-by: Yi Sun <yi.sun at intel.com>
> ---
>  kernels/buildin_work_dim.cl |    3 +++
>  utests/CMakeLists.txt       |    1 +
>  utests/buildin_work_dim.cpp |   37 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 41 insertions(+), 0 deletions(-)
>  create mode 100644 kernels/buildin_work_dim.cl
>  create mode 100644 utests/buildin_work_dim.cpp
> 
> diff --git a/kernels/buildin_work_dim.cl b/kernels/buildin_work_dim.cl
> new file mode 100644
> index 0000000..27c0e18
> --- /dev/null
> +++ b/kernels/buildin_work_dim.cl
> @@ -0,0 +1,3 @@
> +kernel void buildin_work_dim( __global int *ret ) {
> +  *ret = get_work_dim();
> +}
> diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
> index 63c873d..5775357 100644
> --- a/utests/CMakeLists.txt
> +++ b/utests/CMakeLists.txt
> @@ -76,6 +76,7 @@ set (utests_sources
>    compiler_volatile.cpp
>    compiler_copy_image1.cpp
>    compiler_get_image_info.cpp
> +  buildin_work_dim.cpp
>    runtime_createcontext.cpp
>    utest_assert.cpp
>    utest.cpp
> diff --git a/utests/buildin_work_dim.cpp b/utests/buildin_work_dim.cpp
> new file mode 100644
> index 0000000..fff4d37
> --- /dev/null
> +++ b/utests/buildin_work_dim.cpp
> @@ -0,0 +1,37 @@
> +#include "utest_helper.hpp"
> +
> +static void buildin_work_dim(void)
> +{
> +  // Setup kernel and buffers
> +	
> +  int result, err;
> +  OCL_CREATE_KERNEL("buildin_work_dim");
> +
> +  OCL_CREATE_BUFFER(buf[0], CL_MEM_READ_WRITE, sizeof(int), NULL);
> +  OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
> +
> +  globals[0] = 1;
> +  globals[1] = 1;
> +  globals[2] = 1;
> +  locals[0] = 1;
> +  locals[1] = 1;
> +  locals[2] = 1;
> +
> +  for( int i=1; i <= 3; i++ )
> +  {    
> +
> +    // Run the kernel
> +    OCL_NDRANGE(i);
> +
> +    err = clEnqueueReadBuffer( queue, buf[0], CL_TRUE, 0, sizeof(int), &result, 0, NULL, NULL);
> +    if (err != CL_SUCCESS)
> +    {
> +       printf("Error: Failed to read output array! %d\n", err);
> +       exit(1);
> +    }
> +
> +    OCL_ASSERT( result == i);
> +  }
> +}
> +
> +MAKE_UTEST_FROM_FUNCTION(buildin_work_dim);
> -- 
> 1.7.6.4
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list