Revert "feature: adding support for custom compiler backends"

This reverts commit 8098bcc48d.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2024-10-16 01:25:42 +02:00
committed by Compute-Runtime-Automation
parent 6de2f1a9c9
commit 2098e64dc1
13 changed files with 457 additions and 483 deletions

View File

@@ -52,9 +52,6 @@ void TranslationOutput::makeCopy(MemAndSize &dst, CIF::Builtins::BufferSimple *s
CompilerInterface::CompilerInterface()
: cache() {
if (debugManager.flags.FinalizerInputType.get() != 0) {
this->finalizerInputType = debugManager.flags.FinalizerInputType.get();
}
}
CompilerInterface::~CompilerInterface() = default;
@@ -62,7 +59,7 @@ TranslationOutput::ErrorCode CompilerInterface::build(
const NEO::Device &device,
const TranslationInput &input,
TranslationOutput &output) {
if (false == isCompilerAvailable(&device, input.srcType, input.outType)) {
if (false == isCompilerAvailable(input.srcType, input.outType)) {
return TranslationOutput::ErrorCode::compilerNotAvailable;
}
@@ -85,11 +82,10 @@ TranslationOutput::ErrorCode CompilerInterface::build(
std::string kernelFileHash;
if (cachingMode == CachingMode::Direct) {
const auto &igc = *getIgc(&device);
kernelFileHash = cache->getCachedFileName(device.getHardwareInfo(),
input.src,
input.apiOptions,
input.internalOptions, ArrayRef<const char>(), ArrayRef<const char>(), igc.revision, igc.libSize, igc.libMTime);
input.internalOptions, ArrayRef<const char>(), ArrayRef<const char>(), igcRevision, igcLibSize, igcLibMTime);
bool success = CompilerCacheHelper::loadCacheAndSetOutput(*cache, kernelFileHash, output, device);
if (success) {
@@ -97,15 +93,12 @@ TranslationOutput::ErrorCode CompilerInterface::build(
}
}
const auto &igc = *getIgc(&device);
auto *igcMain = igc.entryPoint.get();
auto inSrc = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.src.begin(), input.src.size());
auto fclOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.apiOptions.begin(), input.apiOptions.size());
auto fclInternalOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.internalOptions.begin(), input.internalOptions.size());
auto inSrc = CIF::Builtins::CreateConstBuffer(igcMain, input.src.begin(), input.src.size());
auto fclOptions = CIF::Builtins::CreateConstBuffer(igcMain, input.apiOptions.begin(), input.apiOptions.size());
auto fclInternalOptions = CIF::Builtins::CreateConstBuffer(igcMain, input.internalOptions.begin(), input.internalOptions.size());
auto idsBuffer = CIF::Builtins::CreateConstBuffer(igcMain, nullptr, 0);
auto valuesBuffer = CIF::Builtins::CreateConstBuffer(igcMain, nullptr, 0);
auto idsBuffer = CIF::Builtins::CreateConstBuffer(igcMain.get(), nullptr, 0);
auto valuesBuffer = CIF::Builtins::CreateConstBuffer(igcMain.get(), nullptr, 0);
for (const auto &specConst : input.specializedValues) {
idsBuffer->PushBackRawCopy(specConst.first);
valuesBuffer->PushBackRawCopy(specConst.second);
@@ -147,10 +140,9 @@ TranslationOutput::ErrorCode CompilerInterface::build(
const ArrayRef<const char> irRef(intermediateRepresentation->GetMemory<char>(), intermediateRepresentation->GetSize<char>());
const ArrayRef<const char> specIdsRef(idsBuffer->GetMemory<char>(), idsBuffer->GetSize<char>());
const ArrayRef<const char> specValuesRef(valuesBuffer->GetMemory<char>(), valuesBuffer->GetSize<char>());
const auto &igc = *getIgc(&device);
kernelFileHash = cache->getCachedFileName(device.getHardwareInfo(), irRef,
input.apiOptions,
input.internalOptions, specIdsRef, specValuesRef, igc.revision, igc.libSize, igc.libMTime);
input.internalOptions, specIdsRef, specValuesRef, igcRevision, igcLibSize, igcLibMTime);
bool success = CompilerCacheHelper::loadCacheAndSetOutput(*cache, kernelFileHash, output, device);
if (success) {
@@ -158,43 +150,23 @@ TranslationOutput::ErrorCode CompilerInterface::build(
}
}
auto igcOutputType = IGC::CodeType::oclGenBin;
if (this->finalizerInputType != IGC::CodeType::undefined) {
igcOutputType = this->finalizerInputType;
}
auto igcTranslationCtx = createIgcTranslationCtx(device, intermediateCodeType, IGC::CodeType::oclGenBin);
auto igcTranslationCtx = createIgcTranslationCtx(device, intermediateCodeType, igcOutputType);
auto igcOutput = translate(igcTranslationCtx.get(), intermediateRepresentation.get(), idsBuffer.get(), valuesBuffer.get(),
fclOptions.get(), fclInternalOptions.get(), input.gtPinInput);
auto buildOutput = translate(igcTranslationCtx.get(), intermediateRepresentation.get(), idsBuffer.get(), valuesBuffer.get(),
fclOptions.get(), fclInternalOptions.get(), input.gtPinInput);
if (buildOutput == nullptr) {
if (igcOutput == nullptr) {
return TranslationOutput::ErrorCode::unknownError;
}
TranslationOutput::makeCopy(output.backendCompilerLog, buildOutput->GetBuildLog());
TranslationOutput::makeCopy(output.backendCompilerLog, igcOutput->GetBuildLog());
if (buildOutput->Successful() == false) {
if (igcOutput->Successful() == false) {
return TranslationOutput::ErrorCode::buildFailure;
}
if (igcOutputType == this->finalizerInputType) {
TranslationOutput::makeCopy(output.finalizerInputRepresentation, buildOutput->GetOutput());
auto finalizerTranslationCtx = createFinalizerTranslationCtx(device, this->finalizerInputType, IGC::CodeType::oclGenBin);
auto finalizerOutput = translate(finalizerTranslationCtx.get(), buildOutput->GetOutput(),
fclOptions.get(), fclInternalOptions.get(), nullptr);
buildOutput = std::move(finalizerOutput);
TranslationOutput::append(output.backendCompilerLog, buildOutput->GetBuildLog(), "\n", 0);
if (buildOutput->Successful() == false) {
return TranslationOutput::ErrorCode::buildFailure;
}
}
TranslationOutput::makeCopy(output.deviceBinary, buildOutput->GetOutput());
TranslationOutput::makeCopy(output.debugData, buildOutput->GetDebugData());
TranslationOutput::makeCopy(output.deviceBinary, igcOutput->GetOutput());
TranslationOutput::makeCopy(output.debugData, igcOutput->GetDebugData());
if (cache != nullptr && cache->getConfig().enabled) {
CompilerCacheHelper::packAndCacheBinary(*cache, kernelFileHash, NEO::getTargetDevice(device.getRootDeviceEnvironment()), output);
@@ -212,7 +184,7 @@ TranslationOutput::ErrorCode CompilerInterface::compile(
return TranslationOutput::ErrorCode::alreadyCompiled;
}
if (false == isCompilerAvailable(&device, input.srcType, input.outType)) {
if (false == isCompilerAvailable(input.srcType, input.outType)) {
return TranslationOutput::ErrorCode::compilerNotAvailable;
}
@@ -222,10 +194,9 @@ TranslationOutput::ErrorCode CompilerInterface::compile(
outType = getPreferredIntermediateRepresentation(device);
}
auto *fclMain = fcl.entryPoint.get();
auto fclSrc = CIF::Builtins::CreateConstBuffer(fclMain, input.src.begin(), input.src.size());
auto fclOptions = CIF::Builtins::CreateConstBuffer(fclMain, input.apiOptions.begin(), input.apiOptions.size());
auto fclInternalOptions = CIF::Builtins::CreateConstBuffer(fclMain, input.internalOptions.begin(), input.internalOptions.size());
auto fclSrc = CIF::Builtins::CreateConstBuffer(fclMain.get(), input.src.begin(), input.src.size());
auto fclOptions = CIF::Builtins::CreateConstBuffer(fclMain.get(), input.apiOptions.begin(), input.apiOptions.size());
auto fclInternalOptions = CIF::Builtins::CreateConstBuffer(fclMain.get(), input.internalOptions.begin(), input.internalOptions.size());
auto fclTranslationCtx = createFclTranslationCtx(device, input.srcType, outType);
@@ -252,14 +223,13 @@ TranslationOutput::ErrorCode CompilerInterface::link(
const NEO::Device &device,
const TranslationInput &input,
TranslationOutput &output) {
if (false == isCompilerAvailable(&device, input.srcType, input.outType)) {
if (false == isCompilerAvailable(input.srcType, input.outType)) {
return TranslationOutput::ErrorCode::compilerNotAvailable;
}
auto *igcMain = getIgc(&device)->entryPoint.get();
auto inSrc = CIF::Builtins::CreateConstBuffer(igcMain, input.src.begin(), input.src.size());
auto igcOptions = CIF::Builtins::CreateConstBuffer(igcMain, input.apiOptions.begin(), input.apiOptions.size());
auto igcInternalOptions = CIF::Builtins::CreateConstBuffer(igcMain, input.internalOptions.begin(), input.internalOptions.size());
auto inSrc = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.src.begin(), input.src.size());
auto igcOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.apiOptions.begin(), input.apiOptions.size());
auto igcInternalOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.internalOptions.begin(), input.internalOptions.size());
if (inSrc == nullptr) {
return TranslationOutput::ErrorCode::unknownError;
@@ -299,16 +269,15 @@ TranslationOutput::ErrorCode CompilerInterface::link(
}
TranslationOutput::ErrorCode CompilerInterface::getSpecConstantsInfo(const NEO::Device &device, ArrayRef<const char> srcSpirV, SpecConstantInfo &output) {
if (false == isIgcAvailable(&device)) {
if (false == isIgcAvailable()) {
return TranslationOutput::ErrorCode::compilerNotAvailable;
}
auto igcTranslationCtx = createIgcTranslationCtx(device, IGC::CodeType::spirV, IGC::CodeType::oclGenBin);
auto *igcMain = getIgc(&device)->entryPoint.get();
auto inSrc = CIF::Builtins::CreateConstBuffer(igcMain, srcSpirV.begin(), srcSpirV.size());
output.idsBuffer = CIF::Builtins::CreateConstBuffer(igcMain, nullptr, 0);
output.sizesBuffer = CIF::Builtins::CreateConstBuffer(igcMain, nullptr, 0);
auto inSrc = CIF::Builtins::CreateConstBuffer(igcMain.get(), srcSpirV.begin(), srcSpirV.size());
output.idsBuffer = CIF::Builtins::CreateConstBuffer(igcMain.get(), nullptr, 0);
output.sizesBuffer = CIF::Builtins::CreateConstBuffer(igcMain.get(), nullptr, 0);
auto retVal = getSpecConstantsInfoImpl(igcTranslationCtx.get(), inSrc.get(), output.idsBuffer.get(), output.sizesBuffer.get());
@@ -323,14 +292,13 @@ TranslationOutput::ErrorCode CompilerInterface::createLibrary(
NEO::Device &device,
const TranslationInput &input,
TranslationOutput &output) {
if (false == isIgcAvailable(&device)) {
if (false == isIgcAvailable()) {
return TranslationOutput::ErrorCode::compilerNotAvailable;
}
auto *igcMain = getIgc(&device)->entryPoint.get();
auto igcSrc = CIF::Builtins::CreateConstBuffer(igcMain, input.src.begin(), input.src.size());
auto igcOptions = CIF::Builtins::CreateConstBuffer(igcMain, input.apiOptions.begin(), input.apiOptions.size());
auto igcInternalOptions = CIF::Builtins::CreateConstBuffer(igcMain, input.internalOptions.begin(), input.internalOptions.size());
auto igcSrc = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.src.begin(), input.src.size());
auto igcOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.apiOptions.begin(), input.apiOptions.size());
auto igcInternalOptions = CIF::Builtins::CreateConstBuffer(igcMain.get(), input.internalOptions.begin(), input.internalOptions.size());
auto intermediateRepresentation = IGC::CodeType::llvmBc;
auto igcTranslationCtx = createIgcTranslationCtx(device, IGC::CodeType::elf, intermediateRepresentation);
@@ -356,7 +324,7 @@ TranslationOutput::ErrorCode CompilerInterface::createLibrary(
TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector<char> &retBinary,
std::vector<char> &stateSaveAreaHeader) {
if (false == isIgcAvailable(&device)) {
if (false == isIgcAvailable()) {
return TranslationOutput::ErrorCode::compilerNotAvailable;
}
@@ -390,7 +358,6 @@ TranslationOutput::ErrorCode CompilerInterface::getSipKernelBinary(NEO::Device &
return TranslationOutput::ErrorCode::unknownError;
}
auto *igcMain = getIgc(&device)->entryPoint.get();
auto systemRoutineBuffer = igcMain->CreateBuiltin<CIF::Builtins::BufferLatest>();
auto stateSaveAreaBuffer = igcMain->CreateBuiltin<CIF::Builtins::BufferLatest>();
@@ -414,41 +381,37 @@ CIF::RAII::UPtr_t<IGC::IgcFeaturesAndWorkaroundsTagOCL> CompilerInterface::getIg
}
bool CompilerInterface::loadFcl() {
return NEO::loadCompiler<IGC::FclOclDeviceCtx>(Os::frontEndDllName, fcl.library, fcl.entryPoint);
return NEO::loadCompiler<IGC::FclOclDeviceCtx>(Os::frontEndDllName, fclLib, fclMain);
}
bool CompilerInterface::loadIgcBasedCompiler(CompilerLibraryEntry &entry, const char *libName) {
bool result = NEO::loadCompiler<IGC::IgcOclDeviceCtx>(libName, entry.library, entry.entryPoint);
bool CompilerInterface::loadIgc() {
bool result = NEO::loadCompiler<IGC::IgcOclDeviceCtx>(Os::igcDllName, igcLib, igcMain);
if (result) {
std::string libPath = entry.library->getFullPath();
entry.libSize = NEO::getFileSize(libPath);
entry.libMTime = NEO::getFileModificationTime(libPath);
std::string igcPath = igcLib->getFullPath();
igcLibSize = NEO::getFileSize(igcPath);
igcLibMTime = NEO::getFileModificationTime(igcPath);
auto igcDeviceCtx3 = entry.entryPoint->CreateInterface<IGC::IgcOclDeviceCtx<3>>();
auto igcDeviceCtx3 = igcMain->CreateInterface<IGC::IgcOclDeviceCtx<3>>();
if (igcDeviceCtx3) {
entry.revision = igcDeviceCtx3->GetIGCRevision();
igcRevision = igcDeviceCtx3->GetIGCRevision();
}
}
return result;
}
bool CompilerInterface::loadFinalizer(CompilerLibraryEntry &entry, const char *libName) {
std::string finalizerLibName = libName;
if (debugManager.flags.FinalizerLibraryName.get() != "unk") {
finalizerLibName = debugManager.flags.FinalizerLibraryName.get();
}
return NEO::loadCompiler<IGC::IgcOclDeviceCtx>(libName, entry.library, entry.entryPoint);
}
bool CompilerInterface::initialize(std::unique_ptr<CompilerCache> &&cache, bool requireFcl) {
bool fclAvailable = requireFcl ? this->loadFcl() : false;
bool igcAvailable = this->loadIgcBasedCompiler(defaultIgc, Os::igcDllName);
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) {
@@ -458,12 +421,12 @@ IGC::FclOclDeviceCtxTagOCL *CompilerInterface::getFclDeviceCtx(const Device &dev
return it->second.get();
}
if (fcl.entryPoint == nullptr) {
if (fclMain == nullptr) {
DEBUG_BREAK_IF(true); // compiler not available
return nullptr;
}
auto newDeviceCtx = fcl.entryPoint->CreateInterface<IGC::FclOclDeviceCtxTagOCL>();
auto newDeviceCtx = fclMain->CreateInterface<IGC::FclOclDeviceCtxTagOCL>();
if (newDeviceCtx == nullptr) {
DEBUG_BREAK_IF(true); // could not create device context
return nullptr;
@@ -490,12 +453,10 @@ IGC::IgcOclDeviceCtxTagOCL *CompilerInterface::getIgcDeviceCtx(const Device &dev
return it->second.get();
}
auto *igc = getIgc(&device);
if (igc == nullptr) {
if (igcMain == nullptr) {
DEBUG_BREAK_IF(true); // compiler not available
return nullptr;
}
auto *igcMain = igc->entryPoint.get();
auto newDeviceCtx = igcMain->CreateInterface<IGC::IgcOclDeviceCtxTagOCL>();
if (newDeviceCtx == nullptr) {
@@ -529,51 +490,6 @@ IGC::IgcOclDeviceCtxTagOCL *CompilerInterface::getIgcDeviceCtx(const Device &dev
return igcDeviceContexts[&device].get();
}
IGC::IgcOclDeviceCtxTagOCL *CompilerInterface::getFinalizerDeviceCtx(const Device &device) {
auto ulock = this->lock();
auto it = finalizerDeviceContexts.find(&device);
if (it != finalizerDeviceContexts.end()) {
return it->second.get();
}
auto finalizer = this->getFinalizer(&device);
if (finalizer == nullptr) {
DEBUG_BREAK_IF(true); // compiler not available
return nullptr;
}
auto newDeviceCtx = finalizer->entryPoint->CreateInterface<IGC::IgcOclDeviceCtxTagOCL>();
if (newDeviceCtx == nullptr) {
DEBUG_BREAK_IF(true); // could not create device context
return nullptr;
}
newDeviceCtx->SetProfilingTimerResolution(static_cast<float>(device.getDeviceInfo().outProfilingTimerResolution));
auto igcPlatform = newDeviceCtx->GetPlatformHandle();
auto igcGtSystemInfo = newDeviceCtx->GetGTSystemInfoHandle();
auto igcFtrWa = newDeviceCtx->GetIgcFeaturesAndWorkaroundsHandle();
if (false == NEO::areNotNullptr(igcPlatform.get(), igcGtSystemInfo.get(), igcFtrWa.get())) {
DEBUG_BREAK_IF(true); // could not acquire handles to device descriptors
return nullptr;
}
const HardwareInfo *hwInfo = &device.getHardwareInfo();
auto productFamily = debugManager.flags.ForceCompilerUsePlatform.get();
if (productFamily != "unk") {
getHwInfoForPlatformString(productFamily, hwInfo);
}
populateIgcPlatform(*igcPlatform, *hwInfo);
IGC::GtSysInfoHelper::PopulateInterfaceWith(*igcGtSystemInfo, hwInfo->gtSystemInfo);
auto &compilerProductHelper = device.getCompilerProductHelper();
igcFtrWa->SetFtrGpGpuMidThreadLevelPreempt(compilerProductHelper.isMidThreadPreemptionSupported(*hwInfo));
igcFtrWa->SetFtrWddm2Svm(device.getHardwareInfo().featureTable.flags.ftrWddm2Svm);
igcFtrWa->SetFtrPooledEuEnabled(device.getHardwareInfo().featureTable.flags.ftrPooledEuEnabled);
finalizerDeviceContexts[&device] = std::move(newDeviceCtx);
return finalizerDeviceContexts[&device].get();
}
IGC::CodeType::CodeType_t CompilerInterface::getPreferredIntermediateRepresentation(const Device &device) {
return getFclDeviceCtx(device)->GetPreferredIntermediateRepresentation();
}
@@ -605,18 +521,50 @@ CIF::RAII::UPtr_t<IGC::IgcOclTranslationCtxTagOCL> CompilerInterface::createIgcT
return deviceCtx->CreateTranslationCtx(inType, outType);
}
CIF::RAII::UPtr_t<IGC::IgcOclTranslationCtxTagOCL> CompilerInterface::createFinalizerTranslationCtx(const Device &device, IGC::CodeType::CodeType_t inType, IGC::CodeType::CodeType_t outType) {
auto deviceCtx = getFinalizerDeviceCtx(device);
if (deviceCtx == nullptr) {
DEBUG_BREAK_IF(true); // could not create device context
return nullptr;
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;
}
return deviceCtx->CreateTranslationCtx(inType, outType);
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);
if (!verifyIcbeVersion()) {
return false;
}
return true;
}
@@ -624,47 +572,8 @@ bool CompilerInterface::disableZebin(std::string &options, std::string &internal
return addOptionDisableZebin(options, internalOptions);
}
bool CompilerInterface::isIgcAvailable(const Device *device) {
return nullptr != getIgc(device);
}
bool CompilerInterface::isFinalizerAvailable(const Device *device) {
return nullptr != getFinalizer(device);
}
const CompilerInterface::CompilerLibraryEntry *CompilerInterface::getIgc(const Device *device) {
if (nullptr == device) {
if (defaultIgc.entryPoint == nullptr) {
return nullptr;
}
return &defaultIgc;
}
return getIgc(device->getCompilerProductHelper().getCustomIgcLibraryName());
}
const CompilerInterface::CompilerLibraryEntry *CompilerInterface::getFinalizer(const Device *device) {
if (nullptr == device) {
return nullptr;
}
return getFinalizer(device->getCompilerProductHelper().getFinalizerLibraryName());
}
const CompilerInterface::CompilerLibraryEntry *CompilerInterface::getCustomCompilerLibrary(const char *libName) {
auto it = customCompilerLibraries.find(libName);
if (it != customCompilerLibraries.end()) {
return it->second.get();
}
CompilerLibraryEntry newEntry = {};
this->loadIgcBasedCompiler(newEntry, libName);
if (newEntry.entryPoint == nullptr) {
return nullptr;
}
customCompilerLibraries[libName].reset(new CompilerLibraryEntry(std::move(newEntry)));
return customCompilerLibraries[libName].get();
}
template bool CompilerInterface::checkIcbeVersionOnce<IGC::FclOclDeviceCtx>(CIF::CIFMain *main, const char *libName);
template bool CompilerInterface::checkIcbeVersionOnce<IGC::IgcOclDeviceCtx>(CIF::CIFMain *main, const char *libName);
void CompilerCacheHelper::packAndCacheBinary(CompilerCache &compilerCache, const std::string &kernelFileHash, const NEO::TargetDevice &targetDevice, const NEO::TranslationOutput &translationOutput) {
NEO::SingleDeviceBinary singleDeviceBinary = {};

View File

@@ -64,7 +64,6 @@ struct TranslationOutput {
IGC::CodeType::CodeType_t intermediateCodeType = IGC::CodeType::invalid;
MemAndSize intermediateRepresentation;
MemAndSize finalizerInputRepresentation;
MemAndSize deviceBinary;
MemAndSize debugData;
std::string frontendCompilerLog;
@@ -79,22 +78,6 @@ struct TranslationOutput {
dst.assign(src->GetMemory<char>(), src->GetSize<char>());
}
template <typename ContainerT, typename SeparatorT>
static void append(ContainerT &dst, CIF::Builtins::BufferSimple *src, const SeparatorT *separator, size_t separatorLen) {
if ((nullptr == src) || (src->GetSizeRaw() == 0)) {
return;
}
if ((false == dst.empty()) && separator && (separatorLen > 0)) {
dst.append(separator, separatorLen);
}
dst.append(src->GetMemory<char>(), src->GetSize<char>());
}
template <typename ContainerT, typename SeparatorT>
static void append(ContainerT &dst, CIF::Builtins::BufferSimple *src, const SeparatorT *separator) {
append(dst, src, separator, 1);
}
static void makeCopy(MemAndSize &dst, CIF::Builtins::BufferSimple *src);
};
@@ -150,22 +133,18 @@ class CompilerInterface {
bool disableZebin(std::string &options, std::string &internalOptions);
protected:
struct CompilerLibraryEntry {
std::string revision;
size_t libSize{};
time_t libMTime{};
std::unique_ptr<OsLibrary> library;
CIF::RAII::UPtr_t<CIF::CIFMain> entryPoint;
};
MOCKABLE_VIRTUAL bool initialize(std::unique_ptr<CompilerCache> &&cache, bool requireFcl);
MOCKABLE_VIRTUAL bool loadFcl();
MOCKABLE_VIRTUAL bool loadIgcBasedCompiler(CompilerLibraryEntry &entryPoint, const char *libName);
MOCKABLE_VIRTUAL bool loadFinalizer(CompilerLibraryEntry &entryPoint, const char *libName);
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};
@@ -173,23 +152,22 @@ class CompilerInterface {
std::unique_ptr<CompilerCache> cache;
using igcDevCtxUptr = CIF::RAII::UPtr_t<IGC::IgcOclDeviceCtxTagOCL>;
using finalizerDevCtxUptr = CIF::RAII::UPtr_t<IGC::IgcOclDeviceCtxTagOCL>;
using fclDevCtxUptr = CIF::RAII::UPtr_t<IGC::FclOclDeviceCtxTagOCL>;
CompilerLibraryEntry defaultIgc;
std::unordered_map<std::string, std::unique_ptr<CompilerLibraryEntry>> customCompilerLibraries;
std::unordered_map<const Device *, igcDevCtxUptr> igcDeviceContexts;
std::unique_ptr<OsLibrary> igcLib;
CIF::RAII::UPtr_t<CIF::CIFMain> igcMain;
std::map<const Device *, igcDevCtxUptr> igcDeviceContexts;
std::string igcRevision;
size_t igcLibSize{};
time_t igcLibMTime{};
CompilerLibraryEntry fcl;
std::unordered_map<const Device *, fclDevCtxUptr> fclDeviceContexts;
std::unique_ptr<OsLibrary> fclLib;
CIF::RAII::UPtr_t<CIF::CIFMain> fclMain;
std::map<const Device *, fclDevCtxUptr> fclDeviceContexts;
CIF::RAII::UPtr_t<IGC::FclOclTranslationCtxTagOCL> fclBaseTranslationCtx;
std::unordered_map<const Device *, finalizerDevCtxUptr> finalizerDeviceContexts;
IGC::CodeType::CodeType_t finalizerInputType = IGC::CodeType::undefined;
MOCKABLE_VIRTUAL IGC::FclOclDeviceCtxTagOCL *getFclDeviceCtx(const Device &device);
MOCKABLE_VIRTUAL IGC::IgcOclDeviceCtxTagOCL *getIgcDeviceCtx(const Device &device);
MOCKABLE_VIRTUAL IGC::IgcOclDeviceCtxTagOCL *getFinalizerDeviceCtx(const Device &device);
MOCKABLE_VIRTUAL IGC::CodeType::CodeType_t getPreferredIntermediateRepresentation(const Device &device);
MOCKABLE_VIRTUAL CIF::RAII::UPtr_t<IGC::FclOclTranslationCtxTagOCL> createFclTranslationCtx(const Device &device,
@@ -198,46 +176,18 @@ class CompilerInterface {
MOCKABLE_VIRTUAL CIF::RAII::UPtr_t<IGC::IgcOclTranslationCtxTagOCL> createIgcTranslationCtx(const Device &device,
IGC::CodeType::CodeType_t inType,
IGC::CodeType::CodeType_t outType);
MOCKABLE_VIRTUAL CIF::RAII::UPtr_t<IGC::IgcOclTranslationCtxTagOCL> createFinalizerTranslationCtx(const Device &device,
IGC::CodeType::CodeType_t inType,
IGC::CodeType::CodeType_t outType);
bool isFclAvailable() const {
return (fcl.entryPoint.get() != nullptr);
return (fclMain != nullptr);
}
bool isIgcAvailable(const Device *device);
bool isFinalizerAvailable(const Device *device);
const CompilerLibraryEntry *getCustomCompilerLibrary(const char *libName);
const CompilerLibraryEntry *getIgc(const char *libName) {
if (libName == nullptr) {
if (defaultIgc.entryPoint == nullptr) {
return nullptr;
}
return &defaultIgc;
}
return getCustomCompilerLibrary(libName);
bool isIgcAvailable() const {
return (igcMain != nullptr);
}
const CompilerLibraryEntry *getIgc(const Device *device);
const CompilerLibraryEntry *getFinalizer(const char *libName) {
if (libName == nullptr) {
return nullptr;
}
return getCustomCompilerLibrary(libName);
}
const CompilerLibraryEntry *getFinalizer(const Device *device);
bool isCompilerAvailable(const Device *device, IGC::CodeType::CodeType_t translationSrc, IGC::CodeType::CodeType_t translationDst) {
bool isCompilerAvailable(IGC::CodeType::CodeType_t translationSrc, IGC::CodeType::CodeType_t translationDst) const {
bool requiresFcl = (IGC::CodeType::oclC == translationSrc);
bool requiresIgc = (IGC::CodeType::oclC != translationSrc) || ((IGC::CodeType::spirV != translationDst) && (IGC::CodeType::llvmBc != translationDst) && (IGC::CodeType::llvmLl != translationDst));
bool requiresFinalizer = (finalizerInputType != IGC::CodeType::undefined) && ((translationDst == IGC::CodeType::oclGenBin) || (translationSrc == finalizerInputType));
return (isFclAvailable() || (false == requiresFcl)) && (isIgcAvailable(device) || (false == requiresIgc)) && ((false == requiresFinalizer) || isFinalizerAvailable(device));
return (isFclAvailable() || (false == requiresFcl)) && (isIgcAvailable() || (false == requiresIgc));
}
std::once_flag igcIcbeCheckVersionCallOnce;

View File

@@ -638,8 +638,6 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableSetPair, -1, "Use SET_PAIR to pair two buf
DECLARE_DEBUG_VARIABLE(int32_t, ForcePreferredAllocationMethod, -1, "Sets preferred allocation method for Wddm paths; values = -1: driver default, 0: UseUmdSystemPtr, 1: AllocateByKmd")
DECLARE_DEBUG_VARIABLE(int32_t, EventTimestampRefreshIntervalInMilliSec, -1, "-1: use driver default, This value sets the refresh interval for getting synchronized GPU and CPU timestamp")
DECLARE_DEBUG_VARIABLE(int64_t, ReadOnlyAllocationsTypeMask, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, set as read only resource.")
DECLARE_DEBUG_VARIABLE(int64_t, FinalizerInputType, 0, "0: default (N/A), input type for finalizer")
DECLARE_DEBUG_VARIABLE(std::string, FinalizerLibraryName, std::string("unk"), "Library name for finalizer")
/* Binary Cache */
DECLARE_DEBUG_VARIABLE(bool, BinaryCacheTrace, false, "enable cl_cache to produce .trace files with information about hash computation")

View File

@@ -86,8 +86,6 @@ class CompilerProductHelper {
virtual void getKernelFp64AtomicCapabilities(uint32_t &fp64Caps) const = 0;
virtual void getKernelCapabilitiesExtra(const ReleaseHelper *releaseHelper, uint32_t &extraCaps) const = 0;
virtual bool isBindlessAddressingDisabled(const ReleaseHelper *releaseHelper) const = 0;
virtual const char *getCustomIgcLibraryName() const = 0;
virtual const char *getFinalizerLibraryName() const = 0;
virtual ~CompilerProductHelper() = default;
uint32_t getHwIpVersion(const HardwareInfo &hwInfo) const;
@@ -139,8 +137,6 @@ class CompilerProductHelperHw : public CompilerProductHelper {
void getKernelFp64AtomicCapabilities(uint32_t &fp64Caps) const override;
void getKernelCapabilitiesExtra(const ReleaseHelper *releaseHelper, uint32_t &extraCaps) const override;
bool isBindlessAddressingDisabled(const ReleaseHelper *releaseHelper) const override;
const char *getCustomIgcLibraryName() const override;
const char *getFinalizerLibraryName() const override;
~CompilerProductHelperHw() override = default;

View File

@@ -13,7 +13,6 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/hw_info_helper.h"
#include "shared/source/kernel/kernel_properties.h"
#include "shared/source/os_interface/os_inc_base.h"
#include "shared/source/release_helper/release_helper.h"
namespace NEO {
@@ -318,7 +317,6 @@ void CompilerProductHelperHw<gfxProduct>::getKernelCapabilitiesExtra(const Relea
extraCaps |= releaseHelper->getAdditionalExtraCaps();
}
}
template <PRODUCT_FAMILY gfxProduct>
bool CompilerProductHelperHw<gfxProduct>::isBindlessAddressingDisabled(const ReleaseHelper *releaseHelper) const {
if (releaseHelper) {
@@ -327,14 +325,4 @@ bool CompilerProductHelperHw<gfxProduct>::isBindlessAddressingDisabled(const Rel
return true;
}
template <PRODUCT_FAMILY gfxProduct>
const char *CompilerProductHelperHw<gfxProduct>::getCustomIgcLibraryName() const {
return nullptr;
}
template <PRODUCT_FAMILY gfxProduct>
const char *CompilerProductHelperHw<gfxProduct>::getFinalizerLibraryName() const {
return nullptr;
}
} // namespace NEO