Ocloc: Support for various variants of acronyms

In addition to supporting the official -device acronyms
(e.g. xe-hpg), support for shorter and deprecated acronyms
has also been added.
An example of supported variances:
- xehpg
- xe_hpg
- xe_hpg_core

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
Related-To: NEO-6910
This commit is contained in:
Daria Hinz
2022-06-14 14:49:57 +02:00
committed by Compute-Runtime-Automation
parent 9996228281
commit 2637ae5816
15 changed files with 623 additions and 82 deletions

View File

@ -29,11 +29,14 @@ bool requestedFatBinary(const std::vector<std::string> &args, OclocArgHelper *he
const bool hasMoreArgs = (argIndex + 1 < args.size());
if ((ConstStringRef("-device") == currArg) && hasMoreArgs) {
ConstStringRef deviceArg(args[argIndex + 1]);
auto deviceName = deviceArg.str();
ProductConfigHelper::adjustDeviceName(deviceName);
auto retVal = deviceArg.contains("*");
retVal |= deviceArg.contains(":");
retVal |= deviceArg.contains(",");
retVal |= helper->isFamily(deviceArg.str());
retVal |= helper->isRelease(deviceArg.str());
retVal |= helper->isFamily(deviceName);
retVal |= helper->isRelease(deviceName);
return retVal;
}
@ -93,8 +96,11 @@ void getProductsForRange(unsigned int productFrom, unsigned int productTo, std::
std::vector<ConstStringRef> getProductForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, OclocArgHelper *argHelper) {
std::vector<ConstStringRef> requestedProducts = {};
auto rangeFromStr = rangeFrom.str();
auto rangeToStr = rangeTo.str();
auto rangeFromStr = rangeFrom.str();
ProductConfigHelper::adjustDeviceName(rangeToStr);
ProductConfigHelper::adjustDeviceName(rangeFromStr);
if (argHelper->isFamily(rangeFromStr) && argHelper->isFamily(rangeToStr)) {
auto familyFrom = ProductConfigHelper::returnFamilyForAcronym(rangeFromStr);
@ -125,6 +131,7 @@ std::vector<ConstStringRef> getProductForClosedRange(ConstStringRef rangeFrom, C
std::vector<ConstStringRef> getProductForOpenRange(ConstStringRef openRange, OclocArgHelper *argHelper, bool rangeTo) {
std::vector<ConstStringRef> requestedProducts = {};
auto openRangeStr = openRange.str();
ProductConfigHelper::adjustDeviceName(openRangeStr);
if (argHelper->isFamily(openRangeStr)) {
auto family = ProductConfigHelper::returnFamilyForAcronym(openRangeStr);
@ -167,6 +174,8 @@ std::vector<ConstStringRef> getProductForSpecificTarget(CompilerOptions::Tokeniz
std::vector<ConstStringRef> requestedConfigs;
for (const auto &target : targets) {
auto targetStr = target.str();
ProductConfigHelper::adjustDeviceName(targetStr);
if (argHelper->isFamily(targetStr)) {
auto family = ProductConfigHelper::returnFamilyForAcronym(targetStr);
getProductsAcronymsForTarget(requestedConfigs, family, argHelper);
@ -176,7 +185,7 @@ std::vector<ConstStringRef> getProductForSpecificTarget(CompilerOptions::Tokeniz
} else if (argHelper->isProductConfig(targetStr)) {
requestedConfigs.push_back(target);
} else {
argHelper->printf("Failed to parse target : %s - invalid device:\n", targetStr.c_str());
argHelper->printf("Failed to parse target : %s - invalid device:\n", target.str().c_str());
return {};
}
}

View File

@ -141,7 +141,7 @@ int OfflineCompiler::buildIrBinary() {
pBuildInfo->intermediateRepresentation = useLlvmText ? IGC::CodeType::llvmLl
: (useLlvmBc ? IGC::CodeType::llvmBc : preferredIntermediateRepresentation);
//sourceCode.size() returns the number of characters without null terminated char
// sourceCode.size() returns the number of characters without null terminated char
CIF::RAII::UPtr_t<CIF::Builtins::BufferLatest> fclSrc = nullptr;
pBuildInfo->fclOptions = fclFacade->createConstBuffer(options.c_str(), options.size());
pBuildInfo->fclInternalOptions = fclFacade->createConstBuffer(internalOptions.c_str(), internalOptions.size());
@ -350,6 +350,8 @@ int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceNam
int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) {
AheadOfTimeConfig aotConfig{AOT::UNKNOWN_ISA};
ProductConfigHelper::adjustDeviceName(deviceName);
if (deviceName.find(".") != std::string::npos) {
aotConfig = argHelper->getMajorMinorRevision(deviceName);
if (aotConfig.ProductConfig == AOT::UNKNOWN_ISA) {
@ -380,7 +382,7 @@ int OfflineCompiler::initHardwareInfo(std::string deviceName) {
}
overridePlatformName(deviceName);
std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower);
const char hexPrefix = 2;
int deviceId = -1;
@ -561,7 +563,7 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
const auto &currArg = argv[argIndex];
const bool hasMoreArgs = (argIndex + 1 < numArgs);
if ("compile" == currArg) {
//skip it
// skip it
} else if (("-file" == currArg) && hasMoreArgs) {
inputFile = argv[argIndex + 1];
argIndex++;
@ -777,7 +779,7 @@ std::string OfflineCompiler::getDeprecatedDevicesTypes() {
std::ostringstream os;
for (const auto &prefix : prefixes) {
if (std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), findDuplicate(prefix)))
if (std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), ProductConfigHelper::findAcronymWithoutDash(prefix)))
continue;
if (os.tellp())
os << ", ";