From 7486dd13adb7dfc09f450c4c02130dbe68a4e3b5 Mon Sep 17 00:00:00 2001 From: Stuart Brady Date: Wed, 3 Jul 2019 19:32:44 +0100 Subject: [PATCH] Remove source transformation support This change removes support for the "source" mode of offline compilation which is commented with "to be removed in the future as we will use offline compiler here". The "source" mode allowed for the CL source to be transformed by build_script_source.py and then passed to clCreateProgramWithSource(), and appears to have been developed only for the purpose of testing the offline compilation infrastructure. --- test_common/harness/kernelHelpers.c | 35 +------------------ test_common/harness/parseParameters.cpp | 10 ++---- test_common/harness/parseParameters.h | 1 - test_conformance/build_script_source.py | 7 ---- .../compiler/test_build_helpers.c | 8 ++--- 5 files changed, 7 insertions(+), 54 deletions(-) delete mode 100644 test_conformance/build_script_source.py diff --git a/test_common/harness/kernelHelpers.c b/test_common/harness/kernelHelpers.c index 1f3f67a9..b912c163 100644 --- a/test_common/harness/kernelHelpers.c +++ b/test_common/harness/kernelHelpers.c @@ -202,8 +202,6 @@ std::string add_build_options(const std::string &baseName, const char *options) int create_single_kernel_helper_create_program(cl_context context, cl_program *outProgram, unsigned int numKernelLines, const char **kernelProgram, const char *buildOptions) { int error = CL_SUCCESS; - std::string modifiedKernelStr; - const char* modifiedKernelCode; if (gOfflineCompiler) { @@ -311,15 +309,6 @@ int create_single_kernel_helper_create_program(cl_context context, cl_program *o defaultScript = "../build_script_binary.py "; #endif } - else if (gOfflineCompilerOutputType == kSource) - { - outputTypeStr = "source"; - #if defined(_WIN32) - defaultScript = "..\\build_script_source.py "; - #else - defaultScript = "../build_script_source.py "; - #endif - } else if (gOfflineCompilerOutputType == kSpir_v) { outputTypeStr = "spir_v"; @@ -395,30 +384,8 @@ int create_single_kernel_helper_create_program(cl_context context, cl_program *o int length = ifs.tellg(); ifs.seekg(0, ifs.beg); - //treat modifiedProgram as input for clCreateProgramWithSource - if (gOfflineCompilerOutputType == kSource) - { - // read source from file: - std::vector modifiedKernelBuf(length); - - ifs.read(&modifiedKernelBuf[0], length); - ifs.close(); - - for (int i = 0; i < length; i++) - modifiedKernelStr.push_back(modifiedKernelBuf[i]); - - modifiedKernelCode = &modifiedKernelStr[0]; - - /* Create the program object from source - to be removed in the future as we will use offline compiler here */ - *outProgram = clCreateProgramWithSource(context, numKernelLines, &modifiedKernelCode, NULL, &error); - if (*outProgram == NULL || error != CL_SUCCESS) - { - print_error(error, "clCreateProgramWithSource failed"); - return error; - } - } //treat modifiedProgram as input for clCreateProgramWithBinary - else if (gOfflineCompilerOutputType == kBinary) + if (gOfflineCompilerOutputType == kBinary) { // read binary from file: std::vector modifiedKernelBuf(length); diff --git a/test_common/harness/parseParameters.cpp b/test_common/harness/parseParameters.cpp index adcc3c24..f0600659 100644 --- a/test_common/harness/parseParameters.cpp +++ b/test_common/harness/parseParameters.cpp @@ -36,9 +36,8 @@ OfflineCompilerOutputType gOfflineCompilerOutputType; void helpInfo () { log_info(" '-ILPath path_to_spirv_bin.\n"); - log_info(" '-offlineCompiler ': use offline compiler\n"); + log_info(" '-offlineCompiler ': use offline compiler\n"); log_info(" ' output_type binary - \"../build_script_binary.py\" is invoked\n"); - log_info(" ' output_type source - \"../build_script_source.py\" is invoked\n"); log_info(" ' output_type spir_v - \"../cl_build_script_spir_v.py\" is invoked. optional modes: generate, cache\n"); log_info(" ' mode generate - force binary generation\n"); log_info(" ' mode cache - force reading binary files from cache\n"); @@ -86,11 +85,6 @@ int parseCustomParam (int argc, const char *argv[], const char *ignore) gOfflineCompilerOutputType = kBinary; delArg++; } - else if (!strcmp(argv[i + 1], "source")) - { - gOfflineCompilerOutputType = kSource; - delArg++; - } else if (!strcmp(argv[i + 1], "spir_v")) { gOfflineCompilerOutputType = kSpir_v; @@ -122,7 +116,7 @@ int parseCustomParam (int argc, const char *argv[], const char *ignore) else { log_error(" Offline Compiler parameters are incorrect. Usage:\n"); - log_error(" -offlineCompiler \n"); + log_error(" -offlineCompiler \n"); return -1; } } diff --git a/test_common/harness/parseParameters.h b/test_common/harness/parseParameters.h index 4fb69a4c..4cded590 100644 --- a/test_common/harness/parseParameters.h +++ b/test_common/harness/parseParameters.h @@ -27,7 +27,6 @@ extern std::string gSpirVPath; enum OfflineCompilerOutputType { kBinary = 0, - kSource, kSpir_v }; diff --git a/test_conformance/build_script_source.py b/test_conformance/build_script_source.py deleted file mode 100644 index 276cfb92..00000000 --- a/test_conformance/build_script_source.py +++ /dev/null @@ -1,7 +0,0 @@ -# Script parameters: -# 1 - input file -# 2 - output file -# 3 - architecture: 32 or 64 -# 4 - one of the strings: binary, source, spir_v -# 5 - OpenCL version: 12, 20 -# 6 - build options diff --git a/test_conformance/compiler/test_build_helpers.c b/test_conformance/compiler/test_build_helpers.c index 35875e04..ef853203 100644 --- a/test_conformance/compiler/test_build_helpers.c +++ b/test_conformance/compiler/test_build_helpers.c @@ -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 && !(gOfflineCompiler && gOfflineCompilerOutputType != kSource)) + if (length != strlen(sample_kernel_code_single_line[0]) + 1 && !gOfflineCompiler) { 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]) && !(gOfflineCompiler && gOfflineCompilerOutputType != kSource)) + if (strlen(buffer) != strlen(sample_kernel_code_single_line[0]) && !gOfflineCompiler) { 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]) && !(gOfflineCompiler && gOfflineCompilerOutputType != kSource)) + if (strlen(buffer) != strlen(sample_kernel_code_single_line[0]) && !gOfflineCompiler) { log_error( "ERROR: Length of program source is incorrect!\n" ); return -1; } - if (length != strlen(sample_kernel_code_single_line[0]) + 1 && !(gOfflineCompiler && gOfflineCompilerOutputType != kSource)) + if (length != strlen(sample_kernel_code_single_line[0]) + 1 && !gOfflineCompiler) { log_error( "ERROR: Returned length of program source is incorrect!\n" ); return -1;