[Piglit] [PATCH 2/2] cl-program-tester: Skip tests if devices don't support the local work size

Aaron Watry awatry at gmail.com
Fri Jun 28 14:51:15 PDT 2013


Looks good to me.

For the series:
Reviewed-by: Aaron Watry <awatry at gmail.com>

On Wed, Jun 26, 2013 at 5:53 PM, Tom Stellard <tom at stellard.net> wrote:
> From: Tom Stellard <thomas.stellard at amd.com>
>
> ---
>  ...ram-tester-check-local-size-test-should-skip.cl | 47 ++++++++++++++++++++++
>  tests/cl/program/program-tester.c                  |  6 +++
>  tests/util/piglit-framework-cl.c                   | 31 ++++++++++++++
>  tests/util/piglit-framework-cl.h                   | 11 +++++
>  4 files changed, 95 insertions(+)
>  create mode 100644 tests/cl/program/execute/program-tester-check-local-size-test-should-skip.cl
>
> diff --git a/tests/cl/program/execute/program-tester-check-local-size-test-should-skip.cl b/tests/cl/program/execute/program-tester-check-local-size-test-should-skip.cl
> new file mode 100644
> index 0000000..b309b8a
> --- /dev/null
> +++ b/tests/cl/program/execute/program-tester-check-local-size-test-should-skip.cl
> @@ -0,0 +1,47 @@
> +/*
> + * Copyright 2013 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + *
> + * Authors: Tom Stellard <thomas.stellard at amd.com>
> + *
> + */
> +
> +/*
> + * This test check that the cl-program-tester program will skip tests
> + * when the local work size is not supported by a device.
> + */
> +
> +/*!
> +
> +[config]
> +kernel_name: test
> +
> +[test]
> +name: This test should skip
> +dimensions: 3
> +global_size: 1048576 1048576 1048576
> +local_size:  1048576 1048576 1048576
> +arg_out: 0 buffer uint[1] 0
> +!*/
> +
> +kernel void test(global int *out) {
> +       out[0] = 0;
> +}
> diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
> index ae2fc9e..d898691 100644
> --- a/tests/cl/program/program-tester.c
> +++ b/tests/cl/program/program-tester.c
> @@ -1700,6 +1700,12 @@ test_kernel(const struct piglit_cl_program_test_config* config,
>         struct buffer_arg* buffer_args = NULL;
>         unsigned int  num_buffer_args = 0;
>
> +       /* Check if this device supports the local work size. */
> +       if (!piglit_cl_framework_check_local_work_size(env->device_id,
> +                                               test.local_work_size)) {
> +               return PIGLIT_SKIP;
> +       }
> +
>         /* Create or use apropriate kernel */
>         if(test.kernel_name == NULL) {
>                 kernel_name = config->kernel_name;
> diff --git a/tests/util/piglit-framework-cl.c b/tests/util/piglit-framework-cl.c
> index deddc8d..241dd42 100644
> --- a/tests/util/piglit-framework-cl.c
> +++ b/tests/util/piglit-framework-cl.c
> @@ -552,3 +552,34 @@ piglit_cl_get_device_arg(const int argc, const char** argv,
>
>         return false;
>  }
> +
> +bool piglit_cl_framework_check_local_work_size(
> +       cl_device_id device_id,
> +       size_t *local_work_size)
> +{
> +       unsigned i;
> +       size_t workgroup_size = 1;
> +       size_t max_workgroup_size = piglit_cl_get_device_info(device_id,
> +                                               CL_DEVICE_MAX_WORK_GROUP_SIZE);
> +       size_t *max_workitem_sizes = piglit_cl_get_device_info(device_id,
> +                                               CL_DEVICE_MAX_WORK_ITEM_SIZES);
> +
> +       if (!local_work_size) {
> +               return true;
> +       }
> +
> +       for (i = 0; i < 3; i++) {
> +               size_t local_size = local_work_size[i];
> +               if (local_size > max_workitem_sizes[i]) {
> +                       return false;
> +               }
> +               if (local_size > 0) {
> +                       workgroup_size *= local_size;
> +               }
> +       }
> +
> +       if (workgroup_size > max_workgroup_size) {
> +               return false;
> +       }
> +       return true;
> +}
> diff --git a/tests/util/piglit-framework-cl.h b/tests/util/piglit-framework-cl.h
> index c1fa0ff..f63883c 100644
> --- a/tests/util/piglit-framework-cl.h
> +++ b/tests/util/piglit-framework-cl.h
> @@ -351,4 +351,15 @@ piglit_cl_get_device_arg(const int argc,
>                           cl_platform_id platform_id,
>                           cl_device_id* device_id);
>
> +/**
> + * \brief Check if the given local work demensions are supported on this device.
> + * @param device_id       Device to check
> + * @param local_work_size Local work dimensions
> + * @return                \c true if the local work dimensions are supported,
> + *                        \c false if they are not.
> + */
> +bool piglit_cl_framework_check_local_work_size(
> +       cl_device_id device_id,
> +       size_t *local_work_size);
> +
>  #endif //PIGLIT_FRAMEWORK_CL_H
> --
> 1.7.11.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list