User create_* helper functions in most tests

Ported from master.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
Kevin Petit
2019-07-31 11:25:42 +01:00
committed by Kévin Petit
parent 59e2da3b4e
commit d3fb3d975f
31 changed files with 276 additions and 897 deletions

View File

@@ -32,11 +32,7 @@ int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue
size_t binarySize;
program = clCreateProgramWithSource( context, 1, sample_binary_kernel_source, NULL, &error );
test_error( error, "Unable to create program from source" );
// Build so we have a binary to get
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
error = create_single_kernel_helper(context, &program, NULL, 1, sample_binary_kernel_source, NULL);
test_error( error, "Unable to build test program" );
// Get the size of the resulting binary (only one device)
@@ -85,11 +81,7 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que
size_t binarySize;
program = clCreateProgramWithSource( context, 1, sample_binary_kernel_source, NULL, &error );
test_error( error, "Unable to create program from source" );
// Build so we have a binary to get
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
error = create_single_kernel_helper(context, &program, NULL, 1, sample_binary_kernel_source, NULL);
test_error( error, "Unable to build test program" );
// Get the size of the resulting binary (only one device)

View File

@@ -86,19 +86,9 @@ int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_comman
size_t realSize;
/* Preprocess: calc the length of each source file line */
sample_single_kernel_lengths[ 0 ] = strlen( sample_single_kernel[ 0 ] );
error = create_single_kernel_helper(context, &program, NULL, 1, sample_single_kernel, NULL);
test_error( error, "Unable to build test program" );
/* Create a program */
program = clCreateProgramWithSource( context, 1, sample_single_kernel, sample_single_kernel_lengths, &error );
if( program == NULL || error != CL_SUCCESS )
{
print_error( error, "Unable to create single kernel program" );
return -1;
}
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build single kernel program" );
error = clCreateKernelsInProgram(program, 1, &kernel, &numKernels);
test_error( error, "Unable to create single kernel program" );
@@ -179,19 +169,9 @@ int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_
cl_uint testArgCount;
/* Preprocess: calc the length of each source file line */
sample_two_kernel_lengths[ 0 ] = strlen( sample_two_kernels[ 0 ] );
sample_two_kernel_lengths[ 1 ] = strlen( sample_two_kernels[ 1 ] );
error = create_single_kernel_helper(context, &program, NULL, 2, sample_two_kernels, NULL);
test_error( error, "Unable to build test program" );
/* Now create a test program */
program = clCreateProgramWithSource( context, 2, sample_two_kernels, sample_two_kernel_lengths, &error );
if( program == NULL || error != CL_SUCCESS )
{
print_error( error, "Unable to create dual kernel program!" );
return -1;
}
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build dual kernel program" );
error = clCreateKernelsInProgram(program, 2, &kernel[0], &numKernels);
test_error( error, "Unable to create dual kernel program" );
@@ -269,18 +249,9 @@ int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_c
cl_uint testArgCount;
/* Preprocess: calc the length of each source file line */
sample_two_kernels_in_1_lengths[ 0 ] = strlen( sample_two_kernels_in_1[ 0 ] );
error = create_single_kernel_helper(context, &program, NULL, 1, sample_two_kernels_in_1, NULL);
test_error( error, "Unable to build test program" );
/* Now create a test program */
program = clCreateProgramWithSource( context, 1, sample_two_kernels_in_1, sample_two_kernels_in_1_lengths, &error );
if( program == NULL || error != CL_SUCCESS )
{
print_error( error, "Unable to create dual kernel program" );
return -1;
}
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build dual kernel program" );
error = clCreateKernelsInProgram(program, 2, &kernel[0], &numKernels);
test_error( error, "Unable to create dual kernel program" );
@@ -357,16 +328,8 @@ int test_load_two_kernels_manually( cl_device_id deviceID, cl_context context, c
/* Now create a test program */
program = clCreateProgramWithSource( context, 1, sample_two_kernels_in_1, NULL, &error );
if( program == NULL || error != CL_SUCCESS )
{
print_error( error, "Unable to create dual kernel program" );
return -1;
}
/* Compile the program */
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build kernel program" );
error = create_single_kernel_helper(context, &program, NULL, 1, sample_two_kernels_in_1, NULL);
test_error( error, "Unable to build test program" );
/* Try manually creating kernels (backwards just in case) */
kernel1 = clCreateKernel( program, "sample_test2", &error );
@@ -396,16 +359,8 @@ int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context contex
size_t i;
/* Now create a test program */
program = clCreateProgramWithSource( context, 1, sample_two_kernels_in_1, NULL, &error );
if( program == NULL || error != CL_SUCCESS )
{
print_error( error, "Unable to create dual kernel program" );
return -1;
}
/* Compile the program */
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build kernel program" );
error = create_single_kernel_helper(context, &program, NULL, 1, sample_two_kernels_in_1, NULL);
test_error( error, "Unable to build test program" );
/* Lookup the number of kernels in the program. */
size_t total_kernels = 0;
@@ -569,11 +524,8 @@ int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_co
local_queue = clCreateCommandQueueWithProperties(local_context, deviceID, 0, &error);
test_error( error, "clCreateCommandQueue failed");
local_program = clCreateProgramWithSource(local_context, 1, &repeate_test_kernel, NULL, &error);
test_error( error, "clCreateProgramWithSource failed");
error = clBuildProgram(local_program, 0, NULL, NULL, NULL, NULL);
test_error( error, "clBuildProgram failed");
error = create_single_kernel_helper(local_context, &local_program, NULL, 1, &repeate_test_kernel, NULL);
test_error( error, "Unable to build test program" );
local_kernel = clCreateKernel(local_program, "test_kernel", &error);
test_error( error, "clCreateKernel failed");

View File

@@ -606,17 +606,8 @@ int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl
cl_kernel kernel[3];
unsigned int kernelCount;
/* Create a test program */
program = clCreateProgramWithSource( context, 2, sample_two_kernel_program, NULL, &error);
if( program == NULL || error != CL_SUCCESS )
{
log_error( "ERROR: Unable to create test program!\n" );
return -1;
}
/* Build */
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
test_error( error, "Unable to build test program" );
error = create_single_kernel_helper(context, &program, NULL, 2, sample_two_kernel_program, NULL);
test_error(error, "Unable to build test program");
/* Try getting the kernel count */
error = clCreateKernelsInProgram( program, 0, NULL, &kernelCount );

View File

@@ -157,13 +157,11 @@ int test_null_buffer_arg(cl_device_id device, cl_context context,
// prep kernel:
if (gIsEmbedded)
program = clCreateProgramWithSource(context, 1, &kernel_string, NULL, &status);
status = create_single_kernel_helper(context, &program, NULL, 1, &kernel_string, NULL);
else
program = clCreateProgramWithSource(context, 1, &kernel_string_long, NULL, &status);
test_error(status, "CreateProgramWithSource failed.");
status = create_single_kernel_helper(context, &program, NULL, 1, &kernel_string_long, NULL);
status = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
test_error(status, "BuildProgram failed.");
test_error(status, "Unable to build test program");
kernel = clCreateKernel(program, "test_kernel", &status);
test_error(status, "CreateKernel failed.");

View File

@@ -29,11 +29,7 @@ int test_release_kernel_order(cl_device_id deviceID, cl_context context, cl_comm
const char *testProgram[] = { "__kernel void sample_test(__global int *data){}" };
/* Create a test program */
program = clCreateProgramWithSource( context, 1, testProgram, NULL, &error);
test_error( error, "Unable to create program to test with" );
/* Compile the program */
error = clBuildProgram( program, 1, &deviceID, NULL, NULL, NULL );
error = create_single_kernel_helper(context, &program, NULL, 1, testProgram, NULL);
test_error( error, "Unable to build sample program to test with" );
/* And create a kernel from it */