Skip to content

Commit 7c8fcb3

Browse files
Module: Force stateless compilation if system shared allocations allowed
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
1 parent 5f4ed48 commit 7c8fcb3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

level_zero/core/source/module/module_imp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ bool ModuleTranslationUnit::buildFromSpirV(const char *input, uint32_t inputSize
9292
internalOptions = NEO::CompilerOptions::concatenate(internalOptions, BuildOptions::debugKernelEnable);
9393
}
9494

95-
if (NEO::DebugManager.flags.DisableStatelessToStatefulOptimization.get()) {
95+
if (NEO::DebugManager.flags.DisableStatelessToStatefulOptimization.get() ||
96+
device->getNEODevice()->areSharedSystemAllocationsAllowed()) {
9697
internalOptions = NEO::CompilerOptions::concatenate(internalOptions, NEO::CompilerOptions::greaterThan4gbBuffersRequired);
9798
}
9899

level_zero/core/test/unit_tests/sources/module/test_module.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,30 @@ HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOpti
11431143
EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("cl-intel-greater-than-4GB-buffer-required"), std::string::npos);
11441144
}
11451145

1146+
HWTEST_F(ModuleTranslationUnitTest, givenSystemSharedAllocationAllowedWhenBuildingModuleThen4GbBuffersAreRequired) {
1147+
struct MockCompilerInterface : CompilerInterface {
1148+
TranslationOutput::ErrorCode build(const NEO::Device &device, const TranslationInput &input, TranslationOutput &output) override {
1149+
inputInternalOptions = input.internalOptions.begin();
1150+
return TranslationOutput::ErrorCode::Success;
1151+
}
1152+
std::string inputInternalOptions;
1153+
};
1154+
1155+
auto mockCompilerInterface = new MockCompilerInterface;
1156+
auto &rootDeviceEnvironment = neoDevice->executionEnvironment->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()];
1157+
rootDeviceEnvironment->compilerInterface.reset(mockCompilerInterface);
1158+
1159+
MockModuleTranslationUnit moduleTu(device);
1160+
auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr);
1161+
EXPECT_TRUE(ret);
1162+
1163+
if (neoDevice->areSharedSystemAllocationsAllowed()) {
1164+
EXPECT_NE(mockCompilerInterface->inputInternalOptions.find("cl-intel-greater-than-4GB-buffer-required"), std::string::npos);
1165+
} else {
1166+
EXPECT_EQ(mockCompilerInterface->inputInternalOptions.find("cl-intel-greater-than-4GB-buffer-required"), std::string::npos);
1167+
}
1168+
}
1169+
11461170
using PrintfModuleTest = Test<DeviceFixture>;
11471171

11481172
HWTEST_F(PrintfModuleTest, GivenModuleWithPrintfWhenKernelIsCreatedThenPrintfAllocationIsPlacedInResidencyContainer) {

0 commit comments

Comments
 (0)