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

Tom Stellard tom at stellard.net
Wed Oct 3 19:39:28 PDT 2012


Hi,

Thanks for the patch.  Sorry for the delay in responding.

This looks pretty good to me, just one small comment below.
On Thu, Sep 27, 2012 at 09:01:51AM -0500, 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";

Since this is an API test, we may want to add all the possible build
options here. See:
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/


> +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,
> +	                                    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
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list