mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
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 <katarzyna.cencelewska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a32a1d549e
commit
861ec524c6
@@ -251,7 +251,8 @@ ze_result_t ModuleTranslationUnit::staticLinkSpirV(std::vector<const char *> 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<L0GfxCoreHelper>();
|
||||
auto &l0GfxCoreHelper = neoDevice->getRootDeviceEnvironment().getHelper<L0GfxCoreHelper>();
|
||||
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};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<IGC::IgcFeaturesAndWorkaroundsTagOCL> CompilerInterface::getIg
|
||||
}
|
||||
|
||||
bool CompilerInterface::loadFcl() {
|
||||
return NEO::loadCompiler<IGC::FclOclDeviceCtx>(Os::frontEndDllName, fclLib, fclMain);
|
||||
return NEO::loadCompiler(Os::frontEndDllName, fclLib, fclMain);
|
||||
}
|
||||
|
||||
bool CompilerInterface::loadIgc() {
|
||||
return NEO::loadCompiler<IGC::IgcOclDeviceCtx>(Os::igcDllName, igcLib, igcMain);
|
||||
return NEO::loadCompiler(Os::igcDllName, igcLib, igcMain);
|
||||
}
|
||||
|
||||
bool CompilerInterface::initialize(std::unique_ptr<CompilerCache> &&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<IGC::IgcOclTranslationCtxTagOCL> CompilerInterface::createIgcT
|
||||
return deviceCtx->CreateTranslationCtx(inType, outType);
|
||||
}
|
||||
|
||||
template <template <CIF::Version_t> class EntryPointT>
|
||||
void checkIcbeVersion(CIF::CIFMain *main, const char *libName, bool &ret) {
|
||||
if (false == main->IsCompatible<EntryPointT>()) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Installed Compiler Library %s is incompatible\n", libName);
|
||||
DEBUG_BREAK_IF(true); // given compiler library is not compatible
|
||||
ret = false;
|
||||
return;
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::once_flag &CompilerInterface::getIcbeVersionCallOnceFlag<IGC::IgcOclDeviceCtx>() {
|
||||
return igcIcbeCheckVersionCallOnce;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::once_flag &CompilerInterface::getIcbeVersionCallOnceFlag<IGC::FclOclDeviceCtx>() {
|
||||
return fclIcbeCheckVersionCallOnce;
|
||||
}
|
||||
|
||||
template <template <CIF::Version_t> class EntryPointT>
|
||||
bool CompilerInterface::checkIcbeVersionOnce(CIF::CIFMain *main, const char *libName) {
|
||||
bool ret = true;
|
||||
std::call_once(getIcbeVersionCallOnceFlag<EntryPointT>(), checkIcbeVersion<EntryPointT>, main, libName, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CompilerInterface::verifyIcbeVersion() {
|
||||
bool versionIsCorrect = true;
|
||||
if (isFclAvailable()) {
|
||||
versionIsCorrect = checkIcbeVersionOnce<IGC::FclOclDeviceCtx>(fclMain.get(), Os::frontEndDllName);
|
||||
}
|
||||
if (isIgcAvailable()) {
|
||||
versionIsCorrect &= checkIcbeVersionOnce<IGC::IgcOclDeviceCtx>(igcMain.get(), Os::igcDllName);
|
||||
}
|
||||
return versionIsCorrect;
|
||||
}
|
||||
|
||||
bool CompilerInterface::addOptionDisableZebin(std::string &options, std::string &internalOptions) {
|
||||
CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::disableZebin);
|
||||
auto pos = options.find(NEO::CompilerOptions::enableZebin.str());
|
||||
if (pos != std::string::npos || !verifyIcbeVersion()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CompilerInterface::disableZebin(std::string &options, std::string &internalOptions) {
|
||||
auto pos = options.find(NEO::CompilerOptions::enableZebin.str());
|
||||
if (pos != std::string::npos) {
|
||||
options.erase(pos, pos + CompilerOptions::enableZebin.length());
|
||||
}
|
||||
return addOptionDisableZebin(options, internalOptions);
|
||||
}
|
||||
|
||||
template bool CompilerInterface::checkIcbeVersionOnce<IGC::FclOclDeviceCtx>(CIF::CIFMain *main, const char *libName);
|
||||
template bool CompilerInterface::checkIcbeVersionOnce<IGC::IgcOclDeviceCtx>(CIF::CIFMain *main, const char *libName);
|
||||
} // namespace NEO
|
||||
@@ -128,11 +128,22 @@ class CompilerInterface {
|
||||
|
||||
MOCKABLE_VIRTUAL CIF::RAII::UPtr_t<IGC::IgcFeaturesAndWorkaroundsTagOCL> getIgcFeaturesAndWorkarounds(const NEO::Device &device);
|
||||
|
||||
bool addOptionDisableZebin(std::string &options, std::string &internalOptions);
|
||||
bool disableZebin(std::string &options, std::string &internalOptions);
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL bool initialize(std::unique_ptr<CompilerCache> &&cache, bool requireFcl);
|
||||
MOCKABLE_VIRTUAL bool loadFcl();
|
||||
MOCKABLE_VIRTUAL bool loadIgc();
|
||||
|
||||
template <template <CIF::Version_t> class EntryPointT>
|
||||
std::once_flag &getIcbeVersionCallOnceFlag();
|
||||
|
||||
template <template <CIF::Version_t> class EntryPointT>
|
||||
bool checkIcbeVersionOnce(CIF::CIFMain *main, const char *libName);
|
||||
|
||||
bool verifyIcbeVersion();
|
||||
|
||||
static SpinLock spinlock;
|
||||
[[nodiscard]] MOCKABLE_VIRTUAL std::unique_lock<SpinLock> lock() {
|
||||
return std::unique_lock<SpinLock>{spinlock};
|
||||
@@ -161,7 +172,6 @@ class CompilerInterface {
|
||||
MOCKABLE_VIRTUAL CIF::RAII::UPtr_t<IGC::IgcOclTranslationCtxTagOCL> createIgcTranslationCtx(const Device &device,
|
||||
IGC::CodeType::CodeType_t inType,
|
||||
IGC::CodeType::CodeType_t outType);
|
||||
|
||||
bool isFclAvailable() const {
|
||||
return (fclMain != nullptr);
|
||||
}
|
||||
@@ -175,5 +185,8 @@ class CompilerInterface {
|
||||
bool requiresIgc = (IGC::CodeType::oclC != translationSrc) || ((IGC::CodeType::spirV != translationDst) && (IGC::CodeType::llvmBc != translationDst) && (IGC::CodeType::llvmLl != translationDst));
|
||||
return (isFclAvailable() || (false == requiresFcl)) && (isIgcAvailable() || (false == requiresIgc));
|
||||
}
|
||||
|
||||
std::once_flag igcIcbeCheckVersionCallOnce;
|
||||
std::once_flag fclIcbeCheckVersionCallOnce;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -86,7 +86,6 @@ inline CIF::RAII::UPtr_t<IGC::OclTranslationOutputTagOCL> translate(TranslationC
|
||||
|
||||
CIF::CIFMain *createMainNoSanitize(CIF::CreateCIFMainFunc_t createFunc);
|
||||
|
||||
template <template <CIF::Version_t> class EntryPointT>
|
||||
inline bool loadCompiler(const char *libName, std::unique_ptr<OsLibrary> &outLib,
|
||||
CIF::RAII::UPtr_t<CIF::CIFMain> &outLibMain) {
|
||||
std::string loadLibraryError;
|
||||
@@ -106,16 +105,6 @@ inline bool loadCompiler(const char *libName, std::unique_ptr<OsLibrary> &outLib
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<CIF::InterfaceId_t> interfacesToIgnore;
|
||||
if (DebugManager.flags.ZebinIgnoreIcbeVersion.get()) {
|
||||
interfacesToIgnore.push_back(IGC::OclGenBinaryBase::GetInterfaceId());
|
||||
}
|
||||
if (false == main->IsCompatible<EntryPointT>(&interfacesToIgnore)) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Installed Compiler Library %s is incompatible\n", libName);
|
||||
DEBUG_BREAK_IF(true); // given compiler library is not compatible
|
||||
return false;
|
||||
}
|
||||
|
||||
outLib = std::move(lib);
|
||||
outLibMain = std::move(main);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ DECLARE_DEBUG_VARIABLE(bool, OverrideInvalidEngineWithDefault, false, "Default t
|
||||
DECLARE_DEBUG_VARIABLE(bool, ForceImplicitFlush, false, "Flush after each enqueue; useful for debugging batched submission logic")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ForcePipeControlPriorToWalker, false, "Force pipe control prior to walker")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ZebinAppendElws, false, "Append cross-thread data with enqueue local work size")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ZebinIgnoreIcbeVersion, false, "Ignore IGC\'s ICBE version")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ZebinIgnoreIcbeVersion, true, "Ignore IGC\'s ICBE version")
|
||||
DECLARE_DEBUG_VARIABLE(bool, UseExternalAllocatorForSshAndDsh, false, "Use 32 bit external allocator for ssh and dsh in Level Zero")
|
||||
DECLARE_DEBUG_VARIABLE(bool, UseBindlessDebugSip, false, "Use bindless debug system routine")
|
||||
DECLARE_DEBUG_VARIABLE(bool, CleanStateInPreamble, false, "Ensures clean state in preamble")
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/program/program_info.h"
|
||||
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
#include "shared/source/compiler_interface/compiler_options.h"
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
@@ -52,10 +53,7 @@ bool isRebuiltToPatchtokensRequired(Device *neoDevice, ArrayRef<const uint8_t> a
|
||||
auto isSourceLevelDebuggerActive = (nullptr != neoDevice->getSourceLevelDebugger());
|
||||
auto isZebinFormat = NEO::isDeviceBinaryFormat<NEO::DeviceBinaryFormat::Zebin>(archive);
|
||||
if ((isSourceLevelDebuggerActive || isVmeUsed) && isZebinFormat) {
|
||||
auto pos = optionsString.find(NEO::CompilerOptions::enableZebin.str());
|
||||
optionsString.erase(pos, pos + NEO::CompilerOptions::enableZebin.length());
|
||||
optionsString += " " + NEO::CompilerOptions::disableZebin.str();
|
||||
return true;
|
||||
return neoDevice->getCompilerInterface()->disableZebin(optionsString, optionsString);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,14 @@ namespace NEO {
|
||||
|
||||
class MockCompilerInterface : public CompilerInterface {
|
||||
public:
|
||||
using CompilerInterface::checkIcbeVersionOnce;
|
||||
using CompilerInterface::fclBaseTranslationCtx;
|
||||
using CompilerInterface::fclDeviceContexts;
|
||||
using CompilerInterface::initialize;
|
||||
using CompilerInterface::isCompilerAvailable;
|
||||
using CompilerInterface::isFclAvailable;
|
||||
using CompilerInterface::isIgcAvailable;
|
||||
using CompilerInterface::verifyIcbeVersion;
|
||||
|
||||
using CompilerInterface::fclMain;
|
||||
using CompilerInterface::igcMain;
|
||||
|
||||
@@ -228,7 +228,7 @@ ForceGpgpuSubmissionForBcsEnqueue = -1
|
||||
ForceSemaphoreDelayBetweenWaits = -1
|
||||
ForceLocalMemoryAccessMode = -1
|
||||
ZebinAppendElws = 0
|
||||
ZebinIgnoreIcbeVersion = 0
|
||||
ZebinIgnoreIcbeVersion = 1
|
||||
LogWaitingForCompletion = 0
|
||||
ForceUserptrAlignment = -1
|
||||
ForceCommandBufferAlignment = -1
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
#include "shared/source/compiler_interface/compiler_cache.h"
|
||||
#include "shared/source/compiler_interface/compiler_interface.h"
|
||||
#include "shared/source/compiler_interface/compiler_interface.inl"
|
||||
#include "shared/source/compiler_interface/compiler_options.h"
|
||||
#include "shared/source/helpers/compiler_product_helper.h"
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
@@ -621,7 +623,7 @@ TEST(TranslateTest, whenAnyArgIsNullThenNullptrIsReturnedAndTranslatorIsNotInvok
|
||||
TEST(LoadCompilerTest, whenEverythingIsOkThenReturnsTrueAndValidOutputs) {
|
||||
std::unique_ptr<NEO::OsLibrary> retLib;
|
||||
CIF::RAII::UPtr_t<CIF::CIFMain> retMain;
|
||||
bool retVal = loadCompiler<IGC::IgcOclDeviceCtx>("", retLib, retMain);
|
||||
bool retVal = loadCompiler("", retLib, retMain);
|
||||
EXPECT_TRUE(retVal);
|
||||
EXPECT_NE(nullptr, retLib.get());
|
||||
EXPECT_NE(nullptr, retMain.get());
|
||||
@@ -630,7 +632,7 @@ TEST(LoadCompilerTest, whenEverythingIsOkThenReturnsTrueAndValidOutputs) {
|
||||
TEST(LoadCompilerTest, whenCouldNotLoadLibraryThenReturnFalseAndNullOutputs) {
|
||||
std::unique_ptr<NEO::OsLibrary> retLib;
|
||||
CIF::RAII::UPtr_t<CIF::CIFMain> retMain;
|
||||
bool retVal = loadCompiler<IGC::IgcOclDeviceCtx>("_falseName.notRealLib", retLib, retMain);
|
||||
bool retVal = loadCompiler("_falseName.notRealLib", retLib, retMain);
|
||||
EXPECT_FALSE(retVal);
|
||||
EXPECT_EQ(nullptr, retLib.get());
|
||||
EXPECT_EQ(nullptr, retMain.get());
|
||||
@@ -641,7 +643,7 @@ TEST(LoadCompilerTest, whenCreateMainFailsThenReturnFalseAndNullOutputs) {
|
||||
|
||||
std::unique_ptr<NEO::OsLibrary> retLib;
|
||||
CIF::RAII::UPtr_t<CIF::CIFMain> retMain;
|
||||
bool retVal = loadCompiler<IGC::IgcOclDeviceCtx>("", retLib, retMain);
|
||||
bool retVal = loadCompiler("", retLib, retMain);
|
||||
EXPECT_FALSE(retVal);
|
||||
EXPECT_EQ(nullptr, retLib.get());
|
||||
EXPECT_EQ(nullptr, retMain.get());
|
||||
@@ -649,28 +651,6 @@ TEST(LoadCompilerTest, whenCreateMainFailsThenReturnFalseAndNullOutputs) {
|
||||
NEO::failCreateCifMain = false;
|
||||
}
|
||||
|
||||
TEST(LoadCompilerTest, whenEntrypointInterfaceIsNotCompatibleThenReturnFalseAndNullOutputs) {
|
||||
|
||||
std::unique_ptr<NEO::OsLibrary> retLib;
|
||||
CIF::RAII::UPtr_t<CIF::CIFMain> retMain;
|
||||
bool retVal = loadCompiler<IGC::GTSystemInfo>("", retLib, retMain);
|
||||
EXPECT_FALSE(retVal);
|
||||
EXPECT_EQ(nullptr, retLib.get());
|
||||
EXPECT_EQ(nullptr, retMain.get());
|
||||
}
|
||||
|
||||
TEST(LoadCompilerTest, GivenZebinIgnoreIcbeVersionDebugFlagThenIgnoreIgcsIcbeVersion) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(true);
|
||||
|
||||
std::unique_ptr<NEO::OsLibrary> retLib;
|
||||
CIF::RAII::UPtr_t<CIF::CIFMain> retMain;
|
||||
bool retVal = loadCompiler<IGC::IgcOclDeviceCtx>("", retLib, retMain);
|
||||
EXPECT_TRUE(retVal);
|
||||
EXPECT_NE(nullptr, retLib.get());
|
||||
EXPECT_NE(nullptr, retMain.get());
|
||||
}
|
||||
|
||||
template <typename DeviceCtxBase, typename TranslationCtx>
|
||||
struct MockCompilerDeviceCtx : DeviceCtxBase {
|
||||
TranslationCtx *CreateTranslationCtxImpl(CIF::Version_t ver, IGC::CodeType::CodeType_t inType,
|
||||
@@ -1214,6 +1194,331 @@ TEST_F(CompilerInterfaceTest, givenCompilerInterfaceWhenGetSpecializationConstan
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
}
|
||||
|
||||
struct UnknownInterfaceCIFMain : MockCIFMain {
|
||||
CIF::InterfaceId_t FindIncompatibleImpl(CIF::InterfaceId_t entryPointInterface, CIF::CompatibilityDataHandle handle) const override {
|
||||
return CIF::UnknownInterface;
|
||||
}
|
||||
};
|
||||
struct MockCompilerInterfaceWithUnknownInterfaceCIFMain : MockCompilerInterface {
|
||||
bool loadFcl() override {
|
||||
CompilerInterface::loadFcl();
|
||||
fclMain.reset(new UnknownInterfaceCIFMain());
|
||||
if (failLoadFcl) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool loadIgc() override {
|
||||
CompilerInterface::loadIgc();
|
||||
igcMain.reset(new UnknownInterfaceCIFMain());
|
||||
if (failLoadIgc) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(TestCompilerInterface, givenNullCompilerCacheAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
ci.failLoadFcl = false;
|
||||
ci.failLoadIgc = false;
|
||||
bool initSuccess = ci.initialize(nullptr, true);
|
||||
EXPECT_FALSE(initSuccess);
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenRequiredFclAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = true;
|
||||
ci.failLoadFcl = false;
|
||||
ci.failLoadIgc = false;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenNotRequiredFclAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = false;
|
||||
ci.failLoadFcl = false;
|
||||
ci.failLoadIgc = false;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenNotRequiredFclAndFclLoadFaildAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = false;
|
||||
ci.failLoadFcl = true;
|
||||
ci.failLoadIgc = false;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenRequiredFclAndFclLoadFaildAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = true;
|
||||
ci.failLoadFcl = true;
|
||||
ci.failLoadIgc = false;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenRequiredFclAndIgcLoadFaildAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = true;
|
||||
ci.failLoadFcl = false;
|
||||
ci.failLoadIgc = true;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenNotRequiredFclAndIgcLoadFaildAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = false;
|
||||
ci.failLoadFcl = false;
|
||||
ci.failLoadIgc = true;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenNotRequiredFclAndFclAndIgcLoadFaildAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = false;
|
||||
ci.failLoadFcl = true;
|
||||
ci.failLoadIgc = true;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenRequiredFclAndFclAndIgcLoadFaildAndFlagZebinIgnoreIcbeVersionDisabledWhenVerifyIcbeVersionReturnFalseThenInitializationNotSuccess) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
|
||||
MockCompilerInterfaceWithUnknownInterfaceCIFMain ci;
|
||||
|
||||
bool requireFcl = true;
|
||||
ci.failLoadFcl = true;
|
||||
ci.failLoadIgc = true;
|
||||
|
||||
EXPECT_FALSE(ci.initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), requireFcl));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenZebinIgnoreIcbeVersionFlagWhenVerifyIcbeVersionFailThenInitializationReturnProperValues) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(1);
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(1);
|
||||
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterfaceWithUnknownInterfaceCIFMain>();
|
||||
|
||||
testing::internal::CaptureStderr();
|
||||
bool initializationOfCompilerInterfaceSuccessed = mockCompilerInterface->initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), true);
|
||||
EXPECT_TRUE(initializationOfCompilerInterfaceSuccessed);
|
||||
std::string stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_TRUE(stderrString.empty());
|
||||
|
||||
DebugManager.flags.ZebinIgnoreIcbeVersion.set(0);
|
||||
testing::internal::CaptureStderr();
|
||||
initializationOfCompilerInterfaceSuccessed = mockCompilerInterface->initialize(std::make_unique<CompilerCache>(CompilerCacheConfig{}), true);
|
||||
EXPECT_FALSE(initializationOfCompilerInterfaceSuccessed);
|
||||
stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_FALSE(stderrString.empty());
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenUnknownInterfaceForIgcAndFclWhenCheckIcbeVersionThenPrintProperDebugMessageOnce) {
|
||||
auto dummy = std::make_unique<UnknownInterfaceCIFMain>();
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterface>();
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(1);
|
||||
|
||||
std::string dummyString = "dummy";
|
||||
std::string expectedError = "Installed Compiler Library " + dummyString + " is incompatible\n";
|
||||
|
||||
testing::internal::CaptureStderr();
|
||||
auto err = mockCompilerInterface->checkIcbeVersionOnce<IGC::FclOclDeviceCtx>(dummy.get(), dummyString.c_str());
|
||||
EXPECT_FALSE(err);
|
||||
std::string stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_EQ(expectedError, stderrString);
|
||||
|
||||
testing::internal::CaptureStderr();
|
||||
err = mockCompilerInterface->checkIcbeVersionOnce<IGC::IgcOclDeviceCtx>(dummy.get(), dummyString.c_str());
|
||||
EXPECT_FALSE(err);
|
||||
stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_EQ(expectedError, stderrString);
|
||||
|
||||
// second check for the same EntryPointTs
|
||||
testing::internal::CaptureStderr();
|
||||
mockCompilerInterface->checkIcbeVersionOnce<IGC::FclOclDeviceCtx>(dummy.get(), dummyString.c_str());
|
||||
stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_TRUE(stderrString.empty());
|
||||
|
||||
testing::internal::CaptureStderr();
|
||||
mockCompilerInterface->checkIcbeVersionOnce<IGC::IgcOclDeviceCtx>(dummy.get(), dummyString.c_str());
|
||||
stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_TRUE(stderrString.empty());
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenUnknownInterfaceAndFclMainWhenverifyIcbeVersionThenPrintProperDebugMessage) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(1);
|
||||
|
||||
auto dummy = new UnknownInterfaceCIFMain();
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterface>();
|
||||
|
||||
mockCompilerInterface->fclMain.reset(dummy);
|
||||
mockCompilerInterface->igcMain.reset(nullptr);
|
||||
std::string expectedError = "Installed Compiler Library " + std::string(Os::frontEndDllName) + " is incompatible\n";
|
||||
|
||||
testing::internal::CaptureStderr();
|
||||
auto err = mockCompilerInterface->verifyIcbeVersion();
|
||||
EXPECT_FALSE(err);
|
||||
std::string stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_FALSE(stderrString.empty());
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenUnknownInterfaceAndIgcMainWhenverifyIcbeVersionThenPrintProperDebugMessage) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(1);
|
||||
|
||||
auto dummy = new UnknownInterfaceCIFMain();
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterface>();
|
||||
|
||||
mockCompilerInterface->igcMain.reset(dummy);
|
||||
mockCompilerInterface->fclMain.reset(nullptr);
|
||||
|
||||
std::string expectedError = "Installed Compiler Library " + std::string(Os::igcDllName) + " is incompatible\n";
|
||||
testing::internal::CaptureStderr();
|
||||
EXPECT_FALSE(mockCompilerInterface->verifyIcbeVersion());
|
||||
std::string stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_EQ(expectedError, stderrString);
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenUnknownInterfaceAndFclMainAndIgcMainWhenVerifyIcbeVersionThenPrintProperDebugMessage) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(1);
|
||||
|
||||
auto dummyIgc = new UnknownInterfaceCIFMain();
|
||||
auto dummyFcl = new UnknownInterfaceCIFMain();
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterface>();
|
||||
|
||||
mockCompilerInterface->igcMain.reset(dummyIgc);
|
||||
mockCompilerInterface->fclMain.reset(dummyFcl);
|
||||
|
||||
std::string expectedError = "Installed Compiler Library " + std::string(Os::frontEndDllName) + " is incompatible\n" + "Installed Compiler Library " + std::string(Os::igcDllName) + " is incompatible\n";
|
||||
testing::internal::CaptureStderr();
|
||||
EXPECT_FALSE(mockCompilerInterface->verifyIcbeVersion());
|
||||
std::string stderrString = testing::internal::GetCapturedStderr();
|
||||
EXPECT_EQ(expectedError, stderrString);
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenInvalidIcbeVersionWhenAddOptionDisableZebinThenFalseIsReturned) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
|
||||
auto dummyInValid = new UnknownInterfaceCIFMain();
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterface>();
|
||||
|
||||
mockCompilerInterface->igcMain.reset(dummyInValid);
|
||||
|
||||
std::string option = "";
|
||||
std::string internalOption = "";
|
||||
EXPECT_FALSE(mockCompilerInterface->addOptionDisableZebin(option, internalOption));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenOptionsWhenCallAddOptionDisableZebinThenProperValueIsReturned) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
|
||||
auto dummyValid = new MockCIFMain();
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterface>();
|
||||
|
||||
mockCompilerInterface->igcMain.reset(dummyValid);
|
||||
|
||||
std::string options = NEO::CompilerOptions::enableZebin.str();
|
||||
std::string internalOptions = "";
|
||||
EXPECT_FALSE(mockCompilerInterface->addOptionDisableZebin(options, internalOptions));
|
||||
|
||||
options = "";
|
||||
EXPECT_TRUE(mockCompilerInterface->addOptionDisableZebin(options, internalOptions));
|
||||
}
|
||||
|
||||
TEST(TestCompilerInterface, givenOptionsWhenCallDisableZebinThenProperOptionsAreSet) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableDebugBreak.set(0);
|
||||
DebugManager.flags.PrintDebugMessages.set(0);
|
||||
|
||||
auto dummyValid = new MockCIFMain();
|
||||
auto mockCompilerInterface = std::make_unique<MockCompilerInterface>();
|
||||
|
||||
mockCompilerInterface->igcMain.reset(dummyValid);
|
||||
|
||||
std::string options = "";
|
||||
std::string internalOptions = "";
|
||||
EXPECT_TRUE(mockCompilerInterface->disableZebin(options, internalOptions));
|
||||
EXPECT_FALSE(CompilerOptions::contains(options, NEO::CompilerOptions::enableZebin.str()));
|
||||
|
||||
options = NEO::CompilerOptions::enableZebin.str();
|
||||
EXPECT_TRUE(mockCompilerInterface->disableZebin(options, internalOptions));
|
||||
EXPECT_TRUE(CompilerOptions::contains(internalOptions, NEO::CompilerOptions::disableZebin.str()));
|
||||
EXPECT_FALSE(CompilerOptions::contains(options, NEO::CompilerOptions::enableZebin.str()));
|
||||
}
|
||||
|
||||
TEST(TranslationOutput, givenNonEmptyPointerAndSizeWhenMakingCopyThenCloneInputData) {
|
||||
MockCIFBuffer src;
|
||||
src.data.assign({2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37});
|
||||
|
||||
Reference in New Issue
Block a user