Use device ID from ProductConfigHelper

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.

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
Related-To: NEO-7487
This commit is contained in:
Daria Hinz
2022-11-07 14:22:31 +01:00
committed by Compute-Runtime-Automation
parent a30cc94708
commit 60a8bcb3d7
10 changed files with 121 additions and 95 deletions

View File

@ -19,7 +19,6 @@
class MockOclocArgHelper : public OclocArgHelper {
public:
using OclocArgHelper::deviceProductTable;
using OclocArgHelper::hasOutput;
using OclocArgHelper::headers;
using OclocArgHelper::inputs;

View File

@ -102,26 +102,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());
}
}

View File

@ -1031,13 +1031,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};
@ -1046,15 +1047,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.ProductConfig);
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",
@ -1092,7 +1095,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);
}
@ -2301,7 +2304,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());
}