mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Add debug key for compiler internal options injection
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
2b60cadf1e
commit
b11d7cd7b0
@@ -508,6 +508,10 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
|
||||
} else {
|
||||
this->createBuildOptions(desc->pBuildFlags, buildOptions, internalBuildOptions);
|
||||
|
||||
if (type == ModuleType::User && NEO::DebugManager.flags.InjectInternalBuildOptions.get() != "unk") {
|
||||
NEO::CompilerOptions::concatenateAppend(internalBuildOptions, NEO::DebugManager.flags.InjectInternalBuildOptions.get());
|
||||
}
|
||||
|
||||
if (desc->format == ZE_MODULE_FORMAT_NATIVE) {
|
||||
success = this->translationUnit->createFromNativeBinary(
|
||||
reinterpret_cast<const char *>(desc->pInputModule), desc->inputSize);
|
||||
|
||||
@@ -89,14 +89,27 @@ struct MockCompilerInterface : public NEO::CompilerInterface {
|
||||
const NEO::TranslationInput &input,
|
||||
NEO::TranslationOutput &output) override {
|
||||
|
||||
receivedApiOptions = input.apiOptions.begin();
|
||||
inputInternalOptions = input.internalOptions.begin();
|
||||
|
||||
if (failBuild) {
|
||||
return NEO::TranslationOutput::ErrorCode::BuildFailure;
|
||||
}
|
||||
return NEO::TranslationOutput::ErrorCode::Success;
|
||||
}
|
||||
NEO::TranslationOutput::ErrorCode link(const NEO::Device &device,
|
||||
const NEO::TranslationInput &input,
|
||||
NEO::TranslationOutput &output) override {
|
||||
|
||||
receivedApiOptions = input.apiOptions.begin();
|
||||
inputInternalOptions = input.internalOptions.begin();
|
||||
|
||||
return NEO::TranslationOutput::ErrorCode::Success;
|
||||
}
|
||||
|
||||
std::string receivedApiOptions;
|
||||
std::string inputInternalOptions;
|
||||
bool failBuild = false;
|
||||
};
|
||||
template <typename T1, typename T2>
|
||||
struct MockCompilerInterfaceWithSpecConstants : public NEO::CompilerInterface {
|
||||
|
||||
@@ -1594,21 +1594,15 @@ kernels:
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOptions) {
|
||||
struct MockCompilerInterface : CompilerInterface {
|
||||
TranslationOutput::ErrorCode build(const NEO::Device &device,
|
||||
const TranslationInput &input,
|
||||
TranslationOutput &output) override {
|
||||
receivedApiOptions = input.apiOptions.begin();
|
||||
return TranslationOutput::ErrorCode::BuildFailure;
|
||||
}
|
||||
std::string receivedApiOptions;
|
||||
};
|
||||
|
||||
auto *pMockCompilerInterface = new MockCompilerInterface;
|
||||
auto &rootDeviceEnvironment = this->neoDevice->executionEnvironment->rootDeviceEnvironments[this->neoDevice->getRootDeviceIndex()];
|
||||
rootDeviceEnvironment->compilerInterface.reset(pMockCompilerInterface);
|
||||
|
||||
L0::ModuleTranslationUnit moduleTu(this->device);
|
||||
moduleTu.options = "abcd";
|
||||
pMockCompilerInterface->failBuild = true;
|
||||
|
||||
auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr);
|
||||
EXPECT_FALSE(ret);
|
||||
EXPECT_STREQ("abcd", moduleTu.options.c_str());
|
||||
@@ -1616,15 +1610,6 @@ HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOpti
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOptions2) {
|
||||
struct MockCompilerInterface : CompilerInterface {
|
||||
TranslationOutput::ErrorCode build(const NEO::Device &device,
|
||||
const TranslationInput &input,
|
||||
TranslationOutput &output) override {
|
||||
inputInternalOptions = input.internalOptions.begin();
|
||||
return TranslationOutput::ErrorCode::Success;
|
||||
}
|
||||
std::string inputInternalOptions;
|
||||
};
|
||||
auto pMockCompilerInterface = new MockCompilerInterface;
|
||||
auto &rootDeviceEnvironment = this->neoDevice->executionEnvironment->rootDeviceEnvironments[this->neoDevice->getRootDeviceIndex()];
|
||||
rootDeviceEnvironment->compilerInterface.reset(pMockCompilerInterface);
|
||||
@@ -1639,14 +1624,6 @@ HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOpti
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTranslationUnitTest, givenSystemSharedAllocationAllowedWhenBuildingModuleThen4GbBuffersAreRequired) {
|
||||
struct MockCompilerInterface : CompilerInterface {
|
||||
TranslationOutput::ErrorCode build(const NEO::Device &device, const TranslationInput &input, TranslationOutput &output) override {
|
||||
inputInternalOptions = input.internalOptions.begin();
|
||||
return TranslationOutput::ErrorCode::Success;
|
||||
}
|
||||
std::string inputInternalOptions;
|
||||
};
|
||||
|
||||
auto mockCompilerInterface = new MockCompilerInterface;
|
||||
auto &rootDeviceEnvironment = neoDevice->executionEnvironment->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()];
|
||||
rootDeviceEnvironment->compilerInterface.reset(mockCompilerInterface);
|
||||
@@ -1788,6 +1765,52 @@ TEST_F(ModuleTest, givenInternalOptionsWhenBindlessDisabledThenBindlesOptionsNot
|
||||
EXPECT_FALSE(NEO::CompilerOptions::contains(internalBuildOptions, NEO::CompilerOptions::bindlessMode));
|
||||
}
|
||||
|
||||
TEST_F(ModuleTest, GivenInjectInternalBuildOptionsWhenBuildingUserModuleThenInternalOptionsAreAppended) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.InjectInternalBuildOptions.set(" -abc");
|
||||
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
uint8_t binary[10];
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
|
||||
moduleDesc.pInputModule = binary;
|
||||
moduleDesc.inputSize = 10;
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto module = std::unique_ptr<L0::ModuleImp>(new L0::ModuleImp(device, moduleBuildLog, ModuleType::User));
|
||||
ASSERT_NE(nullptr, module.get());
|
||||
module->initialize(&moduleDesc, device->getNEODevice());
|
||||
|
||||
EXPECT_TRUE(CompilerOptions::contains(cip->buildInternalOptions, "-abc"));
|
||||
};
|
||||
|
||||
TEST_F(ModuleTest, GivenInjectInternalBuildOptionsWhenBuildingBuiltinModuleThenInternalOptionsAreNotAppended) {
|
||||
DebugManagerStateRestore dbgRestorer;
|
||||
DebugManager.flags.InjectInternalBuildOptions.set(" -abc");
|
||||
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
uint8_t binary[10];
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
|
||||
moduleDesc.pInputModule = binary;
|
||||
moduleDesc.inputSize = 10;
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto module = std::unique_ptr<L0::ModuleImp>(new L0::ModuleImp(device, moduleBuildLog, ModuleType::Builtin));
|
||||
ASSERT_NE(nullptr, module.get());
|
||||
module->initialize(&moduleDesc, device->getNEODevice());
|
||||
|
||||
EXPECT_FALSE(CompilerOptions::contains(cip->buildInternalOptions, "-abc"));
|
||||
};
|
||||
|
||||
using ModuleDebugDataTest = Test<DeviceFixture>;
|
||||
TEST_F(ModuleDebugDataTest, GivenDebugDataWithRelocationsWhenCreatingRelocatedDebugDataThenRelocationsAreApplied) {
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
|
||||
Reference in New Issue
Block a user