[Piglit] [PATCH] Only specify -cl-std when test hasn't explicitly overridden -cl-std (v2)

Blaž Tomažič blaz.tomazic at gmail.com
Tue Dec 18 23:31:53 PST 2012


Looks good to me. But please remove the trailing whitespace after "if (!
strstr(build_options, "-cl-std")){" and use tabs instead of spaces for
indenting to be consistent with the rest of the file.

Blaž

On pon, 2012-12-17 at 22:37 -0600, Aaron Watry wrote:
> The previous code would always add -cl-std if the version was > 1.0.
> This
> ignored whatever the test itself wanted (e.g. the
> invalid-version-declaration
> test). We should probably only add " -cl-std=x.y" when the test hasn't
> requested a specific version.
> 
> Note: This doesn't address the rewrite of the intended functionality
> that Blaz,
> Tom, and I discussed on the list last week.
> 
> v2: Remove -D __OPENCL_C_VERSION__=1%d0 and -D CL_VERSION_1_0=100
>     Change the order in which the -cl-std checks are done.
> ---
>  tests/util/piglit-framework-cl-program.c |   37
> +++++++++--------------------
>  1 files changed, 12 insertions(+), 25 deletions(-)
> 
> diff --git a/tests/util/piglit-framework-cl-program.c
> b/tests/util/piglit-framework-cl-program.c
> index f504bae..a2f19f9 100644
> --- a/tests/util/piglit-framework-cl-program.c
> +++ b/tests/util/piglit-framework-cl-program.c
> @@ -211,31 +211,6 @@ piglit_cl_program_test_run(const int argc,
>         }
>  
>         /* Set build options */
> -       if(version > 10) {
> -               char* template = "-cl-std=CL%d.%d ";
> -               char* old = build_options;
> -               build_options = malloc((strlen(old) + strlen(template)
> + 1) * sizeof(char));
> -               strcpy(build_options, old);
> -               sprintf(build_options+strlen(old), template,
> env.clc_version/10,
> -
> env.clc_version%10);
> -               free(old);
> -       }
> -       if(env.clc_version <= 10) {
> -               char* template = "-D CL_VERSION_1_0=100 ";
> -               char* old = build_options;
> -               build_options = malloc((strlen(old) + strlen(template)
> + 1) * sizeof(char));
> -               strcpy(build_options, old);
> -               sprintf(build_options+strlen(old), template);
> -               free(old);
> -       }
> -       if(env.clc_version <= 11) {
> -               char* template = "-D __OPENCL_C_VERSION__=1%d0 ";
> -               char* old = build_options;
> -               build_options = malloc((strlen(old) + strlen(template)
> + 1) * sizeof(char));
> -               strcpy(build_options, old);
> -               sprintf(build_options+strlen(old), template,
> env.clc_version%10);
> -               free(old);
> -       }
>         if(config->build_options != NULL) {
>                 char* old = build_options;
>                 build_options = malloc((strlen(old) +
> strlen(config->build_options) + 1) * sizeof(char));
> @@ -243,6 +218,18 @@ piglit_cl_program_test_run(const int argc,
>                 sprintf(build_options+strlen(old),
> config->build_options);
>                 free(old);
>         }
> +       if(version > 10) {
> +                //If -cl-std was already in config->build_options,
> use what the test requested
> +               if (!strstr(build_options, "-cl-std")){ 
> +                    char* template = " -cl-std=CL%d.%d";
> +                    char* old = build_options;
> +                    build_options = malloc((strlen(old) +
> strlen(template) + 1) * sizeof(char));
> +                    strcpy(build_options, old);
> +                    sprintf(build_options+strlen(old), template,
> env.clc_version/10,
> +
> env.clc_version%10);
> +                    free(old);
> +                }
> +       }
>  
>         printf("#   Build options: %s\n", build_options);
>  
> -- 
> 1.7.4.4
> 



More information about the Piglit mailing list