From 1634ac9ec3820cfc9177a5a1dc036415df7ebed7 Mon Sep 17 00:00:00 2001 From: Compute-Runtime-Validation Date: Fri, 21 Jan 2022 00:04:45 +0100 Subject: [PATCH] Revert "Dont generate gen file by default" This reverts commit 95943dee0f1dd4a020b133e413ceddf86238afa2. Signed-off-by: Compute-Runtime-Validation --- level_zero/core/test/common/gen_kernel.cmake | 4 +- .../source/built_ins/kernels/CMakeLists.txt | 2 +- opencl/test/unit_test/CMakeLists.txt | 10 +- .../mock/mock_offline_compiler.h | 1 - .../offline_compiler_tests.cpp | 137 ++---------------- .../source/offline_compiler.cpp | 11 +- .../source/offline_compiler.h | 1 - .../source/built_ins/kernels/CMakeLists.txt | 2 +- shared/test/common/test_files/CMakeLists.txt | 2 +- 9 files changed, 27 insertions(+), 143 deletions(-) diff --git a/level_zero/core/test/common/gen_kernel.cmake b/level_zero/core/test/common/gen_kernel.cmake index 6d416ad67d..a79ef06da8 100644 --- a/level_zero/core/test/common/gen_kernel.cmake +++ b/level_zero/core/test/common/gen_kernel.cmake @@ -28,7 +28,7 @@ function(level_zero_generate_kernels target_list platform_name suffix options) add_custom_command( COMMAND echo generate ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -device ${platform_name} -out_dir ${outputdir} -options "${options}" OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -q -gen_file -file ${absolute_filepath} -device ${platform_name} -out_dir ${outputdir} -options "${options}" + COMMAND ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -device ${platform_name} -out_dir ${outputdir} -options "${options}" WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) @@ -80,7 +80,7 @@ function(level_zero_generate_kernels_with_internal_options target_list platform_ add_custom_command( COMMAND echo generate ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -device ${platform_name} -out_dir ${outputdir} ${output_name} -options ${options} -internal_options ${internal_options} , workdir is ${workdir} OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -q -gen_file -file ${absolute_filepath} -device ${platform_name} -out_dir ${outputdir} ${output_name} -options ${options} -internal_options ${internal_options} + COMMAND ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -device ${platform_name} -out_dir ${outputdir} ${output_name} -options ${options} -internal_options ${internal_options} WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) diff --git a/opencl/source/built_ins/kernels/CMakeLists.txt b/opencl/source/built_ins/kernels/CMakeLists.txt index f593fad76a..8ec31d3b58 100644 --- a/opencl/source/built_ins/kernels/CMakeLists.txt +++ b/opencl/source/built_ins/kernels/CMakeLists.txt @@ -68,7 +68,7 @@ function(compile_builtin core_type platform_type builtin bits builtin_options) add_custom_command( OUTPUT ${OUTPUT_FILES} - COMMAND ${ocloc_cmd_prefix} -q -gen_file -file ${absolute_filepath} -device ${DEFAULT_SUPPORTED_${core_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -out_dir ${OUTPUTDIR} -options "$" + COMMAND ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -device ${DEFAULT_SUPPORTED_${core_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -out_dir ${OUTPUTDIR} -options "$" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${builtin} ocloc copy_compiler_files ) diff --git a/opencl/test/unit_test/CMakeLists.txt b/opencl/test/unit_test/CMakeLists.txt index d3e97fce44..4fbc3c9323 100644 --- a/opencl/test/unit_test/CMakeLists.txt +++ b/opencl/test/unit_test/CMakeLists.txt @@ -192,7 +192,7 @@ function(neo_gen_kernels platform_name_with_type platform_name revision_id suffi add_custom_command( OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -q -gen_file -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -revision_id ${revision_id} -out_dir ${outputdir} + COMMAND ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -revision_id ${revision_id} -out_dir ${outputdir} WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) @@ -239,7 +239,7 @@ function(neo_gen_kernels_with_options platform_name_with_type platform_name revi add_custom_command( OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -gen_file -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} -options ${arg} -options_name + COMMAND ${ocloc_cmd_prefix} -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} -options ${arg} -options_name WORKING_DIRECTORY ${workdir} DEPENDS ${filearg} ocloc ) @@ -292,7 +292,7 @@ function(neo_gen_kernels_with_internal_options platform_name_with_type platform_ add_custom_command( OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -gen_file -file ${absolute_filepath} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} ${output_name} -internal_options ${ARGN} + COMMAND ${ocloc_cmd_prefix} -file ${absolute_filepath} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} ${output_name} -internal_options ${ARGN} WORKING_DIRECTORY ${workdir} DEPENDS ${filearg} ocloc ) @@ -340,7 +340,7 @@ function(neo_gen_kernel_with_kernel_debug_options platform_name_with_type platfo add_custom_command( OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -q -gen_file -file ${absolute_filepath} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} -output ${argwospaces} -internal_options ${TEST_KERNEL_kernel_debug_enable} -options "-g" + COMMAND ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} -output ${argwospaces} -internal_options ${TEST_KERNEL_kernel_debug_enable} -options "-g" WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) @@ -377,7 +377,7 @@ function(neo_gen_kernel_from_ll platform_name_with_type platform_name suffix fil add_custom_command( OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -q -gen_file -file ${absolute_filepath} -output ${output_name} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -internal_options ${compile_options} -llvm_input + COMMAND ${ocloc_cmd_prefix} -q -file ${absolute_filepath} -output ${output_name} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -internal_options ${compile_options} -llvm_input WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc ) diff --git a/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h b/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h index fe611b2ac8..9067cda551 100644 --- a/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h +++ b/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h @@ -19,7 +19,6 @@ class MockOfflineCompiler : public OfflineCompiler { using OfflineCompiler::deviceName; using OfflineCompiler::elfBinary; using OfflineCompiler::excludeIr; - using OfflineCompiler::familyNameWithType; using OfflineCompiler::fclDeviceCtx; using OfflineCompiler::forceStatelessToStatefulOptimization; using OfflineCompiler::genBinary; diff --git a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp index 436ef48676..b1b2643a2b 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -7,7 +7,6 @@ #include "offline_compiler_tests.h" -#include "shared/offline_compiler/source/ocloc_api.h" #include "shared/source/compiler_interface/intermediate_representations.h" #include "shared/source/compiler_interface/oclc_extensions.h" #include "shared/source/debug_settings/debug_settings_manager.h" @@ -122,7 +121,6 @@ TEST_F(MultiCommandTests, GivenOutputFileWhenBuildingMultiCommandThenSuccessIsRe }; std::vector singleArgs = { - "-gen_file", "-file", "test_files/copybuffer.cl", "-device", @@ -156,7 +154,6 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWhenBuildingMultiCommandThenSuc }; std::vector singleArgs = { - "-gen_file", "-file", "test_files/copybuffer.cl", "-device", @@ -200,7 +197,6 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWithProductConfigValueWhenBuild }; std::vector singleArgs = { - "-gen_file", "-file", "test_files/copybuffer.cl", "-device", @@ -284,7 +280,6 @@ TEST_F(MultiCommandTests, GivenOutputFileListFlagWhenBuildingMultiCommandThenSuc }; std::vector singleArgs = { - "-gen_file", "-file", "test_files/copybuffer.cl", "-device", @@ -684,8 +679,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingThenBuildSucceeds) { "-file", "test_files/copybuffer.cl", "-device", - gEnvironment->devicePrefix.c_str(), - "-gen_file"}; + gEnvironment->devicePrefix.c_str()}; pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); @@ -719,30 +713,25 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceConfigValueThenBuild "-file", "test_files/copybuffer.cl", "-device", - configString, - "-gen_file"}; + configString}; - MockOfflineCompiler offlineCompiler{}; - - offlineCompiler.argHelper = oclocArgHelperWithoutInput.get(); - retVal = offlineCompiler.initialize(argv.size(), argv); + pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); + EXPECT_NE(nullptr, pOfflineCompiler); EXPECT_EQ(CL_SUCCESS, retVal); testing::internal::CaptureStdout(); - retVal = offlineCompiler.build(); + retVal = pOfflineCompiler->build(); std::string output = testing::internal::GetCapturedStdout(); EXPECT_EQ(CL_SUCCESS, retVal); - - Environment testedEnv{configString, offlineCompiler.familyNameWithType}; - VariableBackup backup(&gEnvironment, &testedEnv); - EXPECT_TRUE(compilerOutputExists("copybuffer", "bc") || compilerOutputExists("copybuffer", "spv")); EXPECT_TRUE(compilerOutputExists("copybuffer", "gen")); EXPECT_TRUE(compilerOutputExists("copybuffer", "bin")); - std::string buildLog = offlineCompiler.getBuildLog(); + std::string buildLog = pOfflineCompiler->getBuildLog(); EXPECT_STREQ(buildLog.c_str(), ""); + + delete pOfflineCompiler; } TEST_F(OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) { @@ -752,8 +741,7 @@ TEST_F(OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) { "test_files/copybuffer.cl", "-device", gEnvironment->devicePrefix.c_str(), - "-llvm_text", - "-gen_file"}; + "-llvm_text"}; pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); @@ -769,97 +757,6 @@ TEST_F(OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) { delete pOfflineCompiler; } -TEST_F(OfflineCompilerTests, WhenGenFileFlagIsNotProvidedThenGenFileIsNotCreated) { - uint32_t numOutputs = 0u; - uint64_t *lenOutputs = nullptr; - uint8_t **dataOutputs = nullptr; - char **nameOutputs = nullptr; - - bool isSpvFile = false; - bool isGenFile = false; - bool isBinFile = false; - - const char *argv[] = { - "ocloc", - "-q", - "-file", - "test_files/copybuffer.cl", - "-device", - gEnvironment->devicePrefix.c_str()}; - - unsigned int argc = sizeof(argv) / sizeof(const char *); - int retVal = oclocInvoke(argc, argv, - 0, nullptr, nullptr, nullptr, - 0, nullptr, nullptr, nullptr, - &numOutputs, &dataOutputs, &lenOutputs, &nameOutputs); - - EXPECT_EQ(retVal, CL_SUCCESS); - EXPECT_EQ(numOutputs, 3u); - - for (unsigned int i = 0; i < numOutputs; i++) { - std::string nameOutput(nameOutputs[i]); - if (nameOutput.find(".spv") != std::string::npos) { - isSpvFile = true; - } - if (nameOutput.find(".gen") != std::string::npos) { - isGenFile = true; - } - if (nameOutput.find(".bin") != std::string::npos) { - isBinFile = true; - } - } - - EXPECT_TRUE(isSpvFile); - EXPECT_FALSE(isGenFile); - EXPECT_TRUE(isBinFile); -} - -TEST_F(OfflineCompilerTests, WhenGenFileFlagIsProvidedThenGenFileIsCreated) { - uint32_t numOutputs = 0u; - uint64_t *lenOutputs = nullptr; - uint8_t **dataOutputs = nullptr; - char **nameOutputs = nullptr; - - bool isSpvFile = false; - bool isGenFile = false; - bool isBinFile = false; - - const char *argv[] = { - "ocloc", - "-q", - "-gen_file", - "-file", - "test_files/copybuffer.cl", - "-device", - gEnvironment->devicePrefix.c_str()}; - - unsigned int argc = sizeof(argv) / sizeof(const char *); - int retVal = oclocInvoke(argc, argv, - 0, nullptr, nullptr, nullptr, - 0, nullptr, nullptr, nullptr, - &numOutputs, &dataOutputs, &lenOutputs, &nameOutputs); - - EXPECT_EQ(retVal, CL_SUCCESS); - EXPECT_EQ(numOutputs, 4u); - - for (unsigned int i = 0; i < numOutputs; i++) { - std::string nameOutput(nameOutputs[i]); - if (nameOutput.find(".spv") != std::string::npos) { - isSpvFile = true; - } - if (nameOutput.find(".gen") != std::string::npos) { - isGenFile = true; - } - if (nameOutput.find(".bin") != std::string::npos) { - isBinFile = true; - } - } - - EXPECT_TRUE(isSpvFile); - EXPECT_TRUE(isGenFile); - EXPECT_TRUE(isBinFile); -} - TEST_F(OfflineCompilerTests, WhenFclNotNeededThenDontLoadIt) { std::vector argv = { "ocloc", @@ -927,8 +824,7 @@ TEST_F(OfflineCompilerTests, GivenCppFileWhenBuildingThenBuildSucceeds) { "test_files/copybuffer.cl", "-device", gEnvironment->devicePrefix.c_str(), - "-cpp_file", - "-gen_file"}; + "-cpp_file"}; pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); @@ -951,7 +847,6 @@ TEST_F(OfflineCompilerTests, GivenOutputDirWhenBuildingThenBuildSucceeds) { "test_files/copybuffer.cl", "-device", gEnvironment->devicePrefix.c_str(), - "-gen_file", "-out_dir", "offline_compiler_test"}; @@ -1294,8 +1189,7 @@ TEST(OfflineCompilerTest, givenSpvOnlyOptionPassedWhenCmdLineParsedThenGenerateO "myOutputFileName", "-spv_only", "-device", - gEnvironment->devicePrefix.c_str(), - "-gen_file"}; + gEnvironment->devicePrefix.c_str()}; auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); @@ -1504,8 +1398,7 @@ TEST(OfflineCompilerTest, givenOutputFileOptionWhenSourceIsCompiledThenOutputFil "-output", "myOutputFileName", "-device", - gEnvironment->devicePrefix.c_str(), - "-gen_file"}; + gEnvironment->devicePrefix.c_str()}; auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); @@ -1538,8 +1431,7 @@ TEST(OfflineCompilerTest, givenDebugDataAvailableWhenSourceIsBuiltThenDebugDataF "-output", "myOutputFileName", "-device", - gEnvironment->devicePrefix.c_str(), - "-gen_file"}; + gEnvironment->devicePrefix.c_str()}; char debugData[10]; MockCompilerDebugVars igcDebugVars(gEnvironment->igcDebugVars); @@ -2140,8 +2032,7 @@ TEST(OclocCompile, givenSpirvInputThenDontGenerateSpirvFile) { "offline_compiler_test", "-device", gEnvironment->devicePrefix.c_str(), - "-spirv_input", - "-gen_file"}; + "-spirv_input"}; int retVal = ocloc.initialize(argv.size(), argv); ASSERT_EQ(0, retVal); diff --git a/shared/offline_compiler/source/offline_compiler.cpp b/shared/offline_compiler/source/offline_compiler.cpp index b892e341a4..9e78df4e07 100644 --- a/shared/offline_compiler/source/offline_compiler.cpp +++ b/shared/offline_compiler/source/offline_compiler.cpp @@ -684,8 +684,6 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector -device [-output saveOutput(genOutputFile, genBinary, genBinarySize); - } + std::string genOutputFile = generateFilePath(outputDirectory, fileBase, ".gen") + generateOptsSuffix(); + + argHelper->saveOutput(genOutputFile, genBinary, genBinarySize); if (useCppFile) { std::string cppOutputFile = generateFilePath(outputDirectory, fileBase, ".cpp"); diff --git a/shared/offline_compiler/source/offline_compiler.h b/shared/offline_compiler/source/offline_compiler.h index c18755a9d0..0105b702a2 100644 --- a/shared/offline_compiler/source/offline_compiler.h +++ b/shared/offline_compiler/source/offline_compiler.h @@ -134,7 +134,6 @@ class OfflineCompiler { bool useLlvmText = false; bool useLlvmBc = false; bool useCppFile = false; - bool useGenFile = false; bool useOptionsSuffix = false; bool quiet = false; bool onlySpirV = false; diff --git a/shared/source/built_ins/kernels/CMakeLists.txt b/shared/source/built_ins/kernels/CMakeLists.txt index ba28615f05..76d0f0a35b 100644 --- a/shared/source/built_ins/kernels/CMakeLists.txt +++ b/shared/source/built_ins/kernels/CMakeLists.txt @@ -88,7 +88,7 @@ function(compile_builtin core_type platform_type builtin bits builtin_options mo get_filename_component(absolute_filepath_spv ${OUTPUT_FILE_SPV} ABSOLUTE) add_custom_command( OUTPUT ${OUTPUT_FILES_BINARIES} - COMMAND ${ocloc_cmd_prefix} -q -gen_file -file ${absolute_filepath_spv} -spirv_input -device ${DEFAULT_SUPPORTED_${core_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -output ${mode}_${BASENAME}_${REVISION_ID} -out_dir ${OUTPUTDIR} -revision_id ${REVISION_ID} ${INTERNAL_OPTIONS} -options "$" + COMMAND ${ocloc_cmd_prefix} -q -file ${absolute_filepath_spv} -spirv_input -device ${DEFAULT_SUPPORTED_${core_type}_${platform_type}_PLATFORM} ${builtin_options} -${bits} -output ${mode}_${BASENAME}_${REVISION_ID} -out_dir ${OUTPUTDIR} -revision_id ${REVISION_ID} ${INTERNAL_OPTIONS} -options "$" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${OUTPUT_FILE_SPV} ocloc copy_compiler_files ) diff --git a/shared/test/common/test_files/CMakeLists.txt b/shared/test/common/test_files/CMakeLists.txt index eebe0a09b8..c836f65511 100644 --- a/shared/test/common/test_files/CMakeLists.txt +++ b/shared/test/common/test_files/CMakeLists.txt @@ -27,7 +27,7 @@ function(compile_kernels_gen platform_name_with_type revision_id platform_name s add_custom_command( OUTPUT ${output_files} - COMMAND ${ocloc_cmd_prefix} -gen_file -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} + COMMAND ${ocloc_cmd_prefix} -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} WORKING_DIRECTORY ${workdir} DEPENDS ${filepath} ocloc copy_compiler_files )