Setting default device id for acronym

This PR includes:
- Move product config implementation from
ocloc arg helper to product config helper.
- Add default device id setting for each platform configuration.
- Add & move hw info config tests from opencl to shared

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
Related-To: NEO-7112
This commit is contained in:
Daria Hinz
2022-07-08 11:29:59 +00:00
committed by Compute-Runtime-Automation
parent 05ad32704b
commit 01af53b63c
100 changed files with 1773 additions and 694 deletions

View File

@ -63,7 +63,6 @@ set(IGDRCL_SRCS_offline_compiler_tests
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_iga_dll.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_iga_dll.h
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_api_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_arg_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_concat_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.h

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

@ -215,7 +215,7 @@ TEST(OclocApiTests, givenUnknownAcronymWhenIdsCommandIsInvokeThenErrorIsReported
TEST(OclocApiTests, WhenGoodFamilyNameIsProvidedThenSuccessIsReturned) {
std::string clFileName(clFiles + "copybuffer.cl");
std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
auto allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs();
auto allSupportedDeviceConfigs = argHelper->productConfigHelper->getDeviceAotInfo();
if (allSupportedDeviceConfigs.empty()) {
GTEST_SKIP();
}

View File

@ -20,6 +20,7 @@
#include "environment.h"
#include "mock/mock_argument_helper.h"
#include "mock/mock_offline_compiler.h"
#include "platforms.h"
#include <algorithm>
#include <unordered_set>
@ -53,7 +54,7 @@ auto allFilesInArchiveExceptPaddingStartsWith(const Ar::Ar &archive, const Const
}
std::string getDeviceConfig(const OfflineCompiler &offlineCompiler, MockOclocArgHelper *argHelper) {
auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = argHelper->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
return {};
}
@ -68,7 +69,7 @@ std::string getDeviceConfig(const OfflineCompiler &offlineCompiler, MockOclocArg
}
std::string prepareTwoDevices(MockOclocArgHelper *argHelper) {
auto enabledProductsAcronyms = argHelper->getEnabledProductAcronyms();
auto enabledProductsAcronyms = argHelper->productConfigHelper->getRepresentativeProductAcronyms();
if (enabledProductsAcronyms.size() < 2) {
return {};
}
@ -90,7 +91,7 @@ void appendAcronymWithoutDashes(std::vector<std::string> &out, ConstStringRef ac
}
std::vector<std::string> prepareProductsWithoutDashes(OclocArgHelper *argHelper) {
auto enabledProductsAcronyms = argHelper->getEnabledProductAcronyms();
auto enabledProductsAcronyms = argHelper->productConfigHelper->getRepresentativeProductAcronyms();
if (enabledProductsAcronyms.size() < 2) {
return {};
}
@ -104,7 +105,7 @@ std::vector<std::string> prepareProductsWithoutDashes(OclocArgHelper *argHelper)
}
std::vector<std::string> prepareReleasesWithoutDashes(OclocArgHelper *argHelper) {
auto enabledReleasesAcronyms = argHelper->getEnabledReleasesAcronyms();
auto enabledReleasesAcronyms = argHelper->productConfigHelper->getReleasesAcronyms();
if (enabledReleasesAcronyms.size() < 2) {
return {};
}
@ -118,7 +119,7 @@ std::vector<std::string> prepareReleasesWithoutDashes(OclocArgHelper *argHelper)
}
std::vector<std::string> prepareFamiliesWithoutDashes(OclocArgHelper *argHelper) {
auto enabledFamiliesAcronyms = argHelper->getEnabledFamiliesAcronyms();
auto enabledFamiliesAcronyms = argHelper->productConfigHelper->getFamiliesAcronyms();
if (enabledFamiliesAcronyms.size() < 2) {
return {};
}
@ -143,9 +144,15 @@ TEST(OclocFatBinaryRequestedFatBinary, WhenDeviceArgMissingThenReturnsFalse) {
EXPECT_FALSE(NEO::requestedFatBinary(4, args, argHelper.get()));
}
TEST(OclocFatBinaryRequestedFatBinary, givenHwInfoForProductConfigWhenUnknownIsaIsPassedThenFalseIsReturned) {
std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
NEO::HardwareInfo hwInfo;
EXPECT_FALSE(argHelper->getHwInfoForProductConfig(AOT::UNKNOWN_ISA, hwInfo, 0u));
}
TEST(OclocFatBinaryRequestedFatBinary, givenReleaseOrFamilyAcronymWhenGetAcronymsForTargetThenCorrectValuesAreReturned) {
std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
auto &enabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs();
auto &enabledDeviceConfigs = argHelper->productConfigHelper->getDeviceAotInfo();
if (enabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
@ -177,7 +184,7 @@ TEST(OclocFatBinaryRequestedFatBinary, givenReleaseOrFamilyAcronymWhenGetAcronym
TEST(OclocFatBinaryRequestedFatBinary, givenDeviceArgToFatBinaryWhenConfigIsNotFullThenFalseIsReturned) {
std::unique_ptr<OclocArgHelper> argHelper = std::make_unique<OclocArgHelper>();
auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = argHelper->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
@ -186,11 +193,12 @@ TEST(OclocFatBinaryRequestedFatBinary, givenDeviceArgToFatBinaryWhenConfigIsNotF
std::stringstream majorString;
majorString << aotConfig.ProductConfigID.Major;
auto major = majorString.str();
auto aotValue0 = argHelper->getProductConfigForVersionValue(major);
auto aotValue0 = argHelper->productConfigHelper->getProductConfigForVersionValue(major);
EXPECT_EQ(aotValue0, AOT::UNKNOWN_ISA);
auto majorMinor = ProductConfigHelper::parseMajorMinorValue(aotConfig);
auto aotValue1 = argHelper->getProductConfigForVersionValue(majorMinor);
auto aotValue1 = argHelper->productConfigHelper->getProductConfigForVersionValue(majorMinor);
EXPECT_EQ(aotValue1, AOT::UNKNOWN_ISA);
const char *cutRevision[] = {"ocloc", "-device", majorMinor.c_str()};
@ -225,7 +233,7 @@ TEST(OclocFatBinaryRequestedFatBinary, givenDeviceArgProvidedWhenFatBinaryFormat
}
TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceArgAsSingleProductThenFatBinaryIsNotRequested) {
auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
for (const auto &deviceConfig : allEnabledDeviceConfigs) {
std::string configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.aotConfig);
@ -241,7 +249,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceArgAsSingleProductThenFatB
}
TEST_F(OclocFatBinaryProductAcronymsTests, givenAsterixThenReturnAllEnabledAcronyms) {
auto expected = oclocArgHelperWithoutInput->getEnabledProductAcronyms();
auto expected = oclocArgHelperWithoutInput->productConfigHelper->getRepresentativeProductAcronyms();
auto got = NEO::getTargetProductsForFatbinary("*", oclocArgHelperWithoutInput.get());
EXPECT_EQ(got.size(), expected.size());
@ -445,7 +453,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoSameReleaseTargetsWhenGetProd
auto acronym = enabledReleasesAcronyms[0];
std::vector<ConstStringRef> acronyms{};
auto release = ProductConfigHelper::returnReleaseForAcronym(acronym.str());
auto release = ProductConfigHelper::getReleaseForAcronym(acronym.str());
getProductsAcronymsForTarget(acronyms, release, oclocArgHelperWithoutInput.get());
auto expectedSize = acronyms.size();
getProductsAcronymsForTarget(acronyms, release, oclocArgHelperWithoutInput.get());
@ -460,7 +468,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoSameFamilyTargetsWhenGetProdu
auto acronym = enabledFamiliesAcronyms[0];
std::vector<ConstStringRef> acronyms{};
auto family = ProductConfigHelper::returnFamilyForAcronym(acronym.str());
auto family = ProductConfigHelper::getFamilyForAcronym(acronym.str());
getProductsAcronymsForTarget(acronyms, family, oclocArgHelperWithoutInput.get());
auto expectedSize = acronyms.size();
getProductsAcronymsForTarget(acronyms, family, oclocArgHelperWithoutInput.get());
@ -475,8 +483,8 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenReleasesAcronymsWithoutDashesWhe
}
std::vector<ConstStringRef> expected{};
auto release0 = ProductConfigHelper::returnReleaseForAcronym(acronyms[0]);
auto release1 = ProductConfigHelper::returnReleaseForAcronym(acronyms[1]);
auto release0 = ProductConfigHelper::getReleaseForAcronym(acronyms[0]);
auto release1 = ProductConfigHelper::getReleaseForAcronym(acronyms[1]);
getProductsAcronymsForTarget(expected, release0, oclocArgHelperWithoutInput.get());
getProductsAcronymsForTarget(expected, release1, oclocArgHelperWithoutInput.get());
@ -492,8 +500,8 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenFamiliesAcronymsWithoutDashesWhe
}
std::vector<ConstStringRef> expected{};
auto family0 = ProductConfigHelper::returnFamilyForAcronym(acronyms[0]);
auto family1 = ProductConfigHelper::returnFamilyForAcronym(acronyms[1]);
auto family0 = ProductConfigHelper::getFamilyForAcronym(acronyms[0]);
auto family1 = ProductConfigHelper::getFamilyForAcronym(acronyms[1]);
getProductsAcronymsForTarget(expected, family0, oclocArgHelperWithoutInput.get());
getProductsAcronymsForTarget(expected, family1, oclocArgHelperWithoutInput.get());
@ -511,8 +519,8 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfReleasesWhenFatBinar
auto acronym1 = enabledReleasesAcronyms.at(product + 1);
std::vector<ConstStringRef> expected{};
auto release0 = ProductConfigHelper::returnReleaseForAcronym(acronym0.str());
auto release1 = ProductConfigHelper::returnReleaseForAcronym(acronym1.str());
auto release0 = ProductConfigHelper::getReleaseForAcronym(acronym0.str());
auto release1 = ProductConfigHelper::getReleaseForAcronym(acronym1.str());
getProductsAcronymsForTarget(expected, release0, oclocArgHelperWithoutInput.get());
getProductsAcronymsForTarget(expected, release1, oclocArgHelperWithoutInput.get());
@ -552,8 +560,8 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfFamiliesWhenFatBinar
auto acronym1 = enabledFamiliesAcronyms.at(product + 1);
std::vector<ConstStringRef> expected{};
auto family0 = ProductConfigHelper::returnFamilyForAcronym(acronym0.str());
auto family1 = ProductConfigHelper::returnFamilyForAcronym(acronym1.str());
auto family0 = ProductConfigHelper::getFamilyForAcronym(acronym0.str());
auto family1 = ProductConfigHelper::getFamilyForAcronym(acronym1.str());
getProductsAcronymsForTarget(expected, family0, oclocArgHelperWithoutInput.get());
getProductsAcronymsForTarget(expected, family1, oclocArgHelperWithoutInput.get());
@ -671,8 +679,8 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenReleasesClosedRangeWithoutDashes
if (acronyms.size() < 2) {
GTEST_SKIP();
}
auto releaseFromIt = ProductConfigHelper::returnReleaseForAcronym(acronyms[0]);
auto releaseToIt = ProductConfigHelper::returnReleaseForAcronym(acronyms[1]);
auto releaseFromIt = ProductConfigHelper::getReleaseForAcronym(acronyms[0]);
auto releaseToIt = ProductConfigHelper::getReleaseForAcronym(acronyms[1]);
if (releaseFromIt > releaseToIt) {
std::swap(releaseFromIt, releaseToIt);
@ -694,8 +702,8 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenFamiliesClosedRangeWithoutDashes
GTEST_SKIP();
}
auto familyFromIt = ProductConfigHelper::returnFamilyForAcronym(acronyms[0]);
auto familyToIt = ProductConfigHelper::returnFamilyForAcronym(acronyms[1]);
auto familyFromIt = ProductConfigHelper::getFamilyForAcronym(acronyms[0]);
auto familyToIt = ProductConfigHelper::getFamilyForAcronym(acronyms[1]);
if (familyFromIt > familyToIt) {
std::swap(familyFromIt, familyToIt);
@ -723,8 +731,8 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenFamiliesClosedRangeWhenFatBinary
auto acronymFrom = enabledFamiliesAcronyms.at(family);
auto acronymTo = enabledFamiliesAcronyms.at(enabledFamiliesAcronyms.size() / 2);
auto familyFromIt = ProductConfigHelper::returnFamilyForAcronym(acronymFrom.str());
auto familyToIt = ProductConfigHelper::returnFamilyForAcronym(acronymTo.str());
auto familyFromIt = ProductConfigHelper::getFamilyForAcronym(acronymFrom.str());
auto familyToIt = ProductConfigHelper::getFamilyForAcronym(acronymTo.str());
if (familyFromIt > familyToIt) {
std::swap(familyFromIt, familyToIt);
@ -870,7 +878,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromReleaseWithoutDashe
}
std::vector<ConstStringRef> expected{};
auto releaseFromId = ProductConfigHelper::returnReleaseForAcronym(acronyms[0]);
auto releaseFromId = ProductConfigHelper::getReleaseForAcronym(acronyms[0]);
auto releaseToId = AOT::RELEASE_MAX;
while (releaseFromId < releaseToId) {
getProductsAcronymsForTarget(expected, releaseFromId, oclocArgHelperWithoutInput.get());
@ -890,7 +898,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromReleaseWhenFatBinar
for (const auto &release : enabledReleasesAcronyms) {
std::vector<ConstStringRef> expected{};
auto releaseFromId = ProductConfigHelper::returnReleaseForAcronym(release.str());
auto releaseFromId = ProductConfigHelper::getReleaseForAcronym(release.str());
auto releaseToId = AOT::RELEASE_MAX;
while (releaseFromId < releaseToId) {
getProductsAcronymsForTarget(expected, releaseFromId, oclocArgHelperWithoutInput.get());
@ -932,7 +940,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeToReleaseWhenFatBinaryB
std::vector<ConstStringRef> expected{};
auto releaseFromId = static_cast<AOT::RELEASE>(static_cast<unsigned int>(AOT::UNKNOWN_RELEASE) + 1);
auto releaseToId = ProductConfigHelper::returnReleaseForAcronym(release.str());
auto releaseToId = ProductConfigHelper::getReleaseForAcronym(release.str());
while (releaseFromId <= releaseToId) {
getProductsAcronymsForTarget(expected, releaseFromId, oclocArgHelperWithoutInput.get());
@ -972,7 +980,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromFamilyWithoutDashes
}
std::vector<ConstStringRef> expected{};
auto familyFromId = ProductConfigHelper::returnFamilyForAcronym(acronyms[0]);
auto familyFromId = ProductConfigHelper::getFamilyForAcronym(acronyms[0]);
auto familyToId = AOT::FAMILY_MAX;
while (familyFromId < familyToId) {
getProductsAcronymsForTarget(expected, familyFromId, oclocArgHelperWithoutInput.get());
@ -992,7 +1000,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromFamilyWhenFatBinary
for (const auto &family : enabledFamiliesAcronyms) {
std::vector<ConstStringRef> expected{};
auto familyFromId = ProductConfigHelper::returnFamilyForAcronym(family.str());
auto familyFromId = ProductConfigHelper::getFamilyForAcronym(family.str());
auto familyToId = AOT::FAMILY_MAX;
while (familyFromId < familyToId) {
getProductsAcronymsForTarget(expected, familyFromId, oclocArgHelperWithoutInput.get());
@ -1034,7 +1042,7 @@ TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeToFamilyWhenFatBinaryBu
std::vector<ConstStringRef> expected{};
auto familyFromId = static_cast<AOT::FAMILY>(static_cast<unsigned int>(AOT::UNKNOWN_FAMILY) + 1);
auto familyToId = ProductConfigHelper::returnFamilyForAcronym(family.str());
auto familyToId = ProductConfigHelper::getFamilyForAcronym(family.str());
while (familyFromId <= familyToId) {
getProductsAcronymsForTarget(expected, familyFromId, oclocArgHelperWithoutInput.get());

View File

@ -17,7 +17,7 @@
namespace NEO {
class OclocEnabledAcronyms : public ::testing::Test {
public:
std::vector<DeviceMapping> enabledProducts{};
std::vector<DeviceAotInfo> enabledProducts{};
std::vector<ConstStringRef> enabledProductsAcronyms{};
std::vector<ConstStringRef> enabledFamiliesAcronyms{};
std::vector<ConstStringRef> enabledReleasesAcronyms{};
@ -29,10 +29,10 @@ class OclocFatBinaryProductAcronymsTests : public OclocEnabledAcronyms {
oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>();
oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{true};
enabledProducts = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs();
enabledProductsAcronyms = oclocArgHelperWithoutInput->getEnabledProductAcronyms();
enabledFamiliesAcronyms = oclocArgHelperWithoutInput->getEnabledFamiliesAcronyms();
enabledReleasesAcronyms = oclocArgHelperWithoutInput->getEnabledReleasesAcronyms();
enabledProducts = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
enabledProductsAcronyms = oclocArgHelperWithoutInput->productConfigHelper->getRepresentativeProductAcronyms();
enabledFamiliesAcronyms = oclocArgHelperWithoutInput->productConfigHelper->getFamiliesAcronyms();
enabledReleasesAcronyms = oclocArgHelperWithoutInput->productConfigHelper->getReleasesAcronyms();
}
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput;
@ -44,10 +44,10 @@ class OclocFatBinaryTest : public OclocEnabledAcronyms {
mockArgHelperFilesMap[spirvFilename] = spirvFileContent;
mockArgHelper.interceptOutput = true;
enabledProducts = mockArgHelper.getAllSupportedDeviceConfigs();
enabledProductsAcronyms = mockArgHelper.getEnabledProductAcronyms();
enabledFamiliesAcronyms = mockArgHelper.getEnabledFamiliesAcronyms();
enabledReleasesAcronyms = mockArgHelper.getEnabledReleasesAcronyms();
enabledProducts = mockArgHelper.productConfigHelper->getDeviceAotInfo();
enabledProductsAcronyms = mockArgHelper.productConfigHelper->getRepresentativeProductAcronyms();
enabledFamiliesAcronyms = mockArgHelper.productConfigHelper->getFamiliesAcronyms();
enabledReleasesAcronyms = mockArgHelper.productConfigHelper->getReleasesAcronyms();
}
protected:

View File

@ -13,13 +13,11 @@ namespace NEO {
TEST_P(OclocProductConfigTests, GivenProductConfigValuesWhenInitHardwareInfoThenCorrectValuesAreSet) {
auto deviceId = 0u;
auto revId = 0u;
auto allSupportedDeviceConfigs = mockOfflineCompiler->argHelper->getAllSupportedDeviceConfigs();
auto allSupportedConfigs = mockOfflineCompiler->argHelper->productConfigHelper->getDeviceAotInfo();
for (const auto &deviceConfig : allSupportedDeviceConfigs) {
for (const auto &deviceConfig : allSupportedConfigs) {
if (aotConfig.ProductConfig == deviceConfig.aotConfig.ProductConfig) {
if (deviceConfig.deviceIds) {
deviceId = deviceConfig.deviceIds->front();
}
deviceId = deviceConfig.deviceIds->front();
revId = deviceConfig.aotConfig.ProductConfigID.Revision;
break;
}

View File

@ -91,32 +91,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

@ -29,6 +29,7 @@
#include "mock/mock_argument_helper.h"
#include "mock/mock_multi_command.h"
#include "mock/mock_offline_compiler.h"
#include "platforms.h"
#include <algorithm>
#include <array>
@ -185,7 +186,7 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWhenBuildingMultiCommandThenSuc
}
TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWithProductConfigValueWhenBuildingMultiCommandThenSuccessIsReturned) {
auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
@ -522,7 +523,7 @@ TEST(MultiCommandWhiteboxTest, GivenInvalidArgsWhenInitializingThenErrorIsReturn
using MockOfflineCompilerTests = ::testing::Test;
TEST_F(MockOfflineCompilerTests, givenProductConfigValueAndRevisionIdWhenInitHwInfoThenTheseValuesAreSet) {
MockOfflineCompiler mockOfflineCompiler;
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
@ -546,7 +547,7 @@ TEST_F(MockOfflineCompilerTests, givenProductConfigValueAndRevisionIdWhenInitHwI
TEST_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenBaseHardwareInfoValuesAreSet) {
MockOfflineCompiler mockOfflineCompiler;
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
@ -569,7 +570,7 @@ TEST_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenBaseHa
TEST_F(MockOfflineCompilerTests, givenDeprecatedAcronymsWithRevisionWhenInitHwInfoThenValuesAreSetAndSuccessIsReturned) {
MockOfflineCompiler mockOfflineCompiler;
auto deprecatedAcronyms = mockOfflineCompiler.argHelper->getDeprecatedAcronyms();
auto deprecatedAcronyms = mockOfflineCompiler.argHelper->productConfigHelper->getDeprecatedAcronyms();
if (deprecatedAcronyms.empty()) {
GTEST_SKIP();
}
@ -584,7 +585,7 @@ TEST_F(MockOfflineCompilerTests, givenDeprecatedAcronymsWithRevisionWhenInitHwIn
TEST_F(MockOfflineCompilerTests, givenHwInfoConfigWhenSetHwInfoForProductConfigThenCorrectValuesAreSet) {
MockOfflineCompiler mockOfflineCompiler;
auto enabledProductAcronyms = mockOfflineCompiler.argHelper->getEnabledProductAcronyms();
auto enabledProductAcronyms = mockOfflineCompiler.argHelper->productConfigHelper->getRepresentativeProductAcronyms();
if (enabledProductAcronyms.empty()) {
GTEST_SKIP();
}
@ -610,7 +611,7 @@ TEST_F(MockOfflineCompilerTests, givenHwInfoConfigWhenSetHwInfoForProductConfigT
TEST_F(MockOfflineCompilerTests, givenHwInfoConfigWhenSetHwInfoForDeprecatedAcronymsThenCorrectValuesAreSet) {
MockOfflineCompiler mockOfflineCompiler;
auto deprecatedAcronyms = mockOfflineCompiler.argHelper->getDeprecatedAcronyms();
auto deprecatedAcronyms = mockOfflineCompiler.argHelper->productConfigHelper->getDeprecatedAcronyms();
if (deprecatedAcronyms.empty()) {
GTEST_SKIP();
}
@ -635,7 +636,7 @@ TEST_F(MockOfflineCompilerTests, givenHwInfoConfigWhenSetHwInfoForDeprecatedAcro
TEST_F(MockOfflineCompilerTests, givenAcronymWithUppercaseWhenInitHwInfoThenSuccessIsReturned) {
MockOfflineCompiler mockOfflineCompiler;
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
@ -658,7 +659,7 @@ TEST_F(MockOfflineCompilerTests, givenAcronymWithUppercaseWhenInitHwInfoThenSucc
TEST_F(MockOfflineCompilerTests, givenDeprecatedAcronymsWithUppercaseWhenInitHwInfoThenSuccessIsReturned) {
MockOfflineCompiler mockOfflineCompiler;
auto deprecatedAcronyms = mockOfflineCompiler.argHelper->getDeprecatedAcronyms();
auto deprecatedAcronyms = mockOfflineCompiler.argHelper->productConfigHelper->getDeprecatedAcronyms();
if (deprecatedAcronyms.empty()) {
GTEST_SKIP();
}
@ -672,7 +673,7 @@ TEST_F(MockOfflineCompilerTests, givenDeprecatedAcronymsWithUppercaseWhenInitHwI
HWTEST2_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenMaxDualSubSlicesSupportedIsSet, IsAtLeastGen12lp) {
MockOfflineCompiler mockOfflineCompiler;
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
@ -728,14 +729,14 @@ All supported acronyms: )===";
}
TEST_F(OfflineCompilerTests, givenFamilyAcronymWhenIdsCommandIsInvokeThenSuccessAndCorrectIdsAreReturned) {
auto enabledFamilies = oclocArgHelperWithoutInput->getEnabledFamiliesAcronyms();
auto enabledFamilies = oclocArgHelperWithoutInput->productConfigHelper->getFamiliesAcronyms();
if (enabledFamilies.empty()) {
GTEST_SKIP();
}
auto supportedDevicesConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs();
auto supportedDevicesConfigs = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
for (const auto &familyAcronym : enabledFamilies) {
std::vector<std::string> expected{};
auto family = ProductConfigHelper::returnFamilyForAcronym(familyAcronym.str());
auto family = ProductConfigHelper::getFamilyForAcronym(familyAcronym.str());
for (const auto &device : supportedDevicesConfigs) {
if (device.family == family) {
auto config = ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig);
@ -762,14 +763,14 @@ TEST_F(OfflineCompilerTests, givenFamilyAcronymWhenIdsCommandIsInvokeThenSuccess
}
TEST_F(OfflineCompilerTests, givenReleaseAcronymWhenIdsCommandIsInvokeThenSuccessAndCorrectIdsAreReturned) {
auto enabledReleases = oclocArgHelperWithoutInput->getEnabledReleasesAcronyms();
auto enabledReleases = oclocArgHelperWithoutInput->productConfigHelper->getReleasesAcronyms();
if (enabledReleases.empty()) {
GTEST_SKIP();
}
auto supportedDevicesConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs();
auto supportedDevicesConfigs = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
for (const auto &releaseAcronym : enabledReleases) {
std::vector<std::string> expected{};
auto release = ProductConfigHelper::returnReleaseForAcronym(releaseAcronym.str());
auto release = ProductConfigHelper::getReleaseForAcronym(releaseAcronym.str());
for (const auto &device : supportedDevicesConfigs) {
if (device.release == release) {
auto config = ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig);
@ -796,14 +797,14 @@ TEST_F(OfflineCompilerTests, givenReleaseAcronymWhenIdsCommandIsInvokeThenSucces
}
TEST_F(OfflineCompilerTests, givenProductAcronymWhenIdsCommandIsInvokeThenSuccessAndCorrectIdsAreReturned) {
auto enabledProducts = oclocArgHelperWithoutInput->getEnabledProductAcronyms();
auto enabledProducts = oclocArgHelperWithoutInput->productConfigHelper->getAllProductAcronyms();
if (enabledProducts.empty()) {
GTEST_SKIP();
}
auto supportedDevicesConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs();
auto supportedDevicesConfigs = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
for (const auto &productAcronym : enabledProducts) {
std::vector<std::string> expected{};
auto product = ProductConfigHelper::returnProductConfigForAcronym(productAcronym.str());
auto product = ProductConfigHelper::getProductConfigForAcronym(productAcronym.str());
for (const auto &device : supportedDevicesConfigs) {
if (device.aotConfig.ProductConfig == product) {
auto config = ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig);
@ -1027,10 +1028,11 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenOfflineCompilerIsCreatedThenSuccessIsR
}
TEST_F(OfflineCompilerTests, givenDeviceIdHexValueWhenInitHwInfoThenItHasCorrectlySetValues) {
auto deviceId = oclocArgHelperWithoutInput->deviceProductTable[0].deviceId;
if (oclocArgHelperWithoutInput->deviceProductTable.size() == 1 && deviceId == 0) {
auto deviceAot = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
if (deviceAot.empty()) {
GTEST_SKIP();
}
auto deviceId = deviceAot[0].deviceIds->front();
MockOfflineCompiler mockOfflineCompiler;
std::stringstream deviceString, productString;
@ -1042,13 +1044,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;
auto deviceId = deviceAotInfo[0].deviceIds->front();
deviceString << "0x" << std::hex << deviceId;
productString << oclocArgHelperWithoutInput->deviceProductTable[0].product;
config = static_cast<AOT::PRODUCT_CONFIG>(deviceAotInfo[0].aotConfig.ProductConfig);
productString << oclocArgHelperWithoutInput->productConfigHelper->getAcronymForProductConfig(config);
std::vector<std::string> argv = {
"ocloc",
@ -1086,7 +1092,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);
}
@ -1182,11 +1188,10 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenPassedValuesAreOutOfRangeT
TEST_F(OfflineCompilerTests, givenInitHardwareInfowhenDeviceConfigContainsDeviceIdsThenSetFirstDeviceId) {
MockOfflineCompiler mockOfflineCompiler;
auto &allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs();
auto &allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
GTEST_SKIP();
}
std::vector<unsigned short> deviceIdsForTests = {0xfffd, 0xfffe, 0xffff};
for (auto &deviceMapConfig : allEnabledDeviceConfigs) {
@ -1622,7 +1627,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingThenBuildSucceeds) {
}
TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceConfigValueThenBuildSucceeds) {
auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs();
auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->productConfigHelper->getDeviceAotInfo();
if (allEnabledDeviceConfigs.empty()) {
return;
}
@ -1962,7 +1967,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());
}
@ -3293,39 +3298,6 @@ TEST(OclocArgHelperTest, GivenNoOutputPrintMessages) {
EXPECT_STREQ(printMsg.data(), capturedStdout.c_str());
}
TEST(OclocArgHelperTest, GivenDifferentAotConfigsInDeviceMappingsWhenComparingThemThenFalseIsReturned) {
DeviceMapping lhs{};
DeviceMapping rhs{};
ASSERT_TRUE(lhs == rhs);
lhs.aotConfig = {AOT::CONFIG_MAX_PLATFORM};
rhs.aotConfig = {AOT::UNKNOWN_ISA};
EXPECT_FALSE(lhs == rhs);
}
TEST(OclocArgHelperTest, GivenDifferentFamiliesInDeviceMappingsWhenComparingThemThenFalseIsReturned) {
DeviceMapping lhs{};
DeviceMapping rhs{};
ASSERT_TRUE(lhs == rhs);
lhs.family = AOT::FAMILY_MAX;
rhs.family = AOT::UNKNOWN_FAMILY;
EXPECT_FALSE(lhs == rhs);
}
TEST(OclocArgHelperTest, GivenDifferentReleasesInDeviceMappingsWhenComparingThemThenFalseIsReturned) {
DeviceMapping lhs{};
DeviceMapping rhs{};
ASSERT_TRUE(lhs == rhs);
lhs.release = AOT::RELEASE_MAX;
rhs.release = AOT::UNKNOWN_RELEASE;
EXPECT_FALSE(lhs == rhs);
}
TEST(OclocArgHelperTest, GivenValidHeaderFileWhenRequestingHeadersAsVectorOfStringsThenLinesAreStored) {
const char input[] = "First\nSecond\nThird";
const auto inputLength{sizeof(input)};