Skip to content

Commit c2e3d24

Browse files
Enable Symbol Table Generation by Default for L0 modules
- Added EnableProgramSymbolTableGeneration to enable or disable default behavior for IGC to generate the program symbol tables for L0 modules with exported functions. - Default value set to true to add -library-compilation to all module builds. Signed-off-by: Neil R Spruit <[email protected]>
1 parent d129cca commit c2e3d24

File tree

5 files changed

+65
-0
lines changed

5 files changed

+65
-0
lines changed

level_zero/core/source/module/module_imp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ NEO::ConstStringRef optLevel = "-ze-opt-level";
4949
NEO::ConstStringRef greaterThan4GbRequired = "-ze-opt-greater-than-4GB-buffer-required";
5050
NEO::ConstStringRef hasBufferOffsetArg = "-ze-intel-has-buffer-offset-arg";
5151
NEO::ConstStringRef debugKernelEnable = "-ze-kernel-debug-enable";
52+
NEO::ConstStringRef enableLibraryCompile = "-library-compilation";
5253
} // namespace BuildOptions
5354

5455
ModuleTranslationUnit::ModuleTranslationUnit(L0::Device *device)
@@ -665,12 +666,16 @@ void ModuleImp::createBuildOptions(const char *pBuildFlags, std::string &apiOpti
665666
moveBuildOption(apiOptions, apiOptions, NEO::CompilerOptions::optLevel, BuildOptions::optLevel);
666667
moveBuildOption(internalBuildOptions, apiOptions, NEO::CompilerOptions::greaterThan4gbBuffersRequired, BuildOptions::greaterThan4GbRequired);
667668
moveBuildOption(internalBuildOptions, apiOptions, NEO::CompilerOptions::allowZebin, NEO::CompilerOptions::allowZebin);
669+
this->libraryExportEnabled = moveBuildOption(apiOptions, apiOptions, BuildOptions::enableLibraryCompile, BuildOptions::enableLibraryCompile);
668670

669671
createBuildExtraOptions(apiOptions, internalBuildOptions);
670672
}
671673
if (NEO::ApiSpecificConfig::getBindlessConfiguration()) {
672674
NEO::CompilerOptions::concatenateAppend(internalBuildOptions, NEO::CompilerOptions::bindlessMode.str());
673675
}
676+
if (!this->libraryExportEnabled && NEO::DebugManager.flags.EnableProgramSymbolTableGeneration.get()) {
677+
NEO::CompilerOptions::concatenateAppend(apiOptions, BuildOptions::enableLibraryCompile.str());
678+
}
674679
}
675680

676681
void ModuleImp::updateBuildLog(NEO::Device *neoDevice) {

level_zero/core/source/module/module_imp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extern NEO::ConstStringRef optLevel;
3030
extern NEO::ConstStringRef greaterThan4GbRequired;
3131
extern NEO::ConstStringRef hasBufferOffsetArg;
3232
extern NEO::ConstStringRef debugKernelEnable;
33+
extern NEO::ConstStringRef enableLibraryCompile;
3334
} // namespace BuildOptions
3435

3536
struct ModuleTranslationUnit {
@@ -158,6 +159,7 @@ struct ModuleImp : public Module {
158159
bool debugEnabled = false;
159160
bool isFullyLinked = false;
160161
bool allocatePrivateMemoryPerDispatch = true;
162+
bool libraryExportEnabled = false;
161163
ModuleType type;
162164
NEO::Linker::UnresolvedExternals unresolvedExternalsInfo{};
163165
std::set<NEO::GraphicsAllocation *> importedSymbolAllocations{};

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,62 @@ TEST(BuildOptions, givenSrcOptLevelWithoutLevelIntegerInSrcNamesWhenMovingBuildO
23112311
EXPECT_FALSE(result);
23122312
}
23132313

2314+
TEST_F(ModuleTest, givenBuildOptionsWhenEnableProgramSymbolTableGenerationIsEnabledThenEnableLibraryCompileIsSet) {
2315+
DebugManagerStateRestore restorer;
2316+
DebugManager.flags.EnableProgramSymbolTableGeneration.set(1);
2317+
auto module = std::make_unique<ModuleImp>(device, nullptr, ModuleType::User);
2318+
ASSERT_NE(nullptr, module);
2319+
2320+
std::string buildOptions;
2321+
std::string internalBuildOptions;
2322+
2323+
module->createBuildOptions("", buildOptions, internalBuildOptions);
2324+
2325+
EXPECT_TRUE(NEO::CompilerOptions::contains(buildOptions, BuildOptions::enableLibraryCompile));
2326+
}
2327+
2328+
TEST_F(ModuleTest, givenBuildOptionsWhenEnableProgramSymbolTableGenerationIsDisabledThenEnableLibraryCompileIsNotSet) {
2329+
DebugManagerStateRestore restorer;
2330+
DebugManager.flags.EnableProgramSymbolTableGeneration.set(0);
2331+
auto module = std::make_unique<ModuleImp>(device, nullptr, ModuleType::User);
2332+
ASSERT_NE(nullptr, module);
2333+
2334+
std::string buildOptions;
2335+
std::string internalBuildOptions;
2336+
2337+
module->createBuildOptions("", buildOptions, internalBuildOptions);
2338+
2339+
EXPECT_FALSE(NEO::CompilerOptions::contains(buildOptions, BuildOptions::enableLibraryCompile));
2340+
}
2341+
2342+
TEST_F(ModuleTest, givenBuildOptionsWithEnableLibraryCompileWhenEnableProgramSymbolTableGenerationIsDisabledThenEnableLibraryCompileIsSet) {
2343+
DebugManagerStateRestore restorer;
2344+
DebugManager.flags.EnableProgramSymbolTableGeneration.set(0);
2345+
auto module = std::make_unique<ModuleImp>(device, nullptr, ModuleType::User);
2346+
ASSERT_NE(nullptr, module);
2347+
2348+
std::string buildOptions;
2349+
std::string internalBuildOptions;
2350+
2351+
module->createBuildOptions(BuildOptions::enableLibraryCompile.str().c_str(), buildOptions, internalBuildOptions);
2352+
2353+
EXPECT_TRUE(NEO::CompilerOptions::contains(buildOptions, BuildOptions::enableLibraryCompile));
2354+
}
2355+
2356+
TEST_F(ModuleTest, givenBuildOptionsWithEnableLibraryCompileWhenEnableProgramSymbolTableGenerationIsEnabledThenEnableLibraryCompileIsSet) {
2357+
DebugManagerStateRestore restorer;
2358+
DebugManager.flags.EnableProgramSymbolTableGeneration.set(1);
2359+
auto module = std::make_unique<ModuleImp>(device, nullptr, ModuleType::User);
2360+
ASSERT_NE(nullptr, module);
2361+
2362+
std::string buildOptions;
2363+
std::string internalBuildOptions;
2364+
2365+
module->createBuildOptions(BuildOptions::enableLibraryCompile.str().c_str(), buildOptions, internalBuildOptions);
2366+
2367+
EXPECT_TRUE(NEO::CompilerOptions::contains(buildOptions, BuildOptions::enableLibraryCompile));
2368+
}
2369+
23142370
TEST_F(ModuleTest, givenInternalOptionsWhenBindlessEnabledThenBindlesOptionsPassed) {
23152371
DebugManagerStateRestore restorer;
23162372
DebugManager.flags.UseBindlessMode.set(1);

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ DECLARE_DEBUG_VARIABLE(bool, ForceSamplerLowFilteringPrecision, false, "Force Lo
334334
DECLARE_DEBUG_VARIABLE(bool, EngineInstancedSubDevices, false, "Create subdevices assigned to specific engine")
335335
DECLARE_DEBUG_VARIABLE(bool, AllowSingleTileEngineInstancedSubDevices, false, "Create subdevices assigned to specific engine on single tile config")
336336
DECLARE_DEBUG_VARIABLE(bool, EnablePrivateBO, false, "Enable PRELIM_I915_GEM_CREATE_EXT_VM_PRIVATE extension creating VM_PRIVATE BOs")
337+
DECLARE_DEBUG_VARIABLE(bool, EnableProgramSymbolTableGeneration, true, "Enforce IGC to always generate the Program Symbol Table for Exported Functions for all Modules used by Level Zero.")
337338
DECLARE_DEBUG_VARIABLE(int32_t, ReturnSubDevicesAsApiDevices, -1, "Expose each subdevice as a separate device during clGetDeviceIDs or zeDeviceGet API call")
338339
DECLARE_DEBUG_VARIABLE(int32_t, ForceRunAloneContext, -1, "Control creation of run-alone HW context, -1:default, 0:disable, 1:enable")
339340
DECLARE_DEBUG_VARIABLE(int32_t, AddClGlSharing, -1, "Add cl-gl extension")

shared/test/common/test_files/igdrcl.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ AllowPatchingVfeStateInCommandLists = 0
349349
PrintMemoryRegionSizes = 0
350350
OverrideDrmRegion = -1
351351
AllowSingleTileEngineInstancedSubDevices = 0
352+
EnableProgramSymbolTableGeneration = 1
352353
BinaryCacheTrace = false
353354
OverrideL1CacheControlInSurfaceState = -1
354355
OverrideL1CacheControlInSurfaceStateForScratchSpace = -1

0 commit comments

Comments
 (0)