mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Restore old device id design in ocloc
This change removes some of the logic related to passing device id as an argument in ocloc introduced in "Setting default device id for acronym". Signed-off-by: Daria Hinz <daria.hinz@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
fd9a63f49f
commit
91a97dfaea
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
class MockOclocArgHelper : public OclocArgHelper {
|
class MockOclocArgHelper : public OclocArgHelper {
|
||||||
public:
|
public:
|
||||||
|
using OclocArgHelper::deviceProductTable;
|
||||||
using OclocArgHelper::hasOutput;
|
using OclocArgHelper::hasOutput;
|
||||||
using OclocArgHelper::headers;
|
using OclocArgHelper::headers;
|
||||||
using OclocArgHelper::inputs;
|
using OclocArgHelper::inputs;
|
||||||
|
@ -91,3 +91,26 @@ TEST(OclocValidate, WhenErrorsEmitedThenRedirectsThemToStdout) {
|
|||||||
EXPECT_EQ(static_cast<int>(NEO::DecodeError::InvalidBinary), res) << oclocStdout;
|
EXPECT_EQ(static_cast<int>(NEO::DecodeError::InvalidBinary), res) << oclocStdout;
|
||||||
EXPECT_NE(nullptr, strstr(oclocStdout.c_str(), "Validator detected errors :\nNEO::Yaml : Could not parse line : [1] : [kernels ] <-- parser position on error. Reason : Vector data type expects to have at least one value starting with -")) << oclocStdout;
|
EXPECT_NE(nullptr, strstr(oclocStdout.c_str(), "Validator detected errors :\nNEO::Yaml : Could not parse line : [1] : [kernels ] <-- parser position on error. Reason : Vector data type expects to have at least one value starting with -")) << oclocStdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(OclocValidate, givenDeviceProductTableEveryProductMatchesProperPattern) {
|
||||||
|
MockOclocArgHelper::FilesMap files{{"src.gen", "01234567"}};
|
||||||
|
MockOclocArgHelper argHelper{files};
|
||||||
|
ASSERT_GE(argHelper.deviceProductTable.size(), 1u);
|
||||||
|
std::vector<std::string> genPatterns;
|
||||||
|
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
|
||||||
|
if (NEO::hardwarePrefix[j] == nullptr)
|
||||||
|
continue;
|
||||||
|
genPatterns.push_back(NEO::hardwarePrefix[j]);
|
||||||
|
}
|
||||||
|
ASSERT_GE(genPatterns.size(), 1u);
|
||||||
|
if (argHelper.deviceProductTable.size() == 1 && argHelper.deviceProductTable[0].deviceId == 0) {
|
||||||
|
auto &deviceProductTable = const_cast<std::vector<DeviceProduct> &>(argHelper.deviceProductTable);
|
||||||
|
deviceProductTable[0].product = genPatterns[0];
|
||||||
|
deviceProductTable[0].deviceId = 0x123;
|
||||||
|
deviceProductTable.push_back(DeviceProduct{0, ""});
|
||||||
|
}
|
||||||
|
for (int i = 0; argHelper.deviceProductTable[i].deviceId != 0; i++) {
|
||||||
|
auto res = std::find(genPatterns.begin(), genPatterns.end(), argHelper.returnProductNameForDevice(argHelper.deviceProductTable[i].deviceId));
|
||||||
|
EXPECT_NE(res, genPatterns.end());
|
||||||
|
}
|
||||||
|
}
|
@ -1028,11 +1028,10 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenOfflineCompilerIsCreatedThenSuccessIsR
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(OfflineCompilerTests, givenDeviceIdHexValueWhenInitHwInfoThenItHasCorrectlySetValues) {
|
TEST_F(OfflineCompilerTests, givenDeviceIdHexValueWhenInitHwInfoThenItHasCorrectlySetValues) {
|
||||||
auto deviceAot = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
|
auto deviceId = oclocArgHelperWithoutInput->deviceProductTable[0].deviceId;
|
||||||
if (deviceAot.empty()) {
|
if (oclocArgHelperWithoutInput->deviceProductTable.size() == 1 && deviceId == 0) {
|
||||||
GTEST_SKIP();
|
GTEST_SKIP();
|
||||||
}
|
}
|
||||||
auto deviceId = deviceAot[0].deviceIds->front();
|
|
||||||
|
|
||||||
MockOfflineCompiler mockOfflineCompiler;
|
MockOfflineCompiler mockOfflineCompiler;
|
||||||
std::stringstream deviceString, productString;
|
std::stringstream deviceString, productString;
|
||||||
@ -1044,17 +1043,15 @@ TEST_F(OfflineCompilerTests, givenDeviceIdHexValueWhenInitHwInfoThenItHasCorrect
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(OfflineCompilerTests, givenProperDeviceIdHexAsDeviceArgumentThenSuccessIsReturned) {
|
TEST_F(OfflineCompilerTests, givenProperDeviceIdHexAsDeviceArgumentThenSuccessIsReturned) {
|
||||||
auto deviceAotInfo = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
|
auto deviceId = oclocArgHelperWithoutInput->deviceProductTable[0].deviceId;
|
||||||
if (deviceAotInfo.empty()) {
|
if (oclocArgHelperWithoutInput->deviceProductTable.size() == 1 && deviceId == 0) {
|
||||||
GTEST_SKIP();
|
GTEST_SKIP();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream deviceString, productString;
|
std::stringstream deviceString, productString;
|
||||||
AOT::PRODUCT_CONFIG config;
|
|
||||||
auto deviceId = deviceAotInfo[0].deviceIds->front();
|
|
||||||
deviceString << "0x" << std::hex << deviceId;
|
deviceString << "0x" << std::hex << deviceId;
|
||||||
config = static_cast<AOT::PRODUCT_CONFIG>(deviceAotInfo[0].aotConfig.ProductConfig);
|
productString << oclocArgHelperWithoutInput->deviceProductTable[0].product;
|
||||||
productString << oclocArgHelperWithoutInput->productConfigHelper->getAcronymForProductConfig(config);
|
|
||||||
|
|
||||||
std::vector<std::string> argv = {
|
std::vector<std::string> argv = {
|
||||||
"ocloc",
|
"ocloc",
|
||||||
@ -1092,7 +1089,7 @@ TEST_F(OfflineCompilerTests, givenIncorrectDeviceIdHexThenInvalidDeviceIsReturne
|
|||||||
|
|
||||||
auto output = testing::internal::GetCapturedStdout();
|
auto output = testing::internal::GetCapturedStdout();
|
||||||
EXPECT_EQ(nullptr, pOfflineCompiler);
|
EXPECT_EQ(nullptr, pOfflineCompiler);
|
||||||
EXPECT_STREQ(output.c_str(), "Could not determine device target: 0x0\nError: Cannot get HW Info for device 0x0.\n");
|
EXPECT_STREQ(output.c_str(), "Could not determine target based on device id: 0x0\nError: Cannot get HW Info for device 0x0.\n");
|
||||||
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
|
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1967,7 +1964,7 @@ TEST(OfflineCompilerTest, GivenUnsupportedDeviceConfigWhenInitHardwareInfoThenIn
|
|||||||
EXPECT_EQ(retVal, OclocErrorCode::INVALID_DEVICE);
|
EXPECT_EQ(retVal, OclocErrorCode::INVALID_DEVICE);
|
||||||
|
|
||||||
auto output = testing::internal::GetCapturedStdout();
|
auto output = testing::internal::GetCapturedStdout();
|
||||||
resString << "Could not determine device target: " << deviceName << "\n";
|
resString << "Could not determine target based on product config: " << deviceName << "\n";
|
||||||
EXPECT_STREQ(output.c_str(), resString.str().c_str());
|
EXPECT_STREQ(output.c_str(), resString.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,13 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo
|
|||||||
uint64_t **lenOutputs, char ***nameOutputs)
|
uint64_t **lenOutputs, char ***nameOutputs)
|
||||||
: numOutputs(numOutputs), nameOutputs(nameOutputs),
|
: numOutputs(numOutputs), nameOutputs(nameOutputs),
|
||||||
dataOutputs(dataOutputs), lenOutputs(lenOutputs), hasOutput(numOutputs != nullptr),
|
dataOutputs(dataOutputs), lenOutputs(lenOutputs), hasOutput(numOutputs != nullptr),
|
||||||
messagePrinter(hasOutput) {
|
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("")}}) {
|
||||||
for (uint32_t i = 0; i < numSources; ++i) {
|
for (uint32_t i = 0; i < numSources; ++i) {
|
||||||
inputs.push_back(Source(dataSources[i], static_cast<size_t>(lenSources[i]), nameSources[i]));
|
inputs.push_back(Source(dataSources[i], static_cast<size_t>(lenSources[i]), nameSources[i]));
|
||||||
}
|
}
|
||||||
@ -197,3 +203,24 @@ void OclocArgHelper::saveOutput(const std::string &filename, const std::ostream
|
|||||||
bool OclocArgHelper::areQuotesRequired(const std::string_view &argName) {
|
bool OclocArgHelper::areQuotesRequired(const std::string_view &argName) {
|
||||||
return argName == "-options" || argName == "-internal_options";
|
return argName == "-options" || argName == "-internal_options";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
for (int i = 0; deviceProductTable[i].deviceId != 0; i++) {
|
||||||
|
if (deviceProductTable[i].deviceId == deviceId) {
|
||||||
|
return deviceProductTable[i].product;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
@ -41,6 +41,11 @@ struct Output {
|
|||||||
Output(const std::string &name, const void *data, const size_t &size);
|
Output(const std::string &name, const void *data, const size_t &size);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DeviceProduct {
|
||||||
|
unsigned short deviceId;
|
||||||
|
std::string product;
|
||||||
|
};
|
||||||
|
|
||||||
class OclocArgHelper {
|
class OclocArgHelper {
|
||||||
protected:
|
protected:
|
||||||
std::vector<Source> inputs, headers;
|
std::vector<Source> inputs, headers;
|
||||||
@ -51,6 +56,7 @@ class OclocArgHelper {
|
|||||||
uint64_t **lenOutputs = nullptr;
|
uint64_t **lenOutputs = nullptr;
|
||||||
bool hasOutput = false;
|
bool hasOutput = false;
|
||||||
MessagePrinter messagePrinter;
|
MessagePrinter messagePrinter;
|
||||||
|
const std::vector<DeviceProduct> deviceProductTable;
|
||||||
void moveOutputs();
|
void moveOutputs();
|
||||||
Source *findSourceFile(const std::string &filename);
|
Source *findSourceFile(const std::string &filename);
|
||||||
bool sourceFileExists(const std::string &filename) const;
|
bool sourceFileExists(const std::string &filename) const;
|
||||||
@ -71,6 +77,7 @@ class OclocArgHelper {
|
|||||||
virtual ~OclocArgHelper();
|
virtual ~OclocArgHelper();
|
||||||
MOCKABLE_VIRTUAL bool fileExists(const std::string &filename) const;
|
MOCKABLE_VIRTUAL bool fileExists(const std::string &filename) const;
|
||||||
bool getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig);
|
bool getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig);
|
||||||
|
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);
|
||||||
MOCKABLE_VIRTUAL std::vector<char> readBinaryFile(const std::string &filename);
|
MOCKABLE_VIRTUAL std::vector<char> readBinaryFile(const std::string &filename);
|
||||||
@ -129,5 +136,6 @@ class OclocArgHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool areQuotesRequired(const std::string_view &argName);
|
bool areQuotesRequired(const std::string_view &argName);
|
||||||
|
std::string returnProductNameForDevice(unsigned short deviceId);
|
||||||
std::unique_ptr<ProductConfigHelper> productConfigHelper;
|
std::unique_ptr<ProductConfigHelper> productConfigHelper;
|
||||||
};
|
};
|
||||||
|
@ -403,7 +403,7 @@ void OfflineCompiler::setFamilyType() {
|
|||||||
familyNameWithType.append(hwInfo.capabilityTable.platformType);
|
familyNameWithType.append(hwInfo.capabilityTable.platformType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName) {
|
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId) {
|
||||||
std::vector<PRODUCT_FAMILY> allSupportedProduct{ALL_SUPPORTED_PRODUCT_FAMILIES};
|
std::vector<PRODUCT_FAMILY> allSupportedProduct{ALL_SUPPORTED_PRODUCT_FAMILIES};
|
||||||
std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower);
|
std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower);
|
||||||
|
|
||||||
@ -413,7 +413,9 @@ int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceNam
|
|||||||
if (revisionId != -1) {
|
if (revisionId != -1) {
|
||||||
hwInfo.platform.usRevId = revisionId;
|
hwInfo.platform.usRevId = revisionId;
|
||||||
}
|
}
|
||||||
|
if (deviceId != -1) {
|
||||||
|
hwInfo.platform.usDeviceID = deviceId;
|
||||||
|
}
|
||||||
uint64_t config = hwInfoConfig ? hwInfoConfig : defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily];
|
uint64_t config = hwInfoConfig ? hwInfoConfig : defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily];
|
||||||
setHwInfoValuesFromConfig(config, hwInfo);
|
setHwInfoValuesFromConfig(config, hwInfo);
|
||||||
hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
|
hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
|
||||||
@ -429,36 +431,27 @@ int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) {
|
|||||||
AOT::PRODUCT_CONFIG productConfig = AOT::UNKNOWN_ISA;
|
AOT::PRODUCT_CONFIG productConfig = AOT::UNKNOWN_ISA;
|
||||||
ProductConfigHelper::adjustDeviceName(deviceName);
|
ProductConfigHelper::adjustDeviceName(deviceName);
|
||||||
|
|
||||||
const char hexPrefix = 2;
|
|
||||||
int deviceId = -1;
|
|
||||||
|
|
||||||
if (deviceName.find(".") != std::string::npos) {
|
if (deviceName.find(".") != std::string::npos) {
|
||||||
productConfig = argHelper->productConfigHelper->getProductConfigForVersionValue(deviceName);
|
productConfig = argHelper->productConfigHelper->getProductConfigForVersionValue(deviceName);
|
||||||
} else if (deviceName.substr(0, hexPrefix) == "0x" && std::all_of(deviceName.begin() + hexPrefix, deviceName.end(), (::isxdigit))) {
|
if (productConfig == AOT::UNKNOWN_ISA) {
|
||||||
deviceId = std::stoi(deviceName, 0, 16);
|
argHelper->printf("Could not determine device target: %s\n", deviceName.c_str());
|
||||||
productConfig = argHelper->productConfigHelper->getProductConfigForDeviceId(deviceId);
|
}
|
||||||
} else if (argHelper->productConfigHelper->isProductConfig(deviceName)) {
|
} else if (argHelper->productConfigHelper->isProductConfig(deviceName)) {
|
||||||
productConfig = ProductConfigHelper::getProductConfigForAcronym(deviceName);
|
productConfig = ProductConfigHelper::getProductConfigForAcronym(deviceName);
|
||||||
} else {
|
|
||||||
return INVALID_DEVICE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argHelper->getHwInfoForProductConfig(productConfig, hwInfo, hwInfoConfig)) {
|
if (productConfig != AOT::UNKNOWN_ISA) {
|
||||||
if (revisionId != -1) {
|
if (argHelper->getHwInfoForProductConfig(productConfig, hwInfo, hwInfoConfig)) {
|
||||||
hwInfo.platform.usRevId = revisionId;
|
if (revisionId != -1) {
|
||||||
|
hwInfo.platform.usRevId = revisionId;
|
||||||
|
}
|
||||||
|
deviceConfig = productConfig;
|
||||||
|
setFamilyType();
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
if (deviceId != -1) {
|
argHelper->printf("Could not determine target based on product config: %s\n", deviceName.c_str());
|
||||||
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) {
|
int OfflineCompiler::initHardwareInfo(std::string deviceName) {
|
||||||
@ -469,12 +462,21 @@ int OfflineCompiler::initHardwareInfo(std::string deviceName) {
|
|||||||
|
|
||||||
overridePlatformName(deviceName);
|
overridePlatformName(deviceName);
|
||||||
|
|
||||||
|
const char hexPrefix = 2;
|
||||||
|
int deviceId = -1;
|
||||||
|
|
||||||
retVal = initHardwareInfoForProductConfig(deviceName);
|
retVal = initHardwareInfoForProductConfig(deviceName);
|
||||||
if (retVal == SUCCESS) {
|
if (retVal == SUCCESS) {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
retVal = initHardwareInfoForDeprecatedAcronyms(deviceName);
|
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);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ All supported acronyms: %s.
|
|||||||
void setFamilyType();
|
void setFamilyType();
|
||||||
int initHardwareInfo(std::string deviceName);
|
int initHardwareInfo(std::string deviceName);
|
||||||
int initHardwareInfoForProductConfig(std::string deviceName);
|
int initHardwareInfoForProductConfig(std::string deviceName);
|
||||||
int initHardwareInfoForDeprecatedAcronyms(std::string deviceName);
|
int initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId);
|
||||||
|
|
||||||
std::string getStringWithinDelimiters(const std::string &src);
|
std::string getStringWithinDelimiters(const std::string &src);
|
||||||
int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles);
|
int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles);
|
||||||
|
@ -34,15 +34,6 @@ bool ProductConfigHelper::compareConfigs(DeviceAotInfo deviceAotInfo0, DeviceAot
|
|||||||
return deviceAotInfo0.aotConfig.ProductConfig < deviceAotInfo1.aotConfig.ProductConfig;
|
return deviceAotInfo0.aotConfig.ProductConfig < deviceAotInfo1.aotConfig.ProductConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
AOT::PRODUCT_CONFIG ProductConfigHelper::getProductConfigForDeviceId(unsigned short deviceId) {
|
|
||||||
for (const auto &device : deviceAotInfo) {
|
|
||||||
if (std::find(device.deviceIds->begin(), device.deviceIds->end(), deviceId) != device.deviceIds->end()) {
|
|
||||||
return static_cast<AOT::PRODUCT_CONFIG>(device.aotConfig.ProductConfig);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AOT::UNKNOWN_ISA;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<DeviceAotInfo> &ProductConfigHelper::getDeviceAotInfo() {
|
std::vector<DeviceAotInfo> &ProductConfigHelper::getDeviceAotInfo() {
|
||||||
return deviceAotInfo;
|
return deviceAotInfo;
|
||||||
}
|
}
|
||||||
@ -70,14 +61,6 @@ NEO::ConstStringRef ProductConfigHelper::getAcronymForAFamily(AOT::FAMILY family
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string ProductConfigHelper::getAcronymForProductConfig(AOT::PRODUCT_CONFIG config) {
|
|
||||||
auto it = std::find_if(deviceAotInfo.begin(), deviceAotInfo.end(), findProductConfig(config));
|
|
||||||
if (it == deviceAotInfo.end()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return it->acronyms.empty() ? parseMajorMinorRevisionValue(it->aotConfig) : it->acronyms.front().str();
|
|
||||||
}
|
|
||||||
|
|
||||||
AOT::RELEASE ProductConfigHelper::getReleaseForAcronym(const std::string &device) {
|
AOT::RELEASE ProductConfigHelper::getReleaseForAcronym(const std::string &device) {
|
||||||
auto it = std::find_if(AOT::releaseAcronyms.begin(), AOT::releaseAcronyms.end(), findMapAcronymWithoutDash(device));
|
auto it = std::find_if(AOT::releaseAcronyms.begin(), AOT::releaseAcronyms.end(), findMapAcronymWithoutDash(device));
|
||||||
if (it == AOT::releaseAcronyms.end())
|
if (it == AOT::releaseAcronyms.end())
|
||||||
|
@ -105,8 +105,6 @@ struct ProductConfigHelper {
|
|||||||
bool isRelease(const std::string &device);
|
bool isRelease(const std::string &device);
|
||||||
bool isProductConfig(const std::string &device);
|
bool isProductConfig(const std::string &device);
|
||||||
|
|
||||||
AOT::PRODUCT_CONFIG getProductConfigForDeviceId(unsigned short deviceId);
|
|
||||||
const std::string getAcronymForProductConfig(AOT::PRODUCT_CONFIG config);
|
|
||||||
std::vector<DeviceAotInfo> &getDeviceAotInfo();
|
std::vector<DeviceAotInfo> &getDeviceAotInfo();
|
||||||
std::vector<NEO::ConstStringRef> getRepresentativeProductAcronyms();
|
std::vector<NEO::ConstStringRef> getRepresentativeProductAcronyms();
|
||||||
std::vector<NEO::ConstStringRef> getReleasesAcronyms();
|
std::vector<NEO::ConstStringRef> getReleasesAcronyms();
|
||||||
|
@ -476,44 +476,3 @@ TEST_F(AotDeviceInfoTests, givenClearedProductAcronymWhenSearchInRepresentativeA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AotDeviceInfoTests, givenDeviceIdWhenSearchForProductConfigAndAcronymThenCorrectResultsAreReturned) {
|
|
||||||
auto deviceAot = productConfigHelper->getDeviceAotInfo();
|
|
||||||
if (deviceAot.empty()) {
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto &device : deviceAot) {
|
|
||||||
for (const auto &deviceId : *device.deviceIds) {
|
|
||||||
auto config = productConfigHelper->getProductConfigForDeviceId(deviceId);
|
|
||||||
EXPECT_NE(config, AOT::UNKNOWN_ISA);
|
|
||||||
auto name = productConfigHelper->getAcronymForProductConfig(config);
|
|
||||||
EXPECT_FALSE(name.empty());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(AotDeviceInfoTests, givenInvalidDeviceIdWhenSearchForProductConfigAndAcronymThenUnknownIsaIsReturned) {
|
|
||||||
auto config = productConfigHelper->getProductConfigForDeviceId(0x0);
|
|
||||||
EXPECT_EQ(config, AOT::UNKNOWN_ISA);
|
|
||||||
auto name = productConfigHelper->getAcronymForProductConfig(config);
|
|
||||||
EXPECT_TRUE(name.empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(AotDeviceInfoTests, givenDeviceIdsFromDevicesFileWhenGetProductConfigThenValueIsExpectedToBeFound) {
|
|
||||||
std::vector<unsigned short> deviceIds{
|
|
||||||
#define NAMEDDEVICE(devId, ignored_product, ignored_devName) devId,
|
|
||||||
#define DEVICE(devId, ignored_product) devId,
|
|
||||||
#include "devices.inl"
|
|
||||||
#undef DEVICE
|
|
||||||
#undef NAMEDDEVICE
|
|
||||||
};
|
|
||||||
|
|
||||||
if (deviceIds.empty()) {
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto &deviceId : deviceIds) {
|
|
||||||
EXPECT_NE(productConfigHelper->getProductConfigForDeviceId(deviceId), AOT::UNKNOWN_ISA);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user