Switch device ID support to product config helper
This commit switches the device ID logic from the deprecated to the new one, so that if the user passes a hex value to the -device parameter, ocloc will use the new implementation in the product config helper. The change also introduces a fix for setting the values in the correct order to configure the hwIfno correctly. Signed-off-by: Daria Hinz daria.hinz@intel.com Related-To: NEO-7487
This commit is contained in:
parent
43ff955199
commit
59109a08bb
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -19,7 +19,6 @@
|
|||
|
||||
class MockOclocArgHelper : public OclocArgHelper {
|
||||
public:
|
||||
using OclocArgHelper::deviceProductTable;
|
||||
using OclocArgHelper::hasOutput;
|
||||
using OclocArgHelper::headers;
|
||||
using OclocArgHelper::inputs;
|
||||
|
|
|
@ -154,7 +154,7 @@ TEST(OclocFatBinaryRequestedFatBinary, givenHwInfoForProductConfigWhenUnknownIsa
|
|||
std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
|
||||
std::unique_ptr<CompilerProductHelper> compilerProductHelper;
|
||||
NEO::HardwareInfo hwInfo;
|
||||
EXPECT_FALSE(argHelper->getHwInfoForProductConfig(AOT::UNKNOWN_ISA, hwInfo, 0u, std::move(compilerProductHelper)));
|
||||
EXPECT_FALSE(argHelper->getHwInfoForProductConfig(AOT::UNKNOWN_ISA, hwInfo, 0u, 0u, 0u, std::move(compilerProductHelper)));
|
||||
}
|
||||
|
||||
TEST(OclocFatBinaryRequestedFatBinary, givenReleaseOrFamilyAcronymWhenGetAcronymsForTargetThenCorrectValuesAreReturned) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -103,26 +103,3 @@ TEST(OclocValidate, WhenErrorsEmitedThenRedirectsThemToStdout) {
|
|||
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;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
|
@ -1034,13 +1034,14 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenOfflineCompilerIsCreatedThenSuccessIsR
|
|||
}
|
||||
|
||||
TEST_F(OfflineCompilerTests, givenDeviceIdHexValueWhenInitHwInfoThenItHasCorrectlySetValues) {
|
||||
auto deviceId = oclocArgHelperWithoutInput->deviceProductTable[0].deviceId;
|
||||
if (oclocArgHelperWithoutInput->deviceProductTable.size() == 1 && deviceId == 0) {
|
||||
auto deviceAotInfo = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
|
||||
if (deviceAotInfo.empty()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
MockOfflineCompiler mockOfflineCompiler;
|
||||
std::stringstream deviceString, productString;
|
||||
auto deviceId = deviceAotInfo[0].deviceIds->front();
|
||||
deviceString << "0x" << std::hex << deviceId;
|
||||
|
||||
mockOfflineCompiler.argHelper->getPrinterRef() = MessagePrinter{true};
|
||||
|
@ -1049,15 +1050,17 @@ TEST_F(OfflineCompilerTests, givenDeviceIdHexValueWhenInitHwInfoThenItHasCorrect
|
|||
}
|
||||
|
||||
TEST_F(OfflineCompilerTests, givenProperDeviceIdHexAsDeviceArgumentThenSuccessIsReturned) {
|
||||
auto deviceId = oclocArgHelperWithoutInput->deviceProductTable[0].deviceId;
|
||||
if (oclocArgHelperWithoutInput->deviceProductTable.size() == 1 && deviceId == 0) {
|
||||
auto deviceAotInfo = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
|
||||
if (deviceAotInfo.empty()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
std::stringstream deviceString, productString;
|
||||
AOT::PRODUCT_CONFIG config = static_cast<AOT::PRODUCT_CONFIG>(deviceAotInfo[0].aotConfig.value);
|
||||
auto deviceId = deviceAotInfo[0].deviceIds->front();
|
||||
|
||||
productString << oclocArgHelperWithoutInput->productConfigHelper->getAcronymForProductConfig(config);
|
||||
deviceString << "0x" << std::hex << deviceId;
|
||||
productString << oclocArgHelperWithoutInput->deviceProductTable[0].product;
|
||||
|
||||
std::vector<std::string> argv = {
|
||||
"ocloc",
|
||||
|
@ -1095,7 +1098,7 @@ TEST_F(OfflineCompilerTests, givenIncorrectDeviceIdHexThenInvalidDeviceIsReturne
|
|||
|
||||
auto output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(nullptr, pOfflineCompiler);
|
||||
EXPECT_STREQ(output.c_str(), "Could not determine target based on device id: 0x0\nError: Cannot get HW Info for device 0x0.\n");
|
||||
EXPECT_STREQ(output.c_str(), "Could not determine device target: 0x0\nError: Cannot get HW Info for device 0x0.\n");
|
||||
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
|
||||
}
|
||||
|
||||
|
@ -2309,7 +2312,7 @@ TEST(OfflineCompilerTest, GivenUnsupportedDeviceConfigWhenInitHardwareInfoThenIn
|
|||
EXPECT_EQ(retVal, OclocErrorCode::INVALID_DEVICE);
|
||||
|
||||
auto output = testing::internal::GetCapturedStdout();
|
||||
resString << "Could not determine target based on product config: " << deviceName << "\n";
|
||||
resString << "Could not determine device target: " << deviceName << "\n";
|
||||
EXPECT_STREQ(output.c_str(), resString.str().c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -58,13 +58,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("")}}) {
|
||||
messagePrinter(hasOutput) {
|
||||
for (uint32_t i = 0; i < numSources; ++i) {
|
||||
inputs.push_back(Source(dataSources[i], static_cast<size_t>(lenSources[i]), nameSources[i]));
|
||||
}
|
||||
|
@ -156,24 +150,32 @@ std::unique_ptr<char[]> OclocArgHelper::loadDataFromFile(const std::string &file
|
|||
}
|
||||
}
|
||||
|
||||
bool OclocArgHelper::getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper) {
|
||||
bool OclocArgHelper::getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig, uint32_t deviceID, int revisionID, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper) {
|
||||
bool retVal = false;
|
||||
if (productConfig == AOT::UNKNOWN_ISA) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
const auto &deviceAotMap = productConfigHelper->getDeviceAotInfo();
|
||||
|
||||
for (auto &deviceConfig : deviceAotMap) {
|
||||
if (deviceConfig.aotConfig.value == productConfig) {
|
||||
hwInfo = *deviceConfig.hwInfo;
|
||||
if (hwInfoConfig) {
|
||||
setHwInfoValuesFromConfig(hwInfoConfig, hwInfo);
|
||||
}
|
||||
NEO::hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
|
||||
compilerProductHelper = NEO::CompilerProductHelper::create(hwInfo.platform.eProductFamily);
|
||||
UNRECOVERABLE_IF(compilerProductHelper == nullptr);
|
||||
compilerProductHelper->setProductConfigForHwInfo(hwInfo, deviceConfig.aotConfig);
|
||||
hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front();
|
||||
|
||||
if (deviceID) {
|
||||
hwInfo.platform.usDeviceID = deviceID;
|
||||
} else {
|
||||
compilerProductHelper->setProductConfigForHwInfo(hwInfo, deviceConfig.aotConfig);
|
||||
hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front();
|
||||
}
|
||||
if (revisionID != -1) {
|
||||
hwInfo.platform.usRevId = revisionID;
|
||||
}
|
||||
uint64_t config = hwInfoConfig ? hwInfoConfig : NEO::defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily];
|
||||
setHwInfoValuesFromConfig(config, hwInfo);
|
||||
NEO::hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
|
||||
|
||||
retVal = true;
|
||||
return retVal;
|
||||
|
@ -199,25 +201,4 @@ void OclocArgHelper::saveOutput(const std::string &filename, const std::ostream
|
|||
std::ofstream file(filename);
|
||||
file << ss.str();
|
||||
}
|
||||
}
|
||||
|
||||
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 "";
|
||||
}
|
|
@ -44,11 +44,6 @@ struct Output {
|
|||
Output(const std::string &name, const void *data, const size_t &size);
|
||||
};
|
||||
|
||||
struct DeviceProduct {
|
||||
unsigned short deviceId;
|
||||
std::string product;
|
||||
};
|
||||
|
||||
class OclocArgHelper {
|
||||
protected:
|
||||
std::vector<Source> inputs, headers;
|
||||
|
@ -59,7 +54,6 @@ class OclocArgHelper {
|
|||
uint64_t **lenOutputs = nullptr;
|
||||
bool hasOutput = false;
|
||||
MessagePrinter messagePrinter;
|
||||
const std::vector<DeviceProduct> deviceProductTable;
|
||||
void moveOutputs();
|
||||
Source *findSourceFile(const std::string &filename);
|
||||
bool sourceFileExists(const std::string &filename) const;
|
||||
|
@ -79,7 +73,7 @@ class OclocArgHelper {
|
|||
uint64_t **lenOutputs, char ***nameOutputs);
|
||||
virtual ~OclocArgHelper();
|
||||
MOCKABLE_VIRTUAL bool fileExists(const std::string &filename) const;
|
||||
bool getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper);
|
||||
bool getHwInfoForProductConfig(uint32_t productConfig, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig, uint32_t deviceID, int revisionID, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper);
|
||||
bool setAcronymForDeviceId(std::string &device);
|
||||
std::vector<std::string> headersToVectorOfStrings();
|
||||
MOCKABLE_VIRTUAL void readFileToVectorOfStrings(const std::string &filename, std::vector<std::string> &lines);
|
||||
|
@ -138,6 +132,5 @@ class OclocArgHelper {
|
|||
return os.str();
|
||||
}
|
||||
|
||||
std::string returnProductNameForDevice(unsigned short deviceId);
|
||||
std::unique_ptr<ProductConfigHelper> productConfigHelper;
|
||||
};
|
||||
|
|
|
@ -425,7 +425,7 @@ std::string &OfflineCompiler::getBuildLog() {
|
|||
return buildLog;
|
||||
}
|
||||
|
||||
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper) {
|
||||
int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper) {
|
||||
std::vector<PRODUCT_FAMILY> allSupportedProduct{ALL_SUPPORTED_PRODUCT_FAMILIES};
|
||||
std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower);
|
||||
|
||||
|
@ -435,9 +435,6 @@ 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);
|
||||
|
@ -450,31 +447,40 @@ int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceNam
|
|||
return INVALID_DEVICE;
|
||||
}
|
||||
|
||||
bool OfflineCompiler::isArgumentDeviceId(const std::string &argument) const {
|
||||
const char hexPrefixLength = 2;
|
||||
return argument.substr(0, hexPrefixLength) == "0x" && std::all_of(argument.begin() + hexPrefixLength, argument.end(), (::isxdigit));
|
||||
}
|
||||
|
||||
int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) {
|
||||
AOT::PRODUCT_CONFIG productConfig = AOT::UNKNOWN_ISA;
|
||||
ProductConfigHelper::adjustDeviceName(deviceName);
|
||||
uint32_t deviceID = 0;
|
||||
|
||||
if (deviceName.find(".") != std::string::npos) {
|
||||
productConfig = argHelper->productConfigHelper->getProductConfigForVersionValue(deviceName);
|
||||
if (productConfig == AOT::UNKNOWN_ISA) {
|
||||
argHelper->printf("Could not determine device target: %s\n", deviceName.c_str());
|
||||
}
|
||||
} else if (isArgumentDeviceId(deviceName)) {
|
||||
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 (productConfig != AOT::UNKNOWN_ISA) {
|
||||
if (argHelper->getHwInfoForProductConfig(productConfig, hwInfo, hwInfoConfig, std::move(compilerProductHelper))) {
|
||||
if (revisionId != -1) {
|
||||
hwInfo.platform.usRevId = revisionId;
|
||||
}
|
||||
deviceConfig = productConfig;
|
||||
productFamilyName = hardwarePrefix[hwInfo.platform.eProductFamily];
|
||||
return SUCCESS;
|
||||
if (argHelper->getHwInfoForProductConfig(productConfig, hwInfo, hwInfoConfig, deviceID, revisionId, std::move(compilerProductHelper))) {
|
||||
if (deviceID) {
|
||||
auto product = argHelper->productConfigHelper->getAcronymForProductConfig(productConfig);
|
||||
argHelper->printf("Auto-detected target based on %s device id: %s\n", deviceName.c_str(), product.c_str());
|
||||
}
|
||||
argHelper->printf("Could not determine target based on product config: %s\n", deviceName.c_str());
|
||||
deviceConfig = productConfig;
|
||||
productFamilyName = hardwarePrefix[hwInfo.platform.eProductFamily];
|
||||
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) {
|
||||
|
@ -483,21 +489,12 @@ int OfflineCompiler::initHardwareInfo(std::string deviceName) {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
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, std::move(compilerProductHelper));
|
||||
retVal = initHardwareInfoForDeprecatedAcronyms(deviceName, std::move(compilerProductHelper));
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -100,8 +100,8 @@ All supported acronyms: %s.
|
|||
|
||||
int initHardwareInfo(std::string deviceName);
|
||||
int initHardwareInfoForProductConfig(std::string deviceName);
|
||||
int initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper);
|
||||
|
||||
int initHardwareInfoForDeprecatedAcronyms(std::string deviceName, std::unique_ptr<NEO::CompilerProductHelper> &&compilerProductHelper);
|
||||
bool isArgumentDeviceId(const std::string &argument) const;
|
||||
std::string getStringWithinDelimiters(const std::string &src);
|
||||
int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles);
|
||||
int parseCommandLine(size_t numArgs, const std::vector<std::string> &allArgs);
|
||||
|
|
|
@ -74,6 +74,28 @@ AOT::FAMILY ProductConfigHelper::getFamilyForAcronym(const std::string &device)
|
|||
return it->second;
|
||||
}
|
||||
|
||||
const std::string ProductConfigHelper::getAcronymForProductConfig(AOT::PRODUCT_CONFIG config) const {
|
||||
auto it = std::find_if(deviceAotInfo.begin(), deviceAotInfo.end(), findProductConfig(config));
|
||||
if (it == deviceAotInfo.end()) {
|
||||
return {};
|
||||
}
|
||||
if (!it->deviceAcronyms.empty()) {
|
||||
return it->deviceAcronyms.front().str();
|
||||
} else if (!it->rtlIdAcronyms.empty()) {
|
||||
return it->rtlIdAcronyms.front().str();
|
||||
} else
|
||||
return parseMajorMinorRevisionValue(it->aotConfig);
|
||||
}
|
||||
|
||||
AOT::PRODUCT_CONFIG ProductConfigHelper::getProductConfigForDeviceId(unsigned short deviceId) const {
|
||||
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.value);
|
||||
}
|
||||
}
|
||||
return AOT::UNKNOWN_ISA;
|
||||
}
|
||||
|
||||
bool ProductConfigHelper::isRelease(const std::string &device) {
|
||||
auto release = getReleaseForAcronym(device);
|
||||
if (release == AOT::UNKNOWN_RELEASE) {
|
||||
|
|
|
@ -118,6 +118,8 @@ struct ProductConfigHelper {
|
|||
std::vector<NEO::ConstStringRef> getDeprecatedAcronyms();
|
||||
std::vector<NEO::ConstStringRef> getAllProductAcronyms();
|
||||
PRODUCT_FAMILY getProductFamilyForAcronym(const std::string &device) const;
|
||||
AOT::PRODUCT_CONFIG getProductConfigForDeviceId(unsigned short deviceId) const;
|
||||
const std::string getAcronymForProductConfig(AOT::PRODUCT_CONFIG config) const;
|
||||
|
||||
protected:
|
||||
std::vector<DeviceAotInfo> deviceAotInfo;
|
||||
|
|
|
@ -526,6 +526,41 @@ TEST_F(AotDeviceInfoTests, givenDeviceAcronymsOrProductConfigWhenGetProductFamil
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(AotDeviceInfoTests, givenDeviceIdWhenSearchForProductConfigAndDeviceAcronymThenCorrectResultsAreReturned) {
|
||||
auto &deviceAot = productConfigHelper->getDeviceAotInfo();
|
||||
if (deviceAot.empty()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
auto &product = deviceAot[0];
|
||||
std::string tmpStr("tmp");
|
||||
product.deviceAcronyms.insert(product.deviceAcronyms.begin(), NEO::ConstStringRef(tmpStr));
|
||||
|
||||
for (const auto &deviceId : *product.deviceIds) {
|
||||
auto config = productConfigHelper->getProductConfigForDeviceId(deviceId);
|
||||
EXPECT_EQ(config, product.aotConfig.value);
|
||||
auto name = productConfigHelper->getAcronymForProductConfig(config);
|
||||
EXPECT_EQ(name, tmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AotDeviceInfoTests, givenDeviceIdWhenSearchForProductConfigAndRtlIdAcronymThenCorrectResultsAreReturned) {
|
||||
auto &deviceAot = productConfigHelper->getDeviceAotInfo();
|
||||
if (deviceAot.empty()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
auto &product = deviceAot[0];
|
||||
product.deviceAcronyms.clear();
|
||||
std::string tmpStr("tmp");
|
||||
product.rtlIdAcronyms.insert(product.rtlIdAcronyms.begin(), NEO::ConstStringRef(tmpStr));
|
||||
|
||||
for (const auto &deviceId : *product.deviceIds) {
|
||||
auto config = productConfigHelper->getProductConfigForDeviceId(deviceId);
|
||||
EXPECT_EQ(config, product.aotConfig.value);
|
||||
auto name = productConfigHelper->getAcronymForProductConfig(config);
|
||||
EXPECT_EQ(name, tmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AotDeviceInfoTests, givenDeprecatedDeviceAcronymsWhenGetProductFamilyThenUnknownIsReturned) {
|
||||
auto deprecatedAcronyms = productConfigHelper->getDeprecatedAcronyms();
|
||||
for (const auto &acronym : deprecatedAcronyms) {
|
||||
|
@ -561,3 +596,48 @@ TEST_F(AotDeviceInfoTests, givenDeviceAcroynmsWhenSearchingForDeviceAcronymsForR
|
|||
EXPECT_TRUE(std::any_of(aotInfos.begin(), aotInfos.end(), ProductConfigHelper::findDeviceAcronymForRelease(it->release)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AotDeviceInfoTests, givenDeviceIdWhenThereAreNoAcronymsThenMajorMinorRevisionIsReturned) {
|
||||
auto &deviceAot = productConfigHelper->getDeviceAotInfo();
|
||||
if (deviceAot.empty()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
for (auto &device : deviceAot) {
|
||||
for (const auto &deviceId : *device.deviceIds) {
|
||||
auto config = productConfigHelper->getProductConfigForDeviceId(deviceId);
|
||||
EXPECT_NE(config, AOT::UNKNOWN_ISA);
|
||||
|
||||
device.deviceAcronyms.clear();
|
||||
device.rtlIdAcronyms.clear();
|
||||
auto name = productConfigHelper->getAcronymForProductConfig(config);
|
||||
auto expected = productConfigHelper->parseMajorMinorRevisionValue(config);
|
||||
EXPECT_STREQ(name.c_str(), expected.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue