mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Dont generate gen file by default
Ocloc can dump gen file when we add -gen_file flag to cmd. Otherwise gen is not generated Signed-off-by: Mateusz Borzyszkowski <mateusz.borzyszkowski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
3f54e9ffb1
commit
95943dee0f
@ -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 -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -revision_id ${revision_id} -out_dir ${outputdir}
|
||||
COMMAND ${ocloc_cmd_prefix} -q -gen_file -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} -file ${absolute_filepath} -device ${platform_name} -${NEO_BITS} -out_dir ${outputdir} -revision_id ${revision_id} -options ${arg} -options_name
|
||||
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
|
||||
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} -file ${absolute_filepath} -device ${platform_name} -revision_id ${revision_id} -${NEO_BITS} -out_dir ${outputdir} ${output_name} -internal_options ${ARGN}
|
||||
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}
|
||||
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 -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 -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"
|
||||
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 -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 -gen_file -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
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -19,6 +19,7 @@ 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;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#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"
|
||||
@ -121,6 +122,7 @@ TEST_F(MultiCommandTests, GivenOutputFileWhenBuildingMultiCommandThenSuccessIsRe
|
||||
};
|
||||
|
||||
std::vector<std::string> singleArgs = {
|
||||
"-gen_file",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
@ -154,6 +156,7 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWhenBuildingMultiCommandThenSuc
|
||||
};
|
||||
|
||||
std::vector<std::string> singleArgs = {
|
||||
"-gen_file",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
@ -197,6 +200,7 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWithProductConfigValueWhenBuild
|
||||
};
|
||||
|
||||
std::vector<std::string> singleArgs = {
|
||||
"-gen_file",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
@ -280,6 +284,7 @@ TEST_F(MultiCommandTests, GivenOutputFileListFlagWhenBuildingMultiCommandThenSuc
|
||||
};
|
||||
|
||||
std::vector<std::string> singleArgs = {
|
||||
"-gen_file",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
@ -679,7 +684,8 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingThenBuildSucceeds) {
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str()};
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-gen_file"};
|
||||
|
||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
|
||||
|
||||
@ -713,25 +719,30 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceConfigValueThenBuild
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
configString};
|
||||
configString,
|
||||
"-gen_file"};
|
||||
|
||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
|
||||
MockOfflineCompiler offlineCompiler{};
|
||||
|
||||
offlineCompiler.argHelper = oclocArgHelperWithoutInput.get();
|
||||
retVal = offlineCompiler.initialize(argv.size(), argv);
|
||||
|
||||
EXPECT_NE(nullptr, pOfflineCompiler);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
retVal = pOfflineCompiler->build();
|
||||
retVal = offlineCompiler.build();
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
Environment testedEnv{configString, offlineCompiler.familyNameWithType};
|
||||
VariableBackup<Environment *> backup(&gEnvironment, &testedEnv);
|
||||
|
||||
EXPECT_TRUE(compilerOutputExists("copybuffer", "bc") || compilerOutputExists("copybuffer", "spv"));
|
||||
EXPECT_TRUE(compilerOutputExists("copybuffer", "gen"));
|
||||
EXPECT_TRUE(compilerOutputExists("copybuffer", "bin"));
|
||||
|
||||
std::string buildLog = pOfflineCompiler->getBuildLog();
|
||||
std::string buildLog = offlineCompiler.getBuildLog();
|
||||
EXPECT_STREQ(buildLog.c_str(), "");
|
||||
|
||||
delete pOfflineCompiler;
|
||||
}
|
||||
|
||||
TEST_F(OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) {
|
||||
@ -741,7 +752,8 @@ TEST_F(OfflineCompilerTests, GivenLlvmTextWhenBuildingThenBuildSucceeds) {
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-llvm_text"};
|
||||
"-llvm_text",
|
||||
"-gen_file"};
|
||||
|
||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
|
||||
|
||||
@ -757,6 +769,97 @@ 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<std::string> argv = {
|
||||
"ocloc",
|
||||
@ -824,7 +927,8 @@ TEST_F(OfflineCompilerTests, GivenCppFileWhenBuildingThenBuildSucceeds) {
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-cpp_file"};
|
||||
"-cpp_file",
|
||||
"-gen_file"};
|
||||
|
||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
|
||||
|
||||
@ -847,6 +951,7 @@ TEST_F(OfflineCompilerTests, GivenOutputDirWhenBuildingThenBuildSucceeds) {
|
||||
"test_files/copybuffer.cl",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-gen_file",
|
||||
"-out_dir",
|
||||
"offline_compiler_test"};
|
||||
|
||||
@ -1189,7 +1294,8 @@ TEST(OfflineCompilerTest, givenSpvOnlyOptionPassedWhenCmdLineParsedThenGenerateO
|
||||
"myOutputFileName",
|
||||
"-spv_only",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str()};
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-gen_file"};
|
||||
|
||||
auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler());
|
||||
ASSERT_NE(nullptr, mockOfflineCompiler);
|
||||
@ -1398,7 +1504,8 @@ TEST(OfflineCompilerTest, givenOutputFileOptionWhenSourceIsCompiledThenOutputFil
|
||||
"-output",
|
||||
"myOutputFileName",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str()};
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-gen_file"};
|
||||
|
||||
auto mockOfflineCompiler = std::unique_ptr<MockOfflineCompiler>(new MockOfflineCompiler());
|
||||
ASSERT_NE(nullptr, mockOfflineCompiler);
|
||||
@ -1431,7 +1538,8 @@ TEST(OfflineCompilerTest, givenDebugDataAvailableWhenSourceIsBuiltThenDebugDataF
|
||||
"-output",
|
||||
"myOutputFileName",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str()};
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-gen_file"};
|
||||
|
||||
char debugData[10];
|
||||
MockCompilerDebugVars igcDebugVars(gEnvironment->igcDebugVars);
|
||||
@ -2032,7 +2140,8 @@ TEST(OclocCompile, givenSpirvInputThenDontGenerateSpirvFile) {
|
||||
"offline_compiler_test",
|
||||
"-device",
|
||||
gEnvironment->devicePrefix.c_str(),
|
||||
"-spirv_input"};
|
||||
"-spirv_input",
|
||||
"-gen_file"};
|
||||
|
||||
int retVal = ocloc.initialize(argv.size(), argv);
|
||||
ASSERT_EQ(0, retVal);
|
||||
|
Reference in New Issue
Block a user