feature: Add support for legacy acronyms in ocloc's fatbinary

Expands support for deprecated acronyms to fatbinary. Previously,
these were allowed only in single-target builds.

Related-To: NEO-10190

Signed-off-by: Chodor, Jaroslaw <jaroslaw.chodor@intel.com>
This commit is contained in:
Chodor, Jaroslaw
2024-02-12 16:41:21 +00:00
committed by Compute-Runtime-Automation
parent 57c946b61c
commit b58717b9e3
7 changed files with 130 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -229,6 +229,11 @@ std::vector<ConstStringRef> getProductForSpecificTarget(const CompilerOptions::T
requestedConfigs.push_back(target);
continue;
}
auto legacyAcronymHwInfo = getHwInfoForDeprecatedAcronym(targetStr);
if (nullptr != legacyAcronymHwInfo) {
requestedConfigs.push_back(target);
continue;
}
argHelper->printf("Failed to parse target : %s - invalid device:\n", target.str().c_str());
return {};
}
@@ -284,14 +289,19 @@ int buildFatBinaryForTarget(int retVal, const std::vector<std::string> &argsCopy
return retVal;
}
std::string productConfig("");
std::string entryName("");
if (product.find(".") != std::string::npos) {
productConfig = product;
entryName = product;
} else {
productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(argHelper->productConfigHelper->getProductConfigFromDeviceName(product));
auto productConfig = argHelper->productConfigHelper->getProductConfigFromDeviceName(product);
if (AOT::UNKNOWN_ISA != productConfig) {
entryName = ProductConfigHelper::parseMajorMinorRevisionValue(productConfig);
} else {
entryName = product;
}
}
fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput());
fatbinary.appendFileEntry(pointerSize + "." + entryName, pCompiler->getPackedDeviceBinaryOutput());
return retVal;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,7 @@
#pragma once
#include "shared/source/compiler_interface/tokenized_string.h"
#include "shared/source/utilities/arrayref.h"
#include "shared/source/utilities/const_stringref.h"
@@ -45,5 +46,6 @@ int buildFatBinaryForTarget(int retVal, const std::vector<std::string> &argsCopy
OfflineCompiler *pCompiler, OclocArgHelper *argHelper, const std::string &deviceConfig);
int appendGenericIr(Ar::ArEncoder &fatbinary, const std::string &inputFile, OclocArgHelper *argHelper, std::string options);
std::vector<uint8_t> createEncodedElfWithSpirv(const ArrayRef<const uint8_t> &spirv, const ArrayRef<const uint8_t> &options);
std::vector<ConstStringRef> getProductForSpecificTarget(const NEO::CompilerOptions::TokenizedString &targets, OclocArgHelper *argHelper);
} // namespace NEO

View File

@@ -741,32 +741,40 @@ std::string &OfflineCompiler::getBuildLog() {
return buildLog;
}
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName, std::unique_ptr<NEO::CompilerProductHelper> &compilerProductHelper, std::unique_ptr<NEO::ReleaseHelper> &releaseHelper) {
const HardwareInfo *getHwInfoForDeprecatedAcronym(const std::string &deviceName) {
std::vector<PRODUCT_FAMILY> allSupportedProduct{ALL_SUPPORTED_PRODUCT_FAMILIES};
std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower);
auto deviceNameLowered = deviceName;
std::transform(deviceNameLowered.begin(), deviceNameLowered.end(), deviceNameLowered.begin(), ::tolower);
for (const auto &product : allSupportedProduct) {
if (0 == strcmp(deviceName.c_str(), hardwarePrefix[product])) {
hwInfo = *hardwareInfoTable[product];
if (revisionId != -1) {
hwInfo.platform.usRevId = revisionId;
}
compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily);
auto defaultIpVersion = compilerProductHelper->getDefaultHwIpVersion();
auto productConfig = compilerProductHelper->matchRevisionIdWithProductConfig(defaultIpVersion, revisionId);
hwInfo.ipVersion = argHelper->productConfigHelper->isSupportedProductConfig(productConfig) ? productConfig : defaultIpVersion;
uint64_t config = hwInfoConfig ? hwInfoConfig : compilerProductHelper->getHwInfoConfig(hwInfo);
setHwInfoValuesFromConfig(config, hwInfo);
releaseHelper = NEO::ReleaseHelper::create(hwInfo.ipVersion);
hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true, releaseHelper.get());
UNRECOVERABLE_IF(compilerProductHelper == nullptr);
productFamilyName = hardwarePrefix[hwInfo.platform.eProductFamily];
return OCLOC_SUCCESS;
if (0 == strcmp(deviceNameLowered.c_str(), hardwarePrefix[product])) {
return hardwareInfoTable[product];
}
}
return OCLOC_INVALID_DEVICE;
return nullptr;
}
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(const std::string &deviceName, std::unique_ptr<NEO::CompilerProductHelper> &compilerProductHelper, std::unique_ptr<NEO::ReleaseHelper> &releaseHelper) {
auto foundHwInfo = getHwInfoForDeprecatedAcronym(deviceName);
if (nullptr == foundHwInfo) {
return OCLOC_INVALID_DEVICE;
}
hwInfo = *foundHwInfo;
if (revisionId != -1) {
hwInfo.platform.usRevId = revisionId;
}
compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily);
auto defaultIpVersion = compilerProductHelper->getDefaultHwIpVersion();
auto productConfig = compilerProductHelper->matchRevisionIdWithProductConfig(defaultIpVersion, revisionId);
hwInfo.ipVersion = argHelper->productConfigHelper->isSupportedProductConfig(productConfig) ? productConfig : defaultIpVersion;
uint64_t config = hwInfoConfig ? hwInfoConfig : compilerProductHelper->getHwInfoConfig(hwInfo);
setHwInfoValuesFromConfig(config, hwInfo);
releaseHelper = NEO::ReleaseHelper::create(hwInfo.ipVersion);
hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true, releaseHelper.get());
UNRECOVERABLE_IF(compilerProductHelper == nullptr);
productFamilyName = hardwarePrefix[hwInfo.platform.eProductFamily];
return OCLOC_SUCCESS;
}
bool OfflineCompiler::isArgumentDeviceId(const std::string &argument) const {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -38,6 +38,8 @@ struct NameVersionPair : ocloc_name_version {
};
static_assert(sizeof(NameVersionPair) == sizeof(ocloc_name_version));
const HardwareInfo *getHwInfoForDeprecatedAcronym(const std::string &deviceName);
class OfflineCompiler {
public:
static std::vector<NameVersionPair> getExtensions(ConstStringRef product, bool needVersions, OclocArgHelper *helper);
@@ -129,7 +131,7 @@ All supported acronyms: %s.
int initHardwareInfo(std::string deviceName);
int initHardwareInfoForProductConfig(std::string deviceName);
int initHardwareInfoForDeprecatedAcronyms(std::string deviceName, std::unique_ptr<NEO::CompilerProductHelper> &compilerProductHelper, std::unique_ptr<NEO::ReleaseHelper> &releaseHelper);
int initHardwareInfoForDeprecatedAcronyms(const std::string &deviceName, std::unique_ptr<NEO::CompilerProductHelper> &compilerProductHelper, std::unique_ptr<NEO::ReleaseHelper> &releaseHelper);
bool isArgumentDeviceId(const std::string &argument) const;
std::string getStringWithinDelimiters(const std::string &src);
int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -231,10 +231,10 @@ class ConstStringRef {
}
ret.reserve(len);
ret.append(*container.begin());
for (auto it = container.begin() + 1, e = container.end(); it != e; ++it) {
ret.append(container.begin()->data(), container.begin()->size());
for (auto it = std::next(container.begin()), e = container.end(); it != e; ++it) {
ret.append(this->ptr, this->len);
ret.append(*it);
ret.append(it->data(), it->size());
}
return ret;
}