Setting default device id for acronym

This PR includes:
- Move product config implementation from
ocloc arg helper to product config helper.
- Add default device id setting for each platform configuration.
- Add & move hw info config tests from opencl to shared

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
Related-To: NEO-7112
This commit is contained in:
Daria Hinz
2022-07-08 11:29:59 +00:00
committed by Compute-Runtime-Automation
parent 05ad32704b
commit 01af53b63c
100 changed files with 1773 additions and 694 deletions

View File

@@ -336,7 +336,7 @@ Examples:
Disassemble Intel Compute GPU device binary
ocloc disasm -file source_file_Gen9core.bin
)===",
argHelper->createStringForArgs(argHelper->getAllSupportedProductAcronyms()).c_str());
argHelper->createStringForArgs(argHelper->productConfigHelper->getAllProductAcronyms()).c_str());
}
int BinaryDecoder::processBinary(const void *&ptr, std::ostream &ptmFile) {

View File

@@ -133,7 +133,7 @@ Examples:
Assemble to Intel Compute GPU device binary
ocloc asm -out reassembled.bin
)===",
argHelper->createStringForArgs(argHelper->getAllSupportedProductAcronyms()).c_str());
argHelper->createStringForArgs(argHelper->productConfigHelper->getAllProductAcronyms()).c_str());
}
int BinaryEncoder::encode() {

View File

@@ -13,6 +13,7 @@
#include "shared/source/helpers/string.h"
#include "hw_cmds.h"
#include "platforms.h"
#include <algorithm>
#include <cstring>
@@ -56,20 +57,7 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo
uint64_t **lenOutputs, char ***nameOutputs)
: numOutputs(numOutputs), nameOutputs(nameOutputs),
dataOutputs(dataOutputs), lenOutputs(lenOutputs), hasOutput(numOutputs != nullptr),
messagePrinter(hasOutput), deviceProductTable({
#define NAMEDDEVICE(devId, product, ignored_devName) {devId, NEO::hardwarePrefix[NEO::product::hwInfo.platform.eProductFamily]},
#define DEVICE(devId, product) {devId, NEO::hardwarePrefix[NEO::product::hwInfo.platform.eProductFamily]},
#include "devices.inl"
#undef DEVICE
#undef NAMEDDEVICE
{0u, std::string("")}}),
deviceMap({
#define DEVICE_CONFIG_IDS(product, productConfig, deviceIds, family, release) {&NEO::productConfig::hwInfo, &NEO::deviceIds, AOT::family, AOT::release, {AOT::product}},
#define DEVICE_CONFIG(product, productConfig, family, release) {&NEO::productConfig::hwInfo, nullptr, AOT::family, AOT::release, {AOT::product}},
#include "product_config.inl"
#undef DEVICE_CONFIG
#undef DEVICE_CONFIG_IDS
}) {
messagePrinter(hasOutput) {
for (uint32_t i = 0; i < numSources; ++i) {
inputs.push_back(Source(dataSources[i], static_cast<size_t>(lenSources[i]), nameSources[i]));
}
@@ -77,14 +65,7 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo
headers.push_back(Source(dataInputHeaders[i], static_cast<size_t>(lenInputHeaders[i]), nameInputHeaders[i]));
}
std::sort(deviceMap.begin(), deviceMap.end(), compareConfigs);
for (auto &device : deviceMap) {
for (const auto &[acronym, value] : AOT::productConfigAcronyms) {
if (value == device.aotConfig.ProductConfig) {
device.acronyms.push_back(NEO::ConstStringRef(acronym));
}
}
}
productConfigHelper = std::make_unique<ProductConfigHelper>();
}
OclocArgHelper::OclocArgHelper() : OclocArgHelper(0, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) {}
@@ -168,25 +149,25 @@ std::unique_ptr<char[]> OclocArgHelper::loadDataFromFile(const std::string &file
}
}
bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig) {
bool OclocArgHelper::getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig) {
bool retVal = false;
if (config == AOT::UNKNOWN_ISA) {
if (productConfig == AOT::UNKNOWN_ISA) {
return retVal;
}
for (auto &deviceConfig : deviceMap) {
if (deviceConfig.aotConfig.ProductConfig == config) {
auto deviceAotMap = productConfigHelper->getDeviceAotInfo();
for (auto &deviceConfig : deviceAotMap) {
if (deviceConfig.aotConfig.ProductConfig == productConfig) {
hwInfo = *deviceConfig.hwInfo;
const auto &compilerHwInfoConfig = *NEO::CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily);
compilerHwInfoConfig.setProductConfigForHwInfo(hwInfo, deviceConfig.aotConfig);
if (hwInfoConfig) {
setHwInfoValuesFromConfig(hwInfoConfig, hwInfo);
}
NEO::hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
if (deviceConfig.deviceIds) {
hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front();
}
const auto &compilerHwInfoConfig = *NEO::CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily);
compilerHwInfoConfig.setProductConfigForHwInfo(hwInfo, deviceConfig.aotConfig);
hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front();
retVal = true;
return retVal;
}
@@ -194,26 +175,6 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInf
return retVal;
}
std::vector<NEO::ConstStringRef> OclocArgHelper::getDeprecatedAcronyms() {
std::vector<NEO::ConstStringRef> prefixes{}, deprecatedAcronyms{}, enabledAcronyms{};
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
if (NEO::hardwarePrefix[j] == nullptr)
continue;
prefixes.push_back(NEO::hardwarePrefix[j]);
}
for (const auto &device : deviceMap) {
enabledAcronyms.insert(enabledAcronyms.end(), device.acronyms.begin(), device.acronyms.end());
}
for (const auto &prefix : prefixes) {
if (std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), ProductConfigHelper::findAcronymWithoutDash(prefix.str())))
continue;
deprecatedAcronyms.push_back(prefix);
}
return deprecatedAcronyms;
}
void OclocArgHelper::saveOutput(const std::string &filename, const void *pData, const size_t &dataSize) {
if (outputEnabled()) {
addOutput(filename, pData, dataSize);
@@ -233,138 +194,6 @@ void OclocArgHelper::saveOutput(const std::string &filename, const std::ostream
}
}
std::vector<NEO::ConstStringRef> OclocArgHelper::getAllSupportedProductAcronyms() {
std::vector<NEO::ConstStringRef> allEnabledAcronyms{};
for (const auto &device : deviceMap) {
allEnabledAcronyms.insert(allEnabledAcronyms.end(), device.acronyms.begin(), device.acronyms.end());
}
return allEnabledAcronyms;
}
std::vector<NEO::ConstStringRef> OclocArgHelper::getEnabledProductAcronyms() {
std::vector<NEO::ConstStringRef> enabledAcronyms{};
for (const auto &device : deviceMap) {
if (!device.acronyms.empty()) {
enabledAcronyms.push_back(device.acronyms.front());
}
}
return enabledAcronyms;
}
std::vector<NEO::ConstStringRef> OclocArgHelper::getEnabledReleasesAcronyms() {
std::vector<NEO::ConstStringRef> ret;
for (const auto &[acronym, value] : AOT::releaseAcronyms) {
if (std::any_of(deviceMap.begin(), deviceMap.end(), findRelease(value))) {
ret.push_back(NEO::ConstStringRef(acronym));
}
}
return ret;
}
std::vector<NEO::ConstStringRef> OclocArgHelper::getEnabledFamiliesAcronyms() {
std::vector<NEO::ConstStringRef> enabledAcronyms;
for (const auto &[acronym, value] : AOT::familyAcronyms) {
if (std::any_of(deviceMap.begin(), deviceMap.end(), findFamily(value))) {
enabledAcronyms.push_back(NEO::ConstStringRef(acronym));
}
}
return enabledAcronyms;
}
bool OclocArgHelper::setAcronymForDeviceId(std::string &device) {
auto product = returnProductNameForDevice(std::stoi(device, 0, 16));
if (!product.empty()) {
printf("Auto-detected target based on %s device id: %s\n", device.c_str(), product.c_str());
} else {
printf("Could not determine target based on device id: %s\n", device.c_str());
return false;
}
device = std::move(product);
return true;
}
std::string OclocArgHelper::returnProductNameForDevice(unsigned short deviceId) {
std::string res = "";
for (int i = 0; deviceProductTable[i].deviceId != 0; i++) {
if (deviceProductTable[i].deviceId == deviceId) {
res = deviceProductTable[i].product;
}
}
return res;
}
std::vector<DeviceMapping> &OclocArgHelper::getAllSupportedDeviceConfigs() {
return deviceMap;
}
int OclocArgHelper::parseProductConfigFromString(const std::string &device, size_t begin, size_t end) {
if (begin == end) {
return CONFIG_STATUS::MISMATCHED_VALUE;
}
if (end == std::string::npos) {
if (!std::all_of(device.begin() + begin, device.end(), (::isdigit))) {
return CONFIG_STATUS::MISMATCHED_VALUE;
}
return std::stoi(device.substr(begin, device.size() - begin));
} else {
if (!std::all_of(device.begin() + begin, device.begin() + end, (::isdigit))) {
return CONFIG_STATUS::MISMATCHED_VALUE;
}
return std::stoi(device.substr(begin, end - begin));
}
}
AOT::PRODUCT_CONFIG OclocArgHelper::getProductConfigForVersionValue(const std::string &device) {
auto majorPos = device.find(".");
auto major = parseProductConfigFromString(device, 0, majorPos);
if (major == CONFIG_STATUS::MISMATCHED_VALUE || majorPos == std::string::npos) {
return AOT::UNKNOWN_ISA;
}
auto minorPos = device.find(".", ++majorPos);
auto minor = parseProductConfigFromString(device, majorPos, minorPos);
if (minor == CONFIG_STATUS::MISMATCHED_VALUE || minorPos == std::string::npos) {
return AOT::UNKNOWN_ISA;
}
auto revision = parseProductConfigFromString(device, minorPos + 1, device.size());
if (revision == CONFIG_STATUS::MISMATCHED_VALUE) {
return AOT::UNKNOWN_ISA;
}
AheadOfTimeConfig product = {0};
product.ProductConfigID.Major = major;
product.ProductConfigID.Minor = minor;
product.ProductConfigID.Revision = revision;
return static_cast<AOT::PRODUCT_CONFIG>(product.ProductConfig);
}
bool OclocArgHelper::isRelease(const std::string &device) {
auto release = ProductConfigHelper::returnReleaseForAcronym(device);
if (release == AOT::UNKNOWN_RELEASE) {
return false;
}
return std::any_of(deviceMap.begin(), deviceMap.end(), findRelease(release));
}
bool OclocArgHelper::isFamily(const std::string &device) {
auto family = ProductConfigHelper::returnFamilyForAcronym(device);
if (family == AOT::UNKNOWN_FAMILY) {
return false;
}
return std::any_of(deviceMap.begin(), deviceMap.end(), findFamily(family));
}
bool OclocArgHelper::isProductConfig(const std::string &device) {
auto config = AOT::UNKNOWN_ISA;
if (device.find(".") != std::string::npos) {
config = getProductConfigForVersionValue(device);
} else {
config = ProductConfigHelper::returnProductConfigForAcronym(device);
}
if (config == AOT::UNKNOWN_ISA) {
return false;
}
return std::any_of(deviceMap.begin(), deviceMap.end(), findProductConfig(config));
}
bool OclocArgHelper::areQuotesRequired(const std::string_view &argName) {
return argName == "-options" || argName == "-internal_options";
}

View File

@@ -12,9 +12,6 @@
#include "shared/source/helpers/product_config_helper.h"
#include "shared/source/utilities/const_stringref.h"
#include "device_ids_configs.h"
#include "platforms.h"
#include <algorithm>
#include <cctype>
#include <fstream>
@@ -44,24 +41,6 @@ struct Output {
Output(const std::string &name, const void *data, const size_t &size);
};
struct DeviceProduct {
unsigned short deviceId;
std::string product;
};
struct DeviceMapping {
const NEO::HardwareInfo *hwInfo = nullptr;
const std::vector<unsigned short> *deviceIds = nullptr;
AOT::FAMILY family = AOT::UNKNOWN_FAMILY;
AOT::RELEASE release = AOT::UNKNOWN_RELEASE;
AheadOfTimeConfig aotConfig = {0};
std::vector<NEO::ConstStringRef> acronyms{};
bool operator==(const DeviceMapping &rhs) {
return aotConfig.ProductConfig == rhs.aotConfig.ProductConfig && family == rhs.family && release == rhs.release;
}
};
class OclocArgHelper {
protected:
std::vector<Source> inputs, headers;
@@ -72,8 +51,6 @@ class OclocArgHelper {
uint64_t **lenOutputs = nullptr;
bool hasOutput = false;
MessagePrinter messagePrinter;
const std::vector<DeviceProduct> deviceProductTable;
std::vector<DeviceMapping> deviceMap;
void moveOutputs();
Source *findSourceFile(const std::string &filename);
bool sourceFileExists(const std::string &filename) const;
@@ -82,25 +59,6 @@ class OclocArgHelper {
outputs.push_back(new Output(filename, data, size));
}
static bool compareConfigs(DeviceMapping deviceMap0, DeviceMapping deviceMap1) {
return deviceMap0.aotConfig.ProductConfig < deviceMap1.aotConfig.ProductConfig;
}
template <typename EqComparableT>
auto findFamily(const EqComparableT &lhs) {
return [&lhs](const auto &rhs) { return lhs == rhs.family; };
}
template <typename EqComparableT>
auto findRelease(const EqComparableT &lhs) {
return [&lhs](const auto &rhs) { return lhs == rhs.release; };
}
template <typename EqComparableT>
auto findProductConfig(const EqComparableT &lhs) {
return [&lhs](const auto &rhs) { return lhs == rhs.aotConfig.ProductConfig; };
}
public:
OclocArgHelper();
OclocArgHelper(const uint32_t numSources, const uint8_t **dataSources,
@@ -111,21 +69,8 @@ class OclocArgHelper {
uint32_t *numOutputs, uint8_t ***dataOutputs,
uint64_t **lenOutputs, char ***nameOutputs);
virtual ~OclocArgHelper();
enum CONFIG_STATUS {
MISMATCHED_VALUE = -1,
};
MOCKABLE_VIRTUAL bool fileExists(const std::string &filename) const;
int parseProductConfigFromString(const std::string &device, size_t begin, size_t end);
bool getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig);
std::vector<DeviceMapping> &getAllSupportedDeviceConfigs();
std::vector<NEO::ConstStringRef> getEnabledProductAcronyms();
std::vector<NEO::ConstStringRef> getEnabledReleasesAcronyms();
std::vector<NEO::ConstStringRef> getEnabledFamiliesAcronyms();
std::vector<NEO::ConstStringRef> getDeprecatedAcronyms();
std::vector<NEO::ConstStringRef> getAllSupportedProductAcronyms();
std::string getAllSupportedAcronyms();
AOT::PRODUCT_CONFIG getProductConfigForVersionValue(const std::string &device);
bool setAcronymForDeviceId(std::string &device);
bool getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig);
std::vector<std::string> headersToVectorOfStrings();
MOCKABLE_VIRTUAL void readFileToVectorOfStrings(const std::string &filename, std::vector<std::string> &lines);
MOCKABLE_VIRTUAL std::vector<char> readBinaryFile(const std::string &filename);
@@ -183,10 +128,6 @@ class OclocArgHelper {
return os.str();
}
bool isRelease(const std::string &device);
bool isFamily(const std::string &device);
bool isProductConfig(const std::string &device);
bool areQuotesRequired(const std::string_view &argName);
std::string returnProductNameForDevice(unsigned short deviceId);
std::unique_ptr<ProductConfigHelper> productConfigHelper;
};

View File

@@ -17,6 +17,7 @@
#include "shared/source/helpers/product_config_helper.h"
#include "igfxfmid.h"
#include "platforms.h"
#include <cstddef>
#include <cstdint>
@@ -35,8 +36,8 @@ bool requestedFatBinary(const std::vector<std::string> &args, OclocArgHelper *he
auto retVal = deviceArg.contains("*");
retVal |= deviceArg.contains(":");
retVal |= deviceArg.contains(",");
retVal |= helper->isFamily(deviceName);
retVal |= helper->isRelease(deviceName);
retVal |= helper->productConfigHelper->isFamily(deviceName);
retVal |= helper->productConfigHelper->isRelease(deviceName);
return retVal;
}
@@ -46,7 +47,7 @@ bool requestedFatBinary(const std::vector<std::string> &args, OclocArgHelper *he
template <>
void getProductsAcronymsForTarget<AOT::FAMILY>(std::vector<NEO::ConstStringRef> &out, AOT::FAMILY target, OclocArgHelper *argHelper) {
auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs();
auto allSuppportedProducts = argHelper->productConfigHelper->getDeviceAotInfo();
for (const auto &device : allSuppportedProducts) {
if (device.family == target && !device.acronyms.empty()) {
if (std::find(out.begin(), out.end(), device.acronyms.front()) == out.end()) {
@@ -58,7 +59,7 @@ void getProductsAcronymsForTarget<AOT::FAMILY>(std::vector<NEO::ConstStringRef>
template <>
void getProductsAcronymsForTarget<AOT::RELEASE>(std::vector<NEO::ConstStringRef> &out, AOT::RELEASE target, OclocArgHelper *argHelper) {
auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs();
auto allSuppportedProducts = argHelper->productConfigHelper->getDeviceAotInfo();
for (const auto &device : allSuppportedProducts) {
if (device.release == target && !device.acronyms.empty()) {
if (std::find(out.begin(), out.end(), device.acronyms.front()) == out.end()) {
@@ -82,7 +83,7 @@ void getProductsForTargetRange(T targetFrom, T targetTo, std::vector<ConstString
void getProductsForRange(unsigned int productFrom, unsigned int productTo, std::vector<ConstStringRef> &out,
OclocArgHelper *argHelper) {
auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs();
auto allSuppportedProducts = argHelper->productConfigHelper->getDeviceAotInfo();
for (const auto &device : allSuppportedProducts) {
auto validAcronym = device.aotConfig.ProductConfig >= productFrom;
@@ -102,19 +103,19 @@ std::vector<ConstStringRef> getProductForClosedRange(ConstStringRef rangeFrom, C
ProductConfigHelper::adjustDeviceName(rangeToStr);
ProductConfigHelper::adjustDeviceName(rangeFromStr);
if (argHelper->isFamily(rangeFromStr) && argHelper->isFamily(rangeToStr)) {
auto familyFrom = ProductConfigHelper::returnFamilyForAcronym(rangeFromStr);
auto familyTo = ProductConfigHelper::returnFamilyForAcronym(rangeToStr);
if (argHelper->productConfigHelper->isFamily(rangeFromStr) && argHelper->productConfigHelper->isFamily(rangeToStr)) {
auto familyFrom = ProductConfigHelper::getFamilyForAcronym(rangeFromStr);
auto familyTo = ProductConfigHelper::getFamilyForAcronym(rangeToStr);
getProductsForTargetRange(familyFrom, familyTo, requestedProducts, argHelper);
} else if (argHelper->isRelease(rangeFromStr) && argHelper->isRelease(rangeToStr)) {
auto releaseFrom = ProductConfigHelper::returnReleaseForAcronym(rangeFromStr);
auto releaseTo = ProductConfigHelper::returnReleaseForAcronym(rangeToStr);
} else if (argHelper->productConfigHelper->isRelease(rangeFromStr) && argHelper->productConfigHelper->isRelease(rangeToStr)) {
auto releaseFrom = ProductConfigHelper::getReleaseForAcronym(rangeFromStr);
auto releaseTo = ProductConfigHelper::getReleaseForAcronym(rangeToStr);
getProductsForTargetRange(releaseFrom, releaseTo, requestedProducts, argHelper);
} else if (argHelper->isProductConfig(rangeFromStr) && argHelper->isProductConfig(rangeToStr)) {
unsigned int productConfigFrom = ProductConfigHelper::returnProductConfigForAcronym(rangeFromStr);
unsigned int productConfigTo = ProductConfigHelper::returnProductConfigForAcronym(rangeToStr);
} else if (argHelper->productConfigHelper->isProductConfig(rangeFromStr) && argHelper->productConfigHelper->isProductConfig(rangeToStr)) {
unsigned int productConfigFrom = ProductConfigHelper::getProductConfigForAcronym(rangeFromStr);
unsigned int productConfigTo = ProductConfigHelper::getProductConfigForAcronym(rangeToStr);
if (productConfigFrom > productConfigTo) {
std::swap(productConfigFrom, productConfigTo);
}
@@ -133,8 +134,8 @@ std::vector<ConstStringRef> getProductForOpenRange(ConstStringRef openRange, Ocl
auto openRangeStr = openRange.str();
ProductConfigHelper::adjustDeviceName(openRangeStr);
if (argHelper->isFamily(openRangeStr)) {
auto family = ProductConfigHelper::returnFamilyForAcronym(openRangeStr);
if (argHelper->productConfigHelper->isFamily(openRangeStr)) {
auto family = ProductConfigHelper::getFamilyForAcronym(openRangeStr);
if (rangeTo) {
unsigned int familyFrom = AOT::UNKNOWN_FAMILY;
++familyFrom;
@@ -144,8 +145,8 @@ std::vector<ConstStringRef> getProductForOpenRange(ConstStringRef openRange, Ocl
--familyTo;
getProductsForTargetRange(family, static_cast<AOT::FAMILY>(familyTo), requestedProducts, argHelper);
}
} else if (argHelper->isRelease(openRangeStr)) {
auto release = ProductConfigHelper::returnReleaseForAcronym(openRangeStr);
} else if (argHelper->productConfigHelper->isRelease(openRangeStr)) {
auto release = ProductConfigHelper::getReleaseForAcronym(openRangeStr);
if (rangeTo) {
unsigned int releaseFrom = AOT::UNKNOWN_FAMILY;
++releaseFrom;
@@ -155,8 +156,8 @@ std::vector<ConstStringRef> getProductForOpenRange(ConstStringRef openRange, Ocl
--releaseTo;
getProductsForTargetRange(release, static_cast<AOT::RELEASE>(releaseTo), requestedProducts, argHelper);
}
} else if (argHelper->isProductConfig(openRangeStr)) {
auto product = ProductConfigHelper::returnProductConfigForAcronym(openRangeStr);
} else if (argHelper->productConfigHelper->isProductConfig(openRangeStr)) {
auto product = ProductConfigHelper::getProductConfigForAcronym(openRangeStr);
if (rangeTo) {
unsigned int productFrom = AOT::UNKNOWN_ISA;
++productFrom;
@@ -176,13 +177,13 @@ std::vector<ConstStringRef> getProductForSpecificTarget(CompilerOptions::Tokeniz
auto targetStr = target.str();
ProductConfigHelper::adjustDeviceName(targetStr);
if (argHelper->isFamily(targetStr)) {
auto family = ProductConfigHelper::returnFamilyForAcronym(targetStr);
if (argHelper->productConfigHelper->isFamily(targetStr)) {
auto family = ProductConfigHelper::getFamilyForAcronym(targetStr);
getProductsAcronymsForTarget(requestedConfigs, family, argHelper);
} else if (argHelper->isRelease(targetStr)) {
auto release = ProductConfigHelper::returnReleaseForAcronym(targetStr);
} else if (argHelper->productConfigHelper->isRelease(targetStr)) {
auto release = ProductConfigHelper::getReleaseForAcronym(targetStr);
getProductsAcronymsForTarget(requestedConfigs, release, argHelper);
} else if (argHelper->isProductConfig(targetStr)) {
} else if (argHelper->productConfigHelper->isProductConfig(targetStr)) {
requestedConfigs.push_back(target);
} else {
argHelper->printf("Failed to parse target : %s - invalid device:\n", target.str().c_str());
@@ -195,7 +196,7 @@ std::vector<ConstStringRef> getProductForSpecificTarget(CompilerOptions::Tokeniz
std::vector<ConstStringRef> getTargetProductsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) {
std::vector<ConstStringRef> retVal;
if (deviceArg == "*") {
return argHelper->getEnabledProductAcronyms();
return argHelper->productConfigHelper->getRepresentativeProductAcronyms();
} else {
auto sets = CompilerOptions::tokenize(deviceArg, ',');
if (sets[0].contains(":")) {
@@ -247,8 +248,9 @@ int buildFatBinaryForTarget(int retVal, const std::vector<std::string> &argsCopy
if (product.find(".") != std::string::npos) {
productConfig = product;
} else {
productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(ProductConfigHelper::returnProductConfigForAcronym(product));
productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(ProductConfigHelper::getProductConfigForAcronym(product));
}
fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput());
return retVal;
}

View File

@@ -35,6 +35,7 @@
#include "ocl_igc_interface/fcl_ocl_device_ctx.h"
#include "ocl_igc_interface/igc_ocl_device_ctx.h"
#include "ocl_igc_interface/platform_helper.h"
#include "platforms.h"
#include <algorithm>
#include <iomanip>
@@ -73,14 +74,14 @@ std::string convertToPascalCase(const std::string &inString) {
}
std::string getDeprecatedDevices(OclocArgHelper *helper) {
auto acronyms = helper->getDeprecatedAcronyms();
auto acronyms = helper->productConfigHelper->getDeprecatedAcronyms();
return helper->createStringForArgs(acronyms);
}
std::string getSupportedDevices(OclocArgHelper *helper) {
auto devices = helper->getAllSupportedProductAcronyms();
auto families = helper->getEnabledFamiliesAcronyms();
auto releases = helper->getEnabledReleasesAcronyms();
auto devices = helper->productConfigHelper->getAllProductAcronyms();
auto families = helper->productConfigHelper->getFamiliesAcronyms();
auto releases = helper->productConfigHelper->getReleasesAcronyms();
auto familiesAndReleases = helper->getArgsWithoutDuplicate(families, releases);
return helper->createStringForArgs(devices, familiesAndReleases);
@@ -162,25 +163,25 @@ int OfflineCompiler::queryAcronymIds(size_t numArgs, const std::vector<std::stri
std::string queryAcronym = allArgs[2];
ProductConfigHelper::adjustDeviceName(queryAcronym);
auto enabledDevices = helper->getAllSupportedDeviceConfigs();
auto enabledDevices = helper->productConfigHelper->getDeviceAotInfo();
std::vector<std::string> matchedVersions{};
if (helper->isFamily(queryAcronym)) {
auto family = ProductConfigHelper::returnFamilyForAcronym(queryAcronym);
if (helper->productConfigHelper->isFamily(queryAcronym)) {
auto family = ProductConfigHelper::getFamilyForAcronym(queryAcronym);
for (const auto &device : enabledDevices) {
if (device.family == family) {
matchedVersions.push_back(ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig));
}
}
} else if (helper->isRelease(queryAcronym)) {
auto release = ProductConfigHelper::returnReleaseForAcronym(queryAcronym);
} else if (helper->productConfigHelper->isRelease(queryAcronym)) {
auto release = ProductConfigHelper::getReleaseForAcronym(queryAcronym);
for (const auto &device : enabledDevices) {
if (device.release == release) {
matchedVersions.push_back(ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig));
}
}
} else if (helper->isProductConfig(queryAcronym)) {
auto product = ProductConfigHelper::returnProductConfigForAcronym(queryAcronym);
} else if (helper->productConfigHelper->isProductConfig(queryAcronym)) {
auto product = ProductConfigHelper::getProductConfigForAcronym(queryAcronym);
for (const auto &device : enabledDevices) {
if (device.aotConfig.ProductConfig == product) {
matchedVersions.push_back(ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig));
@@ -402,7 +403,7 @@ void OfflineCompiler::setFamilyType() {
familyNameWithType.append(hwInfo.capabilityTable.platformType);
}
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId) {
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName) {
std::vector<PRODUCT_FAMILY> allSupportedProduct{ALL_SUPPORTED_PRODUCT_FAMILIES};
std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower);
@@ -412,9 +413,7 @@ int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceNam
if (revisionId != -1) {
hwInfo.platform.usRevId = revisionId;
}
if (deviceId != -1) {
hwInfo.platform.usDeviceID = deviceId;
}
uint64_t config = hwInfoConfig ? hwInfoConfig : defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily];
setHwInfoValuesFromConfig(config, hwInfo);
hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
@@ -427,30 +426,39 @@ int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceNam
}
int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) {
AOT::PRODUCT_CONFIG config = AOT::UNKNOWN_ISA;
AOT::PRODUCT_CONFIG productConfig = AOT::UNKNOWN_ISA;
ProductConfigHelper::adjustDeviceName(deviceName);
const char hexPrefix = 2;
int deviceId = -1;
if (deviceName.find(".") != std::string::npos) {
config = argHelper->getProductConfigForVersionValue(deviceName);
if (config == AOT::UNKNOWN_ISA) {
argHelper->printf("Could not determine device target: %s\n", deviceName.c_str());
}
} else if (argHelper->isProductConfig(deviceName)) {
config = ProductConfigHelper::returnProductConfigForAcronym(deviceName);
productConfig = argHelper->productConfigHelper->getProductConfigForVersionValue(deviceName);
} else if (deviceName.substr(0, hexPrefix) == "0x" && std::all_of(deviceName.begin() + hexPrefix, deviceName.end(), (::isxdigit))) {
deviceId = std::stoi(deviceName, 0, 16);
productConfig = argHelper->productConfigHelper->getProductConfigForDeviceId(deviceId);
} else if (argHelper->productConfigHelper->isProductConfig(deviceName)) {
productConfig = ProductConfigHelper::getProductConfigForAcronym(deviceName);
} else {
return INVALID_DEVICE;
}
if (config != AOT::UNKNOWN_ISA) {
if (argHelper->getHwInfoForProductConfig(config, hwInfo, hwInfoConfig)) {
if (revisionId != -1) {
hwInfo.platform.usRevId = revisionId;
}
deviceConfig = config;
setFamilyType();
return SUCCESS;
if (argHelper->getHwInfoForProductConfig(productConfig, hwInfo, hwInfoConfig)) {
if (revisionId != -1) {
hwInfo.platform.usRevId = revisionId;
}
argHelper->printf("Could not determine target based on product config: %s\n", deviceName.c_str());
if (deviceId != -1) {
auto product = argHelper->productConfigHelper->getAcronymForProductConfig(productConfig);
argHelper->printf("Auto-detected target based on %s device id: %s\n", deviceName.c_str(), product.c_str());
hwInfo.platform.usDeviceID = deviceId;
}
deviceConfig = productConfig;
setFamilyType();
return SUCCESS;
} else {
argHelper->printf("Could not determine device target: %s\n", deviceName.c_str());
return INVALID_DEVICE;
}
return INVALID_DEVICE;
}
int OfflineCompiler::initHardwareInfo(std::string deviceName) {
@@ -461,21 +469,12 @@ int OfflineCompiler::initHardwareInfo(std::string deviceName) {
overridePlatformName(deviceName);
const char hexPrefix = 2;
int deviceId = -1;
retVal = initHardwareInfoForProductConfig(deviceName);
if (retVal == SUCCESS) {
return retVal;
}
if (deviceName.substr(0, hexPrefix) == "0x" && std::all_of(deviceName.begin() + hexPrefix, deviceName.end(), (::isxdigit))) {
deviceId = std::stoi(deviceName, 0, 16);
if (!argHelper->setAcronymForDeviceId(deviceName)) {
return retVal;
}
}
retVal = initHardwareInfoForDeprecatedAcronyms(deviceName, deviceId);
retVal = initHardwareInfoForDeprecatedAcronyms(deviceName);
return retVal;
}

View File

@@ -100,7 +100,7 @@ All supported acronyms: %s.
void setFamilyType();
int initHardwareInfo(std::string deviceName);
int initHardwareInfoForProductConfig(std::string deviceName);
int initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId);
int initHardwareInfoForDeprecatedAcronyms(std::string deviceName);
std::string getStringWithinDelimiters(const std::string &src);
int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles);
@@ -131,7 +131,7 @@ All supported acronyms: %s.
void enforceFormat(std::string &format);
HardwareInfo hwInfo;
AOT::PRODUCT_CONFIG deviceConfig = AOT::UNKNOWN_ISA;
AOT::PRODUCT_CONFIG deviceConfig = {};
std::string deviceName;
std::string familyNameWithType;
std::string inputFile;