[Piglit] [PATCH] Add OpenCL test for building program with build options.

Blaž Tomažič blaz.tomazic at gmail.com
Thu Oct 4 03:15:32 PDT 2012


Sorry for late reply.

On čet, 2012-09-27 at 12:01 -0700, Aaron Watry wrote:
> ---
>  tests/cl/api/build-program.c |   31 ++++++++++++++++++++++++++++---
>  1 file changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/cl/api/build-program.c b/tests/cl/api/build-program.c
> index 470f1d4..6d5b1ad 100644
> --- a/tests/cl/api/build-program.c
> +++ b/tests/cl/api/build-program.c
> @@ -53,6 +53,11 @@ const char* strings[] = {
>  	"kernel void dummy_kernel() { dummy_function(); }",
>  };
>  
> +const char* build_options = "-D BUILD_OPT1=1 -D BUILD_OPT2=2";
> +const char* kernel_with_build_options[] = {
> +	"kernel void dummy_kernel(){ int var1 = BUILD_OPT1; int var2 = BUILD_OPT2; }",
> +};
> +
>  const char* invalid_strings[] = {
>  	"kernel void dummy_kernel {}", // missing brackets intentionaly
>  };
> @@ -98,6 +103,7 @@ piglit_cl_test(const int argc,
>  	cl_int errNo;
>  	cl_program program;
>  	cl_program temp_program;
> +	cl_program program_with_build_opts;
>  	cl_kernel kernel;
>  
>  	/*** Normal usage ***/
> @@ -126,8 +132,25 @@ piglit_cl_test(const int argc,
>  
> 
>  	// TODO: test callback
> -	// TODO: test build options
> -
> +	
> +	/*
> +	 * CL_SUCCESS expected for valid program with valid build options
> +	 */
> +	program_with_build_opts = clCreateProgramWithSource(env->context->cl_ctx,
> +	                                    2,

Strings count has to be 1 and not 2 in this case.

> +	                                    kernel_with_build_options,
> +	                                    NULL,
> +	                                    &errNo);
> +	if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
> +		fprintf(stderr,
> +		        "Failed (error code: %s): Create program with build options with source.\n",
> +		        piglit_cl_get_error_name(errNo));
> +		return PIGLIT_FAIL;
> +	}
> +	test(program_with_build_opts, env->context->num_devices, env->context->device_ids, build_options,
> +	     NULL, NULL,
> +	     CL_SUCCESS, &result, "Build program with options");
> +	
>  	/*** Errors ***/
>  
>  	/*
> @@ -255,6 +278,8 @@ piglit_cl_test(const int argc,
>  	 */
>  
>  	clReleaseProgram(program);
> -
> +	if (program_with_build_opts != NULL)
> +		clReleaseProgram(program_with_build_opts);
> +	
>  	return result;
>  }
> -- 
> 1.7.9.5

Not all build options are tested, but I think that just testing that
they are being used is OK. It will be easier to test other options
with .cl tests.

Aside from the strings count error, it looks good to me:
Reviewed-by: Blaž Tomažič <blaz.tomazic at gmail.com>

Blaž



More information about the Piglit mailing list