Skip to content

Commit 7aecea5

Browse files
Revert "Default L0 Function & Global Symbols with fallback build for SPIRv"
This reverts commit 88b7a4f. Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
1 parent b20e31a commit 7aecea5

File tree

7 files changed

+31
-500
lines changed

7 files changed

+31
-500
lines changed

level_zero/core/source/module/module_imp.cpp

Lines changed: 10 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ NEO::ConstStringRef hasBufferOffsetArg = "-ze-intel-has-buffer-offset-arg";
5252
NEO::ConstStringRef debugKernelEnable = "-ze-kernel-debug-enable";
5353
NEO::ConstStringRef profileFlags = "-zet-profile-flags";
5454
NEO::ConstStringRef optLargeRegisterFile = "-ze-opt-large-register-file";
55-
NEO::ConstStringRef enableLibraryCompile = "-library-compilation";
56-
NEO::ConstStringRef enableGlobalVariableSymbols = "-ze-take-global-address";
5755
} // namespace BuildOptions
5856

5957
ModuleTranslationUnit::ModuleTranslationUnit(L0::Device *device)
@@ -175,70 +173,6 @@ bool ModuleTranslationUnit::processSpecConstantInfo(NEO::CompilerInterface *comp
175173
return true;
176174
}
177175

178-
bool ModuleTranslationUnit::attemptGenBinaryCompile(NEO::TranslationInput inputArgs, bool staticLink, bool libraryExportRequired, bool globalExportRequired) {
179-
auto result = this->compileGenBinary(inputArgs, staticLink);
180-
std::string enableGlobalFlag(BuildOptions::enableGlobalVariableSymbols.str().c_str());
181-
std::string enableLibraryFlag(BuildOptions::enableLibraryCompile.str().c_str());
182-
bool completedGlobalFlagRemovalCheck = false;
183-
bool completedLibraryFlagRemovalCheck = false;
184-
if (result == false) {
185-
if (!globalExportRequired || !libraryExportRequired) {
186-
// If the build failed, attempt to remove the implicit flags for Global Variables and/or Library Compile
187-
std::string reducedOptions(options);
188-
// Attempt build with only removing the Global Variable Flag
189-
if (!globalExportRequired) {
190-
std::string globalFlagRemoved(options);
191-
size_t optionPos = std::string::npos;
192-
optionPos = reducedOptions.find(enableGlobalFlag.c_str());
193-
if (optionPos != std::string::npos) {
194-
reducedOptions.erase(optionPos, BuildOptions::enableGlobalVariableSymbols.length());
195-
}
196-
optionPos = globalFlagRemoved.find(enableGlobalFlag.c_str());
197-
if (optionPos != std::string::npos) {
198-
globalFlagRemoved.erase(optionPos, BuildOptions::enableGlobalVariableSymbols.length());
199-
inputArgs.apiOptions = ArrayRef<const char>(globalFlagRemoved.c_str(), globalFlagRemoved.length());
200-
result = this->compileGenBinary(inputArgs, staticLink);
201-
if (result == true) {
202-
options.assign(globalFlagRemoved);
203-
return result;
204-
}
205-
}
206-
completedGlobalFlagRemovalCheck = true;
207-
}
208-
// Attempt build with only removing the Library Export Symbol Flag
209-
if (!libraryExportRequired) {
210-
std::string libraryFlagRemoved(options);
211-
size_t optionPos = std::string::npos;
212-
optionPos = reducedOptions.find(enableLibraryFlag.c_str());
213-
if (optionPos != std::string::npos) {
214-
reducedOptions.erase(optionPos, BuildOptions::enableLibraryCompile.length());
215-
}
216-
optionPos = libraryFlagRemoved.find(enableLibraryFlag.c_str());
217-
if (optionPos != std::string::npos) {
218-
libraryFlagRemoved.erase(optionPos, BuildOptions::enableLibraryCompile.length());
219-
inputArgs.apiOptions = ArrayRef<const char>(libraryFlagRemoved.c_str(), libraryFlagRemoved.length());
220-
result = this->compileGenBinary(inputArgs, staticLink);
221-
if (result == true) {
222-
options.assign(libraryFlagRemoved);
223-
return result;
224-
}
225-
}
226-
completedLibraryFlagRemovalCheck = true;
227-
}
228-
// Attempt build with the removal of both library and Global Variable flags
229-
if (completedGlobalFlagRemovalCheck && completedLibraryFlagRemovalCheck) {
230-
inputArgs.apiOptions = ArrayRef<const char>(reducedOptions.c_str(), reducedOptions.length());
231-
result = this->compileGenBinary(inputArgs, staticLink);
232-
if (result == true) {
233-
options.assign(reducedOptions);
234-
return result;
235-
}
236-
}
237-
}
238-
}
239-
return result;
240-
}
241-
242176
bool ModuleTranslationUnit::compileGenBinary(NEO::TranslationInput inputArgs, bool staticLink) {
243177
auto compilerInterface = device->getNEODevice()->getCompilerInterface();
244178
UNRECOVERABLE_IF(nullptr == compilerInterface);
@@ -272,7 +206,7 @@ bool ModuleTranslationUnit::compileGenBinary(NEO::TranslationInput inputArgs, bo
272206
}
273207

274208
bool ModuleTranslationUnit::staticLinkSpirV(std::vector<const char *> inputSpirVs, std::vector<uint32_t> inputModuleSizes, const char *buildOptions, const char *internalBuildOptions,
275-
std::vector<const ze_module_constants_t *> specConstants, bool libraryExportRequired, bool globalExportRequired) {
209+
std::vector<const ze_module_constants_t *> specConstants) {
276210
auto compilerInterface = device->getNEODevice()->getCompilerInterface();
277211
UNRECOVERABLE_IF(nullptr == compilerInterface);
278212

@@ -292,11 +226,11 @@ bool ModuleTranslationUnit::staticLinkSpirV(std::vector<const char *> inputSpirV
292226
linkInputArgs.src = ArrayRef<const char>(reinterpret_cast<const char *>(spirvElfSource.data()), spirvElfSource.size());
293227
linkInputArgs.apiOptions = ArrayRef<const char>(options.c_str(), options.length());
294228
linkInputArgs.internalOptions = ArrayRef<const char>(internalOptions.c_str(), internalOptions.length());
295-
return this->attemptGenBinaryCompile(linkInputArgs, true, libraryExportRequired, globalExportRequired);
229+
return this->compileGenBinary(linkInputArgs, true);
296230
}
297231

298232
bool ModuleTranslationUnit::buildFromSpirV(const char *input, uint32_t inputSize, const char *buildOptions, const char *internalBuildOptions,
299-
const ze_module_constants_t *pConstants, bool libraryExportRequired, bool globalExportRequired) {
233+
const ze_module_constants_t *pConstants) {
300234
auto compilerInterface = device->getNEODevice()->getCompilerInterface();
301235
UNRECOVERABLE_IF(nullptr == compilerInterface);
302236

@@ -311,10 +245,10 @@ bool ModuleTranslationUnit::buildFromSpirV(const char *input, uint32_t inputSize
311245
inputArgs.src = ArrayRef<const char>(input, inputSize);
312246
inputArgs.apiOptions = ArrayRef<const char>(options.c_str(), options.length());
313247
inputArgs.internalOptions = ArrayRef<const char>(internalOptions.c_str(), internalOptions.length());
314-
return this->attemptGenBinaryCompile(inputArgs, false, libraryExportRequired, globalExportRequired);
248+
return this->compileGenBinary(inputArgs, false);
315249
}
316250

317-
bool ModuleTranslationUnit::createFromNativeBinary(const char *input, size_t inputSize, bool libraryExportRequired, bool globalExportRequired) {
251+
bool ModuleTranslationUnit::createFromNativeBinary(const char *input, size_t inputSize) {
318252
UNRECOVERABLE_IF((nullptr == device) || (nullptr == device->getNEODevice()));
319253
auto productAbbreviation = NEO::hardwarePrefix[device->getNEODevice()->getHardwareInfo().platform.eProductFamily];
320254

@@ -367,7 +301,7 @@ bool ModuleTranslationUnit::createFromNativeBinary(const char *input, size_t inp
367301
updateBuildLog(NEO::CompilerWarnings::recompiledFromIr.str());
368302
}
369303

370-
return buildFromSpirV(this->irBinary.get(), static_cast<uint32_t>(this->irBinarySize), this->options.c_str(), "", nullptr, libraryExportRequired, globalExportRequired);
304+
return buildFromSpirV(this->irBinary.get(), static_cast<uint32_t>(this->irBinarySize), this->options.c_str(), "", nullptr);
371305
} else {
372306
return processUnpackedBinary();
373307
}
@@ -563,17 +497,13 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
563497
inputModuleSizes,
564498
buildOptions.c_str(),
565499
internalBuildOptions.c_str(),
566-
specConstants,
567-
this->libraryExportRequired,
568-
this->globalExportRequired);
500+
specConstants);
569501
} else {
570502
success = this->translationUnit->buildFromSpirV(reinterpret_cast<const char *>(programExpDesc->pInputModules[0]),
571503
inputModuleSizes[0],
572504
buildOptions.c_str(),
573505
internalBuildOptions.c_str(),
574-
firstSpecConstants,
575-
this->libraryExportRequired,
576-
this->globalExportRequired);
506+
firstSpecConstants);
577507
}
578508
} else {
579509
return false;
@@ -595,16 +525,14 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
595525

596526
if (desc->format == ZE_MODULE_FORMAT_NATIVE) {
597527
success = this->translationUnit->createFromNativeBinary(
598-
reinterpret_cast<const char *>(desc->pInputModule), desc->inputSize, this->libraryExportRequired, this->globalExportRequired);
528+
reinterpret_cast<const char *>(desc->pInputModule), desc->inputSize);
599529
} else if (desc->format == ZE_MODULE_FORMAT_IL_SPIRV) {
600530
this->builtFromSPIRv = true;
601531
success = this->translationUnit->buildFromSpirV(reinterpret_cast<const char *>(desc->pInputModule),
602532
static_cast<uint32_t>(desc->inputSize),
603533
buildOptions.c_str(),
604534
internalBuildOptions.c_str(),
605-
desc->pConstants,
606-
this->libraryExportRequired,
607-
this->globalExportRequired);
535+
desc->pConstants);
608536
} else {
609537
return false;
610538
}
@@ -753,18 +681,10 @@ void ModuleImp::createBuildOptions(const char *pBuildFlags, std::string &apiOpti
753681

754682
moveOptLevelOption(apiOptions, apiOptions);
755683
moveProfileFlagsOption(apiOptions, apiOptions);
756-
this->libraryExportRequired = moveBuildOption(apiOptions, apiOptions, BuildOptions::enableLibraryCompile, BuildOptions::enableLibraryCompile);
757-
this->globalExportRequired = moveBuildOption(apiOptions, apiOptions, BuildOptions::enableGlobalVariableSymbols, BuildOptions::enableGlobalVariableSymbols);
758684
}
759685
if (NEO::ApiSpecificConfig::getBindlessConfiguration()) {
760686
NEO::CompilerOptions::concatenateAppend(internalBuildOptions, NEO::CompilerOptions::bindlessMode.str());
761687
}
762-
if (!this->libraryExportRequired && NEO::DebugManager.flags.EnableDefaultProgramSymbolTableGeneration.get()) {
763-
NEO::CompilerOptions::concatenateAppend(apiOptions, BuildOptions::enableLibraryCompile.str());
764-
}
765-
if (!this->globalExportRequired && NEO::DebugManager.flags.EnableDefaultGlobalSymbolGeneration.get()) {
766-
NEO::CompilerOptions::concatenateAppend(apiOptions, BuildOptions::enableGlobalVariableSymbols.str());
767-
}
768688
}
769689

770690
bool ModuleImp::moveOptLevelOption(std::string &dstOptionsSet, std::string &srcOptionSet) {

level_zero/core/source/module/module_imp.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,22 @@ extern NEO::ConstStringRef hasBufferOffsetArg;
3434
extern NEO::ConstStringRef debugKernelEnable;
3535
extern NEO::ConstStringRef profileFlags;
3636
extern NEO::ConstStringRef optLargeRegisterFile;
37-
extern NEO::ConstStringRef enableLibraryCompile;
38-
extern NEO::ConstStringRef enableGlobalVariableSymbols;
37+
3938
} // namespace BuildOptions
4039

4140
struct ModuleTranslationUnit {
4241
ModuleTranslationUnit(L0::Device *device);
4342
virtual ~ModuleTranslationUnit();
4443
MOCKABLE_VIRTUAL bool buildFromSpirV(const char *input, uint32_t inputSize, const char *buildOptions, const char *internalBuildOptions,
45-
const ze_module_constants_t *pConstants, bool libraryExportRequired, bool globalExportRequired);
44+
const ze_module_constants_t *pConstants);
4645
MOCKABLE_VIRTUAL bool staticLinkSpirV(std::vector<const char *> inputSpirVs, std::vector<uint32_t> inputModuleSizes, const char *buildOptions, const char *internalBuildOptions,
47-
std::vector<const ze_module_constants_t *> specConstants, bool libraryExportRequired, bool globalExportRequired);
48-
MOCKABLE_VIRTUAL bool createFromNativeBinary(const char *input, size_t inputSize, bool libraryExportRequired, bool globalExportRequired);
46+
std::vector<const ze_module_constants_t *> specConstants);
47+
MOCKABLE_VIRTUAL bool createFromNativeBinary(const char *input, size_t inputSize);
4948
MOCKABLE_VIRTUAL bool processUnpackedBinary();
5049
std::vector<uint8_t> generateElfFromSpirV(std::vector<const char *> inputSpirVs, std::vector<uint32_t> inputModuleSizes);
5150
bool processSpecConstantInfo(NEO::CompilerInterface *compilerInterface, const ze_module_constants_t *pConstants, const char *input, uint32_t inputSize);
5251
std::string generateCompilerOptions(const char *buildOptions, const char *internalBuildOptions);
5352
MOCKABLE_VIRTUAL bool compileGenBinary(NEO::TranslationInput inputArgs, bool staticLink);
54-
MOCKABLE_VIRTUAL bool attemptGenBinaryCompile(NEO::TranslationInput inputArgs, bool staticLink, bool libraryExportRequired, bool globalExportRequired);
5553
void updateBuildLog(const std::string &newLogEntry);
5654
void processDebugData();
5755
L0::Device *device = nullptr;
@@ -174,8 +172,6 @@ struct ModuleImp : public Module {
174172
bool isFullyLinked = false;
175173
bool allocatePrivateMemoryPerDispatch = true;
176174
bool isZebinBinary = false;
177-
bool libraryExportRequired = false;
178-
bool globalExportRequired = false;
179175
ModuleType type;
180176
NEO::Linker::UnresolvedExternals unresolvedExternalsInfo{};
181177
std::set<NEO::GraphicsAllocation *> importedSymbolAllocations{};

level_zero/core/test/unit_tests/mocks/mock_module.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,12 @@ struct MockModuleTranslationUnit : public L0::ModuleTranslationUnit {
6666
}
6767

6868
bool compileGenBinary(NEO::TranslationInput inputArgs, bool staticLink) override {
69-
if (failGenCompile || failGenCompileCounter > 0) {
70-
failGenCompileCounter = failGenCompileCounter - 1;
71-
return false;
72-
}
7369
if (unpackedDeviceBinarySize && unpackedDeviceBinary) {
7470
return true;
7571
} else {
7672
return ModuleTranslationUnit::compileGenBinary(inputArgs, staticLink);
7773
}
7874
}
79-
80-
bool attemptGenBinaryCompile(NEO::TranslationInput inputArgs, bool staticLink, bool libraryExportRequired, bool globalExportRequired) override {
81-
bool libraryExport = libraryExportRequired;
82-
bool globalExport = globalExportRequired;
83-
if (requireGlobalExport) {
84-
globalExport = true;
85-
}
86-
if (requireLibraryExport) {
87-
libraryExport = true;
88-
}
89-
if (unpackedDeviceBinarySize && unpackedDeviceBinary) {
90-
return true;
91-
} else {
92-
return ModuleTranslationUnit::attemptGenBinaryCompile(inputArgs, staticLink, libraryExport, globalExport);
93-
}
94-
}
95-
bool failGenCompile = false;
96-
bool requireGlobalExport = false;
97-
bool requireLibraryExport = false;
98-
int failGenCompileCounter = 0;
9975
};
10076

10177
struct MockModule : public L0::ModuleImp {

0 commit comments

Comments
 (0)