mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Support for AOT version in fat binary
AOT version (major.minor.revision) is one of the supported variants for -device arg in ocloc. In this change, version support has been added when passing specific targets to -device using ",". Signed-off-by: Daria Hinz <daria.hinz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
554104dc9e
commit
c9246d085d
@@ -34,9 +34,9 @@ TEST_F(OclocArgHelperTests, givenProductOrAotConfigWhenParseMajorMinorRevisionVa
|
|||||||
auto configStr1 = ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig);
|
auto configStr1 = ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig);
|
||||||
EXPECT_STREQ(configStr0.c_str(), configStr1.c_str());
|
EXPECT_STREQ(configStr0.c_str(), configStr1.c_str());
|
||||||
|
|
||||||
auto gotCofig = argHelper->getMajorMinorRevision(configStr0);
|
auto gotCofig = argHelper->getProductConfigForVersionValue(configStr0);
|
||||||
|
|
||||||
EXPECT_EQ(gotCofig.ProductConfig, productConfig);
|
EXPECT_EQ(gotCofig, productConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +152,24 @@ TEST_F(OclocArgHelperTests, givenEnabledReleaseAcronymsWhenCheckIfIsReleaseThenT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(OclocArgHelperTests, givenEnabledProductsAcronymsAndVersionsWhenCheckIfProductConfigThenTrueIsReturned) {
|
||||||
|
auto enabledProducts = argHelper->getAllSupportedDeviceConfigs();
|
||||||
|
for (const auto &product : enabledProducts) {
|
||||||
|
auto configStr = ProductConfigHelper::parseMajorMinorRevisionValue(product.aotConfig);
|
||||||
|
EXPECT_FALSE(configStr.empty());
|
||||||
|
EXPECT_TRUE(argHelper->isProductConfig(configStr));
|
||||||
|
|
||||||
|
for (const auto &acronym : product.acronyms) {
|
||||||
|
EXPECT_TRUE(argHelper->isProductConfig(acronym.str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(OclocArgHelperTests, givenUnknownIsaVersionWhenCheckIfProductConfigThenFalseIsReturned) {
|
||||||
|
auto configStr = ProductConfigHelper::parseMajorMinorRevisionValue(AOT::UNKNOWN_ISA);
|
||||||
|
EXPECT_FALSE(argHelper->isProductConfig(configStr));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(OclocArgHelperTests, givenDisabledFamilyOrReleaseNameThenReturnsEmptyList) {
|
TEST_F(OclocArgHelperTests, givenDisabledFamilyOrReleaseNameThenReturnsEmptyList) {
|
||||||
EXPECT_FALSE(argHelper->isFamily(NEO::ConstStringRef("gen0").str()));
|
EXPECT_FALSE(argHelper->isFamily(NEO::ConstStringRef("gen0").str()));
|
||||||
EXPECT_FALSE(argHelper->isFamily(NEO::ConstStringRef("genX").str()));
|
EXPECT_FALSE(argHelper->isFamily(NEO::ConstStringRef("genX").str()));
|
||||||
|
|||||||
@@ -186,12 +186,12 @@ TEST(OclocFatBinaryRequestedFatBinary, givenDeviceArgToFatBinaryWhenConfigIsNotF
|
|||||||
std::stringstream majorString;
|
std::stringstream majorString;
|
||||||
majorString << aotConfig.ProductConfigID.Major;
|
majorString << aotConfig.ProductConfigID.Major;
|
||||||
auto major = majorString.str();
|
auto major = majorString.str();
|
||||||
auto aotValue0 = argHelper->getMajorMinorRevision(major);
|
auto aotValue0 = argHelper->getProductConfigForVersionValue(major);
|
||||||
EXPECT_EQ(aotValue0.ProductConfig, AOT::UNKNOWN_ISA);
|
EXPECT_EQ(aotValue0, AOT::UNKNOWN_ISA);
|
||||||
|
|
||||||
auto majorMinor = ProductConfigHelper::parseMajorMinorValue(aotConfig);
|
auto majorMinor = ProductConfigHelper::parseMajorMinorValue(aotConfig);
|
||||||
auto aotValue1 = argHelper->getMajorMinorRevision(majorMinor);
|
auto aotValue1 = argHelper->getProductConfigForVersionValue(majorMinor);
|
||||||
EXPECT_EQ(aotValue1.ProductConfig, AOT::UNKNOWN_ISA);
|
EXPECT_EQ(aotValue1, AOT::UNKNOWN_ISA);
|
||||||
|
|
||||||
const char *cutRevision[] = {"ocloc", "-device", majorMinor.c_str()};
|
const char *cutRevision[] = {"ocloc", "-device", majorMinor.c_str()};
|
||||||
const char *cutMinorAndRevision[] = {"ocloc", "-device", major.c_str()};
|
const char *cutMinorAndRevision[] = {"ocloc", "-device", major.c_str()};
|
||||||
@@ -367,6 +367,43 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfProductsWhenFatBinar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoVersionsOfProductConfigsWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) {
|
||||||
|
if (enabledProducts.size() < 2) {
|
||||||
|
GTEST_SKIP();
|
||||||
|
}
|
||||||
|
for (unsigned int product = 0; product < enabledProducts.size() - 1; product++) {
|
||||||
|
auto config0 = enabledProducts.at(product).aotConfig;
|
||||||
|
auto config1 = enabledProducts.at(product + 1).aotConfig;
|
||||||
|
auto configStr0 = ProductConfigHelper::parseMajorMinorRevisionValue(config0);
|
||||||
|
auto configStr1 = ProductConfigHelper::parseMajorMinorRevisionValue(config1);
|
||||||
|
std::vector<ConstStringRef> expected{configStr0, configStr1};
|
||||||
|
|
||||||
|
std::string acronymsTarget = configStr0 + "," + configStr1;
|
||||||
|
auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get());
|
||||||
|
EXPECT_EQ(got, expected);
|
||||||
|
|
||||||
|
oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false};
|
||||||
|
std::stringstream resString;
|
||||||
|
std::vector<std::string> argv = {
|
||||||
|
"ocloc",
|
||||||
|
"-file",
|
||||||
|
clFiles + "copybuffer.cl",
|
||||||
|
"-device",
|
||||||
|
acronymsTarget};
|
||||||
|
|
||||||
|
testing::internal::CaptureStdout();
|
||||||
|
int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get());
|
||||||
|
auto output = testing::internal::GetCapturedStdout();
|
||||||
|
EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS);
|
||||||
|
|
||||||
|
for (const auto &product : expected) {
|
||||||
|
resString << "Build succeeded for : " << product.str() + ".\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_STREQ(output.c_str(), resString.str().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(OclocFatBinaryProductAcronymsTests, givenProductsAcronymsWithoutDashesWhenBuildFatBinaryThenSuccessIsReturned) {
|
TEST_F(OclocFatBinaryProductAcronymsTests, givenProductsAcronymsWithoutDashesWhenBuildFatBinaryThenSuccessIsReturned) {
|
||||||
auto acronyms = prepareProductsWithoutDashes(oclocArgHelperWithoutInput.get());
|
auto acronyms = prepareProductsWithoutDashes(oclocArgHelperWithoutInput.get());
|
||||||
if (acronyms.size() < 2) {
|
if (acronyms.size() < 2) {
|
||||||
|
|||||||
@@ -295,29 +295,26 @@ int OclocArgHelper::parseProductConfigFromString(const std::string &device, size
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AheadOfTimeConfig OclocArgHelper::getMajorMinorRevision(const std::string &device) {
|
AOT::PRODUCT_CONFIG OclocArgHelper::getProductConfigForVersionValue(const std::string &device) {
|
||||||
AheadOfTimeConfig product = {AOT::UNKNOWN_ISA};
|
|
||||||
auto majorPos = device.find(".");
|
auto majorPos = device.find(".");
|
||||||
auto major = parseProductConfigFromString(device, 0, majorPos);
|
auto major = parseProductConfigFromString(device, 0, majorPos);
|
||||||
if (major == CONFIG_STATUS::MISMATCHED_VALUE || majorPos == std::string::npos) {
|
if (major == CONFIG_STATUS::MISMATCHED_VALUE || majorPos == std::string::npos) {
|
||||||
return product;
|
return AOT::UNKNOWN_ISA;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto minorPos = device.find(".", ++majorPos);
|
auto minorPos = device.find(".", ++majorPos);
|
||||||
auto minor = parseProductConfigFromString(device, majorPos, minorPos);
|
auto minor = parseProductConfigFromString(device, majorPos, minorPos);
|
||||||
|
|
||||||
if (minor == CONFIG_STATUS::MISMATCHED_VALUE || minorPos == std::string::npos) {
|
if (minor == CONFIG_STATUS::MISMATCHED_VALUE || minorPos == std::string::npos) {
|
||||||
return product;
|
return AOT::UNKNOWN_ISA;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto revision = parseProductConfigFromString(device, minorPos + 1, device.size());
|
auto revision = parseProductConfigFromString(device, minorPos + 1, device.size());
|
||||||
if (revision == CONFIG_STATUS::MISMATCHED_VALUE) {
|
if (revision == CONFIG_STATUS::MISMATCHED_VALUE) {
|
||||||
return product;
|
return AOT::UNKNOWN_ISA;
|
||||||
}
|
}
|
||||||
|
AheadOfTimeConfig product = {0};
|
||||||
product.ProductConfigID.Major = major;
|
product.ProductConfigID.Major = major;
|
||||||
product.ProductConfigID.Minor = minor;
|
product.ProductConfigID.Minor = minor;
|
||||||
product.ProductConfigID.Revision = revision;
|
product.ProductConfigID.Revision = revision;
|
||||||
return product;
|
return static_cast<AOT::PRODUCT_CONFIG>(product.ProductConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OclocArgHelper::isRelease(const std::string &device) {
|
bool OclocArgHelper::isRelease(const std::string &device) {
|
||||||
@@ -337,7 +334,12 @@ bool OclocArgHelper::isFamily(const std::string &device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OclocArgHelper::isProductConfig(const std::string &device) {
|
bool OclocArgHelper::isProductConfig(const std::string &device) {
|
||||||
auto config = ProductConfigHelper::returnProductConfigForAcronym(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) {
|
if (config == AOT::UNKNOWN_ISA) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class OclocArgHelper {
|
|||||||
std::vector<NEO::ConstStringRef> getEnabledReleasesAcronyms();
|
std::vector<NEO::ConstStringRef> getEnabledReleasesAcronyms();
|
||||||
std::vector<NEO::ConstStringRef> getEnabledFamiliesAcronyms();
|
std::vector<NEO::ConstStringRef> getEnabledFamiliesAcronyms();
|
||||||
std::string getAllSupportedAcronyms();
|
std::string getAllSupportedAcronyms();
|
||||||
AheadOfTimeConfig getMajorMinorRevision(const std::string &device);
|
AOT::PRODUCT_CONFIG getProductConfigForVersionValue(const std::string &device);
|
||||||
bool setAcronymForDeviceId(std::string &device);
|
bool setAcronymForDeviceId(std::string &device);
|
||||||
std::vector<std::string> headersToVectorOfStrings();
|
std::vector<std::string> headersToVectorOfStrings();
|
||||||
MOCKABLE_VIRTUAL void readFileToVectorOfStrings(const std::string &filename, std::vector<std::string> &lines);
|
MOCKABLE_VIRTUAL void readFileToVectorOfStrings(const std::string &filename, std::vector<std::string> &lines);
|
||||||
|
|||||||
@@ -242,7 +242,13 @@ int buildFatBinaryForTarget(int retVal, const std::vector<std::string> &argsCopy
|
|||||||
if (retVal) {
|
if (retVal) {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
auto productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(ProductConfigHelper::returnProductConfigForAcronym(product));
|
|
||||||
|
std::string productConfig("");
|
||||||
|
if (product.find(".") != std::string::npos) {
|
||||||
|
productConfig = product;
|
||||||
|
} else {
|
||||||
|
productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(ProductConfigHelper::returnProductConfigForAcronym(product));
|
||||||
|
}
|
||||||
fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput());
|
fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput());
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,24 +351,24 @@ int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceNam
|
|||||||
}
|
}
|
||||||
|
|
||||||
int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) {
|
int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) {
|
||||||
AheadOfTimeConfig aotConfig{AOT::UNKNOWN_ISA};
|
AOT::PRODUCT_CONFIG config = AOT::UNKNOWN_ISA;
|
||||||
ProductConfigHelper::adjustDeviceName(deviceName);
|
ProductConfigHelper::adjustDeviceName(deviceName);
|
||||||
|
|
||||||
if (deviceName.find(".") != std::string::npos) {
|
if (deviceName.find(".") != std::string::npos) {
|
||||||
aotConfig = argHelper->getMajorMinorRevision(deviceName);
|
config = argHelper->getProductConfigForVersionValue(deviceName);
|
||||||
if (aotConfig.ProductConfig == AOT::UNKNOWN_ISA) {
|
if (config == AOT::UNKNOWN_ISA) {
|
||||||
argHelper->printf("Could not determine device target: %s\n", deviceName.c_str());
|
argHelper->printf("Could not determine device target: %s\n", deviceName.c_str());
|
||||||
}
|
}
|
||||||
} else if (argHelper->isProductConfig(deviceName)) {
|
} else if (argHelper->isProductConfig(deviceName)) {
|
||||||
aotConfig.ProductConfig = ProductConfigHelper::returnProductConfigForAcronym(deviceName);
|
config = ProductConfigHelper::returnProductConfigForAcronym(deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aotConfig.ProductConfig != AOT::UNKNOWN_ISA) {
|
if (config != AOT::UNKNOWN_ISA) {
|
||||||
if (argHelper->getHwInfoForProductConfig(aotConfig.ProductConfig, hwInfo)) {
|
if (argHelper->getHwInfoForProductConfig(config, hwInfo)) {
|
||||||
if (revisionId != -1) {
|
if (revisionId != -1) {
|
||||||
hwInfo.platform.usRevId = revisionId;
|
hwInfo.platform.usRevId = revisionId;
|
||||||
}
|
}
|
||||||
deviceConfig = static_cast<AOT::PRODUCT_CONFIG>(aotConfig.ProductConfig);
|
deviceConfig = config;
|
||||||
setFamilyType();
|
setFamilyType();
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user