From 6d365cbfc37a981894de2c45940196eccdca618e Mon Sep 17 00:00:00 2001 From: Daria Hinz Date: Mon, 13 Jun 2022 23:13:43 +0000 Subject: [PATCH] Ocloc: New AOT design implementation Ocloc will handle any new values that may be passed to the -device argument. Supported acronyms are available under cmd: ocloc compile --help Supported patterns: - device acronym - release acronym - family acronym - version (major.minor.revision) Fatbinary will no longer handle major.minor.revision variances, only acronyms allowed. Signed-off-by: Daria Hinz --- CMakeLists.txt | 6 + .../unit_tests/sources/module/test_module.cpp | 7 +- .../unit_test/offline_compiler/CMakeLists.txt | 1 + .../mock/mock_offline_compiler.h | 3 + .../offline_compiler/ocloc_api_tests.cpp | 21 +- .../ocloc_arg_helper_tests.cpp | 137 ++ .../ocloc_fatbinary_tests.cpp | 1612 +++++++---------- .../offline_compiler/ocloc_fatbinary_tests.h | 26 +- .../ocloc_product_config_tests.cpp | 6 +- .../ocloc_product_config_tests.h | 6 +- .../offline_compiler_tests.cpp | 139 +- .../pvc/offline_compiler_tests_pvc.cpp | 12 +- .../dg2/offline_compiler_tests_dg2.cpp | 9 +- shared/offline_compiler/source/CMakeLists.txt | 9 +- .../source/decoder/binary_decoder.cpp | 2 +- .../source/decoder/binary_encoder.cpp | 2 +- .../source/ocloc_arg_helper.cpp | 236 +-- .../source/ocloc_arg_helper.h | 60 +- .../source/ocloc_fatbinary.cpp | 478 ++--- .../offline_compiler/source/ocloc_fatbinary.h | 16 +- .../source/offline_compiler.cpp | 230 ++- .../source/offline_compiler.h | 9 +- .../device_binary_format_ar.cpp | 4 +- .../device_binary_formats.cpp | 2 +- .../device_binary_formats.h | 2 +- shared/source/dll/devices/platforms.h | 45 - .../dll/devices/product_config_base.inl | 61 +- .../ehl/os_agnostic_hw_info_config_ehl.inl | 4 +- shared/source/gen11/enable_gen11.cpp | 1 + .../os_agnostic_hw_info_config_icllp.inl | 4 +- .../lkf/os_agnostic_hw_info_config_lkf.inl | 4 +- .../adln/os_agnostic_hw_info_config_adln.inl | 4 +- .../adlp/os_agnostic_hw_info_config_adlp.inl | 4 +- .../adls/os_agnostic_hw_info_config_adls.inl | 4 +- .../dg1/os_agnostic_hw_info_config_dg1.inl | 4 +- shared/source/gen12lp/enable_gen12lp.cpp | 1 + .../rkl/os_agnostic_hw_info_config_rkl.inl | 4 +- .../os_agnostic_hw_info_config_tgllp.inl | 4 +- .../bdw/os_agnostic_hw_info_config_bdw.inl | 4 +- shared/source/gen8/enable_gen8.cpp | 1 + .../bxt/os_agnostic_hw_info_config_bxt.inl | 4 +- .../cfl/os_agnostic_hw_info_config_cfl.inl | 4 +- shared/source/gen9/enable_gen9.cpp | 1 + .../glk/os_agnostic_hw_info_config_glk.inl | 4 +- .../kbl/os_agnostic_hw_info_config_kbl.inl | 4 +- .../skl/os_agnostic_hw_info_config_skl.inl | 4 +- shared/source/helpers/CMakeLists.txt | 2 + .../compiler_aot_config_bdw_and_later.inl | 17 + .../source/helpers/compiler_hw_info_config.h | 3 + shared/source/helpers/constants.h | 1 + .../source/helpers/product_config_helper.cpp | 50 + shared/source/helpers/product_config_helper.h | 54 +- shared/source/os_interface/hw_info_config.h | 4 +- .../source/xe_hp_core/enable_xe_hp_core.cpp | 1 + .../os_agnostic_hw_info_config_xe_hp_core.inl | 4 +- .../source/xe_hpc_core/enable_xe_hpc_core.cpp | 1 + .../pvc/os_agnostic_hw_info_config_pvc.inl | 22 +- .../os_agnostic_hw_info_config_dg2_extra.inl | 32 +- .../dg2/os_agnostic_hw_info_config_dg2.inl | 6 +- .../source/xe_hpg_core/enable_xe_hpg_core.cpp | 1 + .../common/fixtures/product_config_fixture.h | 27 +- .../test/common/mocks/mock_hw_info_config.cpp | 4 +- .../common/xe_hpc_core/pvc/CMakeLists.txt | 15 + .../xe_hpc_core/pvc/product_configs_pvc.h | 19 + .../common/xe_hpg_core/dg2/CMakeLists.txt | 2 + .../xe_hpg_core/dg2/product_configs_dg2.h | 20 + .../device_binary_format_ar_tests.cpp | 42 +- shared/test/unit_test/helpers/CMakeLists.txt | 1 + .../helpers/product_config_helper_tests.cpp | 51 + .../unit_test/helpers/test_hw_info_config.cpp | 20 +- .../pvc/device_binary_format_ar_tests_pvc.cpp | 10 +- .../pvc/linux/hw_info_config_tests_pvc.cpp | 12 + .../pvc/product_config_tests_pvc.cpp | 22 +- .../dg2/device_binary_format_ar_tests_dg2.cpp | 10 +- .../dg2/hw_info_config_tests_dg2.cpp | 42 +- .../dg2/product_config_tests_dg2.cpp | 4 +- third_party/aot_config_headers/platforms.h | 127 ++ 77 files changed, 1962 insertions(+), 1869 deletions(-) create mode 100644 opencl/test/unit_test/offline_compiler/ocloc_arg_helper_tests.cpp delete mode 100644 shared/source/dll/devices/platforms.h create mode 100644 shared/source/helpers/compiler_aot_config_bdw_and_later.inl create mode 100644 shared/source/helpers/product_config_helper.cpp create mode 100644 shared/test/common/xe_hpc_core/pvc/CMakeLists.txt create mode 100644 shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h create mode 100644 shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h create mode 100644 shared/test/unit_test/helpers/product_config_helper_tests.cpp create mode 100644 third_party/aot_config_headers/platforms.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9beb10d8e3..737fe792e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,6 +361,11 @@ if(NOT DEFINED KHRONOS_GL_HEADERS_DIR) endif() message(STATUS "Khronos OpenGL headers dir: ${KHRONOS_GL_HEADERS_DIR}") +if(NOT DEFINED AOT_CONFIG_HEADERS_DIR) + get_filename_component(AOT_CONFIG_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}aot_config_headers" ABSOLUTE) + message(STATUS "AOT config headers dir: ${AOT_CONFIG_HEADERS_DIR}") +endif() + if(NOT THIRD_PARTY_DIR) get_filename_component(THIRD_PARTY_DIR "../third_party/" ABSOLUTE) endif() @@ -722,6 +727,7 @@ endif() # Project-wide include paths # Please keep alphabetical order +include_directories(${AOT_CONFIG_HEADERS_DIR}) include_directories(${NEO_BUILD_DIR}) include_directories(${NEO_SOURCE_DIR}) include_directories(${NEO_SHARED_DIRECTORY}/aub_mem_dump/definitions${BRANCH_DIR_SUFFIX}) diff --git a/level_zero/core/test/unit_tests/sources/module/test_module.cpp b/level_zero/core/test/unit_tests/sources/module/test_module.cpp index b3bc3c0f6b..d4c79d06b7 100644 --- a/level_zero/core/test/unit_tests/sources/module/test_module.cpp +++ b/level_zero/core/test/unit_tests/sources/module/test_module.cpp @@ -2036,13 +2036,14 @@ HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromNativeBinaryThenSetsUpPacked PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); NEO::Ar::ArEncoder encoder; std::string requiredProduct = NEO::hardwarePrefix[productFamily]; std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize, programTokens.storage)); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize + "." + requiredProduct, programTokens.storage)); @@ -2051,7 +2052,7 @@ HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromNativeBinaryThenSetsUpPacked NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; diff --git a/opencl/test/unit_test/offline_compiler/CMakeLists.txt b/opencl/test/unit_test/offline_compiler/CMakeLists.txt index d5b766d5ae..183d6a2845 100644 --- a/opencl/test/unit_test/offline_compiler/CMakeLists.txt +++ b/opencl/test/unit_test/offline_compiler/CMakeLists.txt @@ -61,6 +61,7 @@ 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_fatbinary_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.h ${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fcl_facade_tests.cpp diff --git a/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h b/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h index 5bcc40418b..7a2844b615 100644 --- a/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h +++ b/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h @@ -23,6 +23,7 @@ class MockOfflineCompiler : public OfflineCompiler { using OfflineCompiler::appendExtraInternalOptions; using OfflineCompiler::argHelper; using OfflineCompiler::buildIrBinary; + using OfflineCompiler::deviceConfig; using OfflineCompiler::deviceName; using OfflineCompiler::elfBinary; using OfflineCompiler::excludeIr; @@ -36,6 +37,7 @@ class MockOfflineCompiler : public OfflineCompiler { using OfflineCompiler::hwInfo; using OfflineCompiler::igcFacade; using OfflineCompiler::initHardwareInfo; + using OfflineCompiler::initHardwareInfoForProductConfig; using OfflineCompiler::inputFile; using OfflineCompiler::inputFileLlvm; using OfflineCompiler::inputFileSpirV; @@ -49,6 +51,7 @@ class MockOfflineCompiler : public OfflineCompiler { using OfflineCompiler::outputNoSuffix; using OfflineCompiler::parseCommandLine; using OfflineCompiler::parseDebugSettings; + using OfflineCompiler::revisionId; using OfflineCompiler::setStatelessToStatefullBufferOffsetFlag; using OfflineCompiler::sourceCode; using OfflineCompiler::storeBinary; diff --git a/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp index c1ecff8130..62fe6f79e7 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp @@ -178,12 +178,29 @@ TEST(OclocApiTests, GivenInvalidQueryWhenQueryingThenErrorIsReturned) { TEST(OclocApiTests, WhenGoodFamilyNameIsProvidedThenSuccessIsReturned) { std::string clFileName(clFiles + "copybuffer.cl"); + std::unique_ptr argHelper = std::make_unique(); + auto allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); + if (allSupportedDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + std::string family(""); + for (const auto &config : allSupportedDeviceConfigs) { + if (config.hwInfo->platform.eProductFamily == NEO::DEFAULT_PLATFORM::hwInfo.platform.eProductFamily) { + family = ProductConfigHelper::getAcronymForAFamily(config.family).str(); + break; + } + } + if (family.empty()) { + GTEST_SKIP(); + } + const char *argv[] = { "ocloc", "-file", clFileName.c_str(), "-device", - NEO::familyName[NEO::DEFAULT_PLATFORM::hwInfo.platform.eRenderCoreFamily]}; + family.c_str()}; unsigned int argc = sizeof(argv) / sizeof(const char *); testing::internal::CaptureStdout(); @@ -194,7 +211,7 @@ TEST(OclocApiTests, WhenGoodFamilyNameIsProvidedThenSuccessIsReturned) { std::string output = testing::internal::GetCapturedStdout(); EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4])); + EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file " + clFileName + " -device " + family)); } TEST(OclocApiTests, WhenArgsWithMissingFileAreGivenThenErrorMessageIsProduced) { diff --git a/opencl/test/unit_test/offline_compiler/ocloc_arg_helper_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_arg_helper_tests.cpp new file mode 100644 index 0000000000..4e2a400fde --- /dev/null +++ b/opencl/test/unit_test/offline_compiler/ocloc_arg_helper_tests.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/offline_compiler/source/ocloc_arg_helper.h" +#include "shared/test/common/test_macros/test.h" + +struct OclocArgHelperTests : public ::testing::Test { + OclocArgHelperTests() { + argHelper = std::make_unique(); + } + std::unique_ptr argHelper; +}; + +template +auto findAcronym(const EqComparableT &lhs) { + return [&lhs](const auto &rhs) { return lhs == rhs; }; +} + +TEST_F(OclocArgHelperTests, givenProductOrAotConfigWhenParseMajorMinorRevisionValueThenCorrectStringIsReturned) { + auto &enabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); + if (enabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + for (const auto &device : enabledDeviceConfigs) { + auto productConfig = static_cast(device.aotConfig.ProductConfig); + auto configStr0 = ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + auto configStr1 = ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig); + EXPECT_STREQ(configStr0.c_str(), configStr1.c_str()); + + auto gotCofig = argHelper->getMajorMinorRevision(configStr0); + + EXPECT_EQ(gotCofig.ProductConfig, productConfig); + } +} + +TEST_F(OclocArgHelperTests, givenProductConfigAcronymWhenCheckAllEnabledThenCorrectValuesAreReturned) { + auto &enabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); + if (enabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + std::string acronym(""); + for (auto &device : enabledDeviceConfigs) { + if (!device.acronyms.empty()) { + acronym = device.acronyms.front().str(); + auto enabledAcronyms = argHelper->getEnabledProductAcronyms(); + + auto acronymFound = std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), findAcronym(acronym)); + EXPECT_TRUE(acronymFound); + + device.acronyms.clear(); + device.aotConfig.ProductConfig = AOT::UNKNOWN_ISA; + + enabledAcronyms = argHelper->getEnabledProductAcronyms(); + acronymFound = std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), findAcronym(acronym)); + + EXPECT_FALSE(acronymFound); + EXPECT_FALSE(argHelper->isProductConfig(acronym)); + } + } +} + +TEST_F(OclocArgHelperTests, givenReleaseAcronymWhenCheckAllEnabledThenCorrectValuesAreReturned) { + auto &enabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); + if (enabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + std::string acronym(""); + auto enabledRelease = enabledDeviceConfigs[0].release; + + for (const auto &[name, value] : AOT::releaseAcronyms) { + if (value == enabledRelease) { + acronym = name; + } + } + + auto enabledReleases = argHelper->getEnabledReleasesAcronyms(); + auto releaseFound = std::any_of(enabledReleases.begin(), enabledReleases.end(), findAcronym(acronym)); + + EXPECT_TRUE(releaseFound); + + for (auto &device : enabledDeviceConfigs) { + if (enabledRelease == device.release) { + device.release = AOT::UNKNOWN_RELEASE; + } + } + + enabledReleases = argHelper->getEnabledReleasesAcronyms(); + releaseFound = std::any_of(enabledReleases.begin(), enabledReleases.end(), findAcronym(acronym)); + + EXPECT_FALSE(releaseFound); + EXPECT_FALSE(argHelper->isRelease(acronym)); +} + +TEST_F(OclocArgHelperTests, givenFamilyAcronymWhenCheckAllEnabledThenCorrectValuesAreReturned) { + auto &enabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); + if (enabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + std::string acronym(""); + auto enabledFamily = enabledDeviceConfigs[0].family; + + for (const auto &[name, value] : AOT::familyAcronyms) { + if (value == enabledFamily) { + acronym = name; + } + } + + auto enabledFamilies = argHelper->getEnabledFamiliesAcronyms(); + auto familyFound = std::any_of(enabledFamilies.begin(), enabledFamilies.end(), findAcronym(acronym)); + + EXPECT_TRUE(familyFound); + + for (auto &device : enabledDeviceConfigs) { + if (enabledFamily == device.family) { + device.family = AOT::UNKNOWN_FAMILY; + } + } + + enabledFamilies = argHelper->getEnabledFamiliesAcronyms(); + familyFound = std::any_of(enabledFamilies.begin(), enabledFamilies.end(), findAcronym(acronym)); + + EXPECT_FALSE(familyFound); + EXPECT_FALSE(argHelper->isFamily(acronym)); +} + +TEST_F(OclocArgHelperTests, givenHwInfoForProductConfigWhenUnknownIsaIsPassedThenFalseIsReturned) { + NEO::HardwareInfo hwInfo; + EXPECT_FALSE(argHelper->getHwInfoForProductConfig(AOT::UNKNOWN_ISA, hwInfo)); +} \ No newline at end of file diff --git a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp index 89dc034b31..a40266641a 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp @@ -52,25 +52,30 @@ auto allFilesInArchiveExceptPaddingStartsWith(const Ar::Ar &archive, const Const return true; } -std::string prepareTwoDevices(MockOclocArgHelper *argHelper) { +std::string getDeviceConfig(const OfflineCompiler &offlineCompiler, MockOclocArgHelper *argHelper) { auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 2) { + if (allEnabledDeviceConfigs.empty()) { return {}; } - const auto cfg1 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[0].config); - const auto cfg2 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[1].config); - - return cfg1 + "," + cfg2; + const auto &hwInfo = offlineCompiler.getHardwareInfo(); + for (const auto &device : allEnabledDeviceConfigs) { + if (device.hwInfo->platform.eProductFamily == hwInfo.platform.eProductFamily) { + return ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig); + } + } + return {}; } -std::string getDeviceConfig(const OfflineCompiler &offlineCompiler) { - const auto &hwInfo = offlineCompiler.getHardwareInfo(); +std::string prepareTwoDevices(MockOclocArgHelper *argHelper) { + auto enabledProductsAcronyms = argHelper->getEnabledProductAcronyms(); + if (enabledProductsAcronyms.size() < 2) { + return {}; + } - const std::string product = hardwarePrefix[hwInfo.platform.eProductFamily]; - const auto stepping = hwInfo.platform.usRevId; - - return product + "." + std::to_string(stepping); + const auto cfg1 = enabledProductsAcronyms[0].str(); + const auto cfg2 = enabledProductsAcronyms[1].str(); + return cfg1 + "," + cfg2; } TEST(OclocFatBinaryRequestedFatBinary, WhenDeviceArgMissingThenReturnsFalse) { @@ -85,23 +90,75 @@ TEST(OclocFatBinaryRequestedFatBinary, WhenDeviceArgMissingThenReturnsFalse) { EXPECT_FALSE(NEO::requestedFatBinary(4, args, argHelper.get())); } -TEST(OclocFatBinaryRequestedFatBinary, GivenDeviceArgProvidedWhenFatBinaryFormatWithRangeIsPassedThenTrueIsReturned) { +TEST(OclocFatBinaryRequestedFatBinary, givenReleaseOrFamilyAcronymWhenGetAcronymsForTargetThenCorrectValuesAreReturned) { + std::unique_ptr argHelper = std::make_unique(); + auto &enabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); + if (enabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + ConstStringRef acronym(""); + std::vector outRelease{}, outFamily{}; + + for (auto &device : enabledDeviceConfigs) { + if (!device.acronyms.empty()) { + acronym = device.acronyms.front(); + getProductsAcronymsForTarget(outRelease, device.release, argHelper.get()); + EXPECT_TRUE(std::find(outRelease.begin(), outRelease.end(), acronym) != outRelease.end()); + + getProductsAcronymsForTarget(outFamily, device.family, argHelper.get()); + EXPECT_TRUE(std::find(outFamily.begin(), outFamily.end(), acronym) != outFamily.end()); + + device.acronyms.clear(); + outRelease.clear(); + outFamily.clear(); + + getProductsAcronymsForTarget(outRelease, device.release, argHelper.get()); + EXPECT_FALSE(std::find(outRelease.begin(), outRelease.end(), acronym) != outRelease.end()); + + getProductsAcronymsForTarget(outFamily, device.family, argHelper.get()); + EXPECT_FALSE(std::find(outFamily.begin(), outFamily.end(), acronym) != outFamily.end()); + } + } +} + +TEST(OclocFatBinaryRequestedFatBinary, givenDeviceArgToFatBinaryWhenConfigIsNotFullThenFalseIsReturned) { + std::unique_ptr argHelper = std::make_unique(); + auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); + if (allEnabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + auto aotConfig = allEnabledDeviceConfigs[0].aotConfig; + + std::stringstream majorString; + majorString << aotConfig.ProductConfigID.Major; + auto major = majorString.str(); + auto aotValue0 = argHelper->getMajorMinorRevision(major); + EXPECT_EQ(aotValue0.ProductConfig, AOT::UNKNOWN_ISA); + + auto majorMinor = ProductConfigHelper::parseMajorMinorValue(aotConfig); + auto aotValue1 = argHelper->getMajorMinorRevision(majorMinor); + EXPECT_EQ(aotValue1.ProductConfig, AOT::UNKNOWN_ISA); + + const char *cutRevision[] = {"ocloc", "-device", majorMinor.c_str()}; + const char *cutMinorAndRevision[] = {"ocloc", "-device", major.c_str()}; + + EXPECT_FALSE(NEO::requestedFatBinary(3, cutRevision, argHelper.get())); + EXPECT_FALSE(NEO::requestedFatBinary(3, cutMinorAndRevision, argHelper.get())); +} + +TEST(OclocFatBinaryRequestedFatBinary, givenDeviceArgProvidedWhenFatBinaryFormatWithRangeIsPassedThenTrueIsReturned) { std::unique_ptr argHelper = std::make_unique(); const char *allPlatforms[] = {"ocloc", "-device", "*"}; const char *manyPlatforms[] = {"ocloc", "-device", "a,b"}; - const char *manyGens[] = {"ocloc", "-device", "gen0,gen1"}; - const char *rangePlatformFrom[] = {"ocloc", "-device", "skl-"}; - const char *rangePlatformTo[] = {"ocloc", "-device", "-skl"}; - const char *rangePlatformBounds[] = {"ocloc", "-device", "skl-icllp"}; - const char *rangeGenFrom[] = {"ocloc", "-device", "gen0-"}; - const char *rangeGenTo[] = {"ocloc", "-device", "-gen5"}; - const char *rangeGenBounds[] = {"ocloc", "-device", "gen0-gen5"}; - const char *rangeConfigBounds[] = {"ocloc", "-device", "9-11"}; - const char *manyConfigs[] = {"ocloc", "-device", "9.0,11"}; - const char *rangeConfigFrom[] = {"ocloc", "-device", "10.1-"}; - const char *rangeConfigTo[] = {"ocloc", "-device", "-11.2"}; - const char *rangeConfigsBoundsSecond[] = {"ocloc", "-device", "11.2-12.2"}; + const char *manyGens[] = {"ocloc", "-device", "family0,family1"}; + const char *rangePlatformFrom[] = {"ocloc", "-device", "skl:"}; + const char *rangePlatformTo[] = {"ocloc", "-device", ":skl"}; + const char *rangePlatformBounds[] = {"ocloc", "-device", "skl:icllp"}; + const char *rangeGenFrom[] = {"ocloc", "-device", "family0:"}; + const char *rangeGenTo[] = {"ocloc", "-device", ":release5"}; + const char *rangeGenBounds[] = {"ocloc", "-device", "family0:family5"}; EXPECT_TRUE(NEO::requestedFatBinary(3, allPlatforms, argHelper.get())); EXPECT_TRUE(NEO::requestedFatBinary(3, manyPlatforms, argHelper.get())); @@ -112,1005 +169,654 @@ TEST(OclocFatBinaryRequestedFatBinary, GivenDeviceArgProvidedWhenFatBinaryFormat EXPECT_TRUE(NEO::requestedFatBinary(3, rangeGenFrom, argHelper.get())); EXPECT_TRUE(NEO::requestedFatBinary(3, rangeGenTo, argHelper.get())); EXPECT_TRUE(NEO::requestedFatBinary(3, rangeGenBounds, argHelper.get())); - EXPECT_TRUE(NEO::requestedFatBinary(3, rangeConfigBounds, argHelper.get())); - EXPECT_TRUE(NEO::requestedFatBinary(3, manyConfigs, argHelper.get())); - EXPECT_TRUE(NEO::requestedFatBinary(3, rangeConfigFrom, argHelper.get())); - EXPECT_TRUE(NEO::requestedFatBinary(3, rangeConfigTo, argHelper.get())); - EXPECT_TRUE(NEO::requestedFatBinary(3, rangeConfigsBoundsSecond, argHelper.get())); } -TEST(OclocFatBinaryRequestedFatBinary, GivenDeviceArgToFatBinaryWhenConfigMatchesMoreThanOneProductThenTrueIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - - std::string configNum0 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[allEnabledDeviceConfigs.size() / 2].config); - auto majorPos = configNum0.find("."); - auto cutMinorAndRevision = configNum0.substr(0, majorPos); - auto matchedConfigs = getAllMatchedConfigs(cutMinorAndRevision, argHelper.get()); - - if (matchedConfigs.size() < 2) { - GTEST_SKIP(); - } - - const char *fewConfigs[] = {"ocloc", "-device", cutMinorAndRevision.c_str()}; - EXPECT_TRUE(NEO::requestedFatBinary(3, fewConfigs, argHelper.get())); -} - -TEST(OclocFatBinaryRequestedFatBinary, GivenDeviceArgAsSingleProductConfigThenFatBinaryIsNotRequested) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - - for (auto &deviceConfig : allEnabledDeviceConfigs) { - std::string configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.config); - const char *singleConfig[] = {"ocloc", "-device", configStr.c_str()}; - EXPECT_FALSE(NEO::requestedFatBinary(3, singleConfig, argHelper.get())); - } -} - -TEST(OclocFatBinaryRequestedFatBinary, WhenPlatformIsProvidedButDoesNotContainMoreThanOneProductThenReturnFalse) { - std::unique_ptr argHelper = std::make_unique(); - const char *skl[] = {"ocloc", "-device", "skl"}; - EXPECT_FALSE(NEO::requestedFatBinary(3, skl, argHelper.get())); -} - -TEST(OclocFatBinaryToProductConfigStrings, GivenListOfProductIdsThenReturnsListOfStrings) { - auto platforms = NEO::getAllSupportedTargetPlatforms(); - auto names = NEO::toProductNames(platforms); - EXPECT_EQ(names.size(), platforms.size()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenDifferentDeviceArgWhenCheckIfPlatformsAbbreviationIsPassedThenReturnCorrectValue) { - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); +TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceArgAsSingleProductThenFatBinaryIsNotRequested) { auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); - if (allEnabledPlatforms.size() < 3 || allEnabledDeviceConfigs.size() < 3) { - GTEST_SKIP(); + for (const auto &deviceConfig : allEnabledDeviceConfigs) { + std::string configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.aotConfig); + const char *singleConfig[] = {"ocloc", "-device", configStr.c_str()}; + EXPECT_FALSE(NEO::requestedFatBinary(3, singleConfig, oclocArgHelperWithoutInput.get())); + + for (const auto &acronym : deviceConfig.acronyms) { + auto acronymStr = acronym.str(); + const char *singleAcronym[] = {"ocloc", "-device", acronymStr.c_str()}; + EXPECT_FALSE(NEO::requestedFatBinary(3, singleAcronym, oclocArgHelperWithoutInput.get())); + } } - - auto platform0 = allEnabledPlatforms[0]; - ConstStringRef platformName0(hardwarePrefix[platform0], strlen(hardwarePrefix[platform0])); - auto platform1 = allEnabledPlatforms[1]; - ConstStringRef platformName1(hardwarePrefix[platform1], strlen(hardwarePrefix[platform1])); - - auto deviceMapConfig0 = allEnabledDeviceConfigs[0]; - auto configNumConvention0 = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig0.config); - auto deviceMapConfig1 = allEnabledDeviceConfigs[1]; - auto configNumConvention1 = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig1.config); - - auto twoPlatforms = platformName0.str() + "," + platformName1.str(); - auto configsRange = configNumConvention0 + "-" + configNumConvention1; - auto gen = std::to_string(deviceMapConfig0.hwInfo->platform.eRenderCoreFamily); - - EXPECT_TRUE(isDeviceWithPlatformAbbreviation(platformName0, oclocArgHelperWithoutInput.get())); - EXPECT_TRUE(isDeviceWithPlatformAbbreviation(ConstStringRef(twoPlatforms), oclocArgHelperWithoutInput.get())); - EXPECT_FALSE(isDeviceWithPlatformAbbreviation(ConstStringRef(configsRange), oclocArgHelperWithoutInput.get())); - EXPECT_FALSE(isDeviceWithPlatformAbbreviation(ConstStringRef(gen), oclocArgHelperWithoutInput.get())); } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenAsterixThenReturnAllEnabledConfigs) { - auto expected = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); - auto got = NEO::getTargetConfigsForFatbinary("*", oclocArgHelperWithoutInput.get()); +TEST_F(OclocFatBinaryProductAcronymsTests, givenAsterixThenReturnAllEnabledAcronyms) { + auto expected = oclocArgHelperWithoutInput->getEnabledProductAcronyms(); + auto got = NEO::getTargetProductsForFatbinary("*", oclocArgHelperWithoutInput.get()); EXPECT_EQ(got.size(), expected.size()); } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigWhenConfigIsUndefinedThenReturnEmptyList) { - auto got = NEO::getTargetConfigsForFatbinary("0.0.0", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("0.0", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("0", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); +TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceArgProvidedWhenUnknownFamilyNameIsPassedThenRequestedFatBinaryReturnsFalse) { + const char *unknownFamily[] = {"ocloc", "-device", "gen0"}; + EXPECT_FALSE(NEO::requestedFatBinary(3, unknownFamily, oclocArgHelperWithoutInput.get())); } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigOpenRangeToWhenConfigIsUndefinedThenReturnEmptyList) { - auto got = NEO::getTargetConfigsForFatbinary("-0.0.0", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("-0.0", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("-0", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigOpenRangeFromWhenConfigIsUndefinedThenReturnEmptyList) { - auto got = NEO::getTargetConfigsForFatbinary("0.0.0-", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("0.0-", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("0-", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigClosedRangeWhenAnyOfConfigIsUndefinedOrIncorrectThenReturnEmptyList) { - auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 2) { - GTEST_SKIP(); - } - - auto deviceMapConfig0 = allEnabledDeviceConfigs[0]; - auto config0Str = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig0.config); - - auto got = NEO::getTargetConfigsForFatbinary("1.2-" + config0Str, oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary(config0Str + "-1.2", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("1.a.c-" + config0Str, oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary(config0Str + "-1.a.c", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST(OclocFatBinaryRequestedFatBinary, GivenDeviceArgProvidedWhenUnknownGenNameIsPassedThenRequestedFatBinaryReturnsFalse) { - std::unique_ptr argHelper = std::make_unique(); - const char *unknownGen[] = {"ocloc", "-device", "gen0"}; - const char *unknownGenCaseInsensitive[] = {"ocloc", "-device", "Gen0"}; - - EXPECT_FALSE(NEO::requestedFatBinary(3, unknownGen, argHelper.get())); - EXPECT_FALSE(NEO::requestedFatBinary(3, unknownGenCaseInsensitive, argHelper.get())); -} - -TEST(OclocFatBinaryRequestedFatBinary, GivenDeviceArgProvidedWhenKnownGenNameIsPassedThenRequestedFatBinaryReturnsTrue) { - std::unique_ptr argHelper = std::make_unique(); - unsigned int i = 0; - for (; i < IGFX_MAX_CORE; ++i) { - if (NEO::familyName[i] != nullptr) - break; - } - const char *genFromFamilyName[] = {"ocloc", "-device", NEO::familyName[i]}; - EXPECT_TRUE(NEO::requestedFatBinary(3, genFromFamilyName, argHelper.get())); -} - -TEST(OclocFatBinaryGetAllSupportedTargetPlatforms, WhenRequestedThenReturnsAllPlatformsWithNonNullHardwarePrefixes) { - auto platforms = NEO::getAllSupportedTargetPlatforms(); - std::unordered_set platformsSet(platforms.begin(), platforms.end()); - for (unsigned int productId = 0; productId < IGFX_MAX_PRODUCT; ++productId) { - if (nullptr != NEO::hardwarePrefix[productId]) { - EXPECT_EQ(1U, platformsSet.count(static_cast(productId))) << productId; - } else { - EXPECT_EQ(0U, platformsSet.count(static_cast(productId))) << productId; +TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceArgProvidedWhenKnownNameIsPassedThenRequestedFatBinaryReturnsTrue) { + for (const auto &acronyms : {enabledFamiliesAcronyms, enabledReleasesAcronyms}) { + for (const auto &acronym : acronyms) { + auto acronymStr = acronym.str(); + const char *name[] = {"ocloc", "-device", acronymStr.c_str()}; + EXPECT_TRUE(NEO::requestedFatBinary(3, name, oclocArgHelperWithoutInput.get())); } } } -TEST(OclocFatBinaryAsProductId, GivenEnabledPlatformNameThenReturnsProperPlatformId) { - auto platforms = NEO::getAllSupportedTargetPlatforms(); - auto names = NEO::toProductNames(platforms); - for (size_t i = 0; i < platforms.size(); ++i) { - auto idByName = NEO::asProductId(names[i], platforms); - EXPECT_EQ(idByName, platforms[i]) << names[i].data() << " : " << platforms[i] << " != " << idByName; +TEST_F(OclocFatBinaryProductAcronymsTests, givenEnabledFamilyAcronymsWhenCheckIfIsFamilyThenTrueIsReturned) { + for (const auto &acronym : enabledFamiliesAcronyms) { + EXPECT_TRUE(oclocArgHelperWithoutInput->isFamily(acronym.str())); } } -TEST(OclocFatBinaryAsProductId, GivenDisabledPlatformNameThenReturnsUnknownPlatformId) { - auto platforms = NEO::getAllSupportedTargetPlatforms(); - auto names = NEO::toProductNames(platforms); - platforms.clear(); - for (size_t i = 0; i < platforms.size(); ++i) { - auto idByName = NEO::asProductId(names[i], platforms); - EXPECT_EQ(IGFX_UNKNOWN, platforms[i]) << names[i].data() << " : IGFX_UNKNOWN != " << idByName; +TEST_F(OclocFatBinaryProductAcronymsTests, givenEnabledReleaseAcronymsWhenCheckIfIsReleaseThenTrueIsReturned) { + for (const auto &acronym : enabledReleasesAcronyms) { + EXPECT_TRUE(oclocArgHelperWithoutInput->isRelease(acronym.str())); } } -TEST(OclocFatBinaryAsGfxCoreIdList, GivenEnabledGfxCoreNameThenReturnsNonEmptyList) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenDisabledFamilyOrReleaseNameThenReturnsEmptyList) { + EXPECT_FALSE(oclocArgHelperWithoutInput->isFamily(ConstStringRef("gen0").str())); + EXPECT_FALSE(oclocArgHelperWithoutInput->isFamily(ConstStringRef("genX").str())); + EXPECT_FALSE(oclocArgHelperWithoutInput->isRelease(ConstStringRef("gen0").str())); + EXPECT_FALSE(oclocArgHelperWithoutInput->isRelease(ConstStringRef("genX").str())); +} - std::unique_ptr argHelper = std::make_unique(); +TEST_F(OclocFatBinaryProductAcronymsTests, givenUnkownArchitectureThenReturnEmptyList) { + auto got = NEO::getTargetProductsForFatbinary("gen0", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); +} - for (unsigned int coreId = 0; coreId < IGFX_MAX_CORE; ++coreId) { - if (nullptr != NEO::familyName[coreId]) { - EXPECT_TRUE(argHelper->isGen(ConstStringRef(NEO::familyName[coreId]).str())); - std::string caseInsensitive = NEO::familyName[coreId]; - std::transform(caseInsensitive.begin(), caseInsensitive.end(), caseInsensitive.begin(), ::tolower); - EXPECT_TRUE(argHelper->isGen(caseInsensitive)); +TEST_F(OclocFatBinaryProductAcronymsTests, givenClosedRangeTooExtensiveWhenProductsOrFamiliesOrReleasesAreValidThenFailIsReturned) { + for (const auto &enabledAcronyms : {enabledProductsAcronyms, enabledReleasesAcronyms, enabledFamiliesAcronyms}) { + if (enabledAcronyms.size() < 3) { + GTEST_SKIP(); + } - auto findCore = caseInsensitive.find("_core"); - if (findCore != std::string::npos) { - caseInsensitive = caseInsensitive.substr(0, findCore); - EXPECT_TRUE(argHelper->isGen(caseInsensitive)); - } + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream acronymsString; + acronymsString << enabledAcronyms[0].str() << ":" << enabledAcronyms[1].str() << ":" << enabledAcronyms[2].str(); + auto target = acronymsString.str(); - auto findUnderline = caseInsensitive.find("_"); - if (findUnderline != std::string::npos) { - caseInsensitive.erase(std::remove(caseInsensitive.begin(), caseInsensitive.end(), '_'), caseInsensitive.end()); - EXPECT_TRUE(argHelper->isGen(caseInsensitive)); - } + std::stringstream resString; + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + target}; + + testing::internal::CaptureStdout(); + int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); + auto output = testing::internal::GetCapturedStdout(); + EXPECT_NE(retVal, NEO::OclocErrorCode::SUCCESS); + resString << "Invalid range : " << acronymsString.str() << " - should be from:to or :to or from:\n"; + resString << "Failed to parse target devices from : " << target << "\n"; + EXPECT_STREQ(output.c_str(), resString.str().c_str()); + } +} + +TEST_F(OclocFatBinaryProductAcronymsTests, givenAcronymOpenRangeWhenAcronymIsUnknownThenReturnEmptyList) { + auto got = NEO::getTargetProductsForFatbinary("unk:", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); + + got = NEO::getTargetProductsForFatbinary(":unk", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); +} + +TEST_F(OclocFatBinaryProductAcronymsTests, givenClosedRangeWhenAnyOfAcronymIsUnknownThenReturnEmptyList) { + for (const auto &vec : {enabledProductsAcronyms, enabledReleasesAcronyms, enabledFamiliesAcronyms}) { + for (const auto &acronym : vec) { + auto got = NEO::getTargetProductsForFatbinary("unk:" + acronym.str(), oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); + + got = NEO::getTargetProductsForFatbinary(acronym.str() + ":unk", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); + + got = NEO::getTargetProductsForFatbinary(acronym.str() + ",unk", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); + + got = NEO::getTargetProductsForFatbinary("unk," + acronym.str(), oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); } } } -TEST(OclocFatBinaryAsGfxCoreIdList, GivenDisabledGfxCoreNameThenReturnsEmptyList) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfProductsWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledProductsAcronyms.size() < 2) { + GTEST_SKIP(); + } + for (unsigned int product = 0; product < enabledProductsAcronyms.size() - 1; product++) { + auto acronym0 = enabledProductsAcronyms.at(product); + auto acronym1 = enabledProductsAcronyms.at(product + 1); + std::vector expected{acronym0, acronym1}; - std::unique_ptr argHelper = std::make_unique(); + std::string acronymsTarget = acronym0.str() + "," + acronym1.str(); + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); - EXPECT_FALSE(argHelper->isGen(ConstStringRef("genA").str())); - EXPECT_FALSE(argHelper->isGen(ConstStringRef("gen0").str())); - EXPECT_FALSE(argHelper->isGen(ConstStringRef("gen1").str())); - EXPECT_FALSE(argHelper->isGen(ConstStringRef("gen2").str())); -} + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + acronymsTarget}; -TEST(OclocFatBinaryAsGfxCoreIdList, GivenEnabledGfxCoreNameThenReturnsNonNullIGFX) { + testing::internal::CaptureStdout(); + int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); + auto output = testing::internal::GetCapturedStdout(); + EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - std::unique_ptr argHelper = std::make_unique(); - - for (unsigned int coreId = 0; coreId < IGFX_MAX_CORE; ++coreId) { - if (nullptr != NEO::familyName[coreId]) { - EXPECT_EQ(argHelper->returnIGFXforGen(ConstStringRef(NEO::familyName[coreId]).str()), coreId); - std::string caseInsensitive = NEO::familyName[coreId]; - std::transform(caseInsensitive.begin(), caseInsensitive.end(), caseInsensitive.begin(), ::tolower); - EXPECT_EQ(argHelper->returnIGFXforGen(caseInsensitive), coreId); - - auto findCore = caseInsensitive.find("_core"); - if (findCore != std::string::npos) { - caseInsensitive = caseInsensitive.substr(0, findCore); - EXPECT_EQ(argHelper->returnIGFXforGen(caseInsensitive), coreId); - } - - auto findUnderline = caseInsensitive.find("_"); - if (findUnderline != std::string::npos) { - caseInsensitive.erase(std::remove(caseInsensitive.begin(), caseInsensitive.end(), '_'), caseInsensitive.end()); - EXPECT_EQ(argHelper->returnIGFXforGen(caseInsensitive), coreId); - } + for (const auto &product : expected) { + resString << "Build succeeded for : " << product.str() + ".\n"; } + + EXPECT_STREQ(output.c_str(), resString.str().c_str()); } } -TEST(OclocFatBinaryAsGfxCoreIdList, GivenDisabledGfxCoreNameThenReturnsNullIGFX) { - std::unique_ptr argHelper = std::make_unique(); - - EXPECT_EQ(argHelper->returnIGFXforGen(ConstStringRef("genA").str()), 0u); - EXPECT_EQ(argHelper->returnIGFXforGen(ConstStringRef("gen0").str()), 0u); - EXPECT_EQ(argHelper->returnIGFXforGen(ConstStringRef("gen1").str()), 0u); - EXPECT_EQ(argHelper->returnIGFXforGen(ConstStringRef("gen2").str()), 0u); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenMutiplePlatformThenReturnThosePlatforms) { - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 2) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoSameReleaseTargetsWhenGetProductsAcronymsThenDuplicatesAreNotFound) { + if (enabledReleasesAcronyms.empty()) { GTEST_SKIP(); } - auto platform0 = allEnabledPlatforms[0]; - std::string platform0Name = NEO::hardwarePrefix[platform0]; - auto platform1 = allEnabledPlatforms[1]; - std::string platform1Name = NEO::hardwarePrefix[platform1]; - std::vector expected{platform0Name, platform1Name}; - auto got = NEO::getTargetPlatformsForFatbinary(platform0Name + "," + platform1Name, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(expected, got); + auto acronym = enabledReleasesAcronyms[0]; + std::vector acronyms{}; + + auto release = ProductConfigHelper::returnReleaseForAcronym(acronym.str()); + getProductsAcronymsForTarget(acronyms, release, oclocArgHelperWithoutInput.get()); + auto expectedSize = acronyms.size(); + getProductsAcronymsForTarget(acronyms, release, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(acronyms.size(), expectedSize); } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformOpenRangeFromThenReturnAllEnabledPlatformsThatMatch) { - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 3) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoSameFamilyTargetsWhenGetProductsAcronymsThenDuplicatesAreNotFound) { + if (enabledFamiliesAcronyms.empty()) { GTEST_SKIP(); } - auto platform0 = allEnabledPlatforms[allEnabledPlatforms.size() / 2]; - std::string platformName = NEO::hardwarePrefix[platform0]; - std::vector expectedPlatforms; - auto platformFrom = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platform0); - expectedPlatforms.insert(expectedPlatforms.end(), platformFrom, allEnabledPlatforms.end()); - auto expected = NEO::toProductNames(expectedPlatforms); - auto got = NEO::getTargetPlatformsForFatbinary(platformName + "-", oclocArgHelperWithoutInput.get()); - EXPECT_EQ(expected, got); + auto acronym = enabledFamiliesAcronyms[0]; + std::vector acronyms{}; + + auto family = ProductConfigHelper::returnFamilyForAcronym(acronym.str()); + getProductsAcronymsForTarget(acronyms, family, oclocArgHelperWithoutInput.get()); + auto expectedSize = acronyms.size(); + getProductsAcronymsForTarget(acronyms, family, oclocArgHelperWithoutInput.get()); + + EXPECT_EQ(acronyms.size(), expectedSize); } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformOpenRangeToThenReturnAllEnabledPlatformsThatMatch) { - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 3) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfReleasesWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledReleasesAcronyms.size() < 2) { GTEST_SKIP(); } - auto platform0 = allEnabledPlatforms[allEnabledPlatforms.size() / 2]; - std::string platformName = NEO::hardwarePrefix[platform0]; + for (unsigned int product = 0; product < enabledReleasesAcronyms.size() - 1; product++) { + auto acronym0 = enabledReleasesAcronyms.at(product); + auto acronym1 = enabledReleasesAcronyms.at(product + 1); + std::vector expected{}; - std::vector expectedPlatforms; - auto platformTo = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platform0); - expectedPlatforms.insert(expectedPlatforms.end(), allEnabledPlatforms.begin(), platformTo + 1); - auto expected = NEO::toProductNames(expectedPlatforms); - auto got = NEO::getTargetPlatformsForFatbinary("-" + platformName, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(expected, got); -} + auto release0 = ProductConfigHelper::returnReleaseForAcronym(acronym0.str()); + auto release1 = ProductConfigHelper::returnReleaseForAcronym(acronym1.str()); + getProductsAcronymsForTarget(expected, release0, oclocArgHelperWithoutInput.get()); + getProductsAcronymsForTarget(expected, release1, oclocArgHelperWithoutInput.get()); -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformClosedRangeThenReturnAllEnabledPlatformsThatMatch) { - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 4) { - GTEST_SKIP(); - } - auto platformFrom = allEnabledPlatforms[1]; - auto platformTo = allEnabledPlatforms[allEnabledPlatforms.size() - 2]; - std::string platformNameFrom = NEO::hardwarePrefix[platformFrom]; - std::string platformNameTo = NEO::hardwarePrefix[platformTo]; + std::string acronymsTarget = acronym0.str() + "," + acronym1.str(); + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); - std::vector expectedPlatforms; - expectedPlatforms.insert(expectedPlatforms.end(), allEnabledPlatforms.begin() + 1, allEnabledPlatforms.begin() + allEnabledPlatforms.size() - 1); - auto expected = NEO::toProductNames(expectedPlatforms); - auto got = NEO::getTargetPlatformsForFatbinary(platformNameFrom + "-" + platformNameTo, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(expected, got); + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + acronymsTarget}; - got = NEO::getTargetPlatformsForFatbinary(platformNameTo + "-" + platformNameFrom, oclocArgHelperWithoutInput.get()); // swap min with max implicitly - EXPECT_EQ(expected, got); -} + testing::internal::CaptureStdout(); + int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); + auto output = testing::internal::GetCapturedStdout(); + EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); -std::vector getEnabledCores() { - std::vector ret; - for (unsigned int coreId = 0; coreId < IGFX_MAX_CORE; ++coreId) { - if (nullptr != NEO::familyName[coreId]) { - ret.push_back(static_cast(coreId)); + for (const auto &product : expected) { + resString << "Build succeeded for : " << product.str() + ".\n"; } - } - return ret; -} -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArchitectureThenReturnAllEnabledConfigsThatMatch) { - auto allEnabledCores = getEnabledCores(); - if (allEnabledCores.size() < 3) { - GTEST_SKIP(); - } - auto core = allEnabledCores[allEnabledCores.size() / 2]; - std::string coreName = NEO::familyName[core]; - if (coreName[0] == 'G') { - coreName[0] = 'g'; - } - - std::vector expected; - oclocArgHelperWithoutInput->getProductConfigsForGfxCoreFamily(core, expected); - auto got = NEO::getTargetConfigsForFatbinary(coreName, oclocArgHelperWithoutInput.get()); - - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); + EXPECT_STREQ(output.c_str(), resString.str().c_str()); } } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArchitectureOpenRangeFromThenReturnAllEnabledConfigsThatMatch) { - auto allEnabledCores = getEnabledCores(); - if (allEnabledCores.size() < 3) { - GTEST_SKIP(); - } - auto core0 = allEnabledCores[allEnabledCores.size() / 2]; - std::string coreName = NEO::familyName[core0]; - if (coreName[0] == 'G') { - coreName[0] = 'g'; - } - - std::vector expected; - unsigned int coreIt = core0; - while (coreIt < static_cast(IGFX_MAX_CORE)) { - oclocArgHelperWithoutInput->getProductConfigsForGfxCoreFamily(static_cast(coreIt), expected); - ++coreIt; - } - - auto got = NEO::getTargetConfigsForFatbinary(coreName + "-", oclocArgHelperWithoutInput.get()); - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArchitectureOpenRangeToThenReturnAllEnabledConfigsThatMatch) { - auto allEnabledCores = getEnabledCores(); - if (allEnabledCores.size() < 3) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfFamiliesWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledFamiliesAcronyms.size() < 2) { GTEST_SKIP(); } - auto core0 = allEnabledCores[allEnabledCores.size() / 2]; - std::string coreName = NEO::familyName[core0]; - if (coreName[0] == 'G') { - coreName[0] = 'g'; - } - - std::vector expected; - unsigned int coreIt = IGFX_UNKNOWN_CORE; - ++coreIt; - while (coreIt <= static_cast(core0)) { - oclocArgHelperWithoutInput->getProductConfigsForGfxCoreFamily(static_cast(coreIt), expected); - ++coreIt; - } - - auto got = NEO::getTargetConfigsForFatbinary("-" + coreName, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArchitectureClosedRangeThenReturnAllEnabledConfigsThatMatch) { - auto allEnabledCores = getEnabledCores(); - if (allEnabledCores.size() < 4) { - GTEST_SKIP(); - } - auto coreFrom = allEnabledCores[1]; - auto coreTo = allEnabledCores[allEnabledCores.size() - 2]; - std::string coreNameFrom = NEO::familyName[coreFrom]; - if (coreNameFrom[0] == 'G') { - coreNameFrom[0] = 'g'; - } - std::string coreNameTo = NEO::familyName[coreTo]; - if (coreNameTo[0] == 'G') { - coreNameTo[0] = 'g'; - } - - std::vector expected; - auto coreIt = coreFrom; - while (coreIt <= coreTo) { - oclocArgHelperWithoutInput->getProductConfigsForGfxCoreFamily(static_cast(coreIt), expected); - coreIt = static_cast(static_cast(coreIt) + 1); - } - - auto got = NEO::getTargetConfigsForFatbinary(coreNameFrom + "-" + coreNameTo, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } - - got = NEO::getTargetConfigsForFatbinary(coreNameTo + "-" + coreNameFrom, oclocArgHelperWithoutInput.get()); // swap min with max implicitly - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenUnkownArchitectureThenReturnEmptyList) { - auto got = NEO::getTargetConfigsForFatbinary("gen0", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenMutiplePlatformWhenSecondPlatformsIsUnknownThenReturnErrorMessage) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - auto platform0 = allEnabledPlatforms[0]; - std::string platform0Name = NEO::hardwarePrefix[platform0]; - - auto platformTarget = platform0Name + ",unk"; - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - platformTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_NE(retVal, NEO::OclocErrorCode::SUCCESS); - - resString << "Unknown device : unk\n"; - resString << "Failed to parse target devices from : " << platformTarget << "\n"; - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenClosedRangeTooExtensiveWhenConfigIsValidThenErrorMessageAndFailIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 4) { - GTEST_SKIP(); - } - std::string configNum0 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[0].config); - std::string configNum1 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[1].config); - std::string configNum2 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[2].config); - - std::stringstream configString; - configString << configNum0 << "-" << configNum1 << "-" << configNum2; - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - configString.str()}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_NE(retVal, NEO::OclocErrorCode::SUCCESS); - resString << "Invalid range : " << configString.str() << " - should be from-to or -to or from-" - << "\n"; - resString << "Failed to parse target devices from : " << configString.str() << "\n"; - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenClosedRangeTooExtensiveWhenPlatformIsValidThenErrorMessageAndReturnEmptyList) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 4) { - GTEST_SKIP(); - } - auto platform0 = allEnabledPlatforms[0]; - std::string platform0Name = NEO::hardwarePrefix[platform0]; - auto platform1 = allEnabledPlatforms[1]; - std::string platform1Name = NEO::hardwarePrefix[platform1]; - auto platform2 = allEnabledPlatforms[2]; - std::string platform2Name = NEO::hardwarePrefix[platform2]; - std::string platformsTarget = platform0Name + "-" + platform1Name + "-" + platform2Name; - - std::string resString = "Invalid range : " + platformsTarget + " - should be from-to or -to or from-\n"; - - testing::internal::CaptureStdout(); - auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_STREQ(output.c_str(), resString.c_str()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformClosedRangeWhenSecondPlatformIsUnkownThenReturnEmptyList) { - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - auto platform0 = allEnabledPlatforms[0]; - std::string platform0Name = NEO::hardwarePrefix[platform0]; - - auto got = NEO::getTargetPlatformsForFatbinary(platform0Name + "-unk", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenGenOpenRangeFromWhenGenIsUnknownThenReturnEmptyList) { - auto got = NEO::getTargetConfigsForFatbinary("gen2-", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenGenOpenRangeToWhenGenIsUnknownThenReturnEmptyList) { - auto got = NEO::getTargetConfigsForFatbinary("-gen2", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenGenClosedRangeWhenAnyOfGensIsUnknownThenReturnEmptyList) { - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - auto platform0 = allEnabledPlatforms[0]; - auto gfxCore0 = NEO::hardwareInfoTable[platform0]->platform.eRenderCoreFamily; - std::string genName = NEO::familyName[gfxCore0]; - if (genName[0] == 'G') { - genName[0] = 'g'; - } - - auto got = NEO::getTargetConfigsForFatbinary("gen2-" + genName, oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary(genName + "-gen2", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary(genName + ",gen2", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); - - got = NEO::getTargetConfigsForFatbinary("gen2," + genName, oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenTwoPlatformsWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 3) { - GTEST_SKIP(); - } - - auto platform0 = allEnabledPlatforms[0]; - ConstStringRef platformName0(hardwarePrefix[platform0], strlen(hardwarePrefix[platform0])); - auto platform1 = allEnabledPlatforms[1]; - ConstStringRef platformName1(hardwarePrefix[platform1], strlen(hardwarePrefix[platform1])); - - std::vector expected{platformName0, platformName1}; - - std::string platformsTarget = platformName0.str() + "," + platformName1.str(); - - auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); - EXPECT_EQ(expected, got); - - auto platformRev0 = std::to_string(hardwareInfoTable[platform0]->platform.usRevId); - auto platformRev1 = std::to_string(hardwareInfoTable[platform1]->platform.usRevId); - std::vector platformsRevision{platformRev0, platformRev1}; - std::stringstream resString; - - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - platformsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (uint32_t i = 0; i < got.size(); i++) { - resString << "Build succeeded for : " << expected[i].str() + "." + platformsRevision[i] + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformsClosedRangeWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 4) { - GTEST_SKIP(); - } - - auto platformFrom = allEnabledPlatforms[0]; - ConstStringRef platformNameFrom(hardwarePrefix[platformFrom], strlen(hardwarePrefix[platformFrom])); - auto platformTo = allEnabledPlatforms[allEnabledPlatforms.size() / 2]; - ConstStringRef platformNameTo(hardwarePrefix[platformTo], strlen(hardwarePrefix[platformTo])); - - if (platformFrom > platformTo) { - std::swap(platformFrom, platformTo); - } - - std::vector requestedPlatforms; - auto from = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platformFrom); - auto to = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platformTo) + 1; - requestedPlatforms.insert(requestedPlatforms.end(), from, to); - - auto expected = toProductNames(requestedPlatforms); - - std::string platformsTarget = platformNameFrom.str() + "-" + platformNameTo.str(); - - auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); - EXPECT_EQ(expected, got); - - std::vector platformsRevisions; - - for (auto platform : requestedPlatforms) { - platformsRevisions.push_back(std::to_string(hardwareInfoTable[platform]->platform.usRevId)); - } - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - platformsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (uint32_t i = 0; i < got.size(); i++) { - resString << "Build succeeded for : " << expected[i].str() + "." + platformsRevisions[i] + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformsOpenRangeToWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 4) { - GTEST_SKIP(); - } - - auto platformTo = allEnabledPlatforms[0]; - ConstStringRef platformNameTo(hardwarePrefix[platformTo], strlen(hardwarePrefix[platformTo])); - - std::vector requestedPlatforms; - auto platformToId = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platformTo); - assert(platformToId != allEnabledPlatforms.end()); - - requestedPlatforms.insert(requestedPlatforms.end(), allEnabledPlatforms.begin(), platformToId + 1); - - auto expected = toProductNames(requestedPlatforms); - - std::string platformsTarget = "-" + platformNameTo.str(); - - auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); - EXPECT_EQ(expected, got); - - std::vector platformsRevisions; - - for (auto platform : requestedPlatforms) { - platformsRevisions.push_back(std::to_string(hardwareInfoTable[platform]->platform.usRevId)); - } - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - platformsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (uint32_t i = 0; i < got.size(); i++) { - resString << "Build succeeded for : " << expected[i].str() + "." + platformsRevisions[i] + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformsOpenRangeFromWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); - if (allEnabledPlatforms.size() < 4) { - GTEST_SKIP(); - } - - auto platformFrom = allEnabledPlatforms[0]; - ConstStringRef platformNameFrom(hardwarePrefix[platformFrom], strlen(hardwarePrefix[platformFrom])); - - std::vector requestedPlatforms; - auto platformToId = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platformFrom); - assert(platformToId != allEnabledPlatforms.end()); - - requestedPlatforms.insert(requestedPlatforms.end(), platformToId, allEnabledPlatforms.end()); - - auto expected = toProductNames(requestedPlatforms); - - std::string platformsTarget = platformNameFrom.str() + "-"; - - auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); - EXPECT_EQ(expected, got); - - std::vector platformsRevisions; - - for (auto platform : requestedPlatforms) { - platformsRevisions.push_back(std::to_string(hardwareInfoTable[platform]->platform.usRevId)); - } - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - platformsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (uint32_t i = 0; i < got.size(); i++) { - resString << "Build succeeded for : " << expected[i].str() + "." + platformsRevisions[i] + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenTwoConfigsWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 2) { - GTEST_SKIP(); - } - auto config0 = allEnabledDeviceConfigs[0]; - auto config1 = allEnabledDeviceConfigs[1]; - - auto configStr0 = ProductConfigHelper::parseMajorMinorRevisionValue(config0.config); - auto configStr1 = ProductConfigHelper::parseMajorMinorRevisionValue(config1.config); - - std::vector targets{configStr0, configStr1}; - std::vector expected; - - for (auto &target : targets) { - auto configFirstEl = argHelper->findConfigMatch(target, true); - - auto configLastEl = argHelper->findConfigMatch(target, false); - for (auto &deviceConfig : allEnabledDeviceConfigs) { - if (deviceConfig.config >= configFirstEl && deviceConfig.config <= configLastEl) { - expected.push_back(deviceConfig); - } + for (unsigned int product = 0; product < enabledFamiliesAcronyms.size() - 1; product++) { + auto acronym0 = enabledFamiliesAcronyms.at(product); + auto acronym1 = enabledFamiliesAcronyms.at(product + 1); + std::vector expected{}; + + auto family0 = ProductConfigHelper::returnFamilyForAcronym(acronym0.str()); + auto family1 = ProductConfigHelper::returnFamilyForAcronym(acronym1.str()); + getProductsAcronymsForTarget(expected, family0, oclocArgHelperWithoutInput.get()); + getProductsAcronymsForTarget(expected, family1, oclocArgHelperWithoutInput.get()); + + std::string acronymsTarget = acronym0.str() + "," + acronym1.str(); + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector 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()); } - - auto configsTarget = configStr0 + "," + configStr1; - auto got = NEO::getTargetConfigsForFatbinary(configsTarget, argHelper.get()); - - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - configsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (auto deviceConfig : expected) { - auto targetConfig = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.config); - resString << "Build succeeded for : " << targetConfig + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigOpenRangeFromWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 2) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenProductsClosedRangeWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledProductsAcronyms.size() < 3) { GTEST_SKIP(); } - auto deviceMapConfig = allEnabledDeviceConfigs[allEnabledDeviceConfigs.size() / 2]; - auto configNumConvention = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); - - std::vector expected; - auto configFrom = std::find_if(allEnabledDeviceConfigs.begin(), - allEnabledDeviceConfigs.end(), - [&cf = deviceMapConfig](const DeviceMapping &c) -> bool { return cf.config == c.config; }); - - expected.insert(expected.end(), configFrom, allEnabledDeviceConfigs.end()); - - auto configsTarget = configNumConvention + "-"; - auto got = NEO::getTargetConfigsForFatbinary(configsTarget, argHelper.get()); - - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - configsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (auto deviceConfig : expected) { - auto targetConfig = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.config); - resString << "Build succeeded for : " << targetConfig + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigOpenRangeToWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 2) { - GTEST_SKIP(); - } - - auto deviceMapConfig = allEnabledDeviceConfigs[allEnabledDeviceConfigs.size() / 2]; - auto configNumConvention = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); - - std::vector expected; - for (auto &deviceConfig : allEnabledDeviceConfigs) { - if (deviceConfig.config <= deviceMapConfig.config) { - expected.push_back(deviceConfig); + for (unsigned int product = 0; product < enabledProductsAcronyms.size() - 1; product++) { + if (product == enabledProductsAcronyms.size() / 2) { + continue; } - } - auto configsTarget = "-" + configNumConvention; - auto got = NEO::getTargetConfigsForFatbinary(configsTarget, argHelper.get()); + std::vector expected{}; + auto acronymFrom = enabledProductsAcronyms.at(product); + auto acronymTo = enabledProductsAcronyms.at(enabledProductsAcronyms.size() / 2); - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - configsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (auto deviceConfig : expected) { - auto targetConfig = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.config); - resString << "Build succeeded for : " << targetConfig + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigClosedRangeWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - std::unique_ptr argHelper = std::make_unique(); - auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 4) { - GTEST_SKIP(); - } - - auto deviceMapConfigFrom = allEnabledDeviceConfigs[1]; - auto deviceMapConfigTo = allEnabledDeviceConfigs[allEnabledDeviceConfigs.size() - 2]; - auto configFromNumConvention = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfigFrom.config); - auto configToNumConvention = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfigTo.config); - - std::vector expected; - - for (auto &deviceConfig : allEnabledDeviceConfigs) { - if (deviceConfig.config >= deviceMapConfigFrom.config && deviceConfig.config <= deviceMapConfigTo.config) { - expected.push_back(deviceConfig); + auto prodFromIt = std::find(enabledProductsAcronyms.begin(), enabledProductsAcronyms.end(), acronymFrom); + auto prodToIt = std::find(enabledProductsAcronyms.begin(), enabledProductsAcronyms.end(), acronymTo); + if (prodFromIt > prodToIt) { + std::swap(prodFromIt, prodToIt); } + expected.insert(expected.end(), prodFromIt, ++prodToIt); + + std::string acronymsTarget = acronymFrom.str() + ":" + acronymTo.str(); + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector 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()); } - auto configsTarget = configFromNumConvention + "-" + configToNumConvention; - auto got = NEO::getTargetConfigsForFatbinary(configsTarget, argHelper.get()); // swap min with max implicitly - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } - got = NEO::getTargetConfigsForFatbinary(configToNumConvention + "-" + configFromNumConvention, argHelper.get()); // swap min with max implicitly - - EXPECT_EQ(expected.size(), got.size()); - for (unsigned int i = 0; i < got.size(); i++) { - EXPECT_TRUE(expected[i] == got[i]); - } - - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - configsTarget}; - - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, argHelper.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); - - for (auto deviceConfig : expected) { - auto targetConfig = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.config); - resString << "Build succeeded for : " << targetConfig + ".\n"; - } - - EXPECT_STREQ(output.c_str(), resString.str().c_str()); } -TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArgsWhenCorrectDeviceNumerationIsProvidedWithoutRevisionThenTargetsAreFound) { - auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 2) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenReleasesClosedRangeWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledReleasesAcronyms.size() < 3) { + GTEST_SKIP(); + } + for (unsigned int release = 0; release < enabledReleasesAcronyms.size() - 1; release++) { + if (release == enabledReleasesAcronyms.size() / 2) { + continue; + } + std::vector expected{}; + auto acronymFrom = enabledReleasesAcronyms.at(release); + auto acronymTo = enabledReleasesAcronyms.at(enabledReleasesAcronyms.size() / 2); + + auto releaseFromIt = ProductConfigHelper::returnReleaseForAcronym(acronymFrom.str()); + auto releaseToIt = ProductConfigHelper::returnReleaseForAcronym(acronymTo.str()); + + if (releaseFromIt > releaseToIt) { + std::swap(releaseFromIt, releaseToIt); + } + while (releaseFromIt <= releaseToIt) { + getProductsAcronymsForTarget(expected, releaseFromIt, oclocArgHelperWithoutInput.get()); + releaseFromIt = static_cast(static_cast(releaseFromIt) + 1); + } + + std::string acronymsTarget = acronymFrom.str() + ":" + acronymTo.str(); + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector 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, givenFamiliesClosedRangeWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledFamiliesAcronyms.size() < 3) { + GTEST_SKIP(); + } + for (unsigned int family = 0; family < enabledFamiliesAcronyms.size() - 1; family++) { + if (family == enabledFamiliesAcronyms.size() / 2) { + continue; + } + std::vector expected{}; + auto acronymFrom = enabledFamiliesAcronyms.at(family); + auto acronymTo = enabledFamiliesAcronyms.at(enabledFamiliesAcronyms.size() / 2); + + auto familyFromIt = ProductConfigHelper::returnFamilyForAcronym(acronymFrom.str()); + auto familyToIt = ProductConfigHelper::returnFamilyForAcronym(acronymTo.str()); + + if (familyFromIt > familyToIt) { + std::swap(familyFromIt, familyToIt); + } + while (familyFromIt <= familyToIt) { + getProductsAcronymsForTarget(expected, familyFromIt, oclocArgHelperWithoutInput.get()); + familyFromIt = static_cast(static_cast(familyFromIt) + 1); + } + + std::string acronymsTarget = acronymFrom.str() + ":" + acronymTo.str(); + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector 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, givenOpenRangeFromProductWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledProductsAcronyms.size() < 2) { + GTEST_SKIP(); + } + for (auto acronymIt = enabledProductsAcronyms.begin(); acronymIt != enabledProductsAcronyms.end(); ++acronymIt) { + std::vector expected{}; + expected.insert(expected.end(), acronymIt, enabledProductsAcronyms.end()); + + std::string acronymsTarget = (*acronymIt).str() + ":"; + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector 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, givenOpenRangeToProductWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledProductsAcronyms.size() < 2) { + GTEST_SKIP(); + } + for (auto acronymIt = enabledProductsAcronyms.begin(); acronymIt != enabledProductsAcronyms.end(); ++acronymIt) { + std::vector expected{}; + expected.insert(expected.end(), enabledProductsAcronyms.begin(), acronymIt + 1); + + std::string acronymsTarget = ":" + (*acronymIt).str(); + auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector 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, givenOpenRangeFromReleaseWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledReleasesAcronyms.size() < 3) { GTEST_SKIP(); } - std::string configNum0 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[0].config); - auto majorPos = configNum0.find("."); - auto minorPos = configNum0.find(".", ++majorPos); - auto cutRevision = configNum0.substr(0, minorPos); + for (const auto &release : enabledReleasesAcronyms) { + std::vector expected{}; - auto got = NEO::getTargetConfigsForFatbinary(ConstStringRef(cutRevision), oclocArgHelperWithoutInput.get()); - EXPECT_FALSE(got.empty()); + auto releaseFromId = ProductConfigHelper::returnReleaseForAcronym(release.str()); + auto releaseToId = AOT::RELEASE_MAX; + while (releaseFromId < releaseToId) { + getProductsAcronymsForTarget(expected, releaseFromId, oclocArgHelperWithoutInput.get()); + releaseFromId = static_cast(static_cast(releaseFromId) + 1); + } + + std::string releasesTarget = release.str() + ":"; + auto got = NEO::getTargetProductsForFatbinary(releasesTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + releasesTarget}; + + 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(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArgsWhenCorrectDeviceNumerationIsProvidedWithoutMinorAndRevisionThenTargetsAreFound) { - auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.size() < 2) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeToReleaseWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledReleasesAcronyms.size() < 3) { GTEST_SKIP(); } - std::string configNum0 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[0].config); - auto majorPos = configNum0.find("."); - auto cutMinorAndRevision = configNum0.substr(0, majorPos); + for (const auto &release : enabledReleasesAcronyms) { + std::vector expected{}; - auto got = NEO::getTargetConfigsForFatbinary(ConstStringRef(cutMinorAndRevision), oclocArgHelperWithoutInput.get()); - EXPECT_FALSE(got.empty()); + auto releaseFromId = static_cast(static_cast(AOT::UNKNOWN_RELEASE) + 1); + auto releaseToId = ProductConfigHelper::returnReleaseForAcronym(release.str()); + + while (releaseFromId <= releaseToId) { + getProductsAcronymsForTarget(expected, releaseFromId, oclocArgHelperWithoutInput.get()); + releaseFromId = static_cast(static_cast(releaseFromId) + 1); + } + + std::string releasesTarget = ":" + release.str(); + auto got = NEO::getTargetProductsForFatbinary(releasesTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + releasesTarget}; + + 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(OclocFatBinaryTest, GivenSpirvInputWhenFatBinaryIsRequestedThenArchiveContainsGenericIrFileWithSpirvContent) { +TEST_F(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromFamilyWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledFamiliesAcronyms.size() < 3) { + GTEST_SKIP(); + } + + for (const auto &family : enabledFamiliesAcronyms) { + std::vector expected{}; + + auto familyFromId = ProductConfigHelper::returnFamilyForAcronym(family.str()); + auto familyToId = AOT::FAMILY_MAX; + while (familyFromId < familyToId) { + getProductsAcronymsForTarget(expected, familyFromId, oclocArgHelperWithoutInput.get()); + familyFromId = static_cast(static_cast(familyFromId) + 1); + } + + std::string familiesTarget = family.str() + ":"; + auto got = NEO::getTargetProductsForFatbinary(familiesTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + familiesTarget}; + + 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, givenOpenRangeToFamilyWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + if (enabledFamiliesAcronyms.size() < 3) { + GTEST_SKIP(); + } + + for (const auto &family : enabledFamiliesAcronyms) { + std::vector expected{}; + + auto familyFromId = static_cast(static_cast(AOT::UNKNOWN_FAMILY) + 1); + auto familyToId = ProductConfigHelper::returnFamilyForAcronym(family.str()); + + while (familyFromId <= familyToId) { + getProductsAcronymsForTarget(expected, familyFromId, oclocArgHelperWithoutInput.get()); + familyFromId = static_cast(static_cast(familyFromId) + 1); + } + + std::string familiesTarget = ":" + family.str(); + auto got = NEO::getTargetProductsForFatbinary(familiesTarget, oclocArgHelperWithoutInput.get()); + EXPECT_EQ(got, expected); + + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; + std::stringstream resString; + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + familiesTarget}; + + 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(OclocFatBinaryTest, givenSpirvInputWhenFatBinaryIsRequestedThenArchiveContainsGenericIrFileWithSpirvContent) { const auto devices = prepareTwoDevices(&mockArgHelper); if (devices.empty()) { GTEST_SKIP(); } - const std::vector args = { "ocloc", "-output", @@ -1122,6 +828,7 @@ TEST_F(OclocFatBinaryTest, GivenSpirvInputWhenFatBinaryIsRequestedThenArchiveCon "-device", devices}; + mockArgHelper.getPrinterRef() = MessagePrinter{true}; const auto buildResult = buildFatBinary(args, &mockArgHelper); ASSERT_EQ(OclocErrorCode::SUCCESS, buildResult); ASSERT_EQ(1u, mockArgHelper.interceptedFiles.count(outputArchiveName)); @@ -1157,7 +864,7 @@ TEST_F(OclocFatBinaryTest, GivenSpirvInputWhenFatBinaryIsRequestedThenArchiveCon EXPECT_TRUE(isSpirvDataEqualsInputFileData); } -TEST_F(OclocFatBinaryTest, GivenDeviceFlagWithoutConsecutiveArgumentWhenBuildingFatbinaryThenErrorIsReported) { +TEST_F(OclocFatBinaryTest, givenDeviceFlagWithoutConsecutiveArgumentWhenBuildingFatbinaryThenErrorIsReported) { const std::vector args = { "ocloc", "-device"}; @@ -1172,12 +879,11 @@ TEST_F(OclocFatBinaryTest, GivenDeviceFlagWithoutConsecutiveArgumentWhenBuilding EXPECT_EQ(expectedErrorMessage, output); } -TEST_F(OclocFatBinaryTest, GivenFlagsWhichRequireMoreArgsWithoutThemWhenBuildingFatbinaryThenErrorIsReported) { +TEST_F(OclocFatBinaryTest, givenFlagsWhichRequireMoreArgsWithoutThemWhenBuildingFatbinaryThenErrorIsReported) { const auto devices = prepareTwoDevices(&mockArgHelper); if (devices.empty()) { GTEST_SKIP(); } - const std::array flagsToTest = {"-file", "-output", "-out_dir"}; for (const auto &flag : flagsToTest) { @@ -1198,12 +904,11 @@ TEST_F(OclocFatBinaryTest, GivenFlagsWhichRequireMoreArgsWithoutThemWhenBuilding } } -TEST_F(OclocFatBinaryTest, GivenBitFlagsWhenBuildingFatbinaryThenFilesInArchiveHaveCorrectPointerSize) { +TEST_F(OclocFatBinaryTest, givenBitFlagsWhenBuildingFatbinaryThenFilesInArchiveHaveCorrectPointerSize) { const auto devices = prepareTwoDevices(&mockArgHelper); if (devices.empty()) { GTEST_SKIP(); } - using TestDescription = std::pair; const std::array flagsToTest{ @@ -1226,6 +931,7 @@ TEST_F(OclocFatBinaryTest, GivenBitFlagsWhenBuildingFatbinaryThenFilesInArchiveH "-device", devices}; + mockArgHelper.getPrinterRef() = MessagePrinter{true}; const auto buildResult = buildFatBinary(args, &mockArgHelper); ASSERT_EQ(OclocErrorCode::SUCCESS, buildResult); ASSERT_EQ(1u, mockArgHelper.interceptedFiles.count(outputArchiveName)); @@ -1245,12 +951,11 @@ TEST_F(OclocFatBinaryTest, GivenBitFlagsWhenBuildingFatbinaryThenFilesInArchiveH } } -TEST_F(OclocFatBinaryTest, GivenOutputDirectoryFlagWhenBuildingFatbinaryThenArchiveIsStoredInThatDirectory) { +TEST_F(OclocFatBinaryTest, givenOutputDirectoryFlagWhenBuildingFatbinaryThenArchiveIsStoredInThatDirectory) { const auto devices = prepareTwoDevices(&mockArgHelper); if (devices.empty()) { GTEST_SKIP(); } - const std::string outputDirectory{"someOutputDir"}; const std::vector args = { @@ -1266,6 +971,7 @@ TEST_F(OclocFatBinaryTest, GivenOutputDirectoryFlagWhenBuildingFatbinaryThenArch "-device", devices}; + mockArgHelper.getPrinterRef() = MessagePrinter{true}; const auto buildResult = buildFatBinary(args, &mockArgHelper); ASSERT_EQ(OclocErrorCode::SUCCESS, buildResult); @@ -1273,12 +979,11 @@ TEST_F(OclocFatBinaryTest, GivenOutputDirectoryFlagWhenBuildingFatbinaryThenArch ASSERT_EQ(1u, mockArgHelper.interceptedFiles.count(expectedArchivePath)); } -TEST_F(OclocFatBinaryTest, GivenSpirvInputAndExcludeIrFlagWhenFatBinaryIsRequestedThenArchiveDoesNotContainGenericIrFile) { +TEST_F(OclocFatBinaryTest, givenSpirvInputAndExcludeIrFlagWhenFatBinaryIsRequestedThenArchiveDoesNotContainGenericIrFile) { const auto devices = prepareTwoDevices(&mockArgHelper); if (devices.empty()) { GTEST_SKIP(); } - const std::vector args = { "ocloc", "-output", @@ -1291,6 +996,7 @@ TEST_F(OclocFatBinaryTest, GivenSpirvInputAndExcludeIrFlagWhenFatBinaryIsRequest "-device", devices}; + mockArgHelper.getPrinterRef() = MessagePrinter{true}; const auto buildResult = buildFatBinary(args, &mockArgHelper); ASSERT_EQ(OclocErrorCode::SUCCESS, buildResult); ASSERT_EQ(1u, mockArgHelper.interceptedFiles.count(outputArchiveName)); @@ -1310,7 +1016,7 @@ TEST_F(OclocFatBinaryTest, GivenSpirvInputAndExcludeIrFlagWhenFatBinaryIsRequest EXPECT_EQ(decodedArchive.files.end(), spirvFileIt); } -TEST_F(OclocFatBinaryTest, GivenClInputFileWhenFatBinaryIsRequestedThenArchiveDoesNotContainGenericIrFile) { +TEST_F(OclocFatBinaryTest, givenClInputFileWhenFatBinaryIsRequestedThenArchiveDoesNotContainGenericIrFile) { const auto devices = prepareTwoDevices(&mockArgHelper); if (devices.empty()) { GTEST_SKIP(); @@ -1329,6 +1035,7 @@ TEST_F(OclocFatBinaryTest, GivenClInputFileWhenFatBinaryIsRequestedThenArchiveDo "-device", devices}; + mockArgHelper.getPrinterRef() = MessagePrinter{true}; const auto buildResult = buildFatBinary(args, &mockArgHelper); ASSERT_EQ(OclocErrorCode::SUCCESS, buildResult); ASSERT_EQ(1u, mockArgHelper.interceptedFiles.count(outputArchiveName)); @@ -1348,7 +1055,7 @@ TEST_F(OclocFatBinaryTest, GivenClInputFileWhenFatBinaryIsRequestedThenArchiveDo EXPECT_EQ(decodedArchive.files.end(), spirvFileIt); } -TEST_F(OclocFatBinaryTest, GivenEmptyFileWhenAppendingGenericIrThenInvalidFileIsReturned) { +TEST_F(OclocFatBinaryTest, givenEmptyFileWhenAppendingGenericIrThenInvalidFileIsReturned) { Ar::ArEncoder ar; std::string emptyFile{"empty_file.spv"}; mockArgHelperFilesMap[emptyFile] = ""; @@ -1362,7 +1069,7 @@ TEST_F(OclocFatBinaryTest, GivenEmptyFileWhenAppendingGenericIrThenInvalidFileIs EXPECT_EQ("Error! Couldn't read input file!\n", output); } -TEST_F(OclocFatBinaryTest, GivenInvalidIrFileWhenAppendingGenericIrThenInvalidFileIsReturned) { +TEST_F(OclocFatBinaryTest, givenInvalidIrFileWhenAppendingGenericIrThenInvalidFileIsReturned) { Ar::ArEncoder ar; std::string dummyFile{"dummy_file.spv"}; mockArgHelperFilesMap[dummyFile] = "This is not IR!"; @@ -1378,7 +1085,7 @@ TEST_F(OclocFatBinaryTest, GivenInvalidIrFileWhenAppendingGenericIrThenInvalidFi EXPECT_EQ(expectedErrorMessage, output); } -TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationErrorWhenBuildingFatbinaryForTargetThenNothingIsDoneAndErrorIsReturned) { +TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationErrorWhenBuildingFatbinaryForTargetThenNothingIsDoneAndErrorIsReturned) { const std::vector argv = { "ocloc", "-file", @@ -1387,6 +1094,7 @@ TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationErrorWhenBuildingFatbina gEnvironment->devicePrefix.c_str()}; MockOfflineCompiler mockOfflineCompiler{}; + mockOfflineCompiler.argHelper->getPrinterRef() = MessagePrinter{true}; mockOfflineCompiler.initialize(argv.size(), argv); // We expect that nothing is done and error is returned. @@ -1397,7 +1105,7 @@ TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationErrorWhenBuildingFatbina Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); const int previousReturnValue{OclocErrorCode::INVALID_FILE}; const auto buildResult = buildFatBinaryForTarget(previousReturnValue, argv, pointerSize, ar, &mockOfflineCompiler, mockArgHelper, deviceConfig); @@ -1406,7 +1114,7 @@ TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationErrorWhenBuildingFatbina EXPECT_EQ(0, mockOfflineCompiler.buildCalledCount); } -TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationSuccessAndFailingBuildWhenBuildingFatbinaryForTargetThenCompilationIsInvokedAndErrorLogIsPrinted) { +TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationSuccessAndFailingBuildWhenBuildingFatbinaryForTargetThenCompilationIsInvokedAndErrorLogIsPrinted) { const std::vector argv = { "ocloc", "-file", @@ -1422,7 +1130,7 @@ TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationSuccessAndFailingBuildWh Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); ::testing::internal::CaptureStdout(); const int previousReturnValue{OclocErrorCode::SUCCESS}; @@ -1445,7 +1153,7 @@ TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationSuccessAndFailingBuildWh EXPECT_EQ(expectedOutput, output); } -TEST(OclocFatBinaryHelpersTest, GivenNonEmptyBuildLogWhenBuildingFatbinaryForTargetThenBuildLogIsPrinted) { +TEST(OclocFatBinaryHelpersTest, givenNonEmptyBuildLogWhenBuildingFatbinaryForTargetThenBuildLogIsPrinted) { using namespace std::string_literals; const std::vector argv = { @@ -1468,7 +1176,7 @@ TEST(OclocFatBinaryHelpersTest, GivenNonEmptyBuildLogWhenBuildingFatbinaryForTar Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); ::testing::internal::CaptureStdout(); const int previousReturnValue{OclocErrorCode::SUCCESS}; @@ -1482,7 +1190,7 @@ TEST(OclocFatBinaryHelpersTest, GivenNonEmptyBuildLogWhenBuildingFatbinaryForTar EXPECT_EQ(expectedOutput, output); } -TEST(OclocFatBinaryHelpersTest, GivenQuietModeWhenBuildingFatbinaryForTargetThenNothingIsPrinted) { +TEST(OclocFatBinaryHelpersTest, givenQuietModeWhenBuildingFatbinaryForTargetThenNothingIsPrinted) { using namespace std::string_literals; const std::vector argv = { @@ -1503,7 +1211,7 @@ TEST(OclocFatBinaryHelpersTest, GivenQuietModeWhenBuildingFatbinaryForTargetThen Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); ::testing::internal::CaptureStdout(); const int previousReturnValue{OclocErrorCode::SUCCESS}; diff --git a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h index ec043e206e..0084e98f4d 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h +++ b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h @@ -16,21 +16,39 @@ #include namespace NEO { - -class OclocFatBinaryGetTargetConfigsForFatbinary : public ::testing::Test { +class OclocEnabledAcronyms : public ::testing::Test { public: - OclocFatBinaryGetTargetConfigsForFatbinary() { + std::vector enabledProducts{}; + std::vector enabledProductsAcronyms{}; + std::vector enabledFamiliesAcronyms{}; + std::vector enabledReleasesAcronyms{}; +}; + +class OclocFatBinaryProductAcronymsTests : public OclocEnabledAcronyms { + public: + OclocFatBinaryProductAcronymsTests() { oclocArgHelperWithoutInput = std::make_unique(); oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{true}; + + enabledProducts = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); + enabledProductsAcronyms = oclocArgHelperWithoutInput->getEnabledProductAcronyms(); + enabledFamiliesAcronyms = oclocArgHelperWithoutInput->getEnabledFamiliesAcronyms(); + enabledReleasesAcronyms = oclocArgHelperWithoutInput->getEnabledReleasesAcronyms(); } + std::unique_ptr oclocArgHelperWithoutInput; }; -class OclocFatBinaryTest : public ::testing::Test { +class OclocFatBinaryTest : public OclocEnabledAcronyms { public: OclocFatBinaryTest() { mockArgHelperFilesMap[spirvFilename] = spirvFileContent; mockArgHelper.interceptOutput = true; + + enabledProducts = mockArgHelper.getAllSupportedDeviceConfigs(); + enabledProductsAcronyms = mockArgHelper.getEnabledProductAcronyms(); + enabledFamiliesAcronyms = mockArgHelper.getEnabledFamiliesAcronyms(); + enabledReleasesAcronyms = mockArgHelper.getEnabledReleasesAcronyms(); } protected: diff --git a/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.cpp b/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.cpp index aa8683dd62..0cb400021d 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.cpp @@ -16,16 +16,16 @@ TEST_P(OclocProductConfigTests, GivenProductConfigValuesWhenInitHardwareInfoThen auto allSupportedDeviceConfigs = mockOfflineCompiler->argHelper->getAllSupportedDeviceConfigs(); for (const auto &deviceConfig : allSupportedDeviceConfigs) { - if (productConfig == deviceConfig.config) { + if (aotConfig.ProductConfig == deviceConfig.aotConfig.ProductConfig) { if (deviceConfig.deviceIds) { deviceId = deviceConfig.deviceIds->front(); } - revId = deviceConfig.revId; + revId = deviceConfig.aotConfig.ProductConfigID.Revision; break; } } - mockOfflineCompiler->deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + mockOfflineCompiler->deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); mockOfflineCompiler->initHardwareInfo(mockOfflineCompiler->deviceName); EXPECT_EQ(mockOfflineCompiler->hwInfo.platform.eProductFamily, productFamily); diff --git a/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.h b/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.h index bed9adb16b..ddd92f6252 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.h +++ b/opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.h @@ -12,13 +12,13 @@ #include "opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h" namespace NEO { -struct OclocProductConfigTests : public ::testing::TestWithParam> { +struct OclocProductConfigTests : public ::testing::TestWithParam> { void SetUp() override { - std::tie(productConfig, productFamily) = GetParam(); + std::tie(aotConfig.ProductConfig, productFamily) = GetParam(); mockOfflineCompiler = std::make_unique(); } - PRODUCT_CONFIG productConfig; + AheadOfTimeConfig aotConfig; PRODUCT_FAMILY productFamily; std::unique_ptr mockOfflineCompiler; }; diff --git a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp index cc41bdb3ac..7fa0d9a56e 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -194,7 +194,7 @@ TEST_F(MultiCommandTests, GivenSpecifiedOutputDirWithProductConfigValueWhenBuild std::string configStr; for (auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); + configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); break; } } @@ -521,6 +521,30 @@ TEST(MultiCommandWhiteboxTest, GivenInvalidArgsWhenInitializingThenErrorIsReturn } using MockOfflineCompilerTests = ::testing::Test; +TEST_F(MockOfflineCompilerTests, givenProductConfigValueAndRevisionIdWhenInitHwInfoThenTheseValuesAreSet) { + MockOfflineCompiler mockOfflineCompiler; + auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs(); + if (allEnabledDeviceConfigs.empty()) { + GTEST_SKIP(); + } + + auto config = AOT::UNKNOWN_ISA; + for (const auto &deviceMapConfig : allEnabledDeviceConfigs) { + if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { + config = static_cast(deviceMapConfig.aotConfig.ProductConfig); + break; + } + } + + mockOfflineCompiler.revisionId = 0x3; + mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(config); + EXPECT_FALSE(mockOfflineCompiler.deviceName.empty()); + + mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); + EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, mockOfflineCompiler.revisionId); + EXPECT_EQ(mockOfflineCompiler.deviceConfig, config); +} + TEST_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenBaseHardwareInfoValuesAreSet) { MockOfflineCompiler mockOfflineCompiler; auto allEnabledDeviceConfigs = mockOfflineCompiler.argHelper->getAllSupportedDeviceConfigs(); @@ -528,20 +552,16 @@ TEST_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenBaseHa GTEST_SKIP(); } - auto expectedRevId = 0u; - for (auto &deviceMapConfig : allEnabledDeviceConfigs) { + for (const auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); - expectedRevId = deviceMapConfig.revId; + mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); break; } } EXPECT_FALSE(mockOfflineCompiler.deviceName.empty()); - mockOfflineCompiler.initHardwareInfo(mockOfflineCompiler.deviceName); - EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usRevId, expectedRevId); EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.eProductFamily, productFamily); EXPECT_NE(mockOfflineCompiler.hwInfo.gtSystemInfo.MaxEuPerSubSlice, 0u); EXPECT_NE(mockOfflineCompiler.hwInfo.gtSystemInfo.MaxSlicesSupported, 0u); @@ -555,9 +575,9 @@ HWTEST2_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenMax GTEST_SKIP(); } - for (auto &deviceMapConfig : allEnabledDeviceConfigs) { + for (const auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); + mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); break; } } @@ -741,6 +761,7 @@ TEST_F(OfflineCompilerTests, givenDeviceIdHexValueWhenInitHwInfoThenItHasCorrect std::stringstream deviceString, productString; deviceString << "0x" << std::hex << deviceId; + mockOfflineCompiler.argHelper->getPrinterRef() = MessagePrinter{true}; mockOfflineCompiler.initHardwareInfo(deviceString.str()); EXPECT_EQ(mockOfflineCompiler.hwInfo.platform.usDeviceID, deviceId); } @@ -761,6 +782,7 @@ TEST_F(OfflineCompilerTests, givenProperDeviceIdHexAsDeviceArgumentThenSuccessIs "-device", deviceString.str()}; + oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; testing::internal::CaptureStdout(); pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); EXPECT_EQ(pOfflineCompiler->getHardwareInfo().platform.usDeviceID, deviceId); @@ -804,7 +826,7 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWithMissingRevisionValueWhenIn pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = testing::internal::GetCapturedStdout(); EXPECT_EQ(nullptr, pOfflineCompiler); - EXPECT_STREQ(output.c_str(), "Could not determine target based on product config: 9.1.\nError: Cannot get HW Info for device 9.1..\n"); + EXPECT_STREQ(output.c_str(), "Could not determine device target: 9.1.\nError: Cannot get HW Info for device 9.1..\n"); EXPECT_EQ(CL_INVALID_DEVICE, retVal); } @@ -819,7 +841,7 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWithInvalidPatternThenInvalidD pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = testing::internal::GetCapturedStdout(); EXPECT_EQ(nullptr, pOfflineCompiler); - EXPECT_STREQ(output.c_str(), "Could not determine target based on product config: 9.1..\nError: Cannot get HW Info for device 9.1...\n"); + EXPECT_STREQ(output.c_str(), "Could not determine device target: 9.1..\nError: Cannot get HW Info for device 9.1...\n"); EXPECT_EQ(CL_INVALID_DEVICE, retVal); } @@ -834,7 +856,7 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWithMissingMajorValueWhenInval pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = testing::internal::GetCapturedStdout(); EXPECT_EQ(nullptr, pOfflineCompiler); - EXPECT_STREQ(output.c_str(), "Could not determine target based on product config: .1.2\nError: Cannot get HW Info for device .1.2.\n"); + EXPECT_STREQ(output.c_str(), "Could not determine device target: .1.2\nError: Cannot get HW Info for device .1.2.\n"); EXPECT_EQ(CL_INVALID_DEVICE, retVal); } @@ -849,7 +871,7 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenInvalidRevisionValueIsPass pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = testing::internal::GetCapturedStdout(); EXPECT_EQ(nullptr, pOfflineCompiler); - EXPECT_STREQ(output.c_str(), "Could not determine target based on product config: 9.0.a\nError: Cannot get HW Info for device 9.0.a.\n"); + EXPECT_STREQ(output.c_str(), "Could not determine device target: 9.0.a\nError: Cannot get HW Info for device 9.0.a.\n"); EXPECT_EQ(CL_INVALID_DEVICE, retVal); } @@ -864,7 +886,7 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenInvalidMinorValueIsPassedT pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = testing::internal::GetCapturedStdout(); EXPECT_EQ(nullptr, pOfflineCompiler); - EXPECT_STREQ(output.c_str(), "Could not determine target based on product config: 9.a\nError: Cannot get HW Info for device 9.a.\n"); + EXPECT_STREQ(output.c_str(), "Could not determine device target: 9.a\nError: Cannot get HW Info for device 9.a.\n"); EXPECT_EQ(CL_INVALID_DEVICE, retVal); } @@ -879,7 +901,7 @@ TEST_F(OfflineCompilerTests, givenDeviceNumerationWhenPassedValuesAreOutOfRangeT pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get()); auto output = testing::internal::GetCapturedStdout(); EXPECT_EQ(nullptr, pOfflineCompiler); - EXPECT_STREQ(output.c_str(), "Could not determine target based on product config: 256.350\nError: Cannot get HW Info for device 256.350.\n"); + EXPECT_STREQ(output.c_str(), "Could not determine device target: 256.350\nError: Cannot get HW Info for device 256.350.\n"); EXPECT_EQ(CL_INVALID_DEVICE, retVal); } @@ -894,7 +916,7 @@ TEST_F(OfflineCompilerTests, givenInitHardwareInfowhenDeviceConfigContainsDevice for (auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); + mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); deviceMapConfig.deviceIds = &deviceIdsForTests; break; } @@ -1333,7 +1355,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceConfigValueThenBuild std::string configStr; for (auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); + configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); break; } } @@ -1639,6 +1661,36 @@ TEST(OfflineCompilerTest, WhenParsingCmdLineThenOptionsAreReadCorrectly) { delete mockOfflineCompiler; } +TEST(OfflineCompilerTest, GivenUnknownIsaConfigValueWhenInitHardwareInfoThenInvalidDeviceIsReturned) { + auto mockOfflineCompiler = std::make_unique(); + + auto deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(AOT::UNKNOWN_ISA); + std::stringstream resString; + + testing::internal::CaptureStdout(); + auto retVal = mockOfflineCompiler->initHardwareInfoForProductConfig(deviceName); + EXPECT_EQ(retVal, OclocErrorCode::INVALID_DEVICE); + + auto output = testing::internal::GetCapturedStdout(); + resString << "Could not determine device target: " << deviceName << "\n"; + EXPECT_STREQ(output.c_str(), resString.str().c_str()); +} + +TEST(OfflineCompilerTest, GivenUnsupportedDeviceConfigWhenInitHardwareInfoThenInvalidDeviceIsReturned) { + auto mockOfflineCompiler = std::make_unique(); + + auto deviceName = "00.01.02"; + std::stringstream resString; + + testing::internal::CaptureStdout(); + auto retVal = mockOfflineCompiler->initHardwareInfoForProductConfig(deviceName); + EXPECT_EQ(retVal, OclocErrorCode::INVALID_DEVICE); + + auto output = testing::internal::GetCapturedStdout(); + resString << "Could not determine target based on product config: " << deviceName << "\n"; + EXPECT_STREQ(output.c_str(), resString.str().c_str()); +} + TEST(OfflineCompilerTest, givenStatelessToStatefullOptimizationEnabledWhenDebugSettingsAreParsedThenOptimizationStringIsPresent) { DebugManagerStateRestore stateRestore; MockOfflineCompiler mockOfflineCompiler; @@ -1720,23 +1772,6 @@ TEST(OfflineCompilerTest, GivenValidParamWhenGettingHardwareInfoThenSuccessIsRet EXPECT_NE(PRODUCT_FAMILY::IGFX_UNKNOWN, mockOfflineCompiler->getHardwareInfo().platform.eProductFamily); } -TEST(OfflineCompilerTest, GivenConfigValueWhichIsOutOfRangeWhenGettingHardwareInfoThenInvalidDeviceIsReturned) { - auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); - ASSERT_NE(nullptr, mockOfflineCompiler); - - uint32_t value = 0xffffff + 1; - std::stringstream inproperValue, resString; - inproperValue << value; - - testing::internal::CaptureStdout(); - EXPECT_EQ(CL_INVALID_DEVICE, mockOfflineCompiler->initHardwareInfo(inproperValue.str())); - - resString << "Could not determine target based on product config: " << inproperValue.str() << "\n"; - - auto output = testing::internal::GetCapturedStdout(); - EXPECT_STREQ(output.c_str(), resString.str().c_str()); -} - TEST(OfflineCompilerTest, WhenStoringBinaryThenStoredCorrectly) { auto mockOfflineCompiler = std::unique_ptr(new MockOfflineCompiler()); ASSERT_NE(nullptr, mockOfflineCompiler); @@ -2983,37 +3018,35 @@ TEST(OclocArgHelperTest, GivenNoOutputPrintMessages) { EXPECT_STREQ(printMsg.data(), capturedStdout.c_str()); } -TEST(OclocArgHelperTest, GivenDifferentRevisionIdsInDeviceMappingsWhenComparingThemThenFalseIsReturned) { +TEST(OclocArgHelperTest, GivenDifferentAotConfigsInDeviceMappingsWhenComparingThemThenFalseIsReturned) { DeviceMapping lhs{}; DeviceMapping rhs{}; ASSERT_TRUE(lhs == rhs); - lhs.revId = 1; - rhs.revId = 2; - EXPECT_FALSE(lhs == rhs); -} - -TEST(OclocArgHelperTest, GivenDifferentHwInfosInDeviceMappingsWhenComparingThemThenFalseIsReturned) { - DeviceMapping lhs{}; - DeviceMapping rhs{}; - ASSERT_TRUE(lhs == rhs); - - HardwareInfo firstHwInfo{}; - lhs.hwInfo = &firstHwInfo; - - HardwareInfo secondHwInfo{}; - rhs.hwInfo = &secondHwInfo; + lhs.aotConfig = {AOT::CONFIG_MAX_PLATFORM}; + rhs.aotConfig = {AOT::UNKNOWN_ISA}; EXPECT_FALSE(lhs == rhs); } -TEST(OclocArgHelperTest, GivenDifferentConfigsInDeviceMappingsWhenComparingThemThenFalseIsReturned) { +TEST(OclocArgHelperTest, GivenDifferentFamiliesInDeviceMappingsWhenComparingThemThenFalseIsReturned) { DeviceMapping lhs{}; DeviceMapping rhs{}; ASSERT_TRUE(lhs == rhs); - lhs.config = CONFIG_MAX_PLATFORM; - rhs.config = UNKNOWN_ISA; + 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); } diff --git a/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp index 8b4b875bb8..9a941ce999 100644 --- a/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp +++ b/opencl/test/unit_test/offline_compiler/xe_hpc_core/pvc/offline_compiler_tests_pvc.cpp @@ -5,22 +5,16 @@ * */ +#include "shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h" + #include "opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.h" namespace NEO { -static PRODUCT_CONFIG pvcProductConfig[] = { - PVC_XL_A0, - PVC_XL_A0P, - PVC_XT_A0, - PVC_XT_B0, - PVC_XT_B1, - PVC_XT_C0}; - INSTANTIATE_TEST_CASE_P( OclocProductConfigPvcTestsValues, OclocProductConfigTests, ::testing::Combine( - ::testing::ValuesIn(pvcProductConfig), + ::testing::ValuesIn(AOT_PVC::productConfigs), ::testing::Values(IGFX_PVC))); } // namespace NEO \ No newline at end of file diff --git a/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp index c2fd0af095..8feb17d781 100644 --- a/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp +++ b/opencl/test/unit_test/offline_compiler/xe_hpg_core/dg2/offline_compiler_tests_dg2.cpp @@ -5,19 +5,16 @@ * */ +#include "shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h" + #include "opencl/test/unit_test/offline_compiler/ocloc_product_config_tests.h" namespace NEO { -static PRODUCT_CONFIG dg2ProductConfig[] = { - DG2_G10_A0, - DG2_G11, - DG2_G10_B0}; - INSTANTIATE_TEST_CASE_P( OclocProductConfigDg2TestsValues, OclocProductConfigTests, ::testing::Combine( - ::testing::ValuesIn(dg2ProductConfig), + ::testing::ValuesIn(AOT_DG2::productConfigs), ::testing::Values(IGFX_DG2))); } // namespace NEO \ No newline at end of file diff --git a/shared/offline_compiler/source/CMakeLists.txt b/shared/offline_compiler/source/CMakeLists.txt index 3bfbcbaa99..ffbf522e8d 100644 --- a/shared/offline_compiler/source/CMakeLists.txt +++ b/shared/offline_compiler/source/CMakeLists.txt @@ -12,6 +12,8 @@ set(OCLOC_FOLDER_NAME "offline_compiler") set(CLOC_LIB_SRCS_LIB ${NEO_SHARED_DIRECTORY}/compiler_interface/compiler_options/compiler_options_base.cpp ${NEO_SHARED_DIRECTORY}/compiler_interface/create_main.cpp + ${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.cpp + ${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.h ${NEO_SHARED_DIRECTORY}/device_binary_format/ar/ar.h ${NEO_SHARED_DIRECTORY}/device_binary_format/ar/ar_decoder.cpp ${NEO_SHARED_DIRECTORY}/device_binary_format/ar/ar_decoder.h @@ -28,11 +30,11 @@ set(CLOC_LIB_SRCS_LIB ${NEO_SHARED_DIRECTORY}/dll/devices/devices_base.inl ${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}/product_config.inl ${NEO_SHARED_DIRECTORY}/dll/devices/product_config_base.inl - ${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}platforms.h ${NEO_SHARED_DIRECTORY}/helpers/abort.cpp ${NEO_SHARED_DIRECTORY}/helpers/compiler_hw_info_config.h ${NEO_SHARED_DIRECTORY}/helpers/compiler_hw_info_config.cpp ${NEO_SHARED_DIRECTORY}/helpers/compiler_hw_info_config_base.inl + ${NEO_SHARED_DIRECTORY}/helpers/compiler_aot_config_bdw_and_later.inl ${NEO_SHARED_DIRECTORY}/helpers/compiler_hw_info_config_bdw_and_later.inl ${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.cpp ${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.h @@ -41,9 +43,9 @@ set(CLOC_LIB_SRCS_LIB ${NEO_SHARED_DIRECTORY}/helpers/hw_info.cpp ${NEO_SHARED_DIRECTORY}/helpers/hw_info.h ${NEO_SHARED_DIRECTORY}/helpers${BRANCH_DIR_SUFFIX}hw_info_extended.cpp + ${NEO_SHARED_DIRECTORY}/helpers/product_config_helper.cpp + ${NEO_SHARED_DIRECTORY}/helpers/product_config_helper.h ${NEO_SHARED_DIRECTORY}/os_interface/os_library.h - ${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.cpp - ${NEO_SHARED_DIRECTORY}/compiler_interface/oclc_extensions.h ${OCLOC_DIRECTORY}/source/decoder/binary_decoder.cpp ${OCLOC_DIRECTORY}/source/decoder/binary_decoder.h ${OCLOC_DIRECTORY}/source/decoder/binary_encoder.cpp @@ -81,6 +83,7 @@ set(CLOC_LIB_SRCS_LIB ${NEO_SOURCE_DIR}/shared/source/device_binary_format/device_binary_format_zebin.cpp ${NEO_SOURCE_DIR}/shared/source/device_binary_format/zebin_decoder.cpp ${NEO_SOURCE_DIR}/shared/source/device_binary_format/yaml/yaml_parser.cpp + ${NEO_SOURCE_DIR}/third_party${BRANCH_DIR_SUFFIX}aot_config_headers/platforms.h ) if(${IGA_HEADERS_AVAILABLE}) diff --git a/shared/offline_compiler/source/decoder/binary_decoder.cpp b/shared/offline_compiler/source/decoder/binary_decoder.cpp index 6cc76131cc..91dd90fc8d 100644 --- a/shared/offline_compiler/source/decoder/binary_decoder.cpp +++ b/shared/offline_compiler/source/decoder/binary_decoder.cpp @@ -336,7 +336,7 @@ Examples: Disassemble Intel Compute GPU device binary ocloc disasm -file source_file_Gen9core.bin )===", - NEO::getDevicesTypes().c_str()); + argHelper->getAllSupportedAcronyms().c_str()); } int BinaryDecoder::processBinary(const void *&ptr, std::ostream &ptmFile) { diff --git a/shared/offline_compiler/source/decoder/binary_encoder.cpp b/shared/offline_compiler/source/decoder/binary_encoder.cpp index aa390f50f5..221bfbb2f8 100644 --- a/shared/offline_compiler/source/decoder/binary_encoder.cpp +++ b/shared/offline_compiler/source/decoder/binary_encoder.cpp @@ -133,7 +133,7 @@ Examples: Assemble to Intel Compute GPU device binary ocloc asm -out reassembled.bin )===", - NEO::getDevicesTypes().c_str()); + argHelper->getAllSupportedAcronyms().c_str()); } int BinaryEncoder::encode() { diff --git a/shared/offline_compiler/source/ocloc_arg_helper.cpp b/shared/offline_compiler/source/ocloc_arg_helper.cpp index 437060a2d3..b1d1c56a92 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.cpp +++ b/shared/offline_compiler/source/ocloc_arg_helper.cpp @@ -7,6 +7,7 @@ #include "ocloc_arg_helper.h" +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/helpers/file_io.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/string.h" @@ -63,13 +64,11 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo #undef NAMEDDEVICE {0u, std::string("")}}), deviceMap({ -#define DEVICE_CONFIG_IDS_AND_REVISION(product, productConfig, deviceIds, revision_id) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, revision_id}, -#define DEVICE_CONFIG_IDS(product, productConfig, deviceIds) {product, &NEO::productConfig::hwInfo, &NEO::deviceIds, NEO::productConfig::hwInfo.platform.usRevId}, -#define DEVICE_CONFIG(product, productConfig) {product, &NEO::productConfig::hwInfo, nullptr, NEO::productConfig::hwInfo.platform.usRevId}, +#define DEVICE_CONFIG_IDS(product, productConfig, deviceIds, family, release) {&NEO::productConfig::hwInfo, &NEO::deviceIds, AOT::family, AOT::release, {AOT::product}}, +#define DEVICE_CONFIG(product, productConfig, family, release) {&NEO::productConfig::hwInfo, nullptr, AOT::family, AOT::release, {AOT::product}}, #include "product_config.inl" #undef DEVICE_CONFIG #undef DEVICE_CONFIG_IDS -#undef DEVICE_CONFIG_IDS_AND_REVISION }) { for (uint32_t i = 0; i < numSources; ++i) { inputs.push_back(Source(dataSources[i], static_cast(lenSources[i]), nameSources[i])); @@ -77,15 +76,15 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo for (uint32_t i = 0; i < numInputHeaders; ++i) { headers.push_back(Source(dataInputHeaders[i], static_cast(lenInputHeaders[i]), nameInputHeaders[i])); } - for (unsigned int family = 0; family < IGFX_MAX_CORE; ++family) { - if (NEO::familyName[family] == nullptr) { - continue; - } - insertGenNames(static_cast(family)); - } std::sort(deviceMap.begin(), deviceMap.end(), compareConfigs); - deviceMap.erase(std::unique(deviceMap.begin(), deviceMap.end(), isDuplicateConfig), deviceMap.end()); + for (auto &device : deviceMap) { + for (const auto &[acronym, value] : AOT::productConfigAcronyms) { + if (value == device.aotConfig.ProductConfig) { + device.acronyms.push_back(NEO::ConstStringRef(acronym)); + } + } + } } OclocArgHelper::OclocArgHelper() : OclocArgHelper(0, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) {} @@ -169,31 +168,19 @@ std::unique_ptr OclocArgHelper::loadDataFromFile(const std::string &file } } -void OclocArgHelper::setDeviceInfoForFatbinaryTarget(const DeviceMapping &device) { - deviceForFatbinary.hwInfo = device.hwInfo; - deviceForFatbinary.revId = device.revId; - deviceForFatbinary.deviceIds = device.deviceIds; -} - -void OclocArgHelper::setHwInfoForFatbinaryTarget(NEO::HardwareInfo &hwInfo) { - hwInfo = *deviceForFatbinary.hwInfo; - NEO::hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true); - hwInfo.platform.usRevId = deviceForFatbinary.revId; - if (deviceForFatbinary.deviceIds) { - hwInfo.platform.usDeviceID = deviceForFatbinary.deviceIds->front(); - } -} - bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo) { bool retVal = false; - if (config == UNKNOWN_ISA) { + if (config == AOT::UNKNOWN_ISA) { return retVal; } + for (auto &deviceConfig : deviceMap) { - if (deviceConfig.config == config) { + if (deviceConfig.aotConfig.ProductConfig == config) { hwInfo = *deviceConfig.hwInfo; + const auto &compilerHwInfoConfig = *NEO::CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily); + compilerHwInfoConfig.setProductConfigForHwInfo(hwInfo, deviceConfig.aotConfig); NEO::hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true); - hwInfo.platform.usRevId = deviceConfig.revId; + if (deviceConfig.deviceIds) { hwInfo.platform.usDeviceID = deviceConfig.deviceIds->front(); } @@ -204,14 +191,6 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInf return retVal; } -void OclocArgHelper::getProductConfigsForGfxCoreFamily(GFXCORE_FAMILY core, std::vector &out) { - for (auto &deviceConfig : deviceMap) { - if (deviceConfig.hwInfo->platform.eRenderCoreFamily == core) { - out.push_back(deviceConfig); - } - } -} - void OclocArgHelper::saveOutput(const std::string &filename, const void *pData, const size_t &dataSize) { if (outputEnabled()) { addOutput(filename, pData, dataSize); @@ -231,6 +210,60 @@ void OclocArgHelper::saveOutput(const std::string &filename, const std::ostream } } +std::string OclocArgHelper::getAllSupportedAcronyms() { + std::ostringstream os; + for (const auto &device : deviceMap) { + for (const auto &acronym : device.acronyms) { + if (os.tellp()) + os << ", "; + os << acronym.str(); + } + } + return os.str(); +} + +std::vector OclocArgHelper::getEnabledProductAcronyms() { + std::vector enabledAcronyms{}; + for (const auto &device : deviceMap) { + if (!device.acronyms.empty()) { + enabledAcronyms.push_back(device.acronyms.front()); + } + } + return enabledAcronyms; +} + +std::vector OclocArgHelper::getEnabledReleasesAcronyms() { + std::vector ret; + for (const auto &[acronym, value] : AOT::releaseAcronyms) { + if (std::any_of(deviceMap.begin(), deviceMap.end(), findRelease(value))) { + ret.push_back(NEO::ConstStringRef(acronym)); + } + } + return ret; +} + +std::vector OclocArgHelper::getEnabledFamiliesAcronyms() { + std::vector enabledAcronyms; + for (const auto &[acronym, value] : AOT::familyAcronyms) { + if (std::any_of(deviceMap.begin(), deviceMap.end(), findFamily(value))) { + enabledAcronyms.push_back(NEO::ConstStringRef(acronym)); + } + } + return enabledAcronyms; +} + +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) { std::string res = ""; for (int i = 0; deviceProductTable[i].deviceId != 0; i++) { @@ -245,15 +278,6 @@ std::vector &OclocArgHelper::getAllSupportedDeviceConfigs() { return deviceMap; } -std::vector OclocArgHelper::getAllSupportedProductConfigs() { - std::vector allConfigs; - for (auto &deviceConfig : deviceMap) { - allConfigs.push_back(deviceConfig.config); - } - std::sort(allConfigs.begin(), allConfigs.end()); - return allConfigs; -} - int OclocArgHelper::parseProductConfigFromString(const std::string &device, size_t begin, size_t end) { if (begin == end) { return CONFIG_STATUS::MISMATCHED_VALUE; @@ -271,119 +295,55 @@ int OclocArgHelper::parseProductConfigFromString(const std::string &device, size } } -std::vector OclocArgHelper::getMajorMinorRevision(const std::string &device) { - std::vector numeration; +AheadOfTimeConfig OclocArgHelper::getMajorMinorRevision(const std::string &device) { + AheadOfTimeConfig product = {AOT::UNKNOWN_ISA}; auto majorPos = device.find("."); auto major = parseProductConfigFromString(device, 0, majorPos); - if (major == CONFIG_STATUS::MISMATCHED_VALUE) { - return {}; - } - numeration.push_back(major); - if (majorPos == std::string::npos) { - return numeration; + if (major == CONFIG_STATUS::MISMATCHED_VALUE || majorPos == std::string::npos) { + return product; } auto minorPos = device.find(".", ++majorPos); auto minor = parseProductConfigFromString(device, majorPos, minorPos); - if (minor == CONFIG_STATUS::MISMATCHED_VALUE) { - return {}; - } - numeration.push_back(minor); - if (minorPos == std::string::npos) { - return numeration; + if (minor == CONFIG_STATUS::MISMATCHED_VALUE || minorPos == std::string::npos) { + return product; } + auto revision = parseProductConfigFromString(device, minorPos + 1, device.size()); if (revision == CONFIG_STATUS::MISMATCHED_VALUE) { - return {}; + return product; } - numeration.push_back(revision); - return numeration; + product.ProductConfigID.Major = major; + product.ProductConfigID.Minor = minor; + product.ProductConfigID.Revision = revision; + return product; } -uint32_t OclocArgHelper::getProductConfig(std::vector &numeration) { - uint32_t config = 0x0; - - config = numeration.at(0) << 16; - if (numeration.size() > 1) { - config |= (numeration.at(1) << 8); +bool OclocArgHelper::isRelease(const std::string &device) { + auto release = ProductConfigHelper::returnReleaseForAcronym(device); + if (release == AOT::UNKNOWN_RELEASE) { + return false; } - if (numeration.size() > 2) { - config |= numeration.at(2); - } - - return config; + return std::any_of(deviceMap.begin(), deviceMap.end(), findRelease(release)); } -uint32_t OclocArgHelper::getMaskForConfig(std::vector &numeration) { - uint32_t mask = 0xffffff; - if (numeration.size() == 1) { - mask = 0xff0000; - } else if (numeration.size() == 2) { - mask = 0xffff00; +bool OclocArgHelper::isFamily(const std::string &device) { + auto family = ProductConfigHelper::returnFamilyForAcronym(device); + if (family == AOT::UNKNOWN_FAMILY) { + return false; } - return mask; + return std::any_of(deviceMap.begin(), deviceMap.end(), findFamily(family)); } -bool OclocArgHelper::isGen(const std::string &device) { - std::string buf(device); - std::transform(buf.begin(), buf.end(), buf.begin(), ::tolower); - auto it = genIGFXMap.find(buf); - return it == genIGFXMap.end() ? false : true; -} - -unsigned int OclocArgHelper::returnIGFXforGen(const std::string &device) { - std::string buf(device); - std::transform(buf.begin(), buf.end(), buf.begin(), ::tolower); - auto it = genIGFXMap.find(buf); - if (it == genIGFXMap.end()) - return 0; - return it->second; +bool OclocArgHelper::isProductConfig(const std::string &device) { + auto config = ProductConfigHelper::returnProductConfigForAcronym(device); + if (config == AOT::UNKNOWN_ISA) { + return false; + } + return std::any_of(deviceMap.begin(), deviceMap.end(), findProductConfig(config)); } bool OclocArgHelper::areQuotesRequired(const std::string_view &argName) { return argName == "-options" || argName == "-internal_options"; } - -PRODUCT_CONFIG OclocArgHelper::findConfigMatch(const std::string &device, bool firstAppearance) { - auto numeration = getMajorMinorRevision(device); - if (numeration.empty()) { - return PRODUCT_CONFIG::UNKNOWN_ISA; - } - - std::vector allMatchedConfigs; - std::vector allConfigs = getAllSupportedProductConfigs(); - auto configValue = getProductConfig(numeration); - uint32_t mask = getMaskForConfig(numeration); - - if (!firstAppearance) { - // find last appearance - std::reverse(allConfigs.begin(), allConfigs.end()); - } - - for (auto &productConfig : allConfigs) { - uint32_t value = static_cast(productConfig) & mask; - if (value == configValue) { - return productConfig; - } - } - return PRODUCT_CONFIG::UNKNOWN_ISA; -} - -void OclocArgHelper::insertGenNames(GFXCORE_FAMILY family) { - std::string genName = NEO::familyName[family]; - std::transform(genName.begin(), genName.end(), genName.begin(), ::tolower); - genIGFXMap.insert({genName, family}); - - auto findCore = genName.find("_core"); - if (findCore != std::string::npos) { - genName = genName.substr(0, findCore); - genIGFXMap.insert({genName, family}); - } - - auto findUnderline = genName.find("_"); - if (findUnderline != std::string::npos) { - genName.erase(std::remove(genName.begin(), genName.end(), '_'), genName.end()); - genIGFXMap.insert({genName, family}); - } -} diff --git a/shared/offline_compiler/source/ocloc_arg_helper.h b/shared/offline_compiler/source/ocloc_arg_helper.h index c974093464..7efcfac92c 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.h +++ b/shared/offline_compiler/source/ocloc_arg_helper.h @@ -9,6 +9,8 @@ #include "shared/offline_compiler/source/decoder/helper.h" #include "shared/source/helpers/hw_info.h" +#include "shared/source/helpers/product_config_helper.h" +#include "shared/source/utilities/const_stringref.h" #include "device_ids_configs.h" #include "hw_cmds.h" @@ -48,13 +50,15 @@ struct DeviceProduct { }; struct DeviceMapping { - PRODUCT_CONFIG config = UNKNOWN_ISA; const NEO::HardwareInfo *hwInfo = nullptr; const std::vector *deviceIds = nullptr; - unsigned int revId = 0U; + AOT::FAMILY family = AOT::UNKNOWN_FAMILY; + AOT::RELEASE release = AOT::UNKNOWN_RELEASE; + AheadOfTimeConfig aotConfig = {0}; + std::vector acronyms{}; bool operator==(const DeviceMapping &rhs) { - return config == rhs.config && hwInfo == rhs.hwInfo && revId == rhs.revId; + return aotConfig.ProductConfig == rhs.aotConfig.ProductConfig && family == rhs.family && release == rhs.release; } }; @@ -70,9 +74,6 @@ class OclocArgHelper { MessagePrinter messagePrinter; const std::vector deviceProductTable; std::vector deviceMap; - DeviceMapping deviceForFatbinary; - std::map genIGFXMap; - bool fatBinary = false; void moveOutputs(); Source *findSourceFile(const std::string &filename); bool sourceFileExists(const std::string &filename) const; @@ -82,11 +83,22 @@ class OclocArgHelper { } static bool compareConfigs(DeviceMapping deviceMap0, DeviceMapping deviceMap1) { - return deviceMap0.config < deviceMap1.config; + return deviceMap0.aotConfig.ProductConfig < deviceMap1.aotConfig.ProductConfig; } - static bool isDuplicateConfig(DeviceMapping deviceMap0, DeviceMapping deviceMap1) { - return deviceMap0.config == deviceMap1.config; + template + auto findFamily(const EqComparableT &lhs) { + return [&lhs](const auto &rhs) { return lhs == rhs.family; }; + } + + template + auto findRelease(const EqComparableT &lhs) { + return [&lhs](const auto &rhs) { return lhs == rhs.release; }; + } + + template + auto findProductConfig(const EqComparableT &lhs) { + return [&lhs](const auto &rhs) { return lhs == rhs.aotConfig.ProductConfig; }; } public: @@ -105,16 +117,13 @@ class OclocArgHelper { MOCKABLE_VIRTUAL bool fileExists(const std::string &filename) const; int parseProductConfigFromString(const std::string &device, size_t begin, size_t end); bool getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo); - void getProductConfigsForGfxCoreFamily(GFXCORE_FAMILY core, std::vector &out); - void setDeviceInfoForFatbinaryTarget(const DeviceMapping &device); - void setHwInfoForFatbinaryTarget(NEO::HardwareInfo &hwInfo); - std::vector getAllSupportedProductConfigs(); std::vector &getAllSupportedDeviceConfigs(); - std::vector getMajorMinorRevision(const std::string &device); - uint32_t getProductConfig(std::vector &numeration); - uint32_t getMaskForConfig(std::vector &numeration); - PRODUCT_CONFIG findConfigMatch(const std::string &device, bool firstAppearance); - void insertGenNames(GFXCORE_FAMILY family); + std::vector getEnabledProductAcronyms(); + std::vector getEnabledReleasesAcronyms(); + std::vector getEnabledFamiliesAcronyms(); + std::string getAllSupportedAcronyms(); + AheadOfTimeConfig getMajorMinorRevision(const std::string &device); + bool setAcronymForDeviceId(std::string &device); std::vector headersToVectorOfStrings(); MOCKABLE_VIRTUAL void readFileToVectorOfStrings(const std::string &filename, std::vector &lines); MOCKABLE_VIRTUAL std::vector readBinaryFile(const std::string &filename); @@ -130,13 +139,6 @@ class OclocArgHelper { return headers; } - void setFatbinary(bool isFatBinary) { - this->fatBinary = isFatBinary; - } - - bool isFatbinary() { - return fatBinary; - } MOCKABLE_VIRTUAL void saveOutput(const std::string &filename, const void *pData, const size_t &dataSize); void saveOutput(const std::string &filename, const std::ostream &stream); @@ -149,8 +151,10 @@ class OclocArgHelper { messagePrinter.printf(format, std::forward(args)...); } - std::string returnProductNameForDevice(unsigned short deviceId); - bool isGen(const std::string &device); - unsigned int returnIGFXforGen(const std::string &device); + bool isRelease(const std::string &device); + bool isFamily(const std::string &device); + bool isProductConfig(const std::string &device); bool areQuotesRequired(const std::string_view &argName); + + std::string returnProductNameForDevice(unsigned short deviceId); }; diff --git a/shared/offline_compiler/source/ocloc_fatbinary.cpp b/shared/offline_compiler/source/ocloc_fatbinary.cpp index fb382f5fbd..bdbde9318a 100644 --- a/shared/offline_compiler/source/ocloc_fatbinary.cpp +++ b/shared/offline_compiler/source/ocloc_fatbinary.cpp @@ -23,295 +23,195 @@ #include namespace NEO { -std::vector getAllMatchedConfigs(const std::string device, OclocArgHelper *argHelper) { - std::vector allMatchedConfigs; - auto numeration = argHelper->getMajorMinorRevision(device); - if (numeration.empty()) { - return {}; - } - auto config = argHelper->getProductConfig(numeration); - std::vector allConfigs = argHelper->getAllSupportedProductConfigs(); - uint32_t mask = argHelper->getMaskForConfig(numeration); - - for (auto &productConfig : allConfigs) { - auto prod = static_cast(productConfig) & mask; - if (config == prod) { - allMatchedConfigs.push_back(productConfig); - } - } - - return allMatchedConfigs; -} - bool requestedFatBinary(const std::vector &args, OclocArgHelper *helper) { for (size_t argIndex = 1; argIndex < args.size(); argIndex++) { const auto &currArg = args[argIndex]; const bool hasMoreArgs = (argIndex + 1 < args.size()); if ((ConstStringRef("-device") == currArg) && hasMoreArgs) { ConstStringRef deviceArg(args[argIndex + 1]); - auto products = getAllMatchedConfigs(deviceArg.str(), helper); - if (products.size() > 1) { - return true; - } - return deviceArg.contains("*") || deviceArg.contains("-") || deviceArg.contains(",") || helper->isGen(deviceArg.str()); + auto retVal = deviceArg.contains("*"); + retVal |= deviceArg.contains(":"); + retVal |= deviceArg.contains(","); + retVal |= helper->isFamily(deviceArg.str()); + retVal |= helper->isRelease(deviceArg.str()); + + return retVal; } } return false; } -std::vector getAllSupportedTargetPlatforms() { - return std::vector{ALL_SUPPORTED_PRODUCT_FAMILIES}; -} - -std::vector toProductNames(const std::vector &productIds) { - std::vector ret; - for (auto prodId : productIds) { - ret.push_back(ConstStringRef(hardwarePrefix[prodId], strlen(hardwarePrefix[prodId]))); - } - return ret; -} - -PRODUCT_FAMILY asProductId(ConstStringRef product, const std::vector &allSupportedPlatforms) { - for (auto &family : allSupportedPlatforms) { - if (product == hardwarePrefix[family]) { - return family; - } - } - return IGFX_UNKNOWN; -} - -std::vector getProductConfigsForOpenRange(ConstStringRef openRange, OclocArgHelper *argHelper, bool rangeTo) { - std::vector requestedConfigs; - std::vector allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - - if (argHelper->isGen(openRange.str())) { - std::vector coreIdList; - auto coreId = argHelper->returnIGFXforGen(openRange.str()); - coreIdList.push_back(static_cast(coreId)); - if (rangeTo) { - auto coreId = coreIdList.back(); - unsigned int coreIt = IGFX_UNKNOWN_CORE; - ++coreIt; - while (coreIt <= static_cast(coreId)) { - argHelper->getProductConfigsForGfxCoreFamily(static_cast(coreIt), requestedConfigs); - ++coreIt; - } - } else { - unsigned int coreIt = coreIdList.front(); - while (coreIt < static_cast(IGFX_MAX_CORE)) { - argHelper->getProductConfigsForGfxCoreFamily(static_cast(coreIt), requestedConfigs); - ++coreIt; +template <> +void getProductsAcronymsForTarget(std::vector &out, AOT::FAMILY target, OclocArgHelper *argHelper) { + auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs(); + for (const auto &device : allSuppportedProducts) { + if (device.family == target && !device.acronyms.empty()) { + if (std::find(out.begin(), out.end(), device.acronyms.front()) == out.end()) { + out.push_back(device.acronyms.front()); } } + } +} + +template <> +void getProductsAcronymsForTarget(std::vector &out, AOT::RELEASE target, OclocArgHelper *argHelper) { + auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs(); + for (const auto &device : allSuppportedProducts) { + if (device.release == target && !device.acronyms.empty()) { + if (std::find(out.begin(), out.end(), device.acronyms.front()) == out.end()) { + out.push_back(device.acronyms.front()); + } + } + } +} + +template +void getProductsForTargetRange(T targetFrom, T targetTo, std::vector &out, + OclocArgHelper *argHelper) { + if (targetFrom > targetTo) { + std::swap(targetFrom, targetTo); + } + while (targetFrom <= targetTo) { + getProductsAcronymsForTarget(out, targetFrom, argHelper); + targetFrom = static_cast(static_cast(targetFrom) + 1); + } +} + +void getProductsForRange(unsigned int productFrom, unsigned int productTo, std::vector &out, + OclocArgHelper *argHelper) { + auto allSuppportedProducts = argHelper->getAllSupportedDeviceConfigs(); + + for (const auto &device : allSuppportedProducts) { + auto validAcronym = device.aotConfig.ProductConfig >= productFrom; + validAcronym &= device.aotConfig.ProductConfig <= productTo; + validAcronym &= !device.acronyms.empty(); + if (validAcronym) { + out.push_back(device.acronyms.front()); + } + } +} + +std::vector getProductForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, OclocArgHelper *argHelper) { + std::vector requestedProducts = {}; + auto rangeFromStr = rangeFrom.str(); + auto rangeToStr = rangeTo.str(); + + if (argHelper->isFamily(rangeFromStr) && argHelper->isFamily(rangeToStr)) { + auto familyFrom = ProductConfigHelper::returnFamilyForAcronym(rangeFromStr); + auto familyTo = ProductConfigHelper::returnFamilyForAcronym(rangeToStr); + getProductsForTargetRange(familyFrom, familyTo, requestedProducts, argHelper); + + } else if (argHelper->isRelease(rangeFromStr) && argHelper->isRelease(rangeToStr)) { + auto releaseFrom = ProductConfigHelper::returnReleaseForAcronym(rangeFromStr); + auto releaseTo = ProductConfigHelper::returnReleaseForAcronym(rangeToStr); + getProductsForTargetRange(releaseFrom, releaseTo, requestedProducts, argHelper); + + } else if (argHelper->isProductConfig(rangeFromStr) && argHelper->isProductConfig(rangeToStr)) { + unsigned int productConfigFrom = ProductConfigHelper::returnProductConfigForAcronym(rangeFromStr); + unsigned int productConfigTo = ProductConfigHelper::returnProductConfigForAcronym(rangeToStr); + if (productConfigFrom > productConfigTo) { + std::swap(productConfigFrom, productConfigTo); + } + getProductsForRange(productConfigFrom, productConfigTo, requestedProducts, argHelper); } else { - auto productConfig = argHelper->findConfigMatch(openRange.str(), !rangeTo); - if (productConfig == PRODUCT_CONFIG::UNKNOWN_ISA) { - argHelper->printf("Unknown device : %s\n", openRange.str().c_str()); - return {}; - } - auto configIt = std::find_if(allSupportedDeviceConfigs.begin(), - allSupportedDeviceConfigs.end(), - [&cf = productConfig](const DeviceMapping &c) -> bool { return cf == c.config; }); - if (rangeTo) { - for (auto &deviceConfig : allSupportedDeviceConfigs) { - if (deviceConfig.config <= productConfig) { - requestedConfigs.push_back(deviceConfig); - } - } - } else { - requestedConfigs.insert(requestedConfigs.end(), configIt, allSupportedDeviceConfigs.end()); - } - } - return requestedConfigs; -} - -std::vector getProductConfigsForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, OclocArgHelper *argHelper) { - std::vector requestedConfigs; - std::vector allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - - if (argHelper->isGen(rangeFrom.str())) { - if (false == argHelper->isGen(rangeTo.str())) { - argHelper->printf("Ranges mixing configs and architecture is not supported, should be architectureFrom-architectureTo or configFrom-configTo\n"); - return {}; - } - auto coreFrom = argHelper->returnIGFXforGen(rangeFrom.str()); - auto coreTo = argHelper->returnIGFXforGen(rangeTo.str()); - if (static_cast(coreFrom) > static_cast(coreTo)) { - std::swap(coreFrom, coreTo); - } - while (coreFrom <= coreTo) { - argHelper->getProductConfigsForGfxCoreFamily(static_cast(coreFrom), requestedConfigs); - coreFrom = static_cast(static_cast(coreFrom) + 1); - } - } else { - auto configFrom = argHelper->findConfigMatch(rangeFrom.str(), true); - if (configFrom == PRODUCT_CONFIG::UNKNOWN_ISA) { - argHelper->printf("Unknown device range : %s\n", rangeFrom.str().c_str()); - return {}; - } - - auto configTo = argHelper->findConfigMatch(rangeTo.str(), false); - if (configTo == PRODUCT_CONFIG::UNKNOWN_ISA) { - argHelper->printf("Unknown device range : %s\n", rangeTo.str().c_str()); - return {}; - } - - if (configFrom > configTo) { - configFrom = argHelper->findConfigMatch(rangeTo.str(), true); - configTo = argHelper->findConfigMatch(rangeFrom.str(), false); - } - - for (auto &deviceConfig : allSupportedDeviceConfigs) { - if (deviceConfig.config >= configFrom && deviceConfig.config <= configTo) { - requestedConfigs.push_back(deviceConfig); - } - } - } - - return requestedConfigs; -} - -std::vector getPlatformsForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, PRODUCT_FAMILY platformFrom, OclocArgHelper *argHelper) { - std::vector requestedPlatforms; - std::vector allSupportedPlatforms = getAllSupportedTargetPlatforms(); - - auto platformTo = asProductId(rangeTo, allSupportedPlatforms); - if (IGFX_UNKNOWN == platformTo) { - argHelper->printf("Unknown device : %s\n", rangeTo.str().c_str()); + auto target = rangeFromStr + ":" + rangeToStr; + argHelper->printf("Failed to parse target : %s.\n", target.c_str()); return {}; } - if (platformFrom > platformTo) { - std::swap(platformFrom, platformTo); - } - auto from = std::find(allSupportedPlatforms.begin(), allSupportedPlatforms.end(), platformFrom); - auto to = std::find(allSupportedPlatforms.begin(), allSupportedPlatforms.end(), platformTo) + 1; - requestedPlatforms.insert(requestedPlatforms.end(), from, to); - - return toProductNames(requestedPlatforms); + return requestedProducts; } -std::vector getPlatformsForOpenRange(ConstStringRef openRange, PRODUCT_FAMILY prodId, OclocArgHelper *argHelper, bool rangeTo) { - std::vector requestedPlatforms; - std::vector allSupportedPlatforms = getAllSupportedTargetPlatforms(); +std::vector getProductForOpenRange(ConstStringRef openRange, OclocArgHelper *argHelper, bool rangeTo) { + std::vector requestedProducts = {}; + auto openRangeStr = openRange.str(); - auto prodIt = std::find(allSupportedPlatforms.begin(), allSupportedPlatforms.end(), prodId); - assert(prodIt != allSupportedPlatforms.end()); - if (rangeTo) { - requestedPlatforms.insert(requestedPlatforms.end(), allSupportedPlatforms.begin(), prodIt + 1); - } else { - requestedPlatforms.insert(requestedPlatforms.end(), prodIt, allSupportedPlatforms.end()); - } - - return toProductNames(requestedPlatforms); -} - -std::vector getProductConfigsForSpecificTargets(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper) { - std::vector requestedConfigs; - std::vector allSupportedDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - - for (auto &target : targets) { - if (argHelper->isGen(target.str())) { - auto coreId = argHelper->returnIGFXforGen(target.str()); - argHelper->getProductConfigsForGfxCoreFamily(static_cast(coreId), requestedConfigs); + if (argHelper->isFamily(openRangeStr)) { + auto family = ProductConfigHelper::returnFamilyForAcronym(openRangeStr); + if (rangeTo) { + unsigned int familyFrom = AOT::UNKNOWN_FAMILY; + ++familyFrom; + getProductsForTargetRange(static_cast(familyFrom), family, requestedProducts, argHelper); } else { - auto configFirstEl = argHelper->findConfigMatch(target.str(), true); - if (configFirstEl == PRODUCT_CONFIG::UNKNOWN_ISA) { - argHelper->printf("Unknown device range : %s\n", target.str().c_str()); - return {}; - } + unsigned int familyTo = AOT::FAMILY_MAX; + --familyTo; + getProductsForTargetRange(family, static_cast(familyTo), requestedProducts, argHelper); + } + } else if (argHelper->isRelease(openRangeStr)) { + auto release = ProductConfigHelper::returnReleaseForAcronym(openRangeStr); + if (rangeTo) { + unsigned int releaseFrom = AOT::UNKNOWN_FAMILY; + ++releaseFrom; + getProductsForTargetRange(static_cast(releaseFrom), release, requestedProducts, argHelper); + } else { + unsigned int releaseTo = AOT::RELEASE_MAX; + --releaseTo; + getProductsForTargetRange(release, static_cast(releaseTo), requestedProducts, argHelper); + } + } else if (argHelper->isProductConfig(openRangeStr)) { + auto product = ProductConfigHelper::returnProductConfigForAcronym(openRangeStr); + if (rangeTo) { + unsigned int productFrom = AOT::UNKNOWN_ISA; + ++productFrom; + getProductsForRange(productFrom, static_cast(product), requestedProducts, argHelper); + } else { + unsigned int productTo = AOT::CONFIG_MAX_PLATFORM; + --productTo; + getProductsForRange(product, static_cast(productTo), requestedProducts, argHelper); + } + } + return requestedProducts; +} - auto configLastEl = argHelper->findConfigMatch(target.str(), false); - for (auto &deviceConfig : allSupportedDeviceConfigs) { - if (deviceConfig.config >= configFirstEl && deviceConfig.config <= configLastEl) { - requestedConfigs.push_back(deviceConfig); - } - } +std::vector getProductForSpecificTarget(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper) { + std::vector requestedConfigs; + for (const auto &target : targets) { + auto targetStr = target.str(); + if (argHelper->isFamily(targetStr)) { + auto family = ProductConfigHelper::returnFamilyForAcronym(targetStr); + getProductsAcronymsForTarget(requestedConfigs, family, argHelper); + } else if (argHelper->isRelease(targetStr)) { + auto release = ProductConfigHelper::returnReleaseForAcronym(targetStr); + getProductsAcronymsForTarget(requestedConfigs, release, argHelper); + } else if (argHelper->isProductConfig(targetStr)) { + requestedConfigs.push_back(target); + } else { + argHelper->printf("Failed to parse target : %s - invalid device:\n", targetStr.c_str()); + return {}; } } return requestedConfigs; } -std::vector getPlatformsForSpecificTargets(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper) { - std::vector requestedPlatforms; - std::vector allSupportedPlatforms = getAllSupportedTargetPlatforms(); - - for (auto &target : targets) { - auto prodId = asProductId(target, allSupportedPlatforms); - if (IGFX_UNKNOWN == prodId) { - argHelper->printf("Unknown device : %s\n", target.str().c_str()); - return {}; - } - requestedPlatforms.push_back(prodId); - } - return toProductNames(requestedPlatforms); -} - -bool isDeviceWithPlatformAbbreviation(ConstStringRef deviceArg, OclocArgHelper *argHelper) { - std::vector allSupportedPlatforms = getAllSupportedTargetPlatforms(); - PRODUCT_FAMILY prodId = IGFX_UNKNOWN; - auto sets = CompilerOptions::tokenize(deviceArg, ','); - if (sets[0].contains("-")) { - auto range = CompilerOptions::tokenize(deviceArg, '-'); - prodId = asProductId(range[0], allSupportedPlatforms); - - } else { - prodId = asProductId(sets[0], allSupportedPlatforms); - } - return prodId != IGFX_UNKNOWN; -} - -std::vector getTargetPlatformsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) { - std::vector allSupportedPlatforms = getAllSupportedTargetPlatforms(); +std::vector getTargetProductsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) { std::vector retVal; - - auto sets = CompilerOptions::tokenize(deviceArg, ','); - if (sets[0].contains("-")) { - auto range = CompilerOptions::tokenize(deviceArg, '-'); - if (range.size() > 2) { - argHelper->printf("Invalid range : %s - should be from-to or -to or from-\n", sets[0].str().c_str()); - return {}; - } - auto prodId = asProductId(range[0], allSupportedPlatforms); - if (range.size() == 1) { - bool rangeTo = ('-' == sets[0][0]); - retVal = getPlatformsForOpenRange(range[0], prodId, argHelper, rangeTo); - } else { - retVal = getPlatformsForClosedRange(range[0], range[1], prodId, argHelper); - } - } else { - retVal = getPlatformsForSpecificTargets(sets, argHelper); - } - return retVal; -} - -std::vector getTargetConfigsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) { if (deviceArg == "*") { - return argHelper->getAllSupportedDeviceConfigs(); - } - std::vector retVal; - auto sets = CompilerOptions::tokenize(deviceArg, ','); - if (sets[0].contains("-")) { - auto range = CompilerOptions::tokenize(deviceArg, '-'); - if (range.size() > 2) { - argHelper->printf("Invalid range : %s - should be from-to or -to or from-\n", sets[0].str().c_str()); - return {}; - } - if (range.size() == 1) { - bool rangeTo = ('-' == sets[0][0]); - retVal = getProductConfigsForOpenRange(range[0], argHelper, rangeTo); - - } else { - retVal = getProductConfigsForClosedRange(range[0], range[1], argHelper); - } + return argHelper->getEnabledProductAcronyms(); } else { - retVal = getProductConfigsForSpecificTargets(sets, argHelper); + auto sets = CompilerOptions::tokenize(deviceArg, ','); + if (sets[0].contains(":")) { + auto range = CompilerOptions::tokenize(deviceArg, ':'); + if (range.size() > 2) { + argHelper->printf("Invalid range : %s - should be from:to or :to or from:\n", sets[0].str().c_str()); + return {}; + } + if (range.size() == 1) { + bool rangeTo = (':' == sets[0][0]); + + retVal = getProductForOpenRange(range[0], argHelper, rangeTo); + + } else { + retVal = getProductForClosedRange(range[0], range[1], argHelper); + } + } else { + retVal = getProductForSpecificTarget(sets, argHelper); + } } return retVal; } int buildFatBinaryForTarget(int retVal, const std::vector &argsCopy, std::string pointerSize, Ar::ArEncoder &fatbinary, - OfflineCompiler *pCompiler, OclocArgHelper *argHelper, const std::string &deviceConfig) { + OfflineCompiler *pCompiler, OclocArgHelper *argHelper, const std::string &product) { if (retVal == 0) { retVal = buildWithSafetyGuard(pCompiler); @@ -321,9 +221,9 @@ int buildFatBinaryForTarget(int retVal, const std::vector &argsCopy } if (retVal == 0) { if (!pCompiler->isQuiet()) - argHelper->printf("Build succeeded for : %s.\n", deviceConfig.c_str()); + argHelper->printf("Build succeeded for : %s.\n", product.c_str()); } else { - argHelper->printf("Build failed for : %s with error code: %d\n", deviceConfig.c_str(), retVal); + argHelper->printf("Build failed for : %s with error code: %d\n", product.c_str(), retVal); argHelper->printf("Command was:"); for (const auto &arg : argsCopy) argHelper->printf(" %s", arg.c_str()); @@ -333,7 +233,8 @@ int buildFatBinaryForTarget(int retVal, const std::vector &argsCopy if (retVal) { return retVal; } - fatbinary.appendFileEntry(pointerSize + "." + deviceConfig, pCompiler->getPackedDeviceBinaryOutput()); + auto productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(ProductConfigHelper::returnProductConfigForAcronym(product)); + fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput()); return retVal; } @@ -384,56 +285,25 @@ int buildFatBinary(const std::vector &args, OclocArgHelper *argHelp } Ar::ArEncoder fatbinary(true); - if (isDeviceWithPlatformAbbreviation(ConstStringRef(args[deviceArgIndex]), argHelper)) { - std::vector targetPlatforms; - targetPlatforms = getTargetPlatformsForFatbinary(ConstStringRef(args[deviceArgIndex]), argHelper); - if (targetPlatforms.empty()) { - argHelper->printf("Failed to parse target devices from : %s\n", args[deviceArgIndex].c_str()); - return 1; - } - for (auto &targetPlatform : targetPlatforms) { - int retVal = 0; - argsCopy[deviceArgIndex] = targetPlatform.str(); + std::vector targetProducts; + targetProducts = getTargetProductsForFatbinary(ConstStringRef(args[deviceArgIndex]), argHelper); + if (targetProducts.empty()) { + argHelper->printf("Failed to parse target devices from : %s\n", args[deviceArgIndex].c_str()); + return 1; + } + for (const auto &product : targetProducts) { + int retVal = 0; + argsCopy[deviceArgIndex] = product.str(); - std::unique_ptr pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)}; - if (OclocErrorCode::SUCCESS != retVal) { - argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n"); - return retVal; - } - - std::string product = hardwarePrefix[pCompiler->getHardwareInfo().platform.eProductFamily]; - auto stepping = pCompiler->getHardwareInfo().platform.usRevId; - auto targetPlatforms = product + "." + std::to_string(stepping); - - retVal = buildFatBinaryForTarget(retVal, argsCopy, pointerSizeInBits, fatbinary, pCompiler.get(), argHelper, targetPlatforms); - if (retVal) { - return retVal; - } + std::unique_ptr pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)}; + if (OclocErrorCode::SUCCESS != retVal) { + argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n"); + return retVal; } - } else { - std::vector targetConfigs; - targetConfigs = getTargetConfigsForFatbinary(ConstStringRef(args[deviceArgIndex]), argHelper); - if (targetConfigs.empty()) { - argHelper->printf("Failed to parse target devices from : %s\n", args[deviceArgIndex].c_str()); - return 1; - } - for (auto &targetConfig : targetConfigs) { - int retVal = 0; - - argHelper->setFatbinary(true); - argHelper->setDeviceInfoForFatbinaryTarget(targetConfig); - std::unique_ptr pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)}; - if (OclocErrorCode::SUCCESS != retVal) { - argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n"); - return retVal; - } - - auto targetConfigStr = ProductConfigHelper::parseMajorMinorRevisionValue(targetConfig.config); - retVal = buildFatBinaryForTarget(retVal, argsCopy, pointerSizeInBits, fatbinary, pCompiler.get(), argHelper, targetConfigStr); - if (retVal) { - return retVal; - } + retVal = buildFatBinaryForTarget(retVal, argsCopy, pointerSizeInBits, fatbinary, pCompiler.get(), argHelper, product.str()); + if (retVal) { + return retVal; } } diff --git a/shared/offline_compiler/source/ocloc_fatbinary.h b/shared/offline_compiler/source/ocloc_fatbinary.h index 1636ed4159..6b83cd316f 100644 --- a/shared/offline_compiler/source/ocloc_fatbinary.h +++ b/shared/offline_compiler/source/ocloc_fatbinary.h @@ -34,19 +34,9 @@ inline int buildFatBinary(int argc, const char *argv[], OclocArgHelper *argHelpe return buildFatBinary(args, argHelper); } -bool isDeviceWithPlatformAbbreviation(ConstStringRef deviceArg, OclocArgHelper *argHelper); -std::vector getAllSupportedTargetPlatforms(); -std::vector getAllMatchedConfigs(const std::string device, OclocArgHelper *argHelper); -std::vector getTargetConfigsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper); -std::vector getTargetPlatformsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper); -std::vector getProductConfigsForOpenRange(ConstStringRef openRange, OclocArgHelper *argHelper, bool rangeTo); -std::vector getProductConfigsForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, OclocArgHelper *argHelper); -std::vector getPlatformsForClosedRange(ConstStringRef rangeFrom, ConstStringRef rangeTo, PRODUCT_FAMILY platformFrom, OclocArgHelper *argHelper); -std::vector getPlatformsForOpenRange(ConstStringRef openRange, PRODUCT_FAMILY prodId, OclocArgHelper *argHelper, bool rangeTo); -std::vector getProductConfigsForSpecificTargets(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper); -std::vector getPlatformsForSpecificTargets(CompilerOptions::TokenizedString targets, OclocArgHelper *argHelper); -std::vector toProductNames(const std::vector &productIds); -PRODUCT_FAMILY asProductId(ConstStringRef product, const std::vector &allSupportedPlatforms); +template +void getProductsAcronymsForTarget(std::vector &out, Target target, OclocArgHelper *argHelper); +std::vector getTargetProductsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper); int buildFatBinaryForTarget(int retVal, const std::vector &argsCopy, std::string pointerSize, Ar::ArEncoder &fatbinary, OfflineCompiler *pCompiler, OclocArgHelper *argHelper, const std::string &deviceConfig); int appendGenericIr(Ar::ArEncoder &fatbinary, const std::string &inputFile, OclocArgHelper *argHelper); diff --git a/shared/offline_compiler/source/offline_compiler.cpp b/shared/offline_compiler/source/offline_compiler.cpp index abceee96df..b5daeb98ff 100644 --- a/shared/offline_compiler/source/offline_compiler.cpp +++ b/shared/offline_compiler/source/offline_compiler.cpp @@ -327,75 +327,75 @@ void OfflineCompiler::setFamilyType() { familyNameWithType.append(hwInfo.capabilityTable.platformType); } -int OfflineCompiler::initHardwareInfo(std::string deviceName) { - int retVal = INVALID_DEVICE; +int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId) { + std::vector allSupportedProduct{ALL_SUPPORTED_PRODUCT_FAMILIES}; + for (const auto &product : allSupportedProduct) { + if (0 == strcmp(deviceName.c_str(), hardwarePrefix[product])) { + hwInfo = *hardwareInfoTable[product]; + if (revisionId != -1) { + hwInfo.platform.usRevId = revisionId; + } + if (deviceId != -1) { + hwInfo.platform.usDeviceID = deviceId; + } + auto hwInfoConfig = defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily]; + setHwInfoValuesFromConfig(hwInfoConfig, hwInfo); + hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true); + setFamilyType(); + return SUCCESS; + } + } + return INVALID_DEVICE; +} - if (deviceName.empty()) { - return retVal; +int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) { + AheadOfTimeConfig aotConfig{AOT::UNKNOWN_ISA}; + if (deviceName.find(".") != std::string::npos) { + aotConfig = argHelper->getMajorMinorRevision(deviceName); + if (aotConfig.ProductConfig == AOT::UNKNOWN_ISA) { + argHelper->printf("Could not determine device target: %s\n", deviceName.c_str()); + } + } else if (argHelper->isProductConfig(deviceName)) { + aotConfig.ProductConfig = ProductConfigHelper::returnProductConfigForAcronym(deviceName); } - if (argHelper->isFatbinary()) { - argHelper->setHwInfoForFatbinaryTarget(hwInfo); - setFamilyType(); - retVal = SUCCESS; + if (aotConfig.ProductConfig != AOT::UNKNOWN_ISA) { + if (argHelper->getHwInfoForProductConfig(aotConfig.ProductConfig, hwInfo)) { + if (revisionId != -1) { + hwInfo.platform.usRevId = revisionId; + } + deviceConfig = static_cast(aotConfig.ProductConfig); + setFamilyType(); + return SUCCESS; + } + argHelper->printf("Could not determine target based on product config: %s\n", deviceName.c_str()); + } + return INVALID_DEVICE; +} + +int OfflineCompiler::initHardwareInfo(std::string deviceName) { + int retVal = INVALID_DEVICE; + if (deviceName.empty()) { return retVal; } overridePlatformName(deviceName); std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower); const char hexPrefix = 2; - auto deviceId = -1; - std::string product(""); + int deviceId = -1; - auto numeration = argHelper->getMajorMinorRevision(deviceName); - if (!numeration.empty()) { - uint32_t productConfig = argHelper->getProductConfig(numeration); - - if (argHelper->getHwInfoForProductConfig(productConfig, hwInfo)) { - deviceConfig = static_cast(productConfig); - setFamilyType(); - retVal = SUCCESS; - return retVal; - } - argHelper->printf("Could not determine target based on product config: %s\n", deviceName.c_str()); - return retVal; - } else if (deviceName.find(".") != std::string::npos) { - argHelper->printf("Could not determine target based on product config: %s\n", deviceName.c_str()); + retVal = initHardwareInfoForProductConfig(deviceName); + if (retVal == SUCCESS) { return retVal; } if (deviceName.substr(0, hexPrefix) == "0x" && std::all_of(deviceName.begin() + hexPrefix, deviceName.end(), (::isxdigit))) { - deviceId = stoi(deviceName, 0, 16); - product = argHelper->returnProductNameForDevice(deviceId); - if (!product.empty()) { - argHelper->printf("Auto-detected target based on %s device id: %s\n", deviceName.c_str(), product.c_str()); - deviceName = product; - } else { - argHelper->printf("Could not determine target based on device id: %s\n", deviceName.c_str()); + deviceId = std::stoi(deviceName, 0, 16); + if (!argHelper->setAcronymForDeviceId(deviceName)) { return retVal; } } - - for (unsigned int productId = 0; productId < IGFX_MAX_PRODUCT; ++productId) { - if (hardwarePrefix[productId] && (0 == strcmp(deviceName.c_str(), hardwarePrefix[productId]))) { - if (hardwareInfoTable[productId]) { - hwInfo = *hardwareInfoTable[productId]; - if (revisionId != -1) { - hwInfo.platform.usRevId = revisionId; - } - if (deviceId != -1) { - hwInfo.platform.usDeviceID = deviceId; - } - - auto hwInfoConfig = defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily]; - setHwInfoValuesFromConfig(hwInfoConfig, hwInfo); - hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true); - setFamilyType(); - retVal = SUCCESS; - break; - } - } - } + retVal = initHardwareInfoForDeprecatedAcronyms(deviceName, deviceId); return retVal; } @@ -756,51 +756,52 @@ std::string OfflineCompiler::getFileNameTrunk(std::string &filePath) { return fileTrunk; } -std::string getDevicesTypes() { - std::list prefixes; +template +auto findDuplicate(const EqComparableT &lhs) { + return [&lhs](const auto &rhs) { return lhs == rhs; }; +} + +std::string OfflineCompiler::getDeprecatedDevicesTypes() { + std::vector prefixes; for (int j = 0; j < IGFX_MAX_PRODUCT; j++) { if (hardwarePrefix[j] == nullptr) continue; prefixes.push_back(hardwarePrefix[j]); } - std::ostringstream os; - for (auto it = prefixes.begin(); it != prefixes.end(); it++) { - if (it != prefixes.begin()) - os << ", "; - os << *it; + std::vector enabledAcronyms{}; + auto enabledConfigs = argHelper->getAllSupportedDeviceConfigs(); + for (const auto &device : enabledConfigs) { + enabledAcronyms.insert(enabledAcronyms.end(), device.acronyms.begin(), device.acronyms.end()); } - return os.str(); -} - -std::string getDevicesFamilies() { - std::list prefixes; - for (unsigned int i = 0; i < IGFX_MAX_CORE; ++i) { - if (familyName[i] == nullptr) + std::ostringstream os; + for (const auto &prefix : prefixes) { + if (std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), findDuplicate(prefix))) continue; - prefixes.push_back(familyName[i]); - } - - std::ostringstream os; - for (auto it = prefixes.begin(); it != prefixes.end(); it++) { - if (it != prefixes.begin()) + if (os.tellp()) os << ", "; - os << *it; + os << prefix; } return os.str(); } -std::string OfflineCompiler::getDevicesConfigs() { - std::list configNum; - auto allSupportedConfigs = argHelper->getAllSupportedProductConfigs(); +std::string OfflineCompiler::getDevicesReleasesAndFamilies() { + auto acronyms = argHelper->getEnabledReleasesAcronyms(); + auto familiesAcronyms = argHelper->getEnabledFamiliesAcronyms(); + + for (const auto &family : familiesAcronyms) { + if (!std::any_of(acronyms.begin(), acronyms.end(), findDuplicate(family))) { + acronyms.push_back(family); + } + } std::ostringstream os; - for (auto it = allSupportedConfigs.begin(); it != allSupportedConfigs.end(); it++) { - if (it != allSupportedConfigs.begin()) + for (const auto &acronym : acronyms) { + if (os.tellp()) os << ", "; - os << ProductConfigHelper::parseMajorMinorRevisionValue(*it); + os << acronym.str(); } return os.str(); @@ -818,14 +819,9 @@ Usage: ocloc [compile] -file -device [-output Target device. - can be: %s, %s or hexadecimal value with 0x prefix - can be single or multiple target devices. - The [[.]] numbers: - - family of graphics products, - - can be omitted, then ocloc will - compile for all of the matching devices. - - can be omitted, then ocloc will - compile for all of the . matching - devices. + can be: %s, %s, version or hexadecimal value with 0x prefix - can be single or multiple target devices. + The version is a representation of the + .. value. The hexadecimal value represents device ID. If such value is provided, ocloc will try to match it with corresponding device type. @@ -836,41 +832,31 @@ Usage: ocloc [compile] -file -device [-output can be: %s - - can be single or multiple target devices. - Supported -device patterns examples: - -device skl ; will compile 1 target - -device skl,icllp ; will compile 2 targets - -device skl-icllp ; will compile all targets - in range (inclusive) - -device skl- ; will compile all targets - newer/same as provided - -device -skl ; will compile all targets - older/same as provided - -device gen9 ; will compile all targets - matching the same gen - -device gen9-gen11 ; will compile all targets - in range (inclusive) - -device gen9- ; will compile all targets - newer/same as provided - -device -gen9 ; will compile all targets - older/same as provided + - can be single target device. -output Optional output file base name. Default is input file's base name. @@ -962,9 +948,9 @@ Examples : Compile file to Intel Compute GPU device binary (out = source_file_Gen9core.bin) ocloc -file source_file.cl -device skl )===", - getDevicesConfigs().c_str(), - NEO::getDevicesFamilies().c_str(), - NEO::getDevicesTypes().c_str()); + argHelper->getAllSupportedAcronyms().c_str(), + getDevicesReleasesAndFamilies().c_str(), + getDeprecatedDevicesTypes().c_str()); } void OfflineCompiler::storeBinary( diff --git a/shared/offline_compiler/source/offline_compiler.h b/shared/offline_compiler/source/offline_compiler.h index 3e2cab7fc6..c1dbb1e210 100644 --- a/shared/offline_compiler/source/offline_compiler.h +++ b/shared/offline_compiler/source/offline_compiler.h @@ -29,7 +29,6 @@ class OsLibrary; std::string convertToPascalCase(const std::string &inString); std::string generateFilePath(const std::string &directory, const std::string &fileNameBase, const char *extension); -std::string getDevicesTypes(); class OfflineCompiler { public: @@ -39,7 +38,8 @@ class OfflineCompiler { MOCKABLE_VIRTUAL int build(); std::string &getBuildLog(); void printUsage(); - std::string getDevicesConfigs(); + std::string getDevicesReleasesAndFamilies(); + std::string getDeprecatedDevicesTypes(); static constexpr ConstStringRef queryHelp = "Depending on will generate file\n" @@ -91,6 +91,9 @@ class OfflineCompiler { void setFamilyType(); int initHardwareInfo(std::string deviceName); + int initHardwareInfoForProductConfig(std::string deviceName); + int initHardwareInfoForDeprecatedAcronyms(std::string deviceName, int deviceId); + std::string getStringWithinDelimiters(const std::string &src); int initialize(size_t numArgs, const std::vector &allArgs, bool dumpFiles); int parseCommandLine(size_t numArgs, const std::vector &allArgs); @@ -120,7 +123,7 @@ class OfflineCompiler { void enforceFormat(std::string &format); HardwareInfo hwInfo; - PRODUCT_CONFIG deviceConfig = UNKNOWN_ISA; + AOT::PRODUCT_CONFIG deviceConfig = AOT::UNKNOWN_ISA; std::string deviceName; std::string familyNameWithType; std::string inputFile; diff --git a/shared/source/device_binary_format/device_binary_format_ar.cpp b/shared/source/device_binary_format/device_binary_format_ar.cpp index 77cfac561a..04c9742ae7 100644 --- a/shared/source/device_binary_format/device_binary_format_ar.cpp +++ b/shared/source/device_binary_format/device_binary_format_ar.cpp @@ -34,8 +34,8 @@ SingleDeviceBinary unpackSingleDeviceBinary(co } std::string pointerSize = ((requestedTargetDevice.maxPointerSizeInBytes == 8) ? "64" : "32"); - std::string filterPointerSizeAndMajorMinorRevision = pointerSize + "." + NEO::ProductConfigHelper::parseMajorMinorRevisionValue(requestedTargetDevice.productConfig); - std::string filterPointerSizeAndMajorMinor = pointerSize + "." + NEO::ProductConfigHelper::parseMajorMinorValue(requestedTargetDevice.productConfig); + std::string filterPointerSizeAndMajorMinorRevision = pointerSize + "." + ProductConfigHelper::parseMajorMinorRevisionValue(requestedTargetDevice.aotConfig); + std::string filterPointerSizeAndMajorMinor = pointerSize + "." + ProductConfigHelper::parseMajorMinorValue(requestedTargetDevice.aotConfig); std::string filterPointerSizeAndPlatform = pointerSize + "." + requestedProductAbbreviation.str(); std::string filterPointerSizeAndPlatformAndStepping = filterPointerSizeAndPlatform + "." + std::to_string(requestedTargetDevice.stepping); ConstStringRef filterGenericIrFileName{"generic_ir"}; diff --git a/shared/source/device_binary_format/device_binary_formats.cpp b/shared/source/device_binary_format/device_binary_formats.cpp index a4330c0f86..349b8f24b0 100644 --- a/shared/source/device_binary_format/device_binary_formats.cpp +++ b/shared/source/device_binary_format/device_binary_formats.cpp @@ -25,7 +25,7 @@ TargetDevice targetDeviceFromHwInfo(const HardwareInfo &hwInfo) { targetDevice.coreFamily = hwInfo.platform.eRenderCoreFamily; targetDevice.productFamily = hwInfo.platform.eProductFamily; - targetDevice.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + targetDevice.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); targetDevice.stepping = hwInfo.platform.usRevId; targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t); targetDevice.grfSize = hwInfo.capabilityTable.grfSize; diff --git a/shared/source/device_binary_format/device_binary_formats.h b/shared/source/device_binary_format/device_binary_formats.h index f940cee130..9e968468c3 100644 --- a/shared/source/device_binary_format/device_binary_formats.h +++ b/shared/source/device_binary_format/device_binary_formats.h @@ -60,7 +60,7 @@ inline const char *asString(DecodeError err) { struct TargetDevice { GFXCORE_FAMILY coreFamily = IGFX_UNKNOWN_CORE; PRODUCT_FAMILY productFamily = IGFX_UNKNOWN; - PRODUCT_CONFIG productConfig = UNKNOWN_ISA; + AheadOfTimeConfig aotConfig = {0}; uint32_t stepping = 0U; uint32_t maxPointerSizeInBytes = 4U; uint32_t grfSize = 32U; diff --git a/shared/source/dll/devices/platforms.h b/shared/source/dll/devices/platforms.h deleted file mode 100644 index e3b6792204..0000000000 --- a/shared/source/dll/devices/platforms.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2021-2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#pragma once - -typedef enum { - UNKNOWN_ISA = 0, - BDW = 0x080000, - SKL = 0x090000, - KBL = 0x090100, - CML = 0x090200, - AML = 0x090200, - WHL = 0x090200, - CFL = 0x090200, - BXT = 0x090300, - APL = 0x090300, - GLK = 0x090400, - ICL = 0x0b0000, - LKF = 0x0b0100, - JSL = 0x0b0200, - EHL = 0x0b0200, - DG1 = 0x0c0000, - RPL_S = 0x0c0000, - ADL_P = 0x0c0000, - ADL_S = 0x0c0000, - ADL_N = 0x0c0000, - RKL = 0x0c0000, - TGL = 0x0c0000, - XEHP_SDV = 0x0c0100, - DG2_G10_A0 = 0x0c0200, - DG2_G11 = 0x0c0201, - DG2_G10_B0 = 0x0c0201, - DG2_G12 = 0x0c0202, - PVC_XL_A0 = 0x0c0300, - PVC_XL_A0P = 0x0c0301, - PVC_XT_A0 = 0x0c0400, - PVC_XT_B0 = 0x0c0401, - PVC_XT_B1 = 0x0c0402, - PVC_XT_C0 = 0x0c0403, - CONFIG_MAX_PLATFORM, -} PRODUCT_CONFIG; \ No newline at end of file diff --git a/shared/source/dll/devices/product_config_base.inl b/shared/source/dll/devices/product_config_base.inl index 8d915bf295..02b1793e79 100644 --- a/shared/source/dll/devices/product_config_base.inl +++ b/shared/source/dll/devices/product_config_base.inl @@ -7,85 +7,86 @@ #if SUPPORT_XE_HPC_CORE #ifdef SUPPORT_PVC -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_A0, PvcHwConfig, PVC_XL_IDS, 0x00) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_A0P, PvcHwConfig, PVC_XL_IDS, 0x01) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_A0, PvcHwConfig, PVC_XT_IDS, 0x03) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_B0, PvcHwConfig, PVC_XT_IDS, 0x05) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_B1, PvcHwConfig, PVC_XT_IDS, 0x06) -DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_C0, PvcHwConfig, PVC_XT_IDS, 0x07) +DEVICE_CONFIG_IDS(PVC_XL_A0, PvcHwConfig, PVC_XL_IDS, XE_FAMILY, XE_HPC_RELEASE) +DEVICE_CONFIG_IDS(PVC_XL_A0P, PvcHwConfig, PVC_XL_IDS, XE_FAMILY, XE_HPC_RELEASE) +DEVICE_CONFIG_IDS(PVC_XT_A0, PvcHwConfig, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) +DEVICE_CONFIG_IDS(PVC_XT_B0, PvcHwConfig, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) +DEVICE_CONFIG_IDS(PVC_XT_B1, PvcHwConfig, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) +DEVICE_CONFIG_IDS(PVC_XT_C0, PvcHwConfig, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) + #endif #endif #ifdef SUPPORT_XE_HPG_CORE #ifdef SUPPORT_DG2 -DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_A0, Dg2HwConfig, DG2_G10_IDS, 0x00) -DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_B0, Dg2HwConfig, DG2_G10_IDS, 0x04) -DEVICE_CONFIG_IDS(DG2_G11, Dg2HwConfig, DG2_G11_IDS) +DEVICE_CONFIG_IDS(DG2_G10_A0, Dg2HwConfig, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) +DEVICE_CONFIG_IDS(DG2_G10_A1, Dg2HwConfig, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) +DEVICE_CONFIG_IDS(DG2_G10_B0, Dg2HwConfig, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) +DEVICE_CONFIG_IDS(DG2_G10_C0, Dg2HwConfig, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) +DEVICE_CONFIG_IDS(DG2_G11_A0, Dg2HwConfig, DG2_G11_IDS, XE_FAMILY, XE_HPG_RELEASE) +DEVICE_CONFIG_IDS(DG2_G11_B0, Dg2HwConfig, DG2_G11_IDS, XE_FAMILY, XE_HPG_RELEASE) +DEVICE_CONFIG_IDS(DG2_G11_B1, Dg2HwConfig, DG2_G11_IDS, XE_FAMILY, XE_HPG_RELEASE) + #endif #endif #ifdef SUPPORT_XE_HP_CORE #ifdef SUPPORT_XE_HP_SDV -DEVICE_CONFIG(XEHP_SDV, XehpSdvHwConfig) +DEVICE_CONFIG(XEHP_SDV, XehpSdvHwConfig, XE_FAMILY, XE_HP_RELEASE) #endif #endif #ifdef SUPPORT_GEN12LP #ifdef SUPPORT_TGLLP -DEVICE_CONFIG(TGL, TgllpHw1x6x16) +DEVICE_CONFIG(TGL, TgllpHw1x6x16, GEN12LP_FAMILY, GEN12LP_RELEASE) #endif #ifdef SUPPORT_DG1 -DEVICE_CONFIG(DG1, Dg1HwConfig) +DEVICE_CONFIG(DG1, Dg1HwConfig, GEN12LP_FAMILY, GEN12LP_RELEASE) #endif #ifdef SUPPORT_RKL -DEVICE_CONFIG(RKL, RklHwConfig) +DEVICE_CONFIG(RKL, RklHwConfig, GEN12LP_FAMILY, GEN12LP_RELEASE) #endif #ifdef SUPPORT_ADLS -DEVICE_CONFIG(ADL_S, AdlsHwConfig) +DEVICE_CONFIG(ADL_S, AdlsHwConfig, GEN12LP_FAMILY, GEN12LP_RELEASE) #endif #ifdef SUPPORT_ADLP -DEVICE_CONFIG(ADL_P, AdlpHwConfig) +DEVICE_CONFIG(ADL_P, AdlpHwConfig, GEN12LP_FAMILY, GEN12LP_RELEASE) #endif #ifdef SUPPORT_ADLN -DEVICE_CONFIG(ADL_N, AdlnHwConfig) +DEVICE_CONFIG(ADL_N, AdlnHwConfig, GEN12LP_FAMILY, GEN12LP_RELEASE) #endif #endif #ifdef SUPPORT_GEN11 #ifdef SUPPORT_ICLLP -DEVICE_CONFIG(ICL, IcllpHw1x8x8) +DEVICE_CONFIG(ICL, IcllpHw1x8x8, GEN11_FAMILY, GEN11_RELEASE) #endif - #ifdef SUPPORT_EHL -DEVICE_CONFIG(EHL, EhlHwConfig) +DEVICE_CONFIG(EHL, EhlHwConfig, GEN11_FAMILY, GEN11_RELEASE) #endif #ifdef SUPPORT_LKF -DEVICE_CONFIG(LKF, LkfHw1x8x8) +DEVICE_CONFIG(LKF, LkfHw1x8x8, GEN11_FAMILY, GEN11_RELEASE) #endif #endif #ifdef SUPPORT_GEN9 #ifdef SUPPORT_SKL -DEVICE_CONFIG(SKL, SklHw1x3x8) +DEVICE_CONFIG(SKL, SklHw1x3x8, GEN9_FAMILY, GEN9_RELEASE) #endif - #ifdef SUPPORT_KBL -DEVICE_CONFIG(KBL, KblHw1x3x6) +DEVICE_CONFIG(KBL, KblHw1x3x6, GEN9_FAMILY, GEN9_RELEASE) #endif - #ifdef SUPPORT_CFL -DEVICE_CONFIG(CFL, CflHw1x3x6) +DEVICE_CONFIG(CFL, CflHw1x3x6, GEN9_FAMILY, GEN9_RELEASE) #endif - #ifdef SUPPORT_GLK -DEVICE_CONFIG(GLK, GlkHw1x3x6) +DEVICE_CONFIG(GLK, GlkHw1x3x6, GEN9_FAMILY, GEN9_RELEASE) #endif - #ifdef SUPPORT_BXT -DEVICE_CONFIG(BXT, BxtHw1x3x6) +DEVICE_CONFIG(APL, BxtHw1x3x6, GEN9_FAMILY, GEN9_RELEASE) #endif #endif #ifdef SUPPORT_GEN8 -DEVICE_CONFIG(BDW, BdwHw1x3x8) +DEVICE_CONFIG(BDW, BdwHw1x3x8, GEN8_FAMILY, GEN8_RELEASE) #endif diff --git a/shared/source/gen11/ehl/os_agnostic_hw_info_config_ehl.inl b/shared/source/gen11/ehl/os_agnostic_hw_info_config_ehl.inl index 0abd53c642..b1145b955e 100644 --- a/shared/source/gen11/ehl/os_agnostic_hw_info_config_ehl.inl +++ b/shared/source/gen11/ehl/os_agnostic_hw_info_config_ehl.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::EHL; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::EHL; } \ No newline at end of file diff --git a/shared/source/gen11/enable_gen11.cpp b/shared/source/gen11/enable_gen11.cpp index 2287fa03b0..07c4f88b07 100644 --- a/shared/source/gen11/enable_gen11.cpp +++ b/shared/source/gen11/enable_gen11.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen11/hw_cmds.h" +#include "shared/source/helpers/compiler_aot_config_bdw_and_later.inl" #include "shared/source/helpers/compiler_hw_info_config_base.inl" #include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/helpers/enable_product.inl" diff --git a/shared/source/gen11/icllp/os_agnostic_hw_info_config_icllp.inl b/shared/source/gen11/icllp/os_agnostic_hw_info_config_icllp.inl index f24fb7a399..3e8d9913ab 100644 --- a/shared/source/gen11/icllp/os_agnostic_hw_info_config_icllp.inl +++ b/shared/source/gen11/icllp/os_agnostic_hw_info_config_icllp.inl @@ -21,6 +21,6 @@ bool HwInfoConfigHw::isReturnedCmdSizeForMediaSamplerAdjustmentRequi } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::ICL; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::ICL; } \ No newline at end of file diff --git a/shared/source/gen11/lkf/os_agnostic_hw_info_config_lkf.inl b/shared/source/gen11/lkf/os_agnostic_hw_info_config_lkf.inl index 2370962e4d..a9ed280afe 100644 --- a/shared/source/gen11/lkf/os_agnostic_hw_info_config_lkf.inl +++ b/shared/source/gen11/lkf/os_agnostic_hw_info_config_lkf.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::LKF; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::LKF; } \ No newline at end of file diff --git a/shared/source/gen12lp/adln/os_agnostic_hw_info_config_adln.inl b/shared/source/gen12lp/adln/os_agnostic_hw_info_config_adln.inl index 85bb68f22b..cebf17d359 100644 --- a/shared/source/gen12lp/adln/os_agnostic_hw_info_config_adln.inl +++ b/shared/source/gen12lp/adln/os_agnostic_hw_info_config_adln.inl @@ -15,8 +15,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::ADL_N; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::ADL_N; } template <> diff --git a/shared/source/gen12lp/adlp/os_agnostic_hw_info_config_adlp.inl b/shared/source/gen12lp/adlp/os_agnostic_hw_info_config_adlp.inl index 75f4353c2a..0cff5f1186 100644 --- a/shared/source/gen12lp/adlp/os_agnostic_hw_info_config_adlp.inl +++ b/shared/source/gen12lp/adlp/os_agnostic_hw_info_config_adlp.inl @@ -17,8 +17,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::ADL_P; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::ADL_P; } template <> diff --git a/shared/source/gen12lp/adls/os_agnostic_hw_info_config_adls.inl b/shared/source/gen12lp/adls/os_agnostic_hw_info_config_adls.inl index 7069d3880f..91c88c1cd0 100644 --- a/shared/source/gen12lp/adls/os_agnostic_hw_info_config_adls.inl +++ b/shared/source/gen12lp/adls/os_agnostic_hw_info_config_adls.inl @@ -17,8 +17,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::ADL_S; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::ADL_S; } template <> diff --git a/shared/source/gen12lp/dg1/os_agnostic_hw_info_config_dg1.inl b/shared/source/gen12lp/dg1/os_agnostic_hw_info_config_dg1.inl index 2a5f347580..32d2cba750 100644 --- a/shared/source/gen12lp/dg1/os_agnostic_hw_info_config_dg1.inl +++ b/shared/source/gen12lp/dg1/os_agnostic_hw_info_config_dg1.inl @@ -17,8 +17,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::DG1; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::DG1; } template <> diff --git a/shared/source/gen12lp/enable_gen12lp.cpp b/shared/source/gen12lp/enable_gen12lp.cpp index a9b65e8f60..2417192801 100644 --- a/shared/source/gen12lp/enable_gen12lp.cpp +++ b/shared/source/gen12lp/enable_gen12lp.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen12lp/hw_cmds.h" +#include "shared/source/helpers/compiler_aot_config_bdw_and_later.inl" #include "shared/source/helpers/compiler_hw_info_config_base.inl" #include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/helpers/enable_product.inl" diff --git a/shared/source/gen12lp/rkl/os_agnostic_hw_info_config_rkl.inl b/shared/source/gen12lp/rkl/os_agnostic_hw_info_config_rkl.inl index 5db9238a77..0d10b50fbb 100644 --- a/shared/source/gen12lp/rkl/os_agnostic_hw_info_config_rkl.inl +++ b/shared/source/gen12lp/rkl/os_agnostic_hw_info_config_rkl.inl @@ -19,8 +19,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::RKL; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::RKL; } template <> diff --git a/shared/source/gen12lp/tgllp/os_agnostic_hw_info_config_tgllp.inl b/shared/source/gen12lp/tgllp/os_agnostic_hw_info_config_tgllp.inl index 3d59cf5801..2b1227c199 100644 --- a/shared/source/gen12lp/tgllp/os_agnostic_hw_info_config_tgllp.inl +++ b/shared/source/gen12lp/tgllp/os_agnostic_hw_info_config_tgllp.inl @@ -19,8 +19,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::TGL; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::TGL; } template <> diff --git a/shared/source/gen8/bdw/os_agnostic_hw_info_config_bdw.inl b/shared/source/gen8/bdw/os_agnostic_hw_info_config_bdw.inl index aa221c51d4..6b7b4dc83c 100644 --- a/shared/source/gen8/bdw/os_agnostic_hw_info_config_bdw.inl +++ b/shared/source/gen8/bdw/os_agnostic_hw_info_config_bdw.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::BDW; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::BDW; } \ No newline at end of file diff --git a/shared/source/gen8/enable_gen8.cpp b/shared/source/gen8/enable_gen8.cpp index 968e36fbc7..5c24bfa78a 100644 --- a/shared/source/gen8/enable_gen8.cpp +++ b/shared/source/gen8/enable_gen8.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen8/hw_cmds.h" +#include "shared/source/helpers/compiler_aot_config_bdw_and_later.inl" #include "shared/source/helpers/compiler_hw_info_config_base.inl" #include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/helpers/enable_product.inl" diff --git a/shared/source/gen9/bxt/os_agnostic_hw_info_config_bxt.inl b/shared/source/gen9/bxt/os_agnostic_hw_info_config_bxt.inl index 3ad3aa1a22..322b89e36b 100644 --- a/shared/source/gen9/bxt/os_agnostic_hw_info_config_bxt.inl +++ b/shared/source/gen9/bxt/os_agnostic_hw_info_config_bxt.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::BXT; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::APL; } \ No newline at end of file diff --git a/shared/source/gen9/cfl/os_agnostic_hw_info_config_cfl.inl b/shared/source/gen9/cfl/os_agnostic_hw_info_config_cfl.inl index 13a448a843..9fa6a33869 100644 --- a/shared/source/gen9/cfl/os_agnostic_hw_info_config_cfl.inl +++ b/shared/source/gen9/cfl/os_agnostic_hw_info_config_cfl.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::CFL; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::CFL; } \ No newline at end of file diff --git a/shared/source/gen9/enable_gen9.cpp b/shared/source/gen9/enable_gen9.cpp index bbdf2c2004..ebfe3d0dff 100644 --- a/shared/source/gen9/enable_gen9.cpp +++ b/shared/source/gen9/enable_gen9.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen9/hw_cmds.h" +#include "shared/source/helpers/compiler_aot_config_bdw_and_later.inl" #include "shared/source/helpers/compiler_hw_info_config_base.inl" #include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/helpers/enable_product.inl" diff --git a/shared/source/gen9/glk/os_agnostic_hw_info_config_glk.inl b/shared/source/gen9/glk/os_agnostic_hw_info_config_glk.inl index f9aa44d0d0..cbf40c4cc5 100644 --- a/shared/source/gen9/glk/os_agnostic_hw_info_config_glk.inl +++ b/shared/source/gen9/glk/os_agnostic_hw_info_config_glk.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::GLK; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::GLK; } \ No newline at end of file diff --git a/shared/source/gen9/kbl/os_agnostic_hw_info_config_kbl.inl b/shared/source/gen9/kbl/os_agnostic_hw_info_config_kbl.inl index 125f1076af..fa253b8d08 100644 --- a/shared/source/gen9/kbl/os_agnostic_hw_info_config_kbl.inl +++ b/shared/source/gen9/kbl/os_agnostic_hw_info_config_kbl.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::KBL; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::KBL; } \ No newline at end of file diff --git a/shared/source/gen9/skl/os_agnostic_hw_info_config_skl.inl b/shared/source/gen9/skl/os_agnostic_hw_info_config_skl.inl index 40e8b0c5c9..261a654226 100644 --- a/shared/source/gen9/skl/os_agnostic_hw_info_config_skl.inl +++ b/shared/source/gen9/skl/os_agnostic_hw_info_config_skl.inl @@ -6,6 +6,6 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::SKL; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::SKL; } \ No newline at end of file diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index 154586972d..da7ded8c0e 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -34,6 +34,7 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config.h ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config_base.inl + ${CMAKE_CURRENT_SOURCE_DIR}/compiler_aot_config_bdw_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config_bdw_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/compiler_options_parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/compiler_options_parser.h @@ -105,6 +106,7 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/preamble_base.inl ${CMAKE_CURRENT_SOURCE_DIR}/preamble_bdw_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.h + ${CMAKE_CURRENT_SOURCE_DIR}/product_config_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/product_config_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/ptr_math.h ${CMAKE_CURRENT_SOURCE_DIR}/ray_tracing_helper.h diff --git a/shared/source/helpers/compiler_aot_config_bdw_and_later.inl b/shared/source/helpers/compiler_aot_config_bdw_and_later.inl new file mode 100644 index 0000000000..108505501c --- /dev/null +++ b/shared/source/helpers/compiler_aot_config_bdw_and_later.inl @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/compiler_hw_info_config.h" +#include "shared/source/helpers/hw_info.h" + +namespace NEO { +template +void CompilerHwInfoConfigHw::setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const { + hwInfo.platform.usRevId = config.ProductConfigID.Revision; +} + +} // namespace NEO diff --git a/shared/source/helpers/compiler_hw_info_config.h b/shared/source/helpers/compiler_hw_info_config.h index 661d6e270d..a205fc7c4e 100644 --- a/shared/source/helpers/compiler_hw_info_config.h +++ b/shared/source/helpers/compiler_hw_info_config.h @@ -8,6 +8,7 @@ #pragma once #include "shared/source/helpers/hw_info.h" +#include "shared/source/helpers/product_config_helper.h" #include "igfxfmid.h" @@ -28,6 +29,7 @@ class CompilerHwInfoConfig { virtual bool isStatelessToStatefulBufferOffsetSupported() const = 0; virtual bool isForceToStatelessRequired() const = 0; virtual void adjustHwInfoForIgc(HardwareInfo &hwInfo) const = 0; + virtual void setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const = 0; }; template @@ -43,6 +45,7 @@ class CompilerHwInfoConfigHw : public CompilerHwInfoConfig { bool isStatelessToStatefulBufferOffsetSupported() const override; bool isForceToStatelessRequired() const override; void adjustHwInfoForIgc(HardwareInfo &hwInfo) const override; + void setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const override; protected: CompilerHwInfoConfigHw() = default; diff --git a/shared/source/helpers/constants.h b/shared/source/helpers/constants.h index 2cc58555dd..77d7265740 100644 --- a/shared/source/helpers/constants.h +++ b/shared/source/helpers/constants.h @@ -89,6 +89,7 @@ namespace CommonConstants { constexpr uint64_t unsupportedPatIndex = std::numeric_limits::max(); constexpr uint32_t unspecifiedDeviceIndex = std::numeric_limits::max(); constexpr uint32_t invalidStepping = std::numeric_limits::max(); +constexpr uint32_t invalidRevisionID = std::numeric_limits::max(); constexpr uint32_t maximalSimdSize = 32; constexpr uint32_t maximalSizeOfAtomicType = 8; constexpr uint32_t engineGroupCount = static_cast(NEO::EngineGroupType::MaxEngineGroups); diff --git a/shared/source/helpers/product_config_helper.cpp b/shared/source/helpers/product_config_helper.cpp new file mode 100644 index 0000000000..0c4414cf73 --- /dev/null +++ b/shared/source/helpers/product_config_helper.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/product_config_helper.h" + +AOT::RELEASE ProductConfigHelper::returnReleaseForAcronym(const std::string &device) { + auto it = AOT::releaseAcronyms.find(device); + if (it == AOT::releaseAcronyms.end()) + return AOT::UNKNOWN_RELEASE; + return it->second; +} + +AOT::FAMILY ProductConfigHelper::returnFamilyForAcronym(const std::string &device) { + auto it = AOT::familyAcronyms.find(device); + if (it == AOT::familyAcronyms.end()) + return AOT::UNKNOWN_FAMILY; + return it->second; +} + +AOT::PRODUCT_CONFIG ProductConfigHelper::returnProductConfigForAcronym(const std::string &device) { + auto it = AOT::productConfigAcronyms.find(device); + if (it == AOT::productConfigAcronyms.end()) + return AOT::UNKNOWN_ISA; + return it->second; +} + +NEO::ConstStringRef ProductConfigHelper::getAcronymForAFamily(AOT::FAMILY family) { + for (const auto &[acronym, value] : AOT::familyAcronyms) { + if (value == family) { + return NEO::ConstStringRef(acronym); + } + } + return {}; +} + +std::string ProductConfigHelper::parseMajorMinorRevisionValue(AheadOfTimeConfig config) { + std::stringstream stringConfig; + stringConfig << config.ProductConfigID.Major << "." << config.ProductConfigID.Minor << "." << config.ProductConfigID.Revision; + return stringConfig.str(); +} + +std::string ProductConfigHelper::parseMajorMinorValue(AheadOfTimeConfig config) { + std::stringstream stringConfig; + stringConfig << config.ProductConfigID.Major << "." << config.ProductConfigID.Minor; + return stringConfig.str(); +} diff --git a/shared/source/helpers/product_config_helper.h b/shared/source/helpers/product_config_helper.h index 08d8d392b1..e6197d496c 100644 --- a/shared/source/helpers/product_config_helper.h +++ b/shared/source/helpers/product_config_helper.h @@ -6,36 +6,38 @@ */ #pragma once +#include "shared/source/utilities/const_stringref.h" + #include "platforms.h" #include #include -namespace NEO { -struct ProductConfigHelper { - static uint32_t getMajor(PRODUCT_CONFIG config) { - return (static_cast(config) & 0xff0000) >> 16; - } - - static uint32_t getMinor(PRODUCT_CONFIG config) { - return (static_cast(config) & 0x00ff00) >> 8; - } - - static uint32_t getRevision(PRODUCT_CONFIG config) { - return static_cast(config) & 0x0000ff; - } - - static std::string parseMajorMinorRevisionValue(PRODUCT_CONFIG config) { - std::stringstream stringConfig; - stringConfig << getMajor(config) << "." << getMinor(config) << "." << getRevision(config); - return stringConfig.str(); - } - - static std::string parseMajorMinorValue(PRODUCT_CONFIG config) { - std::stringstream stringConfig; - stringConfig << getMajor(config) << "." << getMinor(config); - return stringConfig.str(); - } +struct AheadOfTimeConfig { + union { + uint32_t ProductConfig; + struct + { + uint32_t Revision : 6; + uint32_t Reserved : 8; + uint32_t Minor : 8; + uint32_t Major : 10; + } ProductConfigID; + }; }; -} // namespace NEO +struct ProductConfigHelper { + static std::string parseMajorMinorValue(AheadOfTimeConfig config); + static std::string parseMajorMinorRevisionValue(AheadOfTimeConfig config); + inline static std::string parseMajorMinorRevisionValue(AOT::PRODUCT_CONFIG config) { + std::stringstream stringConfig; + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = config; + return parseMajorMinorRevisionValue(aotConfig); + } + + static AOT::PRODUCT_CONFIG returnProductConfigForAcronym(const std::string &device); + static AOT::RELEASE returnReleaseForAcronym(const std::string &device); + static AOT::FAMILY returnFamilyForAcronym(const std::string &device); + static NEO::ConstStringRef getAcronymForAFamily(AOT::FAMILY family); +}; diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index f7ed60f16f..b61902090a 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -58,7 +58,7 @@ class HwInfoConfig { virtual bool obtainBlitterPreference(const HardwareInfo &hwInfo) const = 0; virtual bool isBlitterFullySupported(const HardwareInfo &hwInfo) const = 0; virtual bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const = 0; - virtual PRODUCT_CONFIG getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const = 0; + virtual AOT::PRODUCT_CONFIG getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const = 0; virtual uint32_t getHwRevIdFromStepping(uint32_t stepping, const HardwareInfo &hwInfo) const = 0; virtual uint32_t getSteppingFromHwRevId(const HardwareInfo &hwInfo) const = 0; virtual uint32_t getAubStreamSteppingFromHwRevId(const HardwareInfo &hwInfo) const = 0; @@ -156,7 +156,7 @@ class HwInfoConfigHw : public HwInfoConfig { bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const override; bool overrideGfxPartitionLayoutForWsl() const override; uint32_t getHwRevIdFromStepping(uint32_t stepping, const HardwareInfo &hwInfo) const override; - PRODUCT_CONFIG getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const override; + AOT::PRODUCT_CONFIG getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const override; uint32_t getSteppingFromHwRevId(const HardwareInfo &hwInfo) const override; uint32_t getAubStreamSteppingFromHwRevId(const HardwareInfo &hwInfo) const override; void setAdditionalPipelineSelectFields(void *pipelineSelectCmd, const PipelineSelectArgs &pipelineSelectArgs, const HardwareInfo &hwInfo) override; diff --git a/shared/source/xe_hp_core/enable_xe_hp_core.cpp b/shared/source/xe_hp_core/enable_xe_hp_core.cpp index 9185302d16..2e55fda3fa 100644 --- a/shared/source/xe_hp_core/enable_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/enable_xe_hp_core.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/helpers/compiler_aot_config_bdw_and_later.inl" #include "shared/source/helpers/compiler_hw_info_config_base.inl" #include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/helpers/enable_product.inl" diff --git a/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl b/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl index 2b4f68a151..45e832e991 100644 --- a/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl +++ b/shared/source/xe_hp_core/os_agnostic_hw_info_config_xe_hp_core.inl @@ -21,8 +21,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return PRODUCT_CONFIG::XEHP_SDV; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::XEHP_SDV; } template <> diff --git a/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp b/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp index df9a631eb7..c608579f17 100644 --- a/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/helpers/compiler_aot_config_bdw_and_later.inl" #include "shared/source/helpers/compiler_hw_info_config_base.inl" #include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/helpers/enable_product.inl" diff --git a/shared/source/xe_hpc_core/pvc/os_agnostic_hw_info_config_pvc.inl b/shared/source/xe_hpc_core/pvc/os_agnostic_hw_info_config_pvc.inl index 11f4898062..2706388136 100644 --- a/shared/source/xe_hpc_core/pvc/os_agnostic_hw_info_config_pvc.inl +++ b/shared/source/xe_hpc_core/pvc/os_agnostic_hw_info_config_pvc.inl @@ -53,31 +53,31 @@ uint32_t HwInfoConfigHw::getSteppingFromHwRevId(const HardwareInfo & } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { uint32_t stepping = getSteppingFromHwRevId(hwInfo); if (stepping == CommonConstants::invalidStepping) { - return PRODUCT_CONFIG::UNKNOWN_ISA; + return AOT::UNKNOWN_ISA; } if (PVC::isXl(hwInfo)) { switch (hwInfo.platform.usRevId) { case 0x0: - return PRODUCT_CONFIG::PVC_XL_A0; + return AOT::PVC_XL_A0; default: case 0x1: - return PRODUCT_CONFIG::PVC_XL_A0P; + return AOT::PVC_XL_A0P; } } else { switch (hwInfo.platform.usRevId) { case 0x3: - return PRODUCT_CONFIG::PVC_XT_A0; - case 0x5: - return PRODUCT_CONFIG::PVC_XT_B0; - case 0x6: - return PRODUCT_CONFIG::PVC_XT_B1; + return AOT::PVC_XT_A0; + case 05: + return AOT::PVC_XT_B0; + case 06: + return AOT::PVC_XT_B1; default: - case 0x7: - return PRODUCT_CONFIG::PVC_XT_C0; + case 07: + return AOT::PVC_XT_C0; } } } diff --git a/shared/source/xe_hpg_core/dg2/definitions/os_agnostic_hw_info_config_dg2_extra.inl b/shared/source/xe_hpg_core/dg2/definitions/os_agnostic_hw_info_config_dg2_extra.inl index 9fdbb0f354..0308cc3247 100644 --- a/shared/source/xe_hpg_core/dg2/definitions/os_agnostic_hw_info_config_dg2_extra.inl +++ b/shared/source/xe_hpg_core/dg2/definitions/os_agnostic_hw_info_config_dg2_extra.inl @@ -6,21 +6,27 @@ */ template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - uint32_t stepping = getSteppingFromHwRevId(hwInfo); - if (stepping == CommonConstants::invalidStepping) { - return PRODUCT_CONFIG::UNKNOWN_ISA; - } +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { if (DG2::isG10(hwInfo)) { - switch (stepping) { - case REVISION_A0: - case REVISION_A1: - return PRODUCT_CONFIG::DG2_G10_A0; - default: - case REVISION_B: - return PRODUCT_CONFIG::DG2_G10_B0; + switch (hwInfo.platform.usRevId) { + case 0x0: + return AOT::DG2_G10_A0; + case 0x1: + return AOT::DG2_G10_A1; + case 0x4: + return AOT::DG2_G10_B0; + case 0x8: + return AOT::DG2_G10_C0; } } else { - return PRODUCT_CONFIG::DG2_G11; + switch (hwInfo.platform.usRevId) { + case 0x0: + return AOT::DG2_G11_A0; + case 0x4: + return AOT::DG2_G11_B0; + case 0x5: + return AOT::DG2_G11_B1; + } } + return AOT::UNKNOWN_ISA; } \ No newline at end of file diff --git a/shared/source/xe_hpg_core/dg2/os_agnostic_hw_info_config_dg2.inl b/shared/source/xe_hpg_core/dg2/os_agnostic_hw_info_config_dg2.inl index 9fa0b79a36..0787ebb1eb 100644 --- a/shared/source/xe_hpg_core/dg2/os_agnostic_hw_info_config_dg2.inl +++ b/shared/source/xe_hpg_core/dg2/os_agnostic_hw_info_config_dg2.inl @@ -35,8 +35,9 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c return 0x4; case REVISION_C: return 0x8; + default: + return CommonConstants::invalidStepping; } - return CommonConstants::invalidStepping; } template <> @@ -50,8 +51,9 @@ uint32_t HwInfoConfigHw::getSteppingFromHwRevId(const HardwareInfo & return REVISION_B; case 0x8: return REVISION_C; + default: + return CommonConstants::invalidStepping; } - return CommonConstants::invalidStepping; } template <> diff --git a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp index 4d474f955f..d1f8ed0973 100644 --- a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/helpers/compiler_aot_config_bdw_and_later.inl" #include "shared/source/helpers/compiler_hw_info_config_base.inl" #include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/helpers/enable_product.inl" diff --git a/shared/test/common/fixtures/product_config_fixture.h b/shared/test/common/fixtures/product_config_fixture.h index fbb294752f..c79b7d757e 100644 --- a/shared/test/common/fixtures/product_config_fixture.h +++ b/shared/test/common/fixtures/product_config_fixture.h @@ -7,20 +7,39 @@ #pragma once +#include "shared/source/helpers/constants.h" +#include "shared/source/helpers/product_config_helper.h" #include "shared/source/os_interface/hw_info_config.h" -#include "shared/source/xe_hpc_core/hw_cmds_base.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/test_macros/test.h" using namespace NEO; -struct ProductConfigTests : public ::testing::Test { +template +struct ProductConfigTest : public T { void SetUp() override { + T::SetUp(); hwInfo = *NEO::defaultHwInfo; hwInfoConfig = NEO::HwInfoConfig::get(productFamily); } NEO::HwInfoConfig *hwInfoConfig = nullptr; NEO::HardwareInfo hwInfo = {}; - PRODUCT_CONFIG productConfig = UNKNOWN_ISA; -}; \ No newline at end of file + AOT::PRODUCT_CONFIG productConfig = AOT::UNKNOWN_ISA; +}; + +struct ProductConfigHwInfoTests : public ProductConfigTest<::testing::TestWithParam>> { + void SetUp() override { + ProductConfigTest::SetUp(); + std::tie(productConfig, prod) = GetParam(); + if (prod != productFamily) { + GTEST_SKIP(); + } + } + PRODUCT_FAMILY prod = IGFX_UNKNOWN; + const AheadOfTimeConfig invalidConfig = {CommonConstants::invalidRevisionID}; +}; + +using ProductConfigTests = ProductConfigTest<::testing::Test>; +using ProductConfigHwInfoBadRevisionTests = ProductConfigHwInfoTests; +using ProductConfigHwInfoBadArchTests = ProductConfigHwInfoTests; diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index b30ccdd467..0ac54abb81 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -107,8 +107,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, } template <> -PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return UNKNOWN_ISA; +AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return AOT::UNKNOWN_ISA; } template <> diff --git a/shared/test/common/xe_hpc_core/pvc/CMakeLists.txt b/shared/test/common/xe_hpc_core/pvc/CMakeLists.txt new file mode 100644 index 0000000000..bef8c4a90c --- /dev/null +++ b/shared/test/common/xe_hpc_core/pvc/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_PVC) + set(NEO_CORE_TESTS_PVC + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/product_configs_pvc.h + ) + set_property(GLOBAL PROPERTY NEO_CORE_TESTS_PVC ${NEO_CORE_TESTS_PVC}) + target_sources(${TARGET_NAME} PRIVATE ${NEO_CORE_TESTS_PVC}) + +endif() diff --git a/shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h b/shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h new file mode 100644 index 0000000000..aa9a8d2e2f --- /dev/null +++ b/shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "platforms.h" + +namespace AOT_PVC { +constexpr AOT::PRODUCT_CONFIG productConfigs[] = { + AOT::PVC_XL_A0, + AOT::PVC_XL_A0P, + AOT::PVC_XT_A0, + AOT::PVC_XT_B0, + AOT::PVC_XT_B1, + AOT::PVC_XT_C0}; +} diff --git a/shared/test/common/xe_hpg_core/dg2/CMakeLists.txt b/shared/test/common/xe_hpg_core/dg2/CMakeLists.txt index c5acae5b49..cfd7e5275b 100644 --- a/shared/test/common/xe_hpg_core/dg2/CMakeLists.txt +++ b/shared/test/common/xe_hpg_core/dg2/CMakeLists.txt @@ -13,6 +13,7 @@ if(TESTS_DG2) set(NEO_CORE_TESTS_XE_HPG_CORE_DG2 ${IGDRCL_SRCS_tests_xe_hpg_core_dg2_excludes} ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/product_configs_dg2.h ${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_encode_dispatch_kernel_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_helper_dg2.cpp @@ -21,4 +22,5 @@ if(TESTS_DG2) ) target_sources(${TARGET_NAME} PRIVATE ${NEO_CORE_TESTS_XE_HPG_CORE_DG2}) + add_subdirectories() endif() diff --git a/shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h b/shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h new file mode 100644 index 0000000000..407835c08e --- /dev/null +++ b/shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "platforms.h" + +namespace AOT_DG2 { +constexpr AOT::PRODUCT_CONFIG productConfigs[] = { + AOT::DG2_G10_A0, + AOT::DG2_G10_A1, + AOT::DG2_G10_B0, + AOT::DG2_G10_C0, + AOT::DG2_G11_A0, + AOT::DG2_G11_B0, + AOT::DG2_G11_B1}; +} diff --git a/shared/test/unit_test/device_binary_format/device_binary_format_ar_tests.cpp b/shared/test/unit_test/device_binary_format/device_binary_format_ar_tests.cpp index 5f963784a0..4b5dd26dee 100644 --- a/shared/test/unit_test/device_binary_format/device_binary_format_ar_tests.cpp +++ b/shared/test/unit_test/device_binary_format/device_binary_format_ar_tests.cpp @@ -59,11 +59,12 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenChooseItA PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); NEO::Ar::ArEncoder encoder; std::string requiredProduct = NEO::hardwarePrefix[productFamily]; - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -74,7 +75,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenChooseItA NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.productConfig = productConfig; + target.aotConfig = aotConfig; target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -99,11 +100,12 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenPackedTar PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); NEO::Ar::ArEncoder encoder; std::string requiredProduct = NEO::hardwarePrefix[productFamily]; - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -114,7 +116,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenPackedTar NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.productConfig = productConfig; + target.aotConfig = aotConfig; target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -129,13 +131,14 @@ TEST(UnpackSingleDeviceBinaryAr, WhenMultipleBinariesMatchedThenChooseBestMatch) PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); NEO::Ar::ArEncoder encoder; std::string requiredProduct = NEO::hardwarePrefix[productFamily]; std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize, programTokens.storage)); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize + "." + requiredProduct, programTokens.storage)); @@ -144,7 +147,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenMultipleBinariesMatchedThenChooseBestMatch) NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -237,9 +240,10 @@ TEST(UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithProductConfigThenTry const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); programTokensWrongTokenVersion.headerMutable->Version -= 1; NEO::Ar::ArEncoder encoder; @@ -254,7 +258,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithProductConfigThenTry NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -344,9 +348,10 @@ TEST(UnpackSingleDeviceBinaryAr, WhenDeviceBinaryNotMatchedButIrWithProductConfi PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); std::string requiredProduct = NEO::hardwarePrefix[productFamily]; std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -363,7 +368,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenDeviceBinaryNotMatchedButIrWithProductConfi target.coreFamily = static_cast(programTokens.header->Device); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; - target.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); auto arData = encoder.encode(); std::string unpackErrors; @@ -567,9 +572,10 @@ TEST(UnpackSingleDeviceBinaryAr, WhenCouldNotFindBinaryWithRightPointerSizeThenU const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); std::string requiredProduct = NEO::hardwarePrefix[productFamily]; std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -585,7 +591,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenCouldNotFindBinaryWithRightPointerSizeThenU target.coreFamily = static_cast(programTokens.header->Device); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; - target.productConfig = productConfig; + target.aotConfig = aotConfig; auto arData = encoder.encode(); std::string unpackErrors; diff --git a/shared/test/unit_test/helpers/CMakeLists.txt b/shared/test/unit_test/helpers/CMakeLists.txt index 8c5ff86bad..cc0dff85e0 100644 --- a/shared/test/unit_test/helpers/CMakeLists.txt +++ b/shared/test/unit_test/helpers/CMakeLists.txt @@ -23,6 +23,7 @@ set(IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/gtest_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/l3_range_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_management_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/product_config_helper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ptr_math_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/raii_hw_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/static_size3.h diff --git a/shared/test/unit_test/helpers/product_config_helper_tests.cpp b/shared/test/unit_test/helpers/product_config_helper_tests.cpp new file mode 100644 index 0000000000..7704f4c58b --- /dev/null +++ b/shared/test/unit_test/helpers/product_config_helper_tests.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/product_config_helper.h" +#include "shared/test/common/test_macros/test.h" + +using ProductConfigHelperTests = ::testing::Test; + +TEST_F(ProductConfigHelperTests, givenProductAcronymWhenHelperSearchForAMatchThenCorrespondingValueIsReturned) { + for (const auto &product : AOT::productConfigAcronyms) { + EXPECT_EQ(ProductConfigHelper::returnProductConfigForAcronym(product.first), product.second); + } +} + +TEST_F(ProductConfigHelperTests, givenReleaseAcronymWhenHelperSearchForAMatchThenCorrespondingValueIsReturned) { + for (const auto &release : AOT::releaseAcronyms) { + EXPECT_EQ(ProductConfigHelper::returnReleaseForAcronym(release.first), release.second); + } +} + +TEST_F(ProductConfigHelperTests, givenFamilyAcronymWhenHelperSearchForAMatchThenCorrespondingValueIsReturned) { + for (const auto &family : AOT::familyAcronyms) { + EXPECT_EQ(ProductConfigHelper::returnFamilyForAcronym(family.first), family.second); + } +} + +TEST_F(ProductConfigHelperTests, givenUnknownAcronymWhenHelperSearchForAMatchThenUnknownEnumValueIsReturned) { + EXPECT_EQ(ProductConfigHelper::returnProductConfigForAcronym("unk"), AOT::UNKNOWN_ISA); + EXPECT_EQ(ProductConfigHelper::returnReleaseForAcronym("unk"), AOT::UNKNOWN_RELEASE); + EXPECT_EQ(ProductConfigHelper::returnFamilyForAcronym("unk"), AOT::UNKNOWN_FAMILY); +} + +TEST_F(ProductConfigHelperTests, givenFamilyEnumWhenHelperSearchForAMatchThenCorrespondingAcronymIsReturned) { + for (const auto &family : AOT::familyAcronyms) { + EXPECT_EQ(ProductConfigHelper::getAcronymForAFamily(family.second), family.first); + } +} + +TEST_F(ProductConfigHelperTests, givenUnknownFamilyEnumWhenHelperSearchForAMatchThenEmptyAcronymIsReturned) { + auto acronym = ProductConfigHelper::getAcronymForAFamily(AOT::UNKNOWN_FAMILY); + EXPECT_TRUE(acronym.empty()); +} + +TEST_F(ProductConfigHelperTests, givenUnknownIsaEnumWhenParseMajorMinorRevisionValueThenCorrectStringIsReturned) { + auto unknownIsa = ProductConfigHelper::parseMajorMinorRevisionValue(AOT::UNKNOWN_ISA); + EXPECT_STREQ(unknownIsa.c_str(), "0.0.0"); +} \ No newline at end of file diff --git a/shared/test/unit_test/helpers/test_hw_info_config.cpp b/shared/test/unit_test/helpers/test_hw_info_config.cpp index 42efbc676c..e4ef5bea3a 100644 --- a/shared/test/unit_test/helpers/test_hw_info_config.cpp +++ b/shared/test/unit_test/helpers/test_hw_info_config.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/test_macros/test.h" @@ -47,11 +48,6 @@ HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenGetThreadEuRatioForScratchThen8I EXPECT_EQ(8u, hwInfoConfig.getThreadEuRatioForScratch(*defaultHwInfo)); } -HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenGetProductConfigThenCorrectMatchIsFound) { - const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); - EXPECT_NE(hwInfoConfig.getProductConfigFromHwInfo(*defaultHwInfo), UNKNOWN_ISA); -} - HWTEST_F(HwInfoConfigTest, whenIsGrfNumReportedWithScmIsQueriedThenTrueIsReturned) { const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); EXPECT_TRUE(hwInfoConfig.isGrfNumReportedWithScm()); @@ -88,3 +84,17 @@ HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigWhenIsImplicitScalingSupportedThenE const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); EXPECT_FALSE(hwInfoConfig.isImplicitScalingSupported(*defaultHwInfo)); } + +HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigWhenGetProductConfigThenCorrectMatchIsFound, IsAtMostXeHpCore) { + const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + EXPECT_NE(hwInfoConfig.getProductConfigFromHwInfo(*defaultHwInfo), AOT::UNKNOWN_ISA); +} + +HWTEST2_F(HwInfoConfigTest, givenAotConfigWhenSetHwInfoRevisionIdThenCorrectValueIsSet, IsAtMostXeHpCore) { + const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(*defaultHwInfo); + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = productConfig; + CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->setProductConfigForHwInfo(*defaultHwInfo, aotConfig); + EXPECT_EQ(defaultHwInfo->platform.usRevId, aotConfig.ProductConfigID.Revision); +} \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpc_core/pvc/device_binary_format_ar_tests_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/device_binary_format_ar_tests_pvc.cpp index fb2eae6204..c15f54fdfc 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/device_binary_format_ar_tests_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/device_binary_format_ar_tests_pvc.cpp @@ -24,8 +24,12 @@ PVCTEST_F(PvcUnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithPvcProductCo PatchTokensTestData::ValidEmptyProgram programTokens; PatchTokensTestData::ValidEmptyProgram programTokensWrongTokenVersion; - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(PVC_XL_A0); - std::string anotherProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(PVC_XL_A0P); + AheadOfTimeConfig aotConfig0{}, aotConfig1{}; + aotConfig0.ProductConfig = AOT::PVC_XL_A0; + aotConfig1.ProductConfig = AOT::PVC_XL_A0P; + + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig0); + std::string anotherProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig1); programTokensWrongTokenVersion.headerMutable->Version -= 1; NEO::Ar::ArEncoder encoder; @@ -41,7 +45,7 @@ PVCTEST_F(PvcUnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithPvcProductCo NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.productConfig = PVC_XL_A0; + target.aotConfig = aotConfig0; target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; diff --git a/shared/test/unit_test/xe_hpc_core/pvc/linux/hw_info_config_tests_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/linux/hw_info_config_tests_pvc.cpp index 0f4239ba55..d0ddf63a91 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/linux/hw_info_config_tests_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/linux/hw_info_config_tests_pvc.cpp @@ -5,9 +5,12 @@ * */ +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/os_interface/os_interface.h" +#include "shared/test/common/fixtures/product_config_fixture.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/libult/linux/drm_mock.h" +#include "shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h" #include "shared/test/unit_test/helpers/gtest_helpers.h" #include "shared/test/unit_test/os_interface/linux/hw_info_config_linux_tests.h" @@ -62,3 +65,12 @@ PVCTEST_F(HwInfoConfigTestLinuxPvc, givenHwInfoConfigWhenAskedIfPatIndexProgramm const auto &hwInfoConfig = *HwInfoConfig::get(pInHwInfo.platform.eProductFamily); EXPECT_TRUE(hwInfoConfig.isVmBindPatIndexProgrammingSupported()); } + +PVCTEST_F(ProductConfigTests, givenAotConfigWhenSetHwInfoRevisionIdForPvcThenCorrectValueIsSet) { + for (const auto &config : AOT_PVC::productConfigs) { + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = config; + CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily)->setProductConfigForHwInfo(hwInfo, aotConfig); + EXPECT_EQ(hwInfo.platform.usRevId, aotConfig.ProductConfigID.Revision); + } +} diff --git a/shared/test/unit_test/xe_hpc_core/pvc/product_config_tests_pvc.cpp b/shared/test/unit_test/xe_hpc_core/pvc/product_config_tests_pvc.cpp index d1a6f892c6..53a2bc9052 100644 --- a/shared/test/unit_test/xe_hpc_core/pvc/product_config_tests_pvc.cpp +++ b/shared/test/unit_test/xe_hpc_core/pvc/product_config_tests_pvc.cpp @@ -21,15 +21,15 @@ PVCTEST_F(ProductConfigTests, givenPvcXlDeviceIdWhenDifferentRevisionIsPassedThe hwInfo.platform.usRevId = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XL_A0); + EXPECT_EQ(productConfig, AOT::PVC_XL_A0); hwInfo.platform.usRevId = 0x1; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XL_A0P); + EXPECT_EQ(productConfig, AOT::PVC_XL_A0P); hwInfo.platform.usRevId = 0x6; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XL_A0P); + EXPECT_EQ(productConfig, AOT::PVC_XL_A0P); } } @@ -39,19 +39,19 @@ PVCTEST_F(ProductConfigTests, givenPvcXtDeviceIdWhenDifferentRevisionIsPassedThe hwInfo.platform.usRevId = 0x3; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XT_A0); + EXPECT_EQ(productConfig, AOT::PVC_XT_A0); hwInfo.platform.usRevId = 0x5; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XT_B0); + EXPECT_EQ(productConfig, AOT::PVC_XT_B0); hwInfo.platform.usRevId = 0x6; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XT_B1); + EXPECT_EQ(productConfig, AOT::PVC_XT_B1); hwInfo.platform.usRevId = 0x7; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XT_C0); + EXPECT_EQ(productConfig, AOT::PVC_XT_C0); } } @@ -60,15 +60,15 @@ PVCTEST_F(ProductConfigTests, givenDefaultDeviceAndRevisionIdWhenGetProductConfi hwInfo.platform.usDeviceID = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, PVC_XT_C0); + EXPECT_EQ(productConfig, AOT::PVC_XT_C0); } PVCTEST_F(ProductConfigTests, givenInvalidRevisionIdWhenGetProductConfigThenUnknownIsaIsReturned) { hwInfo.platform.usRevId = 0x2; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, UNKNOWN_ISA); + EXPECT_EQ(productConfig, AOT::UNKNOWN_ISA); hwInfo.platform.usRevId = 0x4; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, UNKNOWN_ISA); -} \ No newline at end of file + EXPECT_EQ(productConfig, AOT::UNKNOWN_ISA); +} diff --git a/shared/test/unit_test/xe_hpg_core/dg2/device_binary_format_ar_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/device_binary_format_ar_tests_dg2.cpp index 6e78d34b9a..611b9cf648 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/device_binary_format_ar_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/device_binary_format_ar_tests_dg2.cpp @@ -24,8 +24,12 @@ DG2TEST_F(Dg2UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithDg2ProductCo PatchTokensTestData::ValidEmptyProgram programTokens; PatchTokensTestData::ValidEmptyProgram programTokensWrongTokenVersion; - std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(DG2_G10_A0); - std::string anotherProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(DG2_G10_B0); + AheadOfTimeConfig aotConfig0{}, aotConfig1{}; + aotConfig0.ProductConfig = AOT::DG2_G10_A0; + aotConfig1.ProductConfig = AOT::DG2_G10_B0; + + std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig0); + std::string anotherProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig1); programTokensWrongTokenVersion.headerMutable->Version -= 1; NEO::Ar::ArEncoder encoder; @@ -41,7 +45,7 @@ DG2TEST_F(Dg2UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithDg2ProductCo NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.productConfig = DG2_G10_A0; + target.aotConfig = aotConfig0; target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; diff --git a/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp index cecaee0427..48998afdc2 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/hw_info_config_tests_dg2.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/command_stream/stream_properties.h" +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/os_interface/hw_info_config.h" @@ -13,6 +14,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/test_macros/test.h" +#include "shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h" using namespace NEO; @@ -409,10 +411,10 @@ DG2TEST_F(ProductConfigTests, givenDg2G11DeviceIdsWhenConfigIsCheckedThenCorrect DG2TEST_F(ProductConfigTests, givenInvalidRevisionIdWhenDeviceIdIsDefaultThenUnknownIsaIsReturned) { hwInfo.platform.usDeviceID = 0; - hwInfo.platform.usRevId = 0xffff; + hwInfo.platform.usRevId = CommonConstants::invalidRevisionID; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, UNKNOWN_ISA); + EXPECT_EQ(productConfig, AOT::UNKNOWN_ISA); } DG2TEST_F(ProductConfigTests, givenDg2G10DeviceIdWhenDifferentRevisionIsPassedThenCorrectProductConfigIsReturned) { @@ -421,19 +423,30 @@ DG2TEST_F(ProductConfigTests, givenDg2G10DeviceIdWhenDifferentRevisionIsPassedTh hwInfo.platform.usRevId = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, DG2_G10_A0); + EXPECT_EQ(productConfig, AOT::DG2_G10_A0); hwInfo.platform.usRevId = 0x1; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, DG2_G10_A0); + EXPECT_EQ(productConfig, AOT::DG2_G10_A1); hwInfo.platform.usRevId = 0x4; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, DG2_G10_B0); + EXPECT_EQ(productConfig, AOT::DG2_G10_B0); hwInfo.platform.usRevId = 0x8; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, DG2_G10_B0); + EXPECT_EQ(productConfig, AOT::DG2_G10_C0); + } +} + +DG2TEST_F(ProductConfigTests, givenDg2DeviceIdWhenIncorrectRevisionIsPassedThenCorrectProductConfigIsReturned) { + for (const auto &dg2 : {DG2_G10_IDS, DG2_G11_IDS}) { + for (const auto &deviceId : dg2) { + hwInfo.platform.usDeviceID = deviceId; + hwInfo.platform.usRevId = CommonConstants::invalidRevisionID; + productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); + EXPECT_EQ(productConfig, AOT::UNKNOWN_ISA); + } } } @@ -443,11 +456,24 @@ DG2TEST_F(ProductConfigTests, givenDg2G11DeviceIdWhenDifferentRevisionIsPassedTh hwInfo.platform.usRevId = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, DG2_G11); + EXPECT_EQ(productConfig, AOT::DG2_G11_A0); hwInfo.platform.usRevId = 0x4; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, DG2_G11); + EXPECT_EQ(productConfig, AOT::DG2_G11_B0); + + hwInfo.platform.usRevId = 0x5; + productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); + EXPECT_EQ(productConfig, AOT::DG2_G11_B1); + } +} + +DG2TEST_F(ProductConfigTests, givenAotConfigWhenSetHwInfoRevisionIdForDg2ThenCorrectValueIsSet) { + for (const auto &config : AOT_DG2::productConfigs) { + AheadOfTimeConfig aotConfig = {0}; + aotConfig.ProductConfig = config; + CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily)->setProductConfigForHwInfo(hwInfo, aotConfig); + EXPECT_EQ(hwInfo.platform.usRevId, aotConfig.ProductConfigID.Revision); } } diff --git a/shared/test/unit_test/xe_hpg_core/dg2/product_config_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/product_config_tests_dg2.cpp index c79d19bf8c..41b8131cfa 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/product_config_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/product_config_tests_dg2.cpp @@ -15,10 +15,10 @@ using namespace NEO; -DG2TEST_F(ProductConfigTests, givenDefaultDeviceAndRevisionIdWhenGetProductConfigThenLastKnownDg2ConfigIsReturned) { +DG2TEST_F(ProductConfigTests, givenDefaultDeviceAndRevisionIdWhenGetProductConfigThenDg2G11A0ConfigIsReturned) { hwInfo.platform.usRevId = 0x0; hwInfo.platform.usDeviceID = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, DG2_G11); + EXPECT_EQ(productConfig, AOT::DG2_G11_A0); } \ No newline at end of file diff --git a/third_party/aot_config_headers/platforms.h b/third_party/aot_config_headers/platforms.h new file mode 100644 index 0000000000..2d79188d3a --- /dev/null +++ b/third_party/aot_config_headers/platforms.h @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2021-2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include +#include + +#pragma once + +namespace AOT { + +typedef enum { + UNKNOWN_ISA = 0, + BDW = 0x02000000, + SKL = 0x02400009, + KBL = 0x02404009, + CFL = 0x02408009, + APL = 0x0240c000, + GLK = 0x02410000, + WHL = 0x02414000, + AML = 0x02418000, + CML = 0x0241c000, + ICL = 0x02c00000, + LKF = 0x02c04000, + EHL = 0x02c08000, + TGL = 0x03000000, + RKL = 0x03004000, + RPL_S = 0x03008000, + ADL_S = 0x03008000, + ADL_P = 0x0300c000, + ADL_N = 0x03010000, + DG1 = 0x03028000, + XEHP_SDV = 0x030c8004, + DG2_G10_A0 = 0x030dc000, + DG2_G10_A1 = 0x030dc001, + DG2_G10_B0 = 0x030dc004, + DG2_G10_C0 = 0x030dc008, + DG2_G11_A0 = 0x030e0000, + DG2_G11_B0 = 0x030e0004, + DG2_G11_B1 = 0x030e0005, + DG2_G12_A0 = 0x030e4000, + PVC_XL_A0 = 0x030f0000, + PVC_XL_A0P = 0x030f0001, + PVC_XT_A0 = 0x030f0003, + PVC_XT_B0 = 0x030f0005, + PVC_XT_B1 = 0x030f0006, + PVC_XT_C0 = 0x030f0007, + CONFIG_MAX_PLATFORM, +} PRODUCT_CONFIG; + +typedef enum { + UNKNOWN_RELEASE = 0, + GEN8_RELEASE, + GEN9_RELEASE, + GEN11_RELEASE, + GEN12LP_RELEASE, + XE_HP_RELEASE, + XE_HPG_RELEASE, + XE_HPC_RELEASE, + RELEASE_MAX, +} RELEASE; + +typedef enum { + UNKNOWN_FAMILY = 0, + GEN8_FAMILY, + GEN9_FAMILY, + GEN11_FAMILY, + GEN12LP_FAMILY, + XE_FAMILY, + FAMILY_MAX, +} FAMILY; + +static const std::map familyAcronyms = { + {"gen8", GEN8_FAMILY}, + {"gen9", GEN9_FAMILY}, + {"gen11", GEN11_FAMILY}, + {"gen12lp", GEN12LP_FAMILY}, + {"xe", XE_FAMILY}, +}; + +static const std::map releaseAcronyms = { + {"gen8", GEN8_RELEASE}, + {"gen9", GEN9_RELEASE}, + {"gen11", GEN11_RELEASE}, + {"gen12lp", GEN12LP_RELEASE}, + {"xe-hp", XE_HP_RELEASE}, + {"xe-hpg", XE_HPG_RELEASE}, + {"xe-hpc", XE_HPC_RELEASE}, +}; + +static const std::map productConfigAcronyms = { + {"bdw", BDW}, + {"skl", SKL}, + {"kbl", KBL}, + {"cfl", CFL}, + {"apl", APL}, + {"bxt", APL}, + {"glk", GLK}, + {"whl", WHL}, + {"aml", AML}, + {"cml", CML}, + {"icllp", ICL}, + {"lkf", LKF}, + {"ehl", EHL}, + {"jsl", EHL}, + {"tgllp", TGL}, + {"rkl", RKL}, + {"rpl-s", RPL_S}, + {"adl-s", ADL_S}, + {"adl-p", ADL_P}, + {"adl-n", ADL_N}, + {"dg1", DG1}, + {"acm-g10", DG2_G10_C0}, + {"dg2-g10", DG2_G10_C0}, + {"ats-m150", DG2_G10_C0}, + {"acm-g11", DG2_G11_B1}, + {"dg2-g11", DG2_G11_B1}, + {"ats-m75", DG2_G11_B1}, + {"acm-g12", DG2_G12_A0}, + {"dg2-g12", DG2_G12_A0}, + {"pvc-sdv", PVC_XL_A0P}, + {"pvc", PVC_XT_C0}, +}; +} // namespace AOT