diff --git a/test_common/harness/imageHelpers.cpp b/test_common/harness/imageHelpers.cpp index cdb7028c..be1d68d0 100644 --- a/test_common/harness/imageHelpers.cpp +++ b/test_common/harness/imageHelpers.cpp @@ -2971,7 +2971,10 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS "{\n" " write_imagef( out, (int2)(get_global_id(0),0), in[get_global_id(0)] );\n" "}\n" }; - cl_program program = clCreateProgramWithSource( context, 1, kernel, NULL, &err ); + + clProgramWrapper program; + err = create_single_kernel_helper_create_program(context, &program, 1, kernel); + if( NULL == program || err ) { log_error( "Error: could not create program in DetectFloatToHalfRoundingMode (err: %d)", err ); @@ -2987,7 +2990,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS log_error( "Error: could not get device from command queue in DetectFloatToHalfRoundingMode (%d)", err ); clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); return err; } @@ -2997,7 +2999,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS log_error( "Error: could not build program in DetectFloatToHalfRoundingMode (%d)", err ); clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); return err; } @@ -3007,7 +3008,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS log_error( "Error: could not create kernel in DetectFloatToHalfRoundingMode (%d)", err ); clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); return err; } @@ -3017,7 +3017,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS log_error( "Error: could not set argument 0 of kernel in DetectFloatToHalfRoundingMode (%d)", err ); clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); clReleaseKernel( k ); return err; } @@ -3028,7 +3027,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS log_error( "Error: could not set argument 1 of kernel in DetectFloatToHalfRoundingMode (%d)", err ); clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); clReleaseKernel( k ); return err; } @@ -3041,7 +3039,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS log_error( "Error: could not enqueue kernel in DetectFloatToHalfRoundingMode (%d)", err ); clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); clReleaseKernel( k ); return err; } @@ -3057,7 +3054,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS log_error( "Error: could not read output image in DetectFloatToHalfRoundingMode (%d)", err ); clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); clReleaseKernel( k ); return err; } @@ -3105,7 +3101,6 @@ int DetectFloatToHalfRoundingMode( cl_command_queue q ) // Returns CL_SUCCESS // clean up clReleaseMemObject( inBuf ); clReleaseMemObject( outImage ); - clReleaseProgram( program ); clReleaseKernel( k ); return err; } diff --git a/test_conformance/SVM/main.cpp b/test_conformance/SVM/main.cpp index 7ca01c67..59c2da32 100644 --- a/test_conformance/SVM/main.cpp +++ b/test_conformance/SVM/main.cpp @@ -19,6 +19,7 @@ #include #include #include "../../test_common/harness/testHarness.h" +#include "../../test_common/harness/kernelHelpers.h" #include "common.h" @@ -243,32 +244,8 @@ cl_int create_cl_objects(cl_device_id device_from_harness, const char** ppCodeSt if(ppCodeString) { - *program = clCreateProgramWithSource(*context, 1, ppCodeString , NULL, &error); - test_error( error, "clCreateProgramWithSource failed" ); - - error = clBuildProgram(*program,0,NULL,"-cl-std=CL2.0",NULL,NULL); - if (error != CL_SUCCESS) - { - print_error(error, "clBuildProgram failed"); - - char *buildLog = NULL; - size_t buildLogSize = 0; - error = clGetProgramBuildInfo (*program, devices[0], CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, &buildLogSize); - buildLog = (char*)malloc(buildLogSize); - memset(buildLog, 0, buildLogSize); - error = clGetProgramBuildInfo (*program, devices[0], CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, NULL); - char string[15000]; - sprintf(string,"%s", buildLog); - //MessageBox(NULL,(LPCWSTR)string,(LPCWSTR)"OpenCL Error",MB_OK); - //MessageBox(NULL,string,"OpenCL Error",MB_OK); - free(buildLog); - log_info("%s",string); - if (error) { - print_error(error, "clGetProgramBuildInfo CL_PROGRAM_BUILD_LOG failed"); - return -1; - } - return -1; - } + error = create_single_kernel_helper(*context, program, 0, 1, ppCodeString, 0, "-cl-std=CL2.0"); + test_error( error, "failed to create program" ); } return 0; diff --git a/test_conformance/api/test_binary.cpp b/test_conformance/api/test_binary.cpp index 41431252..8d3c01e5 100644 --- a/test_conformance/api/test_binary.cpp +++ b/test_conformance/api/test_binary.cpp @@ -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) diff --git a/test_conformance/api/test_create_kernels.c b/test_conformance/api/test_create_kernels.c index 83080437..ceb18732 100644 --- a/test_conformance/api/test_create_kernels.c +++ b/test_conformance/api/test_create_kernels.c @@ -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"); diff --git a/test_conformance/api/test_kernels.c b/test_conformance/api/test_kernels.c index 9cfbca27..6daaabee 100644 --- a/test_conformance/api/test_kernels.c +++ b/test_conformance/api/test_kernels.c @@ -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 ); diff --git a/test_conformance/api/test_null_buffer_arg.c b/test_conformance/api/test_null_buffer_arg.c index 006678eb..b845fc0b 100644 --- a/test_conformance/api/test_null_buffer_arg.c +++ b/test_conformance/api/test_null_buffer_arg.c @@ -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."); diff --git a/test_conformance/api/test_retain_program.c b/test_conformance/api/test_retain_program.c index 7fe22f0c..4930c862 100644 --- a/test_conformance/api/test_retain_program.c +++ b/test_conformance/api/test_retain_program.c @@ -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 */ diff --git a/test_conformance/basic/test_createkernelsinprogram.c b/test_conformance/basic/test_createkernelsinprogram.c index e6269bfa..2940f298 100644 --- a/test_conformance/basic/test_createkernelsinprogram.c +++ b/test_conformance/basic/test_createkernelsinprogram.c @@ -56,21 +56,12 @@ test_createkernelsinprogram(cl_device_id device, cl_context context, cl_command_ cl_program program; cl_kernel kernel[2]; unsigned int num_kernels; - size_t lengths[2]; int err; - lengths[0] = strlen(sample_single_kernel); - program = clCreateProgramWithSource(context, 1, &sample_single_kernel, lengths, NULL); - if (!program) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program, NULL, 1, &sample_single_kernel, NULL); if (err != CL_SUCCESS) { - log_error("clBuildProgramExecutable failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } @@ -84,18 +75,10 @@ test_createkernelsinprogram(cl_device_id device, cl_context context, cl_command_ clReleaseKernel(kernel[0]); clReleaseProgram(program); - lengths[0] = strlen(sample_double_kernel); - program = clCreateProgramWithSource(context, 1, &sample_double_kernel, lengths, NULL); - if (!program) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program, NULL, 1, &sample_double_kernel, NULL); if (err != CL_SUCCESS) { - log_error("clBuildProgramExecutable failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_float2int.c b/test_conformance/basic/test_float2int.c index c8e48d2b..55411728 100644 --- a/test_conformance/basic/test_float2int.c +++ b/test_conformance/basic/test_float2int.c @@ -62,7 +62,6 @@ test_float2int(cl_device_id device, cl_context context, cl_command_queue queue, cl_program program; cl_kernel kernel; void *values[2]; - size_t lengths[1]; size_t threads[1]; int err; int i; @@ -95,25 +94,10 @@ test_float2int(cl_device_id device, cl_context context, cl_command_queue queue, return -1; } - lengths[0] = strlen(float2int_kernel_code); - program = clCreateProgramWithSource(context, 1, &float2int_kernel_code, lengths, NULL); - if (!program) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program, &kernel, 1, &float2int_kernel_code, "test_float2int"); if (err != CL_SUCCESS) { - log_error("clBuildProgramExecutable failed\n"); - return -1; - } - - kernel = clCreateKernel(program, "test_float2int", NULL); - if (!kernel) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_int2float.c b/test_conformance/basic/test_int2float.c index d69d7e1a..3211ccd2 100644 --- a/test_conformance/basic/test_int2float.c +++ b/test_conformance/basic/test_int2float.c @@ -61,7 +61,6 @@ test_int2float(cl_device_id device, cl_context context, cl_command_queue queue, cl_program program; cl_kernel kernel; void *values[2]; - size_t lengths[1]; size_t threads[1]; int err; int i; @@ -94,25 +93,10 @@ test_int2float(cl_device_id device, cl_context context, cl_command_queue queue, return -1; } - lengths[0] = strlen(int2float_kernel_code); - program = clCreateProgramWithSource(context, 1, &int2float_kernel_code, lengths, NULL); - if (!program) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program, &kernel, 1, &int2float_kernel_code, "test_int2float"); if (err != CL_SUCCESS) { - log_error("clBuildProgramExecutable failed\n"); - return -1; - } - - kernel = clCreateKernel(program, "test_int2float", NULL); - if (!kernel) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_intmath_int.c b/test_conformance/basic/test_intmath_int.c index 9664f91d..3706fd93 100644 --- a/test_conformance/basic/test_intmath_int.c +++ b/test_conformance/basic/test_intmath_int.c @@ -213,87 +213,31 @@ test_intmath_int(cl_device_id device, cl_context context, cl_command_queue queue return -1; } - program[0] = clCreateProgramWithSource(context, 1, &int_add_kernel_code, NULL, NULL); - if (!program[0]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[0], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[0], &kernel[0], 1, &int_add_kernel_code, "test_int_add"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[0] = clCreateKernel(program[0], "test_int_add", NULL); - if (!kernel[0]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[1] = clCreateProgramWithSource(context, 1, &int_sub_kernel_code, NULL, NULL); - if (!program[1]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[1], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[1], &kernel[1], 1, &int_sub_kernel_code, "test_int_sub"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[1] = clCreateKernel(program[1], "test_int_sub", NULL); - if (!kernel[1]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[2] = clCreateProgramWithSource(context, 1, &int_mul_kernel_code, NULL, NULL); - if (!program[2]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[2], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[2], &kernel[2], 1, &int_mul_kernel_code, "test_int_mul"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[2] = clCreateKernel(program[2], "test_int_mul", NULL); - if (!kernel[2]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[3] = clCreateProgramWithSource(context, 1, &int_mad_kernel_code, NULL, NULL); - if (!program[3]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[3], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[3], &kernel[3], 1, &int_mad_kernel_code, "test_int_mad"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); - return -1; - } - - kernel[3] = clCreateKernel(program[3], "test_int_mad", NULL); - if (!kernel[3]) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_intmath_int2.c b/test_conformance/basic/test_intmath_int2.c index b67d54bf..811a842b 100644 --- a/test_conformance/basic/test_intmath_int2.c +++ b/test_conformance/basic/test_intmath_int2.c @@ -212,87 +212,31 @@ test_intmath_int2(cl_device_id device, cl_context context, cl_command_queue queu return -1; } - program[0] = clCreateProgramWithSource(context, 1, &int_add2_kernel_code, NULL, NULL); - if (!program[0]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[0], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[0], &kernel[0], 1, &int_add2_kernel_code, "test_int_add2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[0] = clCreateKernel(program[0], "test_int_add2", NULL); - if (!kernel[0]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[1] = clCreateProgramWithSource(context, 1, &int_sub2_kernel_code, NULL, NULL); - if (!program[1]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[1], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[1], &kernel[1], 1, &int_sub2_kernel_code, "test_int_sub2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[1] = clCreateKernel(program[1], "test_int_sub2", NULL); - if (!kernel[1]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[2] = clCreateProgramWithSource(context, 1, &int_mul2_kernel_code, NULL, NULL); - if (!program[2]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[2], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[2], &kernel[2], 1, &int_mul2_kernel_code, "test_int_mul2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[2] = clCreateKernel(program[2], "test_int_mul2", NULL); - if (!kernel[2]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[3] = clCreateProgramWithSource(context, 1, &int_mad2_kernel_code, NULL, NULL); - if (!program[3]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[3], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[3], &kernel[3], 1, &int_mad2_kernel_code, "test_int_mad2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); - return -1; - } - - kernel[3] = clCreateKernel(program[3], "test_int_mad2", NULL); - if (!kernel[3]) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_intmath_int4.c b/test_conformance/basic/test_intmath_int4.c index fa3a1321..473cefb1 100644 --- a/test_conformance/basic/test_intmath_int4.c +++ b/test_conformance/basic/test_intmath_int4.c @@ -211,87 +211,31 @@ test_intmath_int4(cl_device_id device, cl_context context, cl_command_queue queu return -1; } - program[0] = clCreateProgramWithSource(context, 1, &int_add4_kernel_code, NULL, NULL); - if (!program[0]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[0], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[0], &kernel[0], 1, &int_add4_kernel_code, "test_int_add4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[0] = clCreateKernel(program[0], "test_int_add4", NULL); - if (!kernel[0]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[1] = clCreateProgramWithSource(context, 1, &int_sub4_kernel_code, NULL, NULL); - if (!program[1]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[1], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[1], &kernel[1], 1, &int_sub4_kernel_code, "test_int_sub4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[1] = clCreateKernel(program[1], "test_int_sub4", NULL); - if (!kernel[1]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[2] = clCreateProgramWithSource(context, 1, &int_mul4_kernel_code, NULL, NULL); - if (!program[2]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[2], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[2], &kernel[2], 1, &int_mul4_kernel_code, "test_int_mul4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[2] = clCreateKernel(program[2], "test_int_mul4", NULL); - if (!kernel[2]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[3] = clCreateProgramWithSource(context, 1, &int_mad4_kernel_code, NULL, NULL); - if (!program[3]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[3], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[3], &kernel[3], 1, &int_mad4_kernel_code, "test_int_mad4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); - return -1; - } - - kernel[3] = clCreateKernel(program[3], "test_int_mad4", NULL); - if (!kernel[3]) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_intmath_long.c b/test_conformance/basic/test_intmath_long.c index 8b01b066..20a8333e 100644 --- a/test_conformance/basic/test_intmath_long.c +++ b/test_conformance/basic/test_intmath_long.c @@ -221,87 +221,31 @@ test_intmath_long(cl_device_id device, cl_context context, cl_command_queue queu return -1; } - program[0] = clCreateProgramWithSource(context, 1, &long_add_kernel_code, NULL, NULL); - if (!program[0]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[0], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[0], &kernel[0], 1, &long_add_kernel_code, "test_long_add"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[0] = clCreateKernel(program[0], "test_long_add", NULL); - if (!kernel[0]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[1] = clCreateProgramWithSource(context, 1, &long_sub_kernel_code, NULL, NULL); - if (!program[1]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[1], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[1], &kernel[1], 1, &long_sub_kernel_code, "test_long_sub"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[1] = clCreateKernel(program[1], "test_long_sub", NULL); - if (!kernel[1]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[2] = clCreateProgramWithSource(context, 1, &long_mul_kernel_code, NULL, NULL); - if (!program[2]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[2], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[2], &kernel[2], 1, &long_mul_kernel_code, "test_long_mul"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[2] = clCreateKernel(program[2], "test_long_mul", NULL); - if (!kernel[2]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[3] = clCreateProgramWithSource(context, 1, &long_mad_kernel_code, NULL, NULL); - if (!program[3]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[3], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[3], &kernel[3], 1, &long_mad_kernel_code, "test_long_mad"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); - return -1; - } - - kernel[3] = clCreateKernel(program[3], "test_long_mad", NULL); - if (!kernel[3]) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_intmath_long2.c b/test_conformance/basic/test_intmath_long2.c index def38a00..d883e182 100644 --- a/test_conformance/basic/test_intmath_long2.c +++ b/test_conformance/basic/test_intmath_long2.c @@ -219,87 +219,31 @@ test_intmath_long2(cl_device_id device, cl_context context, cl_command_queue que return -1; } - program[0] = clCreateProgramWithSource(context, 1, &long_add2_kernel_code, NULL, NULL); - if (!program[0]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[0], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[0], &kernel[0], 1, &long_add2_kernel_code, "test_long_add2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[0] = clCreateKernel(program[0], "test_long_add2", NULL); - if (!kernel[0]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[1] = clCreateProgramWithSource(context, 1, &long_sub2_kernel_code, NULL, NULL); - if (!program[1]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[1], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[1], &kernel[1], 1, &long_sub2_kernel_code, "test_long_sub2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[1] = clCreateKernel(program[1], "test_long_sub2", NULL); - if (!kernel[1]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[2] = clCreateProgramWithSource(context, 1, &long_mul2_kernel_code, NULL, NULL); - if (!program[2]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[2], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[2], &kernel[2], 1, &long_mul2_kernel_code, "test_long_mul2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[2] = clCreateKernel(program[2], "test_long_mul2", NULL); - if (!kernel[2]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[3] = clCreateProgramWithSource(context, 1, &long_mad2_kernel_code, NULL, NULL); - if (!program[3]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[3], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[3], &kernel[3], 1, &long_mad2_kernel_code, "test_long_mad2"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); - return -1; - } - - kernel[3] = clCreateKernel(program[3], "test_long_mad2", NULL); - if (!kernel[3]) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_intmath_long4.c b/test_conformance/basic/test_intmath_long4.c index 07eeb1ef..84c5ed83 100644 --- a/test_conformance/basic/test_intmath_long4.c +++ b/test_conformance/basic/test_intmath_long4.c @@ -219,87 +219,31 @@ test_intmath_long4(cl_device_id device, cl_context context, cl_command_queue que return -1; } - program[0] = clCreateProgramWithSource(context, 1, &long_add4_kernel_code, NULL, NULL); - if (!program[0]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[0], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[0], &kernel[0], 1, &long_add4_kernel_code, "test_long_add4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[0] = clCreateKernel(program[0], "test_long_add4", NULL); - if (!kernel[0]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[1] = clCreateProgramWithSource(context, 1, &long_sub4_kernel_code, NULL, NULL); - if (!program[1]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[1], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[1], &kernel[1], 1, &long_sub4_kernel_code, "test_long_sub4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[1] = clCreateKernel(program[1], "test_long_sub4", NULL); - if (!kernel[1]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[2] = clCreateProgramWithSource(context, 1, &long_mul4_kernel_code, NULL, NULL); - if (!program[2]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[2], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[2], &kernel[2], 1, &long_mul4_kernel_code, "test_long_mul4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } - kernel[2] = clCreateKernel(program[2], "test_long_mul4", NULL); - if (!kernel[2]) - { - log_error("clCreateKernel failed\n"); - return -1; - } - - program[3] = clCreateProgramWithSource(context, 1, &long_mad4_kernel_code, NULL, NULL); - if (!program[3]) - { - log_error("clCreateProgramWithSource failed\n"); - return -1; - } - - err = clBuildProgram(program[3], 0, NULL, NULL, NULL, NULL); + err = create_single_kernel_helper(context, &program[3], &kernel[3], 1, &long_mad4_kernel_code, "test_long_mad4"); if (err != CL_SUCCESS) { - log_error("clBuildProgram failed\n"); - return -1; - } - - kernel[3] = clCreateKernel(program[3], "test_long_mad4", NULL); - if (!kernel[3]) - { - log_error("clCreateKernel failed\n"); + log_error("create_single_kernel_helper failed\n"); return -1; } diff --git a/test_conformance/basic/test_progvar.cpp b/test_conformance/basic/test_progvar.cpp index 243d2361..1879d8d6 100644 --- a/test_conformance/basic/test_progvar.cpp +++ b/test_conformance/basic/test_progvar.cpp @@ -1350,10 +1350,8 @@ static int l_user_type( cl_device_id device, cl_context context, cl_command_queu ksrc.add( reader_src ); int status = CL_SUCCESS; - program = clCreateProgramWithSource( context, ksrc.num_str(), ksrc.strs(), ksrc.lengths(), &status ); - test_error_ret(status,"Failed to create program for user type test",status); - status = clBuildProgram( program, 1, &device, OPTIONS, 0, 0 ); + status = create_single_kernel_helper_create_program(context, &program, ksrc.num_str(), ksrc.strs(), OPTIONS); if(check_error(status, "Failed to build program for user type test (%s)", IGetErrorString(status))) { print_build_log(program, 1, &device, ksrc.num_str(), ksrc.strs(), ksrc.lengths(), OPTIONS); diff --git a/test_conformance/compiler/test_async_build.c b/test_conformance/compiler/test_async_build.c index aebe97f7..30024228 100644 --- a/test_conformance/compiler/test_async_build.c +++ b/test_conformance/compiler/test_async_build.c @@ -53,12 +53,8 @@ int test_async_build(cl_device_id deviceID, cl_context context, cl_command_queue buildNotificationSent = 0; /* First, test by doing the slow method of the individual calls */ - program = clCreateProgramWithSource( context, 1, sample_async_kernel, NULL, &error ); - if( program == NULL || error != CL_SUCCESS) - { - print_error( error, "Unable to create test program" ); - return -1; - } + error = create_single_kernel_helper_create_program(context, &program, 1, sample_async_kernel); + test_error(error, "Unable to create program from source"); /* Compile the program */ error = clBuildProgram( program, 1, &deviceID, NULL, test_notify_build_complete, (void *)"userData" ); diff --git a/test_conformance/compiler/test_build_helpers.c b/test_conformance/compiler/test_build_helpers.c index e882186b..975a21f8 100644 --- a/test_conformance/compiler/test_build_helpers.c +++ b/test_conformance/compiler/test_build_helpers.c @@ -317,7 +317,7 @@ int test_get_program_info(cl_device_id deviceID, cl_context context, cl_command_ cl_uint numInstances; - program = clCreateProgramWithSource( context, 1, sample_kernel_code_single_line, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &program, 1, sample_kernel_code_single_line); if( program == NULL ) { log_error( "ERROR: Unable to create reference program!\n" ); @@ -413,7 +413,7 @@ int test_get_program_source(cl_device_id deviceID, cl_context context, cl_comman size_t length; - program = clCreateProgramWithSource( context, 1, sample_kernel_code_single_line, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &program, 1, sample_kernel_code_single_line); if( program == NULL ) { log_error( "ERROR: Unable to create test program!\n" ); @@ -423,7 +423,7 @@ int test_get_program_source(cl_device_id deviceID, cl_context context, cl_comman /* Try getting the length */ error = clGetProgramInfo( program, CL_PROGRAM_SOURCE, NULL, NULL, &length ); test_error( error, "Unable to get program source length" ); - if( length != strlen( sample_kernel_code_single_line[0] ) + 1 ) + if (length != strlen(sample_kernel_code_single_line[0]) + 1 && gCompilationMode == kOnline) { log_error( "ERROR: Length returned for program source is incorrect!\n" ); return -1; @@ -432,7 +432,7 @@ int test_get_program_source(cl_device_id deviceID, cl_context context, cl_comman /* Try normal source */ error = clGetProgramInfo( program, CL_PROGRAM_SOURCE, sizeof( buffer ), buffer, NULL ); test_error( error, "Unable to get program source" ); - if( strlen( buffer ) != strlen( sample_kernel_code_single_line[0] ) ) + if (strlen(buffer) != strlen(sample_kernel_code_single_line[0]) && gCompilationMode == kOnline) { log_error( "ERROR: Length of program source is incorrect!\n" ); return -1; @@ -441,12 +441,12 @@ int test_get_program_source(cl_device_id deviceID, cl_context context, cl_comman /* Try both at once */ error = clGetProgramInfo( program, CL_PROGRAM_SOURCE, sizeof( buffer ), buffer, &length ); test_error( error, "Unable to get program source" ); - if( strlen( buffer ) != strlen( sample_kernel_code_single_line[0] ) ) + if (strlen(buffer) != strlen(sample_kernel_code_single_line[0]) && gCompilationMode == kOnline) { log_error( "ERROR: Length of program source is incorrect!\n" ); return -1; } - if( length != strlen( sample_kernel_code_single_line[0] ) + 1 ) + if (length != strlen(sample_kernel_code_single_line[0]) + 1 && gCompilationMode == kOnline) { log_error( "ERROR: Returned length of program source is incorrect!\n" ); return -1; @@ -468,7 +468,7 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co cl_build_status status; - program = clCreateProgramWithSource( context, 1, sample_kernel_code_single_line, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &program, 1, sample_kernel_code_single_line); if( program == NULL ) { log_error( "ERROR: Unable to create test program!\n" ); diff --git a/test_conformance/compiler/test_build_options.cpp b/test_conformance/compiler/test_build_options.cpp index cd5941d5..0e2f7ae8 100644 --- a/test_conformance/compiler/test_build_options.cpp +++ b/test_conformance/compiler/test_build_options.cpp @@ -97,7 +97,8 @@ int test_options_build_optimizations(cl_device_id deviceID, cl_context context, for(size_t i = 0; i < sizeof(optimization_options) / (sizeof(char*)); i++) { - clProgramWrapper program = clCreateProgramWithSource( context, 1, options_test_kernel, NULL, &error ); + clProgramWrapper program; + error = create_single_kernel_helper_create_program(context, &program, 1, options_test_kernel, optimization_options[i]); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create reference program!\n" ); diff --git a/test_conformance/compiler/test_compile.c b/test_conformance/compiler/test_compile.c index 3f1082e9..dc0d0972 100644 --- a/test_conformance/compiler/test_compile.c +++ b/test_conformance/compiler/test_compile.c @@ -189,7 +189,7 @@ int test_large_single_compile(cl_context context, cl_device_id deviceID, unsigne free_mtdata(d); d = NULL; /* Try to create a program with these lines */ - program = clCreateProgramWithSource( context, numLines, lines, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &program, numLines, lines); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -296,7 +296,7 @@ int test_large_multi_file_library(cl_context context, cl_device_id deviceID, cl_ } /* Try to create a program with these lines */ - program = clCreateProgramWithSource( context, 2*numLines + 2, lines, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &program, 2 * numLines + 2, lines); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s) (in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -465,7 +465,7 @@ int test_large_multiple_embedded_headers(cl_context context, cl_device_id device sprintf(buffer, composite_kernel_extern_template, i); const char* line = _strdup(buffer); - headers[i] = clCreateProgramWithSource(context, 1, &line, NULL, &error); + error = create_single_kernel_helper_create_program(context, &headers[i], 1, &line); if( headers[i] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple header program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__); @@ -484,7 +484,7 @@ int test_large_multiple_embedded_headers(cl_context context, cl_device_id device } /* Try to create a program with these lines */ - program = clCreateProgramWithSource( context, 2*numLines + 2, lines, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &program, 2 * numLines + 2, lines); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s) (in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -500,7 +500,7 @@ int test_large_multiple_embedded_headers(cl_context context, cl_device_id device { sprintf(buffer, simple_kernel_template, i); const char* kernel_source = _strdup(buffer); - simple_kernels[i] = clCreateProgramWithSource( context, 1, &kernel_source, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &simple_kernels[i], 1, &kernel_source); if( simple_kernels[i] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s) (in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -659,7 +659,7 @@ int test_large_multiple_libraries(cl_context context, cl_device_id deviceID, cl_ } /* Try to create a program with these lines */ - my_program_and_libraries[0] = clCreateProgramWithSource( context, 2*numLines + 2, lines, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &my_program_and_libraries[0], 2 * numLines + 2, lines); if( my_program_and_libraries[0] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -675,7 +675,7 @@ int test_large_multiple_libraries(cl_context context, cl_device_id deviceID, cl_ { sprintf(buffer, simple_kernel_template, i); const char* kernel_source = _strdup(buffer); - simple_kernels[i] = clCreateProgramWithSource( context, 1, &kernel_source, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &simple_kernels[i], 1, &kernel_source); if( simple_kernels[i] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -823,7 +823,7 @@ int test_large_multiple_files_multiple_libraries(cl_context context, cl_device_i } /* Try to create a program with these lines */ - my_programs_and_libraries[0] = clCreateProgramWithSource( context, 2*numLines + 2, lines, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &my_programs_and_libraries[0], 2 * numLines + 2, lines); if( my_programs_and_libraries[0] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -839,7 +839,7 @@ int test_large_multiple_files_multiple_libraries(cl_context context, cl_device_i { sprintf(buffer, simple_kernel_template, i); const char* kernel_source = _strdup(buffer); - simple_kernels[i] = clCreateProgramWithSource( context, 1, &kernel_source, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &simple_kernels[i], 1, &kernel_source); if( simple_kernels[i] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -982,7 +982,7 @@ int test_large_multiple_files(cl_context context, cl_device_id deviceID, cl_comm } /* Try to create a program with these lines */ - my_programs[0] = clCreateProgramWithSource( context, 2*numLines + 2, lines, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &my_programs[0], 2 * numLines + 2, lines); if( my_programs[0] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -998,7 +998,7 @@ int test_large_multiple_files(cl_context context, cl_device_id deviceID, cl_comm { sprintf(buffer, simple_kernel_template, i); const char* kernel_source = _strdup(buffer); - my_programs[i+1] = clCreateProgramWithSource( context, 1, &kernel_source, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &my_programs[i + 1], 1, &kernel_source); if( my_programs[i+1] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1092,7 +1092,7 @@ int test_simple_compile_only(cl_device_id deviceID, cl_context context, cl_comma cl_program program; log_info("Testing a simple compilation only...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1116,7 +1116,7 @@ int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, c log_info("Testing a simple static compilations only...\n"); - program = clCreateProgramWithSource(context, 1, &compile_static_var, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &compile_static_var); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple static variable test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1131,7 +1131,7 @@ int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, c error = clReleaseProgram( program ); test_error( error, "Unable to release program object" ); - program = clCreateProgramWithSource(context, 1, &compile_static_struct, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &compile_static_struct); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple static struct test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1146,7 +1146,7 @@ int test_simple_static_compile_only(cl_device_id deviceID, cl_context context, c error = clReleaseProgram( program ); test_error( error, "Unable to release program object" ); - program = clCreateProgramWithSource(context, 1, &compile_static_function, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &compile_static_function); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple static function test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1170,7 +1170,7 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, c cl_program program; log_info("Testing a simple extern compilations only...\n"); - program = clCreateProgramWithSource(context, 1, &simple_header, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_header); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple extern kernel test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1185,7 +1185,7 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, c error = clReleaseProgram( program ); test_error( error, "Unable to release program object" ); - program = clCreateProgramWithSource(context, 1, &compile_extern_var, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &compile_extern_var); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple extern variable test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1200,7 +1200,7 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, c error = clReleaseProgram( program ); test_error( error, "Unable to release program object" ); - program = clCreateProgramWithSource(context, 1, &compile_extern_struct, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &compile_extern_struct); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple extern struct test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1215,7 +1215,7 @@ int test_simple_extern_compile_only(cl_device_id deviceID, cl_context context, c error = clReleaseProgram( program ); test_error( error, "Unable to release program object" ); - program = clCreateProgramWithSource(context, 1, &compile_extern_function, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &compile_extern_function); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple extern function test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1268,7 +1268,7 @@ int test_simple_compile_with_callback(cl_device_id deviceID, cl_context context, cl_event compile_program_completion_event; log_info("Testing a simple compilation with callback...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1335,7 +1335,7 @@ int test_simple_link_only(cl_device_id deviceID, cl_context context, cl_command_ cl_program program; log_info("Testing a simple linking only...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1365,7 +1365,7 @@ int test_two_file_regular_variable_access(cl_device_id deviceID, cl_context cont const char* sources[2] = {simple_kernel, compile_regular_var}; // here we want to avoid linking error due to lack of kernels log_info("Compiling and linking two program objects, where one tries to access regular variable from another...\n"); - program = clCreateProgramWithSource(context, 2, sources, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 2, sources); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a test program with regular variable! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1375,7 +1375,7 @@ int test_two_file_regular_variable_access(cl_device_id deviceID, cl_context cont error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, NULL); test_error( error, "Unable to compile a simple program with regular function" ); - second_program = clCreateProgramWithSource(context, 1, &link_static_var_access, NULL, &error); + error = create_single_kernel_helper_create_program(context, &second_program, 1, &link_static_var_access); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a test program that tries to access a regular variable! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1409,7 +1409,7 @@ int test_two_file_regular_struct_access(cl_device_id deviceID, cl_context contex const char* sources[2] = {simple_kernel, compile_regular_struct}; // here we want to avoid linking error due to lack of kernels log_info("Compiling and linking two program objects, where one tries to access regular struct from another...\n"); - program = clCreateProgramWithSource(context, 2, sources, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 2, sources); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a test program with regular struct! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1419,7 +1419,7 @@ int test_two_file_regular_struct_access(cl_device_id deviceID, cl_context contex error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, NULL); test_error( error, "Unable to compile a simple program with regular struct" ); - second_program = clCreateProgramWithSource(context, 1, &link_static_struct_access, NULL, &error); + error = create_single_kernel_helper_create_program(context, &second_program, 1, &link_static_struct_access); if( second_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a test program that tries to access a regular struct! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1454,7 +1454,7 @@ int test_two_file_regular_function_access(cl_device_id deviceID, cl_context cont const char* sources[2] = {simple_kernel, compile_regular_function}; // here we want to avoid linking error due to lack of kernels log_info("Compiling and linking two program objects, where one tries to access regular function from another...\n"); - program = clCreateProgramWithSource(context, 2, sources, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 2, sources); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a test program with regular function! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1464,7 +1464,7 @@ int test_two_file_regular_function_access(cl_device_id deviceID, cl_context cont error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, NULL); test_error( error, "Unable to compile a simple program with regular function" ); - second_program = clCreateProgramWithSource(context, 1, &link_static_function_access, NULL, &error); + error = create_single_kernel_helper_create_program(context, &second_program, 1, &link_static_function_access); if( second_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a test program that tries to access a regular function! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1514,7 +1514,7 @@ int test_simple_embedded_header_link(cl_device_id deviceID, cl_context context, error = clCompileProgram(program, 1, &deviceID, NULL, 1, &header, &simple_header_name, NULL, NULL); test_error( error, "Unable to compile a simple program with embedded header" ); - simple_program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &simple_program, 1, &simple_kernel); if( simple_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1574,7 +1574,7 @@ int test_simple_link_with_callback(cl_device_id deviceID, cl_context context, cl cl_event link_program_completion_event; log_info("Testing a simple linking with callback...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1738,7 +1738,7 @@ int test_execute_after_simple_compile_and_link(cl_device_id deviceID, cl_context cl_program program; log_info("Testing execution after a simple compile and link...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1777,7 +1777,7 @@ int test_execute_after_simple_compile_and_link_no_device_info(cl_device_id devic cl_program program; log_info("Testing execution after a simple compile and link with no device information provided...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1816,7 +1816,7 @@ int test_execute_after_simple_compile_and_link_with_defines(cl_device_id deviceI cl_program program; log_info("Testing execution after a simple compile and link with defines...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel_with_defines, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel_with_defines, "-DFIRST=5 -DSECOND=37"); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1857,7 +1857,7 @@ int test_execute_after_serialize_reload_object(cl_device_id deviceID, cl_context unsigned char *binary; log_info("Testing execution after serialization and reloading of the object...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1943,7 +1943,7 @@ int test_execute_after_serialize_reload_library(cl_device_id deviceID, cl_contex log_info("Testing execution after linking a binary with a simple library...\n"); // we will test creation of a simple library from one file - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -1995,7 +1995,7 @@ int test_execute_after_serialize_reload_library(cl_device_id deviceID, cl_contex cl_program library_with_binary = clCreateProgramWithBinary(context, 1, &deviceID, &binarySize, (const unsigned char**)buffers, loadErrors, &error); test_error( error, "Unable to create program with binary" ); - another_program = clCreateProgramWithSource(context, 1, &another_simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &another_program, 1, &another_simple_kernel); if( another_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2087,7 +2087,7 @@ int test_execute_after_simple_compile_and_link_with_callbacks(cl_device_id devic cl_event compile_program_completion_event, link_program_completion_event; log_info("Testing execution after a simple compile and link with callbacks...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2146,7 +2146,7 @@ int test_simple_library_only(cl_device_id deviceID, cl_context context, cl_comma cl_program program; log_info("Testing creation of a simple library...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2176,7 +2176,7 @@ int test_simple_library_with_callback(cl_device_id deviceID, cl_context context, cl_event link_program_completion_event; log_info("Testing creation of a simple library with a callback...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2217,7 +2217,7 @@ int test_simple_library_with_link(cl_device_id deviceID, cl_context context, cl_ cl_program program, another_program; log_info("Testing creation and linking with a simple library...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2230,7 +2230,7 @@ int test_simple_library_with_link(cl_device_id deviceID, cl_context context, cl_ cl_program my_newly_minted_library = clLinkProgram(context, 1, &deviceID, "-create-library", 1, &program, NULL, NULL, &error); test_error( error, "Unable to create a simple library" ); - another_program = clCreateProgramWithSource(context, 1, &another_simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &another_program, 1, &another_simple_kernel); if( another_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2266,7 +2266,7 @@ int test_execute_after_simple_library_with_link(cl_device_id deviceID, cl_contex cl_program program, another_program; log_info("Testing execution after linking a binary with a simple library...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2279,7 +2279,7 @@ int test_execute_after_simple_library_with_link(cl_device_id deviceID, cl_contex cl_program my_newly_minted_library = clLinkProgram(context, 1, &deviceID, "-create-library", 1, &program, NULL, NULL, &error); test_error( error, "Unable to create a simple library" ); - another_program = clCreateProgramWithSource(context, 1, &another_simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &another_program, 1, &another_simple_kernel); if( another_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2335,7 +2335,7 @@ int test_two_file_link(cl_device_id deviceID, cl_context context, cl_command_que cl_program program, another_program; log_info("Testing two file compiling and linking...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2346,7 +2346,7 @@ int test_two_file_link(cl_device_id deviceID, cl_context context, cl_command_que test_error( error, "Unable to compile a simple program" ); - another_program = clCreateProgramWithSource(context, 1, &another_simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &another_program, 1, &another_simple_kernel); if( another_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2379,7 +2379,7 @@ int test_execute_after_two_file_link(cl_device_id deviceID, cl_context context, cl_program program, another_program; log_info("Testing two file compiling and linking and execution of two kernels afterwards ...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2389,7 +2389,7 @@ int test_execute_after_two_file_link(cl_device_id deviceID, cl_context context, error = clCompileProgram(program, 1, &deviceID, NULL, 0, NULL, NULL, NULL, NULL); test_error( error, "Unable to compile a simple program" ); - another_program = clCreateProgramWithSource(context, 1, &another_simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &another_program, 1, &another_simple_kernel); if( another_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2656,7 +2656,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, cl_comma unsigned char *binary; log_info("Testing querying of program binary type...\n"); - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2783,7 +2783,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, cl_comma program_type = -1; free(binary); - another_program = clCreateProgramWithSource(context, 1, &another_simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &another_program, 1, &another_simple_kernel); if( another_program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -2884,7 +2884,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, cl_comma test_error( error, "Unable to release program object" ); /* Oh, one more thing. Steve Jobs and apparently Herb Sutter. The question is "Who is copying whom?" */ - program = clCreateProgramWithSource(context, 1, &simple_kernel, NULL, &error); + error = create_single_kernel_helper_create_program(context, &program, 1, &simple_kernel); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create a simple test program! (%s in %s:%d)\n", IGetErrorString( error ), __FILE__, __LINE__ ); @@ -3017,7 +3017,7 @@ int test_large_compile_and_link_status_options_log(cl_context context, cl_device } /* Try to create a program with these lines */ - program = clCreateProgramWithSource( context, 2*numLines + 2, lines, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &program, 2 * numLines + 2, lines); if( program == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s) (in %s:%d)\n", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); @@ -3079,7 +3079,7 @@ int test_large_compile_and_link_status_options_log(cl_context context, cl_device { sprintf(buffer, simple_kernel_template, i); const char* kernel_source = _strdup(buffer); - simple_kernels[i] = clCreateProgramWithSource( context, 1, &kernel_source, NULL, &error ); + error = create_single_kernel_helper_create_program(context, &simple_kernels[i], 1, &kernel_source); if( simple_kernels[i] == NULL || error != CL_SUCCESS ) { log_error( "ERROR: Unable to create long test program with %d lines! (%s in %s:%d)", numLines, IGetErrorString( error ), __FILE__, __LINE__ ); diff --git a/test_conformance/compiler/test_image_macro.c b/test_conformance/compiler/test_image_macro.c index 44dd2575..f85f092f 100644 --- a/test_conformance/compiler/test_image_macro.c +++ b/test_conformance/compiler/test_image_macro.c @@ -59,7 +59,7 @@ int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue if( (image_support == CL_TRUE) ) { - program = clCreateProgramWithSource( context, 1, (const char**) &image_supported_source, NULL, &status ); + status = create_single_kernel_helper_create_program(context, &program, 1, (const char**)&image_supported_source); if( status ) { @@ -75,7 +75,7 @@ int test_image_macro(cl_device_id deviceID, cl_context context, cl_command_queue } else { - program = clCreateProgramWithSource( context, 1, (const char**) &image_not_supported_source, NULL, &status ); + status = create_single_kernel_helper_create_program(context, &program, 1, (const char**)&image_not_supported_source); if( status ) { log_error ("Failure creating program, [%d] \n", status ); diff --git a/test_conformance/conversions/test_conversions.c b/test_conformance/conversions/test_conversions.c index 998f2402..3212d3d0 100644 --- a/test_conformance/conversions/test_conversions.c +++ b/test_conformance/conversions/test_conversions.c @@ -120,7 +120,7 @@ static void PrintArch(void); test_status InitCL( cl_device_id device ); static int GetTestCase( const char *name, Type *outType, Type *inType, SaturationMode *sat, RoundingMode *round ); static int DoTest( cl_device_id device, Type outType, Type inType, SaturationMode sat, RoundingMode round, MTdata d ); -static cl_program MakeProgram( cl_device_id device, Type outType, Type inType, SaturationMode sat, RoundingMode round, int vectorSize, cl_kernel *outKernel ); +static cl_program MakeProgram( Type outType, Type inType, SaturationMode sat, RoundingMode round, int vectorSize, cl_kernel *outKernel ); static int RunKernel( cl_kernel kernel, void *inBuf, void *outBuf, size_t blockCount ); void *FlushToZero( void ); @@ -1131,7 +1131,7 @@ static int DoTest( cl_device_id device, Type outType, Type inType, SaturationMod for( vectorSize = gMinVectorSize; vectorSize < gMaxVectorSize; vectorSize++) { - writeInputBufferInfo.calcInfo[vectorSize].program = MakeProgram( device, outType, inType, sat, round, vectorSize, + writeInputBufferInfo.calcInfo[vectorSize].program = MakeProgram( outType, inType, sat, round, vectorSize, &writeInputBufferInfo.calcInfo[vectorSize].kernel ); if( NULL == writeInputBufferInfo.calcInfo[vectorSize].program ) { @@ -1652,140 +1652,116 @@ void CL_CALLBACK CalcReferenceValuesComplete( cl_event e, cl_int status, void *d // all the calls to CalcReferenceValuesComplete exit. } -static cl_program CreateImplicitConvertProgram( Type outType, Type inType, SaturationMode sat, RoundingMode round, int vectorSize, char testName[256], cl_int *error ) -{ - char inName[32]; - char outName[32]; - const char *programSource[] = - { - "", // optional pragma - "__kernel void ", testName, "( __global ", inName, " *src, __global ", outName, " *dest )\n" - "{\n" - " size_t i = get_global_id(0);\n" - " dest[i] = src[i];\n" - "}\n" - }; - size_t stringCount = sizeof( programSource ) / sizeof( programSource[0] ); - const char **strings = programSource; - - if (outType == kdouble || inType == kdouble) - programSource[0] = "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; - - //create the type name - strncpy( inName, gTypeNames[ inType ], sizeof( inName ) ); - strncpy( outName, gTypeNames[ outType ], sizeof( outName ) ); - sprintf( testName, "test_implicit_%s_%s", outName, inName ); - vlog( "Building implicit %s -> %s conversion test\n", gTypeNames[ inType ], gTypeNames[ outType ] ); - fflush(stdout); - - //create the program - cl_program program = clCreateProgramWithSource(gContext, (cl_uint) stringCount, strings, NULL, error); - if( NULL == program || *error ) - { - vlog_error( "\t\tFAILED -- Failed to create program. (%d)\n", *error ); - return NULL; - } - return program; -} - - -static cl_program CreateStandardProgram( Type outType, Type inType, SaturationMode sat, RoundingMode round, int vectorSize, char testName[256], cl_int *error ) -{ - vectorSize = vectorSizes[ vectorSize ]; - - char convertString[128]; - char inName[32]; - char outName[32]; - const char *programSource[] = - { - "", // optional pragma - "__kernel void ", testName, "( __global ", inName, " *src, __global ", outName, " *dest )\n" - "{\n" - " size_t i = get_global_id(0);\n" - " dest[i] = ", convertString, "( src[i] );\n" - "}\n" - }; - const char *programSourceV3[] = - { - "", // optional pragma - "__kernel void ", testName, "( __global ", inName, " *src, __global ", outName, " *dest )\n" - "{\n" - " size_t i = get_global_id(0);\n" - " if( i + 1 < get_global_size(0))\n" - " vstore3( ", convertString, "( vload3( i, src)), i, dest );\n" - " else\n" - " {\n" - " ", inName, "3 in;\n" - " ", outName, "3 out;\n" - " if( 0 == (i & 1) )\n" - " in.y = src[3*i+1];\n" - " in.x = src[3*i];\n" - " out = ", convertString, "( in ); \n" - " dest[3*i] = out.x;\n" - " if( 0 == (i & 1) )\n" - " dest[3*i+1] = out.y;\n" - " }\n" - "}\n" - }; - size_t stringCount = 3 == vectorSize ? sizeof( programSourceV3 ) / sizeof( programSourceV3[0] ) : - sizeof( programSource ) / sizeof( programSource[0] ); - const char **strings = 3 == vectorSize ? programSourceV3 : programSource; - - if (outType == kdouble || inType == kdouble) { - programSource[0] = "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; - programSourceV3[0] = "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; - } - - //create the type name - switch (vectorSize) - { - case 1: - strncpy( inName, gTypeNames[ inType ], sizeof( inName ) ); - strncpy( outName, gTypeNames[ outType ], sizeof( outName ) ); - snprintf( convertString, sizeof(convertString), "convert_%s%s%s", outName, gSaturationNames[ sat ], gRoundingModeNames[ round ] ); - snprintf( testName, 256, "test_%s_%s", convertString, inName ); - vlog( "Building %s( %s ) test\n", convertString, inName ); - break; - case 3: - strncpy( inName, gTypeNames[ inType ], sizeof( inName ) ); - strncpy( outName, gTypeNames[ outType ], sizeof( outName ) ); - snprintf( convertString, sizeof(convertString), "convert_%s3%s%s", outName, gSaturationNames[ sat ], gRoundingModeNames[ round ] ); - snprintf( testName, 256, "test_%s_%s3", convertString, inName ); - vlog( "Building %s( %s3 ) test\n", convertString, inName ); - break; - default: - snprintf( inName, sizeof( inName ), "%s%d", gTypeNames[ inType ], vectorSize ); - snprintf( outName, sizeof( outName ), "%s%d", gTypeNames[ outType ], vectorSize ); - snprintf( convertString, sizeof(convertString), "convert_%s%s%s", outName, gSaturationNames[ sat ], gRoundingModeNames[ round ] ); - snprintf( testName, 256, "test_%s_%s", convertString, inName ); - vlog( "Building %s( %s ) test\n", convertString, inName ); - break; - } - - fflush(stdout); - - //create the program - cl_program program = clCreateProgramWithSource(gContext, (cl_uint) stringCount, strings, NULL, error); - if( NULL == program || *error ) - { - vlog_error( "\t\tFAILED -- Failed to create program. (%d)\n", *error ); - return NULL; - } - return program; -} - - -static cl_program MakeProgram( cl_device_id device, Type outType, Type inType, SaturationMode sat, RoundingMode round, int vectorSize, cl_kernel *outKernel ) +static cl_program MakeProgram( Type outType, Type inType, SaturationMode sat, RoundingMode round, int vectorSize, cl_kernel *outKernel ) { cl_program program; char testName[256]; int error = 0; + const char **strings; + size_t stringCount = 0; // Create the program. This is a bit complicated because we are trying to avoid byte and short stores. - if( 0 == vectorSize ) - program = CreateImplicitConvertProgram( outType, inType, sat, round, vectorSize, testName, &error ); + if (0 == vectorSize) + { + char inName[32]; + char outName[32]; + const char *programSource[] = + { + "", // optional pragma + "__kernel void ", testName, "( __global ", inName, " *src, __global ", outName, " *dest )\n" + "{\n" + " size_t i = get_global_id(0);\n" + " dest[i] = src[i];\n" + "}\n" + }; + stringCount = sizeof(programSource) / sizeof(programSource[0]); + strings = programSource; + + if (outType == kdouble || inType == kdouble) + programSource[0] = "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; + + //create the type name + strncpy(inName, gTypeNames[inType], sizeof(inName)); + strncpy(outName, gTypeNames[outType], sizeof(outName)); + sprintf(testName, "test_implicit_%s_%s", outName, inName); + vlog("Building implicit %s -> %s conversion test\n", gTypeNames[inType], gTypeNames[outType]); + fflush(stdout); + } else - program = CreateStandardProgram( outType, inType, sat, round, vectorSize, testName, &error ); + { + int vectorSizetmp = vectorSizes[vectorSize]; + + char convertString[128]; + char inName[32]; + char outName[32]; + const char *programSource[] = + { + "", // optional pragma + "__kernel void ", testName, "( __global ", inName, " *src, __global ", outName, " *dest )\n" + "{\n" + " size_t i = get_global_id(0);\n" + " dest[i] = ", convertString, "( src[i] );\n" + "}\n" + }; + const char *programSourceV3[] = + { + "", // optional pragma + "__kernel void ", testName, "( __global ", inName, " *src, __global ", outName, " *dest )\n" + "{\n" + " size_t i = get_global_id(0);\n" + " if( i + 1 < get_global_size(0))\n" + " vstore3( ", convertString, "( vload3( i, src)), i, dest );\n" + " else\n" + " {\n" + " ", inName, "3 in;\n" + " ", outName, "3 out;\n" + " if( 0 == (i & 1) )\n" + " in.y = src[3*i+1];\n" + " in.x = src[3*i];\n" + " out = ", convertString, "( in ); \n" + " dest[3*i] = out.x;\n" + " if( 0 == (i & 1) )\n" + " dest[3*i+1] = out.y;\n" + " }\n" + "}\n" + }; + stringCount = 3 == vectorSizetmp ? sizeof(programSourceV3) / sizeof(programSourceV3[0]) : + sizeof(programSource) / sizeof(programSource[0]); + strings = 3 == vectorSizetmp ? programSourceV3 : programSource; + + if (outType == kdouble || inType == kdouble) { + programSource[0] = "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; + programSourceV3[0] = "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"; + } + + //create the type name + switch (vectorSizetmp) + { + case 1: + strncpy(inName, gTypeNames[inType], sizeof(inName)); + strncpy(outName, gTypeNames[outType], sizeof(outName)); + snprintf(convertString, sizeof(convertString), "convert_%s%s%s", outName, gSaturationNames[sat], gRoundingModeNames[round]); + snprintf(testName, 256, "test_%s_%s", convertString, inName); + vlog("Building %s( %s ) test\n", convertString, inName); + break; + case 3: + strncpy(inName, gTypeNames[inType], sizeof(inName)); + strncpy(outName, gTypeNames[outType], sizeof(outName)); + snprintf(convertString, sizeof(convertString), "convert_%s3%s%s", outName, gSaturationNames[sat], gRoundingModeNames[round]); + snprintf(testName, 256, "test_%s_%s3", convertString, inName); + vlog("Building %s( %s3 ) test\n", convertString, inName); + break; + default: + snprintf(inName, sizeof(inName), "%s%d", gTypeNames[inType], vectorSizetmp); + snprintf(outName, sizeof(outName), "%s%d", gTypeNames[outType], vectorSizetmp); + snprintf(convertString, sizeof(convertString), "convert_%s%s%s", outName, gSaturationNames[sat], gRoundingModeNames[round]); + snprintf(testName, 256, "test_%s_%s", convertString, inName); + vlog("Building %s( %s ) test\n", convertString, inName); + break; + } + + fflush(stdout); + } *outKernel = NULL; const char *flags = NULL; @@ -1793,30 +1769,15 @@ static cl_program MakeProgram( cl_device_id device, Type outType, Type inType, S flags = "-cl-denorms-are-zero"; // build it - if( (error = clBuildProgram( program, 1, &device, flags, NULL, NULL ))) + error = create_single_kernel_helper(gContext, &program, outKernel, (cl_uint)stringCount, strings, testName, flags); + if (error) { char buffer[2048] = ""; - vlog_error("\t\tFAILED -- clBuildProgramExecutable() failed: %d\n", error); - clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, NULL); - vlog_error("Log: %s\n", buffer); - - clReleaseProgram( program ); - return NULL; - } - - *outKernel = clCreateKernel(program, testName, &error); - if( NULL == *outKernel || error) - { - char buffer[2048] = ""; - - vlog_error("\t\tFAILED -- clCreateKernel() failed (%d):\n", error); - clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, NULL); - vlog_error("Log: %s\n", buffer); - clReleaseProgram( program ); + vlog_error("Failed to build kernel/program.\n", error); + clReleaseProgram(program); return NULL; } return program; } - diff --git a/test_conformance/d3d10/harness.cpp b/test_conformance/d3d10/harness.cpp index 44571451..ffdfea5a 100644 --- a/test_conformance/d3d10/harness.cpp +++ b/test_conformance/d3d10/harness.cpp @@ -367,12 +367,7 @@ cl_int HarnessD3D10_CreateKernelFromSource( const char *sourceTexts[] = {source}; size_t sourceLengths[] = {strlen(source) }; - program = clCreateProgramWithSource( - context, - 1, - sourceTexts, - sourceLengths, - &status); + status = create_single_kernel_helper_create_program(context, &program, 1, &sourceTexts[0]); TestRequire( CL_SUCCESS == status, "clCreateProgramWithSource failed"); diff --git a/test_conformance/d3d11/harness.cpp b/test_conformance/d3d11/harness.cpp index dafe27bb..7d33b7f0 100644 --- a/test_conformance/d3d11/harness.cpp +++ b/test_conformance/d3d11/harness.cpp @@ -408,12 +408,7 @@ cl_int HarnessD3D11_CreateKernelFromSource( const char *sourceTexts[] = {source}; size_t sourceLengths[] = {strlen(source) }; - program = clCreateProgramWithSource( - context, - 1, - sourceTexts, - sourceLengths, - &status); + status = create_single_kernel_helper_create_program(context, &program, 1, &sourceTexts[0]); TestRequire( CL_SUCCESS == status, "clCreateProgramWithSource failed"); diff --git a/test_conformance/device_partition/test_device_partition.cpp b/test_conformance/device_partition/test_device_partition.cpp index 08fc504c..468cd22b 100644 --- a/test_conformance/device_partition/test_device_partition.cpp +++ b/test_conformance/device_partition/test_device_partition.cpp @@ -70,7 +70,7 @@ int create_single_kernel_helper( cl_context context, cl_program *outProgram, cl_ int error = CL_SUCCESS; /* Create the program object from source */ - *outProgram = clCreateProgramWithSource( context, numKernelLines, kernelProgram, NULL, &error ); + error = create_single_kernel_helper_create_program(context, outProgram, numKernelLines, kernelProgram); if( *outProgram == NULL || error != CL_SUCCESS) { print_error( error, "clCreateProgramWithSource failed" ); diff --git a/test_conformance/events/test_userevents.cpp b/test_conformance/events/test_userevents.cpp index e2ad9e3e..39dea376 100644 --- a/test_conformance/events/test_userevents.cpp +++ b/test_conformance/events/test_userevents.cpp @@ -23,6 +23,7 @@ #include #include #include +#include "../../test_common/harness/kernelHelpers.h" /////////////////////////////////////////////////////////////////////////////// // ATF performance framework. @@ -167,7 +168,8 @@ int test_userevents( cl_device_id deviceID, cl_context context, cl_command_queue CL_EXIT_ERROR((err != CL_SUCCESS) ? CL_SUCCESS : -1,"clGetEventProfilingInfo returned wrong error."); // Test semantics. - cl_program program = clCreateProgramWithSource(context,1,src,NULL,&err); + cl_program program; + err = create_single_kernel_helper_create_program(context, &program, 1, src); CL_EXIT_ERROR(err,"clCreateProgramWithSource failed"); CL_EXIT_BUILD_ERROR(clBuildProgram(program,0,NULL,"",NULL,NULL),program,"Building program from inline src:\t%s",src[0]); diff --git a/test_conformance/half/cl_utils.c b/test_conformance/half/cl_utils.c index b5d66a3e..7875f1d7 100644 --- a/test_conformance/half/cl_utils.c +++ b/test_conformance/half/cl_utils.c @@ -22,6 +22,7 @@ #include "test_config.h" #include "string.h" +#include "../../test_common/harness/kernelHelpers.h" #include "../../test_common/harness/testHarness.h" @@ -244,7 +245,8 @@ cl_program MakeProgram( cl_device_id device, const char *source[], int count ) int i; //create the program - cl_program program = clCreateProgramWithSource( gContext, count, source, NULL, &error ); + cl_program program; + error = create_single_kernel_helper_create_program(gContext, &program, (cl_uint)count, source); if( NULL == program ) { vlog_error( "\t\tFAILED -- Failed to create program. (%d)\n", error ); diff --git a/test_conformance/multiple_device_context/test_multiple_contexts.c b/test_conformance/multiple_device_context/test_multiple_contexts.c index 9c9ceac6..6d163dd1 100644 --- a/test_conformance/multiple_device_context/test_multiple_contexts.c +++ b/test_conformance/multiple_device_context/test_multiple_contexts.c @@ -130,7 +130,7 @@ TestItem *CreateTestItem( cl_device_id deviceID, cl_int *err ) } // Create a program - item->p = clCreateProgramWithSource( item->c, 1, context_test_kernels, NULL, &error ); + error = create_single_kernel_helper_create_program(item->c, &item->p, 1, context_test_kernels); if( NULL == item->p || CL_SUCCESS != error ) { if( err ) diff --git a/test_conformance/printf/test_printf.c b/test_conformance/printf/test_printf.c index ce26f955..b19c803f 100644 --- a/test_conformance/printf/test_printf.c +++ b/test_conformance/printf/test_printf.c @@ -301,65 +301,19 @@ static cl_program makePrintfProgram(cl_kernel *kernel_ptr, const cl_context cont if(allTestCase[testId]->_type == TYPE_VECTOR) { - program = clCreateProgramWithSource( context,sizeof(sourceVec)/sizeof(sourceVec[0]),sourceVec, NULL, NULL); + err = create_single_kernel_helper(context, &program, NULL, sizeof(sourceVec) / sizeof(sourceVec[0]), sourceVec, NULL); } else if(allTestCase[testId]->_type == TYPE_ADDRESS_SPACE) { - program = clCreateProgramWithSource( context,sizeof(sourceAddrSpace)/sizeof(sourceAddrSpace[0]),sourceAddrSpace, NULL, NULL); + err = create_single_kernel_helper(context, &program, NULL, sizeof(sourceAddrSpace) / sizeof(sourceAddrSpace[0]), sourceAddrSpace, NULL); } else { - program = clCreateProgramWithSource( context,sizeof(sourceGen)/sizeof(sourceGen[0]),sourceGen, NULL, NULL); + err = create_single_kernel_helper(context, &program, NULL, sizeof(sourceGen) / sizeof(sourceGen[0]), sourceGen, NULL); } - if (!program) { - log_error("clCreateProgramWithSource failed\n"); - return NULL; - } - - err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); - if (err != CL_SUCCESS) { - - log_error("clBuildProgramExecutable failed errcode:%d\n", err); - - - err = clGetProgramInfo( program, CL_PROGRAM_DEVICES, sizeof( devID ), &devID, NULL ); - if (err){ - log_error("Unable to get program's device: %d\n",err ); - return NULL; - } - err = clGetProgramBuildInfo( program, devID, CL_PROGRAM_BUILD_LOG, sizeof( buildLog ), buildLog, NULL ); - if (err){ - log_error("Unable to get program's build log: %d\n",err ); - return NULL; - } - size_t sourceLen; - const char** source; - - if(allTestCase[testId]->_type == TYPE_VECTOR) - { - sourceLen = sizeof(sourceVec) / sizeof( sourceVec[0] ); - source = sourceVec; - } - else if(allTestCase[testId]->_type == TYPE_ADDRESS_SPACE) - { - sourceLen = sizeof(sourceAddrSpace) / sizeof( sourceAddrSpace[0] ); - source = sourceAddrSpace; - } - else - { - sourceLen = sizeof(sourceGen) / sizeof( sourceGen[0] ); - source = sourceGen; - } - log_error( "Build log is: ------------\n" ); - log_error( "%s\n", buildLog ); - log_error( "----------\n" ); - log_error( " Source is ----------------\n"); - for(i = 0; i < sourceLen; ++i) { - log_error("%s", source[i]); - } - - log_error( "----------\n" ); + if (!program || err) { + log_error("create_single_kernel_helper failed\n"); return NULL; } diff --git a/test_conformance/select/test_select.c b/test_conformance/select/test_select.c index d61ded28..0224394c 100644 --- a/test_conformance/select/test_select.c +++ b/test_conformance/select/test_select.c @@ -277,52 +277,11 @@ static cl_program makeSelectProgram(cl_kernel *kernel_ptr, const cl_context cont */ // create program - cl_program program = clCreateProgramWithSource( context, - (cl_uint)(vec_len == 3 ? sizeof( sourceV3 ) / sizeof(sourceV3[0]) : sizeof( source ) / sizeof(source[0])), - vec_len == 3 ? sourceV3 : source, NULL, NULL); + cl_program program; - if (!program) { - log_error("clCreateProgramWithSource failed\n"); - return NULL; - } - - err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); - if (err != CL_SUCCESS) { - log_error("clBuildProgramExecutable failed errcode:%d\n", err); - - char buildLog[ 1024 * 128 ]; - cl_device_id devID; - err = clGetProgramInfo( program, CL_PROGRAM_DEVICES, sizeof( devID ), &devID, NULL ); - if (err){ - log_error("Unable to get program's device: %d\n",err ); - return NULL; - } - err = clGetProgramBuildInfo( program, devID, CL_PROGRAM_BUILD_LOG, sizeof( buildLog ), buildLog, NULL ); - if (err){ - log_error("Unable to get program's build log: %d\n",err ); - return NULL; - } - log_error( "Build log is: ------------\n" ); - log_error( "%s\n", buildLog ); - log_error( "----------\n" ); - log_error( " Source is ----------------\n"); - if(vec_len == 3) { - for(i = 0; i < sizeof(sourceV3) / sizeof( sourceV3[0] ); ++i) { - log_error("%s", sourceV3[i]); - } - } else { - for(i = 0; i < sizeof(source) / sizeof( source[0] ); ++i) { - log_error("%s", source[i]); - } - } - - log_error( "----------\n" ); - return NULL; - } - - *kernel_ptr = clCreateKernel(program, testname, &err); - if ( err ) { - log_error("clCreateKernel failed (%d)\n", err); + if (create_single_kernel_helper(context, &program, kernel_ptr, (cl_uint)(vec_len == 3 ? sizeof(sourceV3) / sizeof(sourceV3[0]) : sizeof(source) / sizeof(source[0])), vec_len == 3 ? sourceV3 : source, testname)) + { + log_error("Failed to build program (%d)\n", err); return NULL; }