From 861ec524c6a235f9a67fe449b6c2ea0d50ed9a62 Mon Sep 17 00:00:00 2001 From: "Cencelewska, Katarzyna" Date: Tue, 25 Apr 2023 15:12:25 +0000 Subject: [PATCH] fix: check icbe version only once when patchtoken - set by default flag ZebinIgnoreIcbeVersion to true - for zebin icbe version check is only inside flag - only when use patchtoken then check icbe version is mandatory Resolves: NEO-7904 Signed-off-by: Cencelewska, Katarzyna --- level_zero/core/source/module/module_imp.cpp | 14 +- opencl/source/program/build.cpp | 3 +- opencl/source/program/program.cpp | 7 +- .../compiler_interface/compiler_interface.cpp | 71 +++- .../compiler_interface/compiler_interface.h | 15 +- .../compiler_interface/compiler_interface.inl | 11 - .../debug_settings/debug_variables_base.inl | 2 +- shared/source/program/program_info.cpp | 6 +- .../common/mocks/mock_compiler_interface.h | 2 + shared/test/common/test_files/igdrcl.config | 2 +- .../compiler_interface_tests.cpp | 355 ++++++++++++++++-- 11 files changed, 428 insertions(+), 60 deletions(-) diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index aed0976264..60d8ff84f5 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -251,7 +251,8 @@ ze_result_t ModuleTranslationUnit::staticLinkSpirV(std::vector inp ze_result_t ModuleTranslationUnit::buildFromSpirV(const char *input, uint32_t inputSize, const char *buildOptions, const char *internalBuildOptions, const ze_module_constants_t *pConstants) { - auto compilerInterface = device->getNEODevice()->getCompilerInterface(); + const auto &neoDevice = device->getNEODevice(); + auto compilerInterface = neoDevice->getCompilerInterface(); if (!compilerInterface) { return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE; } @@ -261,16 +262,15 @@ ze_result_t ModuleTranslationUnit::buildFromSpirV(const char *input, uint32_t in return ZE_RESULT_ERROR_MODULE_BUILD_FAILURE; } - auto &l0GfxCoreHelper = this->device->getNEODevice()->getRootDeviceEnvironment().getHelper(); + auto &l0GfxCoreHelper = neoDevice->getRootDeviceEnvironment().getHelper(); std::string internalOptions = this->generateCompilerOptions(buildOptions, internalBuildOptions); - auto isZebinAllowed = l0GfxCoreHelper.isZebinAllowed(this->device->getNEODevice()->getDebugger()); + auto isZebinAllowed = l0GfxCoreHelper.isZebinAllowed(neoDevice->getDebugger()); if (isZebinAllowed == false) { - auto pos = this->options.find(NEO::CompilerOptions::enableZebin.str()); - if (pos != std::string::npos) { - updateBuildLog("Cannot build zebinary for this device with debugger enabled. Remove \"-ze-intel-enable-zebin\" build flag."); + const auto &rootDevice = neoDevice->getRootDevice(); + if (!rootDevice->getCompilerInterface()->addOptionDisableZebin(this->options, internalOptions)) { + updateBuildLog("Cannot build zebinary for this device with debugger enabled. Remove \"-ze-intel-enable-zebin\" build flag"); return ZE_RESULT_ERROR_MODULE_BUILD_FAILURE; } - internalOptions += " " + NEO::CompilerOptions::disableZebin.str(); } NEO::TranslationInput inputArgs = {IGC::CodeType::spirV, IGC::CodeType::oclGenBin}; diff --git a/opencl/source/program/build.cpp b/opencl/source/program/build.cpp index 40b9e934e2..62c1791cee 100644 --- a/opencl/source/program/build.cpp +++ b/opencl/source/program/build.cpp @@ -119,7 +119,8 @@ cl_int Program::build( if (nullptr != this->getContextPtr()) { if (this->getContext().checkIfContextIsNonZebin()) { - CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::disableZebin); + const auto &rootDevice = defaultDevice.getRootDevice(); + rootDevice->getCompilerInterface()->addOptionDisableZebin(options, internalOptions); } } diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index 131bcbcb09..724c4f8cda 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -486,11 +486,8 @@ void Program::disableZebinIfVmeEnabled(std::string &options, std::string &intern } if (containsVme(options, vmeOptions) || containsVme(sourceCode, vmeEnabledExtensions)) { - auto pos = options.find(CompilerOptions::enableZebin.str()); - if (pos != std::string::npos) { - options.erase(pos, pos + CompilerOptions::enableZebin.length()); - } - internalOptions += " " + CompilerOptions::disableZebin.str(); + const auto &rootDevice = getDevices()[0]->getDevice().getRootDevice(); + rootDevice->getCompilerInterface()->disableZebin(options, internalOptions); } } diff --git a/shared/source/compiler_interface/compiler_interface.cpp b/shared/source/compiler_interface/compiler_interface.cpp index c37e095d82..bcc3cc4e75 100644 --- a/shared/source/compiler_interface/compiler_interface.cpp +++ b/shared/source/compiler_interface/compiler_interface.cpp @@ -10,6 +10,7 @@ #include "shared/source/built_ins/sip_kernel_type.h" #include "shared/source/compiler_interface/compiler_cache.h" #include "shared/source/compiler_interface/compiler_interface.inl" +#include "shared/source/compiler_interface/compiler_options.h" #include "shared/source/compiler_interface/igc_platform_helper.h" #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/device/device.h" @@ -369,20 +370,24 @@ CIF::RAII::UPtr_t CompilerInterface::getIg } bool CompilerInterface::loadFcl() { - return NEO::loadCompiler(Os::frontEndDllName, fclLib, fclMain); + return NEO::loadCompiler(Os::frontEndDllName, fclLib, fclMain); } bool CompilerInterface::loadIgc() { - return NEO::loadCompiler(Os::igcDllName, igcLib, igcMain); + return NEO::loadCompiler(Os::igcDllName, igcLib, igcMain); } bool CompilerInterface::initialize(std::unique_ptr &&cache, bool requireFcl) { bool fclAvailable = requireFcl ? this->loadFcl() : false; bool igcAvailable = this->loadIgc(); + bool compilerVersionCorrect = true; + if (!DebugManager.flags.ZebinIgnoreIcbeVersion.get()) { + compilerVersionCorrect = verifyIcbeVersion(); + } this->cache.swap(cache); - return this->cache && igcAvailable && (fclAvailable || (false == requireFcl)); + return this->cache && igcAvailable && (fclAvailable || (false == requireFcl)) && compilerVersionCorrect; } IGC::FclOclDeviceCtxTagOCL *CompilerInterface::getFclDeviceCtx(const Device &device) { @@ -492,4 +497,62 @@ CIF::RAII::UPtr_t CompilerInterface::createIgcT return deviceCtx->CreateTranslationCtx(inType, outType); } -} // namespace NEO +template