mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Ocloc: New AOT approach implementation
Ocloc will handle any new values that may be passed to the -device argument. Supported acronyms are available under cmd: ocloc compile --help Supported patterns: - device acronym - release acronym - family acronym - version (major.minor.revision) Fatbinary will no longer handle major.minor.revision variances, only acronyms allowed. Signed-off-by: Daria Hinz <daria.hinz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
552c91bf07
commit
a44f1b43aa
@@ -23,295 +23,195 @@
|
||||
#include <cstdio>
|
||||
|
||||
namespace NEO {
|
||||
std::vector<PRODUCT_CONFIG> getAllMatchedConfigs(const std::string device, OclocArgHelper *argHelper) {
|
||||
std::vector<PRODUCT_CONFIG> allMatchedConfigs;
|
||||
auto numeration = argHelper->getMajorMinorRevision(device);
|
||||
if (numeration.empty()) {
|
||||
return {};
|
||||
}
|
||||
auto config = argHelper->getProductConfig(numeration);
|
||||
std::vector<PRODUCT_CONFIG> allConfigs = argHelper->getAllSupportedProductConfigs();
|
||||
uint32_t mask = argHelper->getMaskForConfig(numeration);
|
||||
|
||||
for (auto &productConfig : allConfigs) {
|
||||
auto prod = static_cast<uint32_t>(productConfig) & mask;
|
||||
if (config == prod) {
|
||||
allMatchedConfigs.push_back(productConfig);
|
||||
}
|
||||
}
|
||||
|
||||
return allMatchedConfigs;
|
||||
}
|
||||
|
||||
bool requestedFatBinary(const std::vector<std::string> &args, OclocArgHelper *helper) {
|
||||
for (size_t argIndex = 1; argIndex < args.size(); argIndex++) {
|
||||
const auto &currArg = args[argIndex];
|
||||
const bool hasMoreArgs = (argIndex + 1 < args.size());
|
||||
if ((ConstStringRef("-device") == currArg) && hasMoreArgs) {
|
||||
ConstStringRef deviceArg(args[argIndex + 1]);
|
||||
auto products = getAllMatchedConfigs(deviceArg.str(), helper);
|
||||
if (products.size() > 1) {
|
||||
return true;
|
||||
}
|
||||
return deviceArg.contains("*") || deviceArg.contains("-") || deviceArg.contains(",") || helper->isGen(deviceArg.str());
|
||||
auto retVal = deviceArg.contains("*");
|
||||
retVal |= deviceArg.contains(":");
|
||||
retVal |= deviceArg.contains(",");
|
||||
retVal |= helper->isFamily(deviceArg.str());
|
||||
retVal |= helper->isRelease(deviceArg.str());
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<PRODUCT_FAMILY> getAllSupportedTargetPlatforms() {
|
||||
return std::vector<PRODUCT_FAMILY>{ALL_SUPPORTED_PRODUCT_FAMILIES};
|
||||
}
|
||||
|
||||
std::vector<ConstStringRef> toProductNames(const std::vector<PRODUCT_FAMILY> &productIds) {
|
||||
std::vector<ConstStringRef> ret;
|
||||
for (auto prodId : productIds) {
|
||||
ret.push_back(ConstStringRef(hardwarePrefix[prodId], strlen(hardwarePrefix[prodId])));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
PRODUCT_FAMILY asProductId(ConstStringRef product, const std::vector<PRODUCT_FAMILY> &allSupportedPlatforms) {
|
||||
for (auto &family : allSupportedPlatforms) {
|
||||
if (product == hardwarePrefix[family]) {
|
||||
return family;
|
||||
}
|
||||
}
|
||||
return IGFX_UNKNOWN;
|
||||
}
|
||||
|
||||
std::vector<DeviceMapping> getProductConfigsForOpenRange(ConstStringRef openRange, OclocArgHelper *argHelper, bool rangeTo) {
|
||||
std::vector<DeviceMapping> requestedConfigs;
|
||||
std::vector<DeviceMapping> allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs();
|
||||
|
||||
if (argHelper->isGen(openRange.str())) {
|
||||
std::vector<GFXCORE_FAMILY> coreIdList;
|
||||
auto coreId = argHelper->returnIGFXforGen(openRange.str());
|
||||
coreIdList.push_back(static_cast<GFXCORE_FAMILY>(coreId));
|
||||
if (rangeTo) {
|
||||
auto coreId = coreIdList.back();
|
||||
unsigned int coreIt = IGFX_UNKNOWN_CORE;
|
||||
++coreIt;
|
||||
while (coreIt <= static_cast<unsigned int>(coreId)) {
|
||||
argHelper->getProductConfigsForGfxCoreFamily(static_cast<GFXCORE_FAMILY>(coreIt), requestedConfigs);
|
||||
++coreIt;
|
||||
}
|
||||
} else {
|
||||
unsigned int coreIt = coreIdList.front();
|
||||
while (coreIt < static_cast<unsigned int>(IGFX_MAX_CORE)) {
|
||||
argHelper->getProductConfigsForGfxCoreFamily(static_cast<GFXCORE_FAMILY>(coreIt), requestedConfigs);
|
||||
++coreIt;
|
||||
template <>
|
||||
void getProductsAcronymsForTarget<AOT::FAMILY>(std::vector<NEO::ConstStringRef> &out, AOT::FAMILY target, OclocArgHelper *argHelper) {
|
||||
auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs();
|
||||
for (const auto &device : allSuppportedProducts) {
|
||||
if (device.family == target && !device.acronyms.empty()) {
|
||||
if (std::find(out.begin(), out.end(), device.acronyms.front()) == out.end()) {
|
||||
out.push_back(device.acronyms.front());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void getProductsAcronymsForTarget<AOT::RELEASE>(std::vector<NEO::ConstStringRef> &out, AOT::RELEASE target, OclocArgHelper *argHelper) {
|
||||
auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs();
|
||||
for (const auto &device : allSuppportedProducts) {
|
||||
if (device.release == target && !device.acronyms.empty()) {
|
||||
if (std::find(out.begin(), out.end(), device.acronyms.front()) == out.end()) {
|
||||
out.push_back(device.acronyms.front());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void getProductsForTargetRange(T targetFrom, T targetTo, std::vector<ConstStringRef> &out,
|
||||
OclocArgHelper *argHelper) {
|
||||
if (targetFrom > targetTo) {
|
||||
std::swap(targetFrom, targetTo);
|
||||
}
|
||||
while (targetFrom <= targetTo) {
|
||||
getProductsAcronymsForTarget<T>(out, targetFrom, argHelper);
|
||||
targetFrom = static_cast<T>(static_cast<unsigned int>(targetFrom) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void getProductsForRange(unsigned int productFrom, unsigned int productTo, std::vector<ConstStringRef> &out,
|
||||
OclocArgHelper *argHelper) {
|
||||
auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs();
|
||||
|
||||
for (const auto &device : allSuppportedProducts) {
|
||||
auto validAcronym = device.aotConfig.ProductConfig >= productFrom;
|
||||
validAcronym &= device.aotConfig.ProductConfig <= productTo;
|
||||
validAcronym &= !device.acronyms.empty();
|
||||
if (validAcronym) {
|
||||
out.push_back(device.acronyms.front());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ConstStringRef> getProductForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, OclocArgHelper *argHelper) {
|
||||
std::vector<ConstStringRef> requestedProducts = {};
|
||||
auto rangeFromStr = rangeFrom.str();
|
||||
auto rangeToStr = rangeTo.str();
|
||||
|
||||
if (argHelper->isFamily(rangeFromStr) && argHelper->isFamily(rangeToStr)) {
|
||||
auto familyFrom = ProductConfigHelper::returnFamilyForAcronym(rangeFromStr);
|
||||
auto familyTo = ProductConfigHelper::returnFamilyForAcronym(rangeToStr);
|
||||
getProductsForTargetRange(familyFrom, familyTo, requestedProducts, argHelper);
|
||||
|
||||
} else if (argHelper->isRelease(rangeFromStr) && argHelper->isRelease(rangeToStr)) {
|
||||
auto releaseFrom = ProductConfigHelper::returnReleaseForAcronym(rangeFromStr);
|
||||
auto releaseTo = ProductConfigHelper::returnReleaseForAcronym(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);
|
||||
if (productConfigFrom > productConfigTo) {
|
||||
std::swap(productConfigFrom, productConfigTo);
|
||||
}
|
||||
getProductsForRange(productConfigFrom, productConfigTo, requestedProducts, argHelper);
|
||||
} else {
|
||||
auto productConfig = argHelper->findConfigMatch(openRange.str(), !rangeTo);
|
||||
if (productConfig == PRODUCT_CONFIG::UNKNOWN_ISA) {
|
||||
argHelper->printf("Unknown device : %s\n", openRange.str().c_str());
|
||||
return {};
|
||||
}
|
||||
auto configIt = std::find_if(allSupportedDeviceConfigs.begin(),
|
||||
allSupportedDeviceConfigs.end(),
|
||||
[&cf = productConfig](const DeviceMapping &c) -> bool { return cf == c.config; });
|
||||
if (rangeTo) {
|
||||
for (auto &deviceConfig : allSupportedDeviceConfigs) {
|
||||
if (deviceConfig.config <= productConfig) {
|
||||
requestedConfigs.push_back(deviceConfig);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
requestedConfigs.insert(requestedConfigs.end(), configIt, allSupportedDeviceConfigs.end());
|
||||
}
|
||||
}
|
||||
return requestedConfigs;
|
||||
}
|
||||
|
||||
std::vector<DeviceMapping> getProductConfigsForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, OclocArgHelper *argHelper) {
|
||||
std::vector<DeviceMapping> requestedConfigs;
|
||||
std::vector<DeviceMapping> allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs();
|
||||
|
||||
if (argHelper->isGen(rangeFrom.str())) {
|
||||
if (false == argHelper->isGen(rangeTo.str())) {
|
||||
argHelper->printf("Ranges mixing configs and architecture is not supported, should be architectureFrom-architectureTo or configFrom-configTo\n");
|
||||
return {};
|
||||
}
|
||||
auto coreFrom = argHelper->returnIGFXforGen(rangeFrom.str());
|
||||
auto coreTo = argHelper->returnIGFXforGen(rangeTo.str());
|
||||
if (static_cast<GFXCORE_FAMILY>(coreFrom) > static_cast<GFXCORE_FAMILY>(coreTo)) {
|
||||
std::swap(coreFrom, coreTo);
|
||||
}
|
||||
while (coreFrom <= coreTo) {
|
||||
argHelper->getProductConfigsForGfxCoreFamily(static_cast<GFXCORE_FAMILY>(coreFrom), requestedConfigs);
|
||||
coreFrom = static_cast<GFXCORE_FAMILY>(static_cast<unsigned int>(coreFrom) + 1);
|
||||
}
|
||||
} else {
|
||||
auto configFrom = argHelper->findConfigMatch(rangeFrom.str(), true);
|
||||
if (configFrom == PRODUCT_CONFIG::UNKNOWN_ISA) {
|
||||
argHelper->printf("Unknown device range : %s\n", rangeFrom.str().c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
auto configTo = argHelper->findConfigMatch(rangeTo.str(), false);
|
||||
if (configTo == PRODUCT_CONFIG::UNKNOWN_ISA) {
|
||||
argHelper->printf("Unknown device range : %s\n", rangeTo.str().c_str());
|
||||
return {};
|
||||
}
|
||||
|
||||
if (configFrom > configTo) {
|
||||
configFrom = argHelper->findConfigMatch(rangeTo.str(), true);
|
||||
configTo = argHelper->findConfigMatch(rangeFrom.str(), false);
|
||||
}
|
||||
|
||||
for (auto &deviceConfig : allSupportedDeviceConfigs) {
|
||||
if (deviceConfig.config >= configFrom && deviceConfig.config <= configTo) {
|
||||
requestedConfigs.push_back(deviceConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requestedConfigs;
|
||||
}
|
||||
|
||||
std::vector<ConstStringRef> getPlatformsForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, PRODUCT_FAMILY platformFrom, OclocArgHelper *argHelper) {
|
||||
std::vector<PRODUCT_FAMILY> requestedPlatforms;
|
||||
std::vector<PRODUCT_FAMILY> allSupportedPlatforms = getAllSupportedTargetPlatforms();
|
||||
|
||||
auto platformTo = asProductId(rangeTo, allSupportedPlatforms);
|
||||
if (IGFX_UNKNOWN == platformTo) {
|
||||
argHelper->printf("Unknown device : %s\n", rangeTo.str().c_str());
|
||||
auto target = rangeFromStr + ":" + rangeToStr;
|
||||
argHelper->printf("Failed to parse target : %s.\n", target.c_str());
|
||||
return {};
|
||||
}
|
||||
if (platformFrom > platformTo) {
|
||||
std::swap(platformFrom, platformTo);
|
||||
}
|
||||
|
||||
auto from = std::find(allSupportedPlatforms.begin(), allSupportedPlatforms.end(), platformFrom);
|
||||
auto to = std::find(allSupportedPlatforms.begin(), allSupportedPlatforms.end(), platformTo) + 1;
|
||||
requestedPlatforms.insert(requestedPlatforms.end(), from, to);
|
||||
|
||||
return toProductNames(requestedPlatforms);
|
||||
return requestedProducts;
|
||||
}
|
||||
|
||||
std::vector<ConstStringRef> getPlatformsForOpenRange(ConstStringRef openRange, PRODUCT_FAMILY prodId, OclocArgHelper *argHelper, bool rangeTo) {
|
||||
std::vector<PRODUCT_FAMILY> requestedPlatforms;
|
||||
std::vector<PRODUCT_FAMILY> allSupportedPlatforms = getAllSupportedTargetPlatforms();
|
||||
std::vector<ConstStringRef> getProductForOpenRange(ConstStringRef openRange, OclocArgHelper *argHelper, bool rangeTo) {
|
||||
std::vector<ConstStringRef> requestedProducts = {};
|
||||
auto openRangeStr = openRange.str();
|
||||
|
||||
auto prodIt = std::find(allSupportedPlatforms.begin(), allSupportedPlatforms.end(), prodId);
|
||||
assert(prodIt != allSupportedPlatforms.end());
|
||||
if (rangeTo) {
|
||||
requestedPlatforms.insert(requestedPlatforms.end(), allSupportedPlatforms.begin(), prodIt + 1);
|
||||
} else {
|
||||
requestedPlatforms.insert(requestedPlatforms.end(), prodIt, allSupportedPlatforms.end());
|
||||
}
|
||||
|
||||
return toProductNames(requestedPlatforms);
|
||||
}
|
||||
|
||||
std::vector<DeviceMapping> getProductConfigsForSpecificTargets(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper) {
|
||||
std::vector<DeviceMapping> requestedConfigs;
|
||||
std::vector<DeviceMapping> allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs();
|
||||
|
||||
for (auto &target : targets) {
|
||||
if (argHelper->isGen(target.str())) {
|
||||
auto coreId = argHelper->returnIGFXforGen(target.str());
|
||||
argHelper->getProductConfigsForGfxCoreFamily(static_cast<GFXCORE_FAMILY>(coreId), requestedConfigs);
|
||||
if (argHelper->isFamily(openRangeStr)) {
|
||||
auto family = ProductConfigHelper::returnFamilyForAcronym(openRangeStr);
|
||||
if (rangeTo) {
|
||||
unsigned int familyFrom = AOT::UNKNOWN_FAMILY;
|
||||
++familyFrom;
|
||||
getProductsForTargetRange(static_cast<AOT::FAMILY>(familyFrom), family, requestedProducts, argHelper);
|
||||
} else {
|
||||
auto configFirstEl = argHelper->findConfigMatch(target.str(), true);
|
||||
if (configFirstEl == PRODUCT_CONFIG::UNKNOWN_ISA) {
|
||||
argHelper->printf("Unknown device range : %s\n", target.str().c_str());
|
||||
return {};
|
||||
}
|
||||
unsigned int familyTo = AOT::FAMILY_MAX;
|
||||
--familyTo;
|
||||
getProductsForTargetRange(family, static_cast<AOT::FAMILY>(familyTo), requestedProducts, argHelper);
|
||||
}
|
||||
} else if (argHelper->isRelease(openRangeStr)) {
|
||||
auto release = ProductConfigHelper::returnReleaseForAcronym(openRangeStr);
|
||||
if (rangeTo) {
|
||||
unsigned int releaseFrom = AOT::UNKNOWN_FAMILY;
|
||||
++releaseFrom;
|
||||
getProductsForTargetRange(static_cast<AOT::RELEASE>(releaseFrom), release, requestedProducts, argHelper);
|
||||
} else {
|
||||
unsigned int releaseTo = AOT::RELEASE_MAX;
|
||||
--releaseTo;
|
||||
getProductsForTargetRange(release, static_cast<AOT::RELEASE>(releaseTo), requestedProducts, argHelper);
|
||||
}
|
||||
} else if (argHelper->isProductConfig(openRangeStr)) {
|
||||
auto product = ProductConfigHelper::returnProductConfigForAcronym(openRangeStr);
|
||||
if (rangeTo) {
|
||||
unsigned int productFrom = AOT::UNKNOWN_ISA;
|
||||
++productFrom;
|
||||
getProductsForRange(productFrom, static_cast<unsigned int>(product), requestedProducts, argHelper);
|
||||
} else {
|
||||
unsigned int productTo = AOT::CONFIG_MAX_PLATFORM;
|
||||
--productTo;
|
||||
getProductsForRange(product, static_cast<AOT::PRODUCT_CONFIG>(productTo), requestedProducts, argHelper);
|
||||
}
|
||||
}
|
||||
return requestedProducts;
|
||||
}
|
||||
|
||||
auto configLastEl = argHelper->findConfigMatch(target.str(), false);
|
||||
for (auto &deviceConfig : allSupportedDeviceConfigs) {
|
||||
if (deviceConfig.config >= configFirstEl && deviceConfig.config <= configLastEl) {
|
||||
requestedConfigs.push_back(deviceConfig);
|
||||
}
|
||||
}
|
||||
std::vector<ConstStringRef> getProductForSpecificTarget(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper) {
|
||||
std::vector<ConstStringRef> requestedConfigs;
|
||||
for (const auto &target : targets) {
|
||||
auto targetStr = target.str();
|
||||
if (argHelper->isFamily(targetStr)) {
|
||||
auto family = ProductConfigHelper::returnFamilyForAcronym(targetStr);
|
||||
getProductsAcronymsForTarget(requestedConfigs, family, argHelper);
|
||||
} else if (argHelper->isRelease(targetStr)) {
|
||||
auto release = ProductConfigHelper::returnReleaseForAcronym(targetStr);
|
||||
getProductsAcronymsForTarget(requestedConfigs, release, argHelper);
|
||||
} else if (argHelper->isProductConfig(targetStr)) {
|
||||
requestedConfigs.push_back(target);
|
||||
} else {
|
||||
argHelper->printf("Failed to parse target : %s - invalid device:\n", targetStr.c_str());
|
||||
return {};
|
||||
}
|
||||
}
|
||||
return requestedConfigs;
|
||||
}
|
||||
|
||||
std::vector<ConstStringRef> getPlatformsForSpecificTargets(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper) {
|
||||
std::vector<PRODUCT_FAMILY> requestedPlatforms;
|
||||
std::vector<PRODUCT_FAMILY> allSupportedPlatforms = getAllSupportedTargetPlatforms();
|
||||
|
||||
for (auto &target : targets) {
|
||||
auto prodId = asProductId(target, allSupportedPlatforms);
|
||||
if (IGFX_UNKNOWN == prodId) {
|
||||
argHelper->printf("Unknown device : %s\n", target.str().c_str());
|
||||
return {};
|
||||
}
|
||||
requestedPlatforms.push_back(prodId);
|
||||
}
|
||||
return toProductNames(requestedPlatforms);
|
||||
}
|
||||
|
||||
bool isDeviceWithPlatformAbbreviation(ConstStringRef deviceArg, OclocArgHelper *argHelper) {
|
||||
std::vector<PRODUCT_FAMILY> allSupportedPlatforms = getAllSupportedTargetPlatforms();
|
||||
PRODUCT_FAMILY prodId = IGFX_UNKNOWN;
|
||||
auto sets = CompilerOptions::tokenize(deviceArg, ',');
|
||||
if (sets[0].contains("-")) {
|
||||
auto range = CompilerOptions::tokenize(deviceArg, '-');
|
||||
prodId = asProductId(range[0], allSupportedPlatforms);
|
||||
|
||||
} else {
|
||||
prodId = asProductId(sets[0], allSupportedPlatforms);
|
||||
}
|
||||
return prodId != IGFX_UNKNOWN;
|
||||
}
|
||||
|
||||
std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) {
|
||||
std::vector<PRODUCT_FAMILY> allSupportedPlatforms = getAllSupportedTargetPlatforms();
|
||||
std::vector<ConstStringRef> getTargetProductsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) {
|
||||
std::vector<ConstStringRef> retVal;
|
||||
|
||||
auto sets = CompilerOptions::tokenize(deviceArg, ',');
|
||||
if (sets[0].contains("-")) {
|
||||
auto range = CompilerOptions::tokenize(deviceArg, '-');
|
||||
if (range.size() > 2) {
|
||||
argHelper->printf("Invalid range : %s - should be from-to or -to or from-\n", sets[0].str().c_str());
|
||||
return {};
|
||||
}
|
||||
auto prodId = asProductId(range[0], allSupportedPlatforms);
|
||||
if (range.size() == 1) {
|
||||
bool rangeTo = ('-' == sets[0][0]);
|
||||
retVal = getPlatformsForOpenRange(range[0], prodId, argHelper, rangeTo);
|
||||
} else {
|
||||
retVal = getPlatformsForClosedRange(range[0], range[1], prodId, argHelper);
|
||||
}
|
||||
} else {
|
||||
retVal = getPlatformsForSpecificTargets(sets, argHelper);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::vector<DeviceMapping> getTargetConfigsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) {
|
||||
if (deviceArg == "*") {
|
||||
return argHelper->getAllSupportedDeviceConfigs();
|
||||
}
|
||||
std::vector<DeviceMapping> retVal;
|
||||
auto sets = CompilerOptions::tokenize(deviceArg, ',');
|
||||
if (sets[0].contains("-")) {
|
||||
auto range = CompilerOptions::tokenize(deviceArg, '-');
|
||||
if (range.size() > 2) {
|
||||
argHelper->printf("Invalid range : %s - should be from-to or -to or from-\n", sets[0].str().c_str());
|
||||
return {};
|
||||
}
|
||||
if (range.size() == 1) {
|
||||
bool rangeTo = ('-' == sets[0][0]);
|
||||
retVal = getProductConfigsForOpenRange(range[0], argHelper, rangeTo);
|
||||
|
||||
} else {
|
||||
retVal = getProductConfigsForClosedRange(range[0], range[1], argHelper);
|
||||
}
|
||||
return argHelper->getEnabledProductAcronyms();
|
||||
} else {
|
||||
retVal = getProductConfigsForSpecificTargets(sets, argHelper);
|
||||
auto sets = CompilerOptions::tokenize(deviceArg, ',');
|
||||
if (sets[0].contains(":")) {
|
||||
auto range = CompilerOptions::tokenize(deviceArg, ':');
|
||||
if (range.size() > 2) {
|
||||
argHelper->printf("Invalid range : %s - should be from:to or :to or from:\n", sets[0].str().c_str());
|
||||
return {};
|
||||
}
|
||||
if (range.size() == 1) {
|
||||
bool rangeTo = (':' == sets[0][0]);
|
||||
|
||||
retVal = getProductForOpenRange(range[0], argHelper, rangeTo);
|
||||
|
||||
} else {
|
||||
retVal = getProductForClosedRange(range[0], range[1], argHelper);
|
||||
}
|
||||
} else {
|
||||
retVal = getProductForSpecificTarget(sets, argHelper);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int buildFatBinaryForTarget(int retVal, const std::vector<std::string> &argsCopy, std::string pointerSize, Ar::ArEncoder &fatbinary,
|
||||
OfflineCompiler *pCompiler, OclocArgHelper *argHelper, const std::string &deviceConfig) {
|
||||
OfflineCompiler *pCompiler, OclocArgHelper *argHelper, const std::string &product) {
|
||||
|
||||
if (retVal == 0) {
|
||||
retVal = buildWithSafetyGuard(pCompiler);
|
||||
@@ -321,9 +221,9 @@ int buildFatBinaryForTarget(int retVal, const std::vector<std::string> &argsCopy
|
||||
}
|
||||
if (retVal == 0) {
|
||||
if (!pCompiler->isQuiet())
|
||||
argHelper->printf("Build succeeded for : %s.\n", deviceConfig.c_str());
|
||||
argHelper->printf("Build succeeded for : %s.\n", product.c_str());
|
||||
} else {
|
||||
argHelper->printf("Build failed for : %s with error code: %d\n", deviceConfig.c_str(), retVal);
|
||||
argHelper->printf("Build failed for : %s with error code: %d\n", product.c_str(), retVal);
|
||||
argHelper->printf("Command was:");
|
||||
for (const auto &arg : argsCopy)
|
||||
argHelper->printf(" %s", arg.c_str());
|
||||
@@ -333,7 +233,8 @@ int buildFatBinaryForTarget(int retVal, const std::vector<std::string> &argsCopy
|
||||
if (retVal) {
|
||||
return retVal;
|
||||
}
|
||||
fatbinary.appendFileEntry(pointerSize + "." + deviceConfig, pCompiler->getPackedDeviceBinaryOutput());
|
||||
auto productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(ProductConfigHelper::returnProductConfigForAcronym(product));
|
||||
fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -384,56 +285,25 @@ int buildFatBinary(const std::vector<std::string> &args, OclocArgHelper *argHelp
|
||||
}
|
||||
|
||||
Ar::ArEncoder fatbinary(true);
|
||||
if (isDeviceWithPlatformAbbreviation(ConstStringRef(args[deviceArgIndex]), argHelper)) {
|
||||
std::vector<ConstStringRef> targetPlatforms;
|
||||
targetPlatforms = getTargetPlatformsForFatbinary(ConstStringRef(args[deviceArgIndex]), argHelper);
|
||||
if (targetPlatforms.empty()) {
|
||||
argHelper->printf("Failed to parse target devices from : %s\n", args[deviceArgIndex].c_str());
|
||||
return 1;
|
||||
}
|
||||
for (auto &targetPlatform : targetPlatforms) {
|
||||
int retVal = 0;
|
||||
argsCopy[deviceArgIndex] = targetPlatform.str();
|
||||
std::vector<ConstStringRef> targetProducts;
|
||||
targetProducts = getTargetProductsForFatbinary(ConstStringRef(args[deviceArgIndex]), argHelper);
|
||||
if (targetProducts.empty()) {
|
||||
argHelper->printf("Failed to parse target devices from : %s\n", args[deviceArgIndex].c_str());
|
||||
return 1;
|
||||
}
|
||||
for (const auto &product : targetProducts) {
|
||||
int retVal = 0;
|
||||
argsCopy[deviceArgIndex] = product.str();
|
||||
|
||||
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)};
|
||||
if (OclocErrorCode::SUCCESS != retVal) {
|
||||
argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::string product = hardwarePrefix[pCompiler->getHardwareInfo().platform.eProductFamily];
|
||||
auto stepping = pCompiler->getHardwareInfo().platform.usRevId;
|
||||
auto targetPlatforms = product + "." + std::to_string(stepping);
|
||||
|
||||
retVal = buildFatBinaryForTarget(retVal, argsCopy, pointerSizeInBits, fatbinary, pCompiler.get(), argHelper, targetPlatforms);
|
||||
if (retVal) {
|
||||
return retVal;
|
||||
}
|
||||
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)};
|
||||
if (OclocErrorCode::SUCCESS != retVal) {
|
||||
argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
} else {
|
||||
std::vector<DeviceMapping> targetConfigs;
|
||||
targetConfigs = getTargetConfigsForFatbinary(ConstStringRef(args[deviceArgIndex]), argHelper);
|
||||
if (targetConfigs.empty()) {
|
||||
argHelper->printf("Failed to parse target devices from : %s\n", args[deviceArgIndex].c_str());
|
||||
return 1;
|
||||
}
|
||||
for (auto &targetConfig : targetConfigs) {
|
||||
int retVal = 0;
|
||||
|
||||
argHelper->setFatbinary(true);
|
||||
argHelper->setDeviceInfoForFatbinaryTarget(targetConfig);
|
||||
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)};
|
||||
if (OclocErrorCode::SUCCESS != retVal) {
|
||||
argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
auto targetConfigStr = ProductConfigHelper::parseMajorMinorRevisionValue(targetConfig.config);
|
||||
retVal = buildFatBinaryForTarget(retVal, argsCopy, pointerSizeInBits, fatbinary, pCompiler.get(), argHelper, targetConfigStr);
|
||||
if (retVal) {
|
||||
return retVal;
|
||||
}
|
||||
retVal = buildFatBinaryForTarget(retVal, argsCopy, pointerSizeInBits, fatbinary, pCompiler.get(), argHelper, product.str());
|
||||
if (retVal) {
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user