From cca1dbecbc19811caa780bcfb225c4cc6d9792c5 Mon Sep 17 00:00:00 2001 From: Compute-Runtime-Validation Date: Sun, 12 Jun 2022 20:46:42 +0200 Subject: [PATCH] Revert "Ocloc: New AOT approach implementation" This reverts commit a44f1b43aa7bf2828c8107980255ca6ad1682211. Signed-off-by: Compute-Runtime-Validation --- 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 | 1592 ++++++++++------- .../offline_compiler/ocloc_fatbinary_tests.h | 24 +- .../ocloc_product_config_tests.cpp | 6 +- .../ocloc_product_config_tests.h | 6 +- .../offline_compiler_tests.cpp | 138 +- .../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 | 486 +++-- .../offline_compiler/source/ocloc_fatbinary.h | 16 +- .../source/offline_compiler.cpp | 232 +-- .../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 | 44 + .../dll/devices/product_config_base.inl | 52 +- .../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 +- .../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 | 50 +- 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 -- 76 files changed, 1850 insertions(+), 1950 deletions(-) delete mode 100644 opencl/test/unit_test/offline_compiler/ocloc_arg_helper_tests.cpp create mode 100644 shared/source/dll/devices/platforms.h delete mode 100644 shared/source/helpers/compiler_aot_config_bdw_and_later.inl delete mode 100644 shared/source/helpers/product_config_helper.cpp delete mode 100644 shared/test/common/xe_hpc_core/pvc/CMakeLists.txt delete mode 100644 shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h delete mode 100644 shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h delete mode 100644 shared/test/unit_test/helpers/product_config_helper_tests.cpp delete mode 100644 third_party/aot_config_headers/platforms.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 737fe792e6..9beb10d8e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,11 +361,6 @@ 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() @@ -727,7 +722,6 @@ 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 6c890aac93..dd668c38b9 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 @@ -2034,14 +2034,13 @@ HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromNativeBinaryThenSetsUpPacked PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - AheadOfTimeConfig aotConfig = {0}; - aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + auto 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 = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize, programTokens.storage)); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize + "." + requiredProduct, programTokens.storage)); @@ -2050,7 +2049,7 @@ HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromNativeBinaryThenSetsUpPacked NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.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 183d6a2845..d5b766d5ae 100644 --- a/opencl/test/unit_test/offline_compiler/CMakeLists.txt +++ b/opencl/test/unit_test/offline_compiler/CMakeLists.txt @@ -61,7 +61,6 @@ set(IGDRCL_SRCS_offline_compiler_tests ${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_iga_dll.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_iga_dll.h ${CMAKE_CURRENT_SOURCE_DIR}/ocloc_api_tests.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ocloc_arg_helper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ocloc_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 7a2844b615..5bcc40418b 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,7 +23,6 @@ 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; @@ -37,7 +36,6 @@ 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; @@ -51,7 +49,6 @@ 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 62fe6f79e7..c1ecff8130 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_api_tests.cpp @@ -178,29 +178,12 @@ 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", - family.c_str()}; + NEO::familyName[NEO::DEFAULT_PLATFORM::hwInfo.platform.eRenderCoreFamily]}; unsigned int argc = sizeof(argv) / sizeof(const char *); testing::internal::CaptureStdout(); @@ -211,7 +194,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 " + clFileName + " -device " + family)); + EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4])); } 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 deleted file mode 100644 index 4e2a400fde..0000000000 --- a/opencl/test/unit_test/offline_compiler/ocloc_arg_helper_tests.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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 a40266641a..89dc034b31 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.cpp @@ -52,30 +52,25 @@ auto allFilesInArchiveExceptPaddingStartsWith(const Ar::Ar &archive, const Const return true; } -std::string getDeviceConfig(const OfflineCompiler &offlineCompiler, MockOclocArgHelper *argHelper) { +std::string prepareTwoDevices(MockOclocArgHelper *argHelper) { auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - if (allEnabledDeviceConfigs.empty()) { + if (allEnabledDeviceConfigs.size() < 2) { return {}; } - const auto &hwInfo = offlineCompiler.getHardwareInfo(); - for (const auto &device : allEnabledDeviceConfigs) { - if (device.hwInfo->platform.eProductFamily == hwInfo.platform.eProductFamily) { - return ProductConfigHelper::parseMajorMinorRevisionValue(device.aotConfig); - } - } - return {}; + const auto cfg1 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[0].config); + const auto cfg2 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[1].config); + + return cfg1 + "," + cfg2; } -std::string prepareTwoDevices(MockOclocArgHelper *argHelper) { - auto enabledProductsAcronyms = argHelper->getEnabledProductAcronyms(); - if (enabledProductsAcronyms.size() < 2) { - return {}; - } +std::string getDeviceConfig(const OfflineCompiler &offlineCompiler) { + const auto &hwInfo = offlineCompiler.getHardwareInfo(); - const auto cfg1 = enabledProductsAcronyms[0].str(); - const auto cfg2 = enabledProductsAcronyms[1].str(); - return cfg1 + "," + cfg2; + const std::string product = hardwarePrefix[hwInfo.platform.eProductFamily]; + const auto stepping = hwInfo.platform.usRevId; + + return product + "." + std::to_string(stepping); } TEST(OclocFatBinaryRequestedFatBinary, WhenDeviceArgMissingThenReturnsFalse) { @@ -90,75 +85,23 @@ TEST(OclocFatBinaryRequestedFatBinary, WhenDeviceArgMissingThenReturnsFalse) { EXPECT_FALSE(NEO::requestedFatBinary(4, args, argHelper.get())); } -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) { +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", "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"}; + 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"}; EXPECT_TRUE(NEO::requestedFatBinary(3, allPlatforms, argHelper.get())); EXPECT_TRUE(NEO::requestedFatBinary(3, manyPlatforms, argHelper.get())); @@ -169,654 +112,1005 @@ 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_F(OclocFatBinaryProductAcronymsTests, givenDeviceArgAsSingleProductThenFatBinaryIsNotRequested) { - auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); +TEST(OclocFatBinaryRequestedFatBinary, GivenDeviceArgToFatBinaryWhenConfigMatchesMoreThanOneProductThenTrueIsReturned) { + std::unique_ptr argHelper = std::make_unique(); + auto allEnabledDeviceConfigs = argHelper->getAllSupportedDeviceConfigs(); - for (const auto &deviceConfig : allEnabledDeviceConfigs) { - std::string configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceConfig.aotConfig); + 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, 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())); - } + EXPECT_FALSE(NEO::requestedFatBinary(3, singleConfig, argHelper.get())); } } -TEST_F(OclocFatBinaryProductAcronymsTests, givenAsterixThenReturnAllEnabledAcronyms) { - auto expected = oclocArgHelperWithoutInput->getEnabledProductAcronyms(); - auto got = NEO::getTargetProductsForFatbinary("*", oclocArgHelperWithoutInput.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(); + auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); + + if (allEnabledPlatforms.size() < 3 || allEnabledDeviceConfigs.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])); + + 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()); EXPECT_EQ(got.size(), expected.size()); } -TEST_F(OclocFatBinaryProductAcronymsTests, givenDeviceArgProvidedWhenUnknownFamilyNameIsPassedThenRequestedFatBinaryReturnsFalse) { - const char *unknownFamily[] = {"ocloc", "-device", "gen0"}; - EXPECT_FALSE(NEO::requestedFatBinary(3, unknownFamily, oclocArgHelperWithoutInput.get())); -} +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigWhenConfigIsUndefinedThenReturnEmptyList) { + auto got = NEO::getTargetConfigsForFatbinary("0.0.0", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); -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())); - } - } -} + got = NEO::getTargetConfigsForFatbinary("0.0", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); -TEST_F(OclocFatBinaryProductAcronymsTests, givenEnabledFamilyAcronymsWhenCheckIfIsFamilyThenTrueIsReturned) { - for (const auto &acronym : enabledFamiliesAcronyms) { - EXPECT_TRUE(oclocArgHelperWithoutInput->isFamily(acronym.str())); - } -} - -TEST_F(OclocFatBinaryProductAcronymsTests, givenEnabledReleaseAcronymsWhenCheckIfIsReleaseThenTrueIsReturned) { - for (const auto &acronym : enabledReleasesAcronyms) { - EXPECT_TRUE(oclocArgHelperWithoutInput->isRelease(acronym.str())); - } -} - -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())); -} - -TEST_F(OclocFatBinaryProductAcronymsTests, givenUnkownArchitectureThenReturnEmptyList) { - auto got = NEO::getTargetProductsForFatbinary("gen0", oclocArgHelperWithoutInput.get()); + got = NEO::getTargetConfigsForFatbinary("0", oclocArgHelperWithoutInput.get()); EXPECT_TRUE(got.empty()); } -TEST_F(OclocFatBinaryProductAcronymsTests, givenClosedRangeTooExtensiveWhenProductsOrFamiliesOrReleasesAreValidThenFailIsReturned) { - for (const auto &enabledAcronyms : {enabledProductsAcronyms, enabledReleasesAcronyms, enabledFamiliesAcronyms}) { - if (enabledAcronyms.size() < 3) { - GTEST_SKIP(); - } - - oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; - std::stringstream acronymsString; - acronymsString << enabledAcronyms[0].str() << ":" << enabledAcronyms[1].str() << ":" << enabledAcronyms[2].str(); - auto target = acronymsString.str(); - - 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()); +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigOpenRangeToWhenConfigIsUndefinedThenReturnEmptyList) { + auto got = NEO::getTargetConfigsForFatbinary("-0.0.0", oclocArgHelperWithoutInput.get()); EXPECT_TRUE(got.empty()); - got = NEO::getTargetProductsForFatbinary(":unk", oclocArgHelperWithoutInput.get()); + got = NEO::getTargetConfigsForFatbinary("-0.0", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); + + got = NEO::getTargetConfigsForFatbinary("-0", 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()); +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigOpenRangeFromWhenConfigIsUndefinedThenReturnEmptyList) { + auto got = NEO::getTargetConfigsForFatbinary("0.0.0-", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); - got = NEO::getTargetProductsForFatbinary(acronym.str() + ":unk", oclocArgHelperWithoutInput.get()); - EXPECT_TRUE(got.empty()); + got = NEO::getTargetConfigsForFatbinary("0.0-", 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()); - } - } + got = NEO::getTargetConfigsForFatbinary("0-", oclocArgHelperWithoutInput.get()); + EXPECT_TRUE(got.empty()); } -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::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()); - } -} - -TEST_F(OclocFatBinaryProductAcronymsTests, givenTwoSameReleaseTargetsWhenGetProductsAcronymsThenDuplicatesAreNotFound) { - if (enabledReleasesAcronyms.empty()) { +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenProductConfigClosedRangeWhenAnyOfConfigIsUndefinedOrIncorrectThenReturnEmptyList) { + auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); + if (allEnabledDeviceConfigs.size() < 2) { GTEST_SKIP(); } - auto acronym = enabledReleasesAcronyms[0]; - std::vector acronyms{}; + auto deviceMapConfig0 = allEnabledDeviceConfigs[0]; + auto config0Str = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig0.config); - 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); + 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_F(OclocFatBinaryProductAcronymsTests, givenTwoSameFamilyTargetsWhenGetProductsAcronymsThenDuplicatesAreNotFound) { - if (enabledFamiliesAcronyms.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(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(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(OclocFatBinaryAsGfxCoreIdList, GivenEnabledGfxCoreNameThenReturnsNonEmptyList) { + + std::unique_ptr argHelper = std::make_unique(); + + 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)); + + auto findCore = caseInsensitive.find("_core"); + if (findCore != std::string::npos) { + caseInsensitive = caseInsensitive.substr(0, findCore); + EXPECT_TRUE(argHelper->isGen(caseInsensitive)); + } + + auto findUnderline = caseInsensitive.find("_"); + if (findUnderline != std::string::npos) { + caseInsensitive.erase(std::remove(caseInsensitive.begin(), caseInsensitive.end(), '_'), caseInsensitive.end()); + EXPECT_TRUE(argHelper->isGen(caseInsensitive)); + } + } + } +} + +TEST(OclocFatBinaryAsGfxCoreIdList, GivenDisabledGfxCoreNameThenReturnsEmptyList) { + + std::unique_ptr argHelper = std::make_unique(); + + 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())); +} + +TEST(OclocFatBinaryAsGfxCoreIdList, GivenEnabledGfxCoreNameThenReturnsNonNullIGFX) { + + 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); + } + } + } +} + +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) { + 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); +} + +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformOpenRangeFromThenReturnAllEnabledPlatformsThatMatch) { + auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); + if (allEnabledPlatforms.size() < 3) { + 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); +} + +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformOpenRangeToThenReturnAllEnabledPlatformsThatMatch) { + auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); + if (allEnabledPlatforms.size() < 3) { + GTEST_SKIP(); + } + auto platform0 = allEnabledPlatforms[allEnabledPlatforms.size() / 2]; + std::string platformName = NEO::hardwarePrefix[platform0]; + + 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); +} + +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::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); + + got = NEO::getTargetPlatformsForFatbinary(platformNameTo + "-" + platformNameFrom, oclocArgHelperWithoutInput.get()); // swap min with max implicitly + EXPECT_EQ(expected, got); +} + +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)); + } + } + 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]); + } +} + +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) { GTEST_SKIP(); } - auto acronym = enabledFamiliesAcronyms[0]; - std::vector acronyms{}; + auto core0 = allEnabledCores[allEnabledCores.size() / 2]; + std::string coreName = NEO::familyName[core0]; + if (coreName[0] == 'G') { + coreName[0] = 'g'; + } - auto family = ProductConfigHelper::returnFamilyForAcronym(acronym.str()); - getProductsAcronymsForTarget(acronyms, family, oclocArgHelperWithoutInput.get()); - auto expectedSize = acronyms.size(); - getProductsAcronymsForTarget(acronyms, family, oclocArgHelperWithoutInput.get()); + std::vector expected; + unsigned int coreIt = IGFX_UNKNOWN_CORE; + ++coreIt; + while (coreIt <= static_cast(core0)) { + oclocArgHelperWithoutInput->getProductConfigsForGfxCoreFamily(static_cast(coreIt), expected); + ++coreIt; + } - EXPECT_EQ(acronyms.size(), expectedSize); + 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(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfReleasesWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - if (enabledReleasesAcronyms.size() < 2) { +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArchitectureClosedRangeThenReturnAllEnabledConfigsThatMatch) { + auto allEnabledCores = getEnabledCores(); + if (allEnabledCores.size() < 4) { GTEST_SKIP(); } - for (unsigned int product = 0; product < enabledReleasesAcronyms.size() - 1; product++) { - auto acronym0 = enabledReleasesAcronyms.at(product); - auto acronym1 = enabledReleasesAcronyms.at(product + 1); - std::vector expected{}; + 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'; + } - auto release0 = ProductConfigHelper::returnReleaseForAcronym(acronym0.str()); - auto release1 = ProductConfigHelper::returnReleaseForAcronym(acronym1.str()); - getProductsAcronymsForTarget(expected, release0, oclocArgHelperWithoutInput.get()); - getProductsAcronymsForTarget(expected, release1, oclocArgHelperWithoutInput.get()); + std::vector expected; + auto coreIt = coreFrom; + while (coreIt <= coreTo) { + oclocArgHelperWithoutInput->getProductConfigsForGfxCoreFamily(static_cast(coreIt), expected); + coreIt = static_cast(static_cast(coreIt) + 1); + } - std::string acronymsTarget = acronym0.str() + "," + acronym1.str(); - auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(got, expected); + 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]); + } - 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()); + 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(OclocFatBinaryProductAcronymsTests, givenTwoTargetsOfFamiliesWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - if (enabledFamiliesAcronyms.size() < 2) { +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(); } - 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 platform0 = allEnabledPlatforms[0]; + ConstStringRef platformName0(hardwarePrefix[platform0], strlen(hardwarePrefix[platform0])); + auto platform1 = allEnabledPlatforms[1]; + ConstStringRef platformName1(hardwarePrefix[platform1], strlen(hardwarePrefix[platform1])); - auto family0 = ProductConfigHelper::returnFamilyForAcronym(acronym0.str()); - auto family1 = ProductConfigHelper::returnFamilyForAcronym(acronym1.str()); - getProductsAcronymsForTarget(expected, family0, oclocArgHelperWithoutInput.get()); - getProductsAcronymsForTarget(expected, family1, oclocArgHelperWithoutInput.get()); + std::vector expected{platformName0, platformName1}; - std::string acronymsTarget = acronym0.str() + "," + acronym1.str(); - auto got = NEO::getTargetProductsForFatbinary(acronymsTarget, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(got, expected); + std::string platformsTarget = platformName0.str() + "," + platformName1.str(); - oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - acronymsTarget}; + auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); + EXPECT_EQ(expected, got); - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); + 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; - for (const auto &product : expected) { - resString << "Build succeeded for : " << product.str() + ".\n"; - } + std::vector argv = { + "ocloc", + "-file", + clFiles + "copybuffer.cl", + "-device", + platformsTarget}; - EXPECT_STREQ(output.c_str(), resString.str().c_str()); + 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(OclocFatBinaryProductAcronymsTests, givenProductsClosedRangeWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - if (enabledProductsAcronyms.size() < 3) { - GTEST_SKIP(); - } - for (unsigned int product = 0; product < enabledProductsAcronyms.size() - 1; product++) { - if (product == enabledProductsAcronyms.size() / 2) { - continue; - } - std::vector expected{}; - auto acronymFrom = enabledProductsAcronyms.at(product); - auto acronymTo = enabledProductsAcronyms.at(enabledProductsAcronyms.size() / 2); - - 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()); - } -} - -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) { +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformsClosedRangeWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + std::unique_ptr argHelper = std::make_unique(); + auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); + if (allEnabledPlatforms.size() < 4) { GTEST_SKIP(); } - for (const auto &release : enabledReleasesAcronyms) { - std::vector expected{}; + auto platformFrom = allEnabledPlatforms[0]; + ConstStringRef platformNameFrom(hardwarePrefix[platformFrom], strlen(hardwarePrefix[platformFrom])); + auto platformTo = allEnabledPlatforms[allEnabledPlatforms.size() / 2]; + ConstStringRef platformNameTo(hardwarePrefix[platformTo], strlen(hardwarePrefix[platformTo])); - 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()); + 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(OclocFatBinaryProductAcronymsTests, givenOpenRangeToReleaseWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - if (enabledReleasesAcronyms.size() < 3) { +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformsOpenRangeToWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + std::unique_ptr argHelper = std::make_unique(); + auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); + if (allEnabledPlatforms.size() < 4) { GTEST_SKIP(); } - for (const auto &release : enabledReleasesAcronyms) { - std::vector expected{}; + auto platformTo = allEnabledPlatforms[0]; + ConstStringRef platformNameTo(hardwarePrefix[platformTo], strlen(hardwarePrefix[platformTo])); - auto releaseFromId = static_cast(static_cast(AOT::UNKNOWN_RELEASE) + 1); - auto releaseToId = ProductConfigHelper::returnReleaseForAcronym(release.str()); + std::vector requestedPlatforms; + auto platformToId = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platformTo); + assert(platformToId != allEnabledPlatforms.end()); - while (releaseFromId <= releaseToId) { - getProductsAcronymsForTarget(expected, releaseFromId, oclocArgHelperWithoutInput.get()); - releaseFromId = static_cast(static_cast(releaseFromId) + 1); - } + requestedPlatforms.insert(requestedPlatforms.end(), allEnabledPlatforms.begin(), platformToId + 1); - std::string releasesTarget = ":" + release.str(); - auto got = NEO::getTargetProductsForFatbinary(releasesTarget, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(got, expected); + auto expected = toProductNames(requestedPlatforms); - oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - releasesTarget}; + std::string platformsTarget = "-" + platformNameTo.str(); - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); + auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); + EXPECT_EQ(expected, got); - for (const auto &product : expected) { - resString << "Build succeeded for : " << product.str() + ".\n"; - } + std::vector platformsRevisions; - EXPECT_STREQ(output.c_str(), resString.str().c_str()); + 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(OclocFatBinaryProductAcronymsTests, givenOpenRangeFromFamilyWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - if (enabledFamiliesAcronyms.size() < 3) { +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenPlatformsOpenRangeFromWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { + std::unique_ptr argHelper = std::make_unique(); + auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms(); + if (allEnabledPlatforms.size() < 4) { GTEST_SKIP(); } - for (const auto &family : enabledFamiliesAcronyms) { - std::vector expected{}; + auto platformFrom = allEnabledPlatforms[0]; + ConstStringRef platformNameFrom(hardwarePrefix[platformFrom], strlen(hardwarePrefix[platformFrom])); - 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::vector requestedPlatforms; + auto platformToId = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platformFrom); + assert(platformToId != allEnabledPlatforms.end()); - std::string familiesTarget = family.str() + ":"; - auto got = NEO::getTargetProductsForFatbinary(familiesTarget, oclocArgHelperWithoutInput.get()); - EXPECT_EQ(got, expected); + requestedPlatforms.insert(requestedPlatforms.end(), platformToId, allEnabledPlatforms.end()); - oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{false}; - std::stringstream resString; - std::vector argv = { - "ocloc", - "-file", - clFiles + "copybuffer.cl", - "-device", - familiesTarget}; + auto expected = toProductNames(requestedPlatforms); - testing::internal::CaptureStdout(); - int retVal = buildFatBinary(argv, oclocArgHelperWithoutInput.get()); - auto output = testing::internal::GetCapturedStdout(); - EXPECT_EQ(retVal, NEO::OclocErrorCode::SUCCESS); + std::string platformsTarget = platformNameFrom.str() + "-"; - for (const auto &product : expected) { - resString << "Build succeeded for : " << product.str() + ".\n"; - } + auto got = NEO::getTargetPlatformsForFatbinary(platformsTarget, argHelper.get()); + EXPECT_EQ(expected, got); - EXPECT_STREQ(output.c_str(), resString.str().c_str()); + 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(OclocFatBinaryProductAcronymsTests, givenOpenRangeToFamilyWhenFatBinaryBuildIsInvokedThenSuccessIsReturned) { - if (enabledFamiliesAcronyms.size() < 3) { +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); + } + } + } + + 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) { + 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(); } - for (const auto &family : enabledFamiliesAcronyms) { - std::vector expected{}; + auto deviceMapConfig = allEnabledDeviceConfigs[allEnabledDeviceConfigs.size() / 2]; + auto configNumConvention = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); - 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::vector expected; + for (auto &deviceConfig : allEnabledDeviceConfigs) { + if (deviceConfig.config <= deviceMapConfig.config) { + expected.push_back(deviceConfig); } - - 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()); } + 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(OclocFatBinaryTest, givenSpirvInputWhenFatBinaryIsRequestedThenArchiveContainsGenericIrFileWithSpirvContent) { +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 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) { + 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); + + auto got = NEO::getTargetConfigsForFatbinary(ConstStringRef(cutRevision), oclocArgHelperWithoutInput.get()); + EXPECT_FALSE(got.empty()); +} + +TEST_F(OclocFatBinaryGetTargetConfigsForFatbinary, GivenArgsWhenCorrectDeviceNumerationIsProvidedWithoutMinorAndRevisionThenTargetsAreFound) { + auto allEnabledDeviceConfigs = oclocArgHelperWithoutInput->getAllSupportedDeviceConfigs(); + if (allEnabledDeviceConfigs.size() < 2) { + GTEST_SKIP(); + } + + std::string configNum0 = ProductConfigHelper::parseMajorMinorRevisionValue(allEnabledDeviceConfigs[0].config); + auto majorPos = configNum0.find("."); + auto cutMinorAndRevision = configNum0.substr(0, majorPos); + + auto got = NEO::getTargetConfigsForFatbinary(ConstStringRef(cutMinorAndRevision), oclocArgHelperWithoutInput.get()); + EXPECT_FALSE(got.empty()); +} + +TEST_F(OclocFatBinaryTest, GivenSpirvInputWhenFatBinaryIsRequestedThenArchiveContainsGenericIrFileWithSpirvContent) { const auto devices = prepareTwoDevices(&mockArgHelper); if (devices.empty()) { GTEST_SKIP(); } + const std::vector args = { "ocloc", "-output", @@ -828,7 +1122,6 @@ 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)); @@ -864,7 +1157,7 @@ TEST_F(OclocFatBinaryTest, givenSpirvInputWhenFatBinaryIsRequestedThenArchiveCon EXPECT_TRUE(isSpirvDataEqualsInputFileData); } -TEST_F(OclocFatBinaryTest, givenDeviceFlagWithoutConsecutiveArgumentWhenBuildingFatbinaryThenErrorIsReported) { +TEST_F(OclocFatBinaryTest, GivenDeviceFlagWithoutConsecutiveArgumentWhenBuildingFatbinaryThenErrorIsReported) { const std::vector args = { "ocloc", "-device"}; @@ -879,11 +1172,12 @@ 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) { @@ -904,11 +1198,12 @@ 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{ @@ -931,7 +1226,6 @@ 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)); @@ -951,11 +1245,12 @@ 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 = { @@ -971,7 +1266,6 @@ TEST_F(OclocFatBinaryTest, givenOutputDirectoryFlagWhenBuildingFatbinaryThenArch "-device", devices}; - mockArgHelper.getPrinterRef() = MessagePrinter{true}; const auto buildResult = buildFatBinary(args, &mockArgHelper); ASSERT_EQ(OclocErrorCode::SUCCESS, buildResult); @@ -979,11 +1273,12 @@ 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", @@ -996,7 +1291,6 @@ 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)); @@ -1016,7 +1310,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(); @@ -1035,7 +1329,6 @@ 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)); @@ -1055,7 +1348,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] = ""; @@ -1069,7 +1362,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!"; @@ -1085,7 +1378,7 @@ TEST_F(OclocFatBinaryTest, givenInvalidIrFileWhenAppendingGenericIrThenInvalidFi EXPECT_EQ(expectedErrorMessage, output); } -TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationErrorWhenBuildingFatbinaryForTargetThenNothingIsDoneAndErrorIsReturned) { +TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationErrorWhenBuildingFatbinaryForTargetThenNothingIsDoneAndErrorIsReturned) { const std::vector argv = { "ocloc", "-file", @@ -1094,7 +1387,6 @@ 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. @@ -1105,7 +1397,7 @@ TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationErrorWhenBuildingFatbina Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); const int previousReturnValue{OclocErrorCode::INVALID_FILE}; const auto buildResult = buildFatBinaryForTarget(previousReturnValue, argv, pointerSize, ar, &mockOfflineCompiler, mockArgHelper, deviceConfig); @@ -1114,7 +1406,7 @@ TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationErrorWhenBuildingFatbina EXPECT_EQ(0, mockOfflineCompiler.buildCalledCount); } -TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationSuccessAndFailingBuildWhenBuildingFatbinaryForTargetThenCompilationIsInvokedAndErrorLogIsPrinted) { +TEST(OclocFatBinaryHelpersTest, GivenPreviousCompilationSuccessAndFailingBuildWhenBuildingFatbinaryForTargetThenCompilationIsInvokedAndErrorLogIsPrinted) { const std::vector argv = { "ocloc", "-file", @@ -1130,7 +1422,7 @@ TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationSuccessAndFailingBuildWh Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); ::testing::internal::CaptureStdout(); const int previousReturnValue{OclocErrorCode::SUCCESS}; @@ -1153,7 +1445,7 @@ TEST(OclocFatBinaryHelpersTest, givenPreviousCompilationSuccessAndFailingBuildWh EXPECT_EQ(expectedOutput, output); } -TEST(OclocFatBinaryHelpersTest, givenNonEmptyBuildLogWhenBuildingFatbinaryForTargetThenBuildLogIsPrinted) { +TEST(OclocFatBinaryHelpersTest, GivenNonEmptyBuildLogWhenBuildingFatbinaryForTargetThenBuildLogIsPrinted) { using namespace std::string_literals; const std::vector argv = { @@ -1176,7 +1468,7 @@ TEST(OclocFatBinaryHelpersTest, givenNonEmptyBuildLogWhenBuildingFatbinaryForTar Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); ::testing::internal::CaptureStdout(); const int previousReturnValue{OclocErrorCode::SUCCESS}; @@ -1190,7 +1482,7 @@ TEST(OclocFatBinaryHelpersTest, givenNonEmptyBuildLogWhenBuildingFatbinaryForTar EXPECT_EQ(expectedOutput, output); } -TEST(OclocFatBinaryHelpersTest, givenQuietModeWhenBuildingFatbinaryForTargetThenNothingIsPrinted) { +TEST(OclocFatBinaryHelpersTest, GivenQuietModeWhenBuildingFatbinaryForTargetThenNothingIsPrinted) { using namespace std::string_literals; const std::vector argv = { @@ -1211,7 +1503,7 @@ TEST(OclocFatBinaryHelpersTest, givenQuietModeWhenBuildingFatbinaryForTargetThen Ar::ArEncoder ar; const std::string pointerSize{"32"}; const auto mockArgHelper = mockOfflineCompiler.uniqueHelper.get(); - const auto deviceConfig = getDeviceConfig(mockOfflineCompiler, mockArgHelper); + const auto deviceConfig = getDeviceConfig(mockOfflineCompiler); ::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 0084e98f4d..ec043e206e 100644 --- a/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h +++ b/opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h @@ -16,39 +16,21 @@ #include namespace NEO { -class OclocEnabledAcronyms : public ::testing::Test { - public: - std::vector enabledProducts{}; - std::vector enabledProductsAcronyms{}; - std::vector enabledFamiliesAcronyms{}; - std::vector enabledReleasesAcronyms{}; -}; -class OclocFatBinaryProductAcronymsTests : public OclocEnabledAcronyms { +class OclocFatBinaryGetTargetConfigsForFatbinary : public ::testing::Test { public: - OclocFatBinaryProductAcronymsTests() { + OclocFatBinaryGetTargetConfigsForFatbinary() { 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 OclocEnabledAcronyms { +class OclocFatBinaryTest : public ::testing::Test { 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 0cb400021d..aa8683dd62 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 (aotConfig.ProductConfig == deviceConfig.aotConfig.ProductConfig) { + if (productConfig == deviceConfig.config) { if (deviceConfig.deviceIds) { deviceId = deviceConfig.deviceIds->front(); } - revId = deviceConfig.aotConfig.ProductConfigID.Revision; + revId = deviceConfig.revId; break; } } - mockOfflineCompiler->deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + mockOfflineCompiler->deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); 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 ddd92f6252..bed9adb16b 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(aotConfig.ProductConfig, productFamily) = GetParam(); + std::tie(productConfig, productFamily) = GetParam(); mockOfflineCompiler = std::make_unique(); } - AheadOfTimeConfig aotConfig; + PRODUCT_CONFIG productConfig; 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 4d4af8d330..cc41bdb3ac 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.aotConfig); + configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); break; } } @@ -521,30 +521,6 @@ 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(); @@ -553,10 +529,10 @@ TEST_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenBaseHa } auto expectedRevId = 0u; - for (const auto &deviceMapConfig : allEnabledDeviceConfigs) { + for (auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); - expectedRevId = deviceMapConfig.aotConfig.ProductConfigID.Revision; + mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); + expectedRevId = deviceMapConfig.revId; break; } } @@ -564,6 +540,7 @@ TEST_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenBaseHa 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); @@ -578,9 +555,9 @@ HWTEST2_F(MockOfflineCompilerTests, givenProductConfigValueWhenInitHwInfoThenMax GTEST_SKIP(); } - for (const auto &deviceMapConfig : allEnabledDeviceConfigs) { + for (auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); + mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); break; } } @@ -764,7 +741,6 @@ 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); } @@ -785,7 +761,6 @@ 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); @@ -829,7 +804,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 device target: 9.1.\nError: Cannot get HW Info for device 9.1..\n"); + 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_EQ(CL_INVALID_DEVICE, retVal); } @@ -844,7 +819,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 device target: 9.1..\nError: Cannot get HW Info for device 9.1...\n"); + 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_EQ(CL_INVALID_DEVICE, retVal); } @@ -859,7 +834,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 device target: .1.2\nError: Cannot get HW Info for device .1.2.\n"); + 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_EQ(CL_INVALID_DEVICE, retVal); } @@ -874,7 +849,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 device target: 9.0.a\nError: Cannot get HW Info for device 9.0.a.\n"); + 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_EQ(CL_INVALID_DEVICE, retVal); } @@ -889,7 +864,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 device target: 9.a\nError: Cannot get HW Info for device 9.a.\n"); + 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_EQ(CL_INVALID_DEVICE, retVal); } @@ -904,7 +879,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 device target: 256.350\nError: Cannot get HW Info for device 256.350.\n"); + 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_EQ(CL_INVALID_DEVICE, retVal); } @@ -919,7 +894,7 @@ TEST_F(OfflineCompilerTests, givenInitHardwareInfowhenDeviceConfigContainsDevice for (auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); + mockOfflineCompiler.deviceName = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); deviceMapConfig.deviceIds = &deviceIdsForTests; break; } @@ -1358,7 +1333,7 @@ TEST_F(OfflineCompilerTests, GivenArgsWhenBuildingWithDeviceConfigValueThenBuild std::string configStr; for (auto &deviceMapConfig : allEnabledDeviceConfigs) { if (productFamily == deviceMapConfig.hwInfo->platform.eProductFamily) { - configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.aotConfig); + configStr = ProductConfigHelper::parseMajorMinorRevisionValue(deviceMapConfig.config); break; } } @@ -1664,36 +1639,6 @@ 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; @@ -1775,6 +1720,23 @@ 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); @@ -3021,35 +2983,37 @@ TEST(OclocArgHelperTest, GivenNoOutputPrintMessages) { EXPECT_STREQ(printMsg.data(), capturedStdout.c_str()); } -TEST(OclocArgHelperTest, GivenDifferentAotConfigsInDeviceMappingsWhenComparingThemThenFalseIsReturned) { +TEST(OclocArgHelperTest, GivenDifferentRevisionIdsInDeviceMappingsWhenComparingThemThenFalseIsReturned) { DeviceMapping lhs{}; DeviceMapping rhs{}; ASSERT_TRUE(lhs == rhs); - lhs.aotConfig = {AOT::CONFIG_MAX_PLATFORM}; - rhs.aotConfig = {AOT::UNKNOWN_ISA}; + 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; EXPECT_FALSE(lhs == rhs); } -TEST(OclocArgHelperTest, GivenDifferentFamiliesInDeviceMappingsWhenComparingThemThenFalseIsReturned) { +TEST(OclocArgHelperTest, GivenDifferentConfigsInDeviceMappingsWhenComparingThemThenFalseIsReturned) { DeviceMapping lhs{}; DeviceMapping rhs{}; ASSERT_TRUE(lhs == rhs); - lhs.family = AOT::FAMILY_MAX; - rhs.family = AOT::UNKNOWN_FAMILY; - - EXPECT_FALSE(lhs == rhs); -} - -TEST(OclocArgHelperTest, GivenDifferentReleasesInDeviceMappingsWhenComparingThemThenFalseIsReturned) { - DeviceMapping lhs{}; - DeviceMapping rhs{}; - ASSERT_TRUE(lhs == rhs); - - lhs.release = AOT::RELEASE_MAX; - rhs.release = AOT::UNKNOWN_RELEASE; + lhs.config = CONFIG_MAX_PLATFORM; + rhs.config = UNKNOWN_ISA; 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 9a941ce999..8b4b875bb8 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,16 +5,22 @@ * */ -#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(AOT_PVC::productConfigs), + ::testing::ValuesIn(pvcProductConfig), ::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 8feb17d781..c2fd0af095 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,16 +5,19 @@ * */ -#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(AOT_DG2::productConfigs), + ::testing::ValuesIn(dg2ProductConfig), ::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 ffbf522e8d..3bfbcbaa99 100644 --- a/shared/offline_compiler/source/CMakeLists.txt +++ b/shared/offline_compiler/source/CMakeLists.txt @@ -12,8 +12,6 @@ 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 @@ -30,11 +28,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 @@ -43,9 +41,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 @@ -83,7 +81,6 @@ 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 91dd90fc8d..6cc76131cc 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 )===", - argHelper->getAllSupportedAcronyms().c_str()); + NEO::getDevicesTypes().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 221bfbb2f8..aa390f50f5 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 )===", - argHelper->getAllSupportedAcronyms().c_str()); + NEO::getDevicesTypes().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 b1d1c56a92..437060a2d3 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.cpp +++ b/shared/offline_compiler/source/ocloc_arg_helper.cpp @@ -7,7 +7,6 @@ #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" @@ -64,11 +63,13 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo #undef NAMEDDEVICE {0u, std::string("")}}), deviceMap({ -#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}}, +#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}, #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])); @@ -76,15 +77,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); - for (auto &device : deviceMap) { - for (const auto &[acronym, value] : AOT::productConfigAcronyms) { - if (value == device.aotConfig.ProductConfig) { - device.acronyms.push_back(NEO::ConstStringRef(acronym)); - } - } - } + deviceMap.erase(std::unique(deviceMap.begin(), deviceMap.end(), isDuplicateConfig), deviceMap.end()); } OclocArgHelper::OclocArgHelper() : OclocArgHelper(0, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) {} @@ -168,19 +169,31 @@ 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 == AOT::UNKNOWN_ISA) { + if (config == UNKNOWN_ISA) { return retVal; } - for (auto &deviceConfig : deviceMap) { - if (deviceConfig.aotConfig.ProductConfig == config) { + if (deviceConfig.config == 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(); } @@ -191,6 +204,14 @@ 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); @@ -210,60 +231,6 @@ 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++) { @@ -278,6 +245,15 @@ 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; @@ -295,55 +271,119 @@ int OclocArgHelper::parseProductConfigFromString(const std::string &device, size } } -AheadOfTimeConfig OclocArgHelper::getMajorMinorRevision(const std::string &device) { - AheadOfTimeConfig product = {AOT::UNKNOWN_ISA}; +std::vector OclocArgHelper::getMajorMinorRevision(const std::string &device) { + std::vector numeration; auto majorPos = device.find("."); auto major = parseProductConfigFromString(device, 0, majorPos); - if (major == CONFIG_STATUS::MISMATCHED_VALUE || majorPos == std::string::npos) { - return product; + if (major == CONFIG_STATUS::MISMATCHED_VALUE) { + return {}; + } + numeration.push_back(major); + if (majorPos == std::string::npos) { + return numeration; } auto minorPos = device.find(".", ++majorPos); auto minor = parseProductConfigFromString(device, majorPos, minorPos); - if (minor == CONFIG_STATUS::MISMATCHED_VALUE || minorPos == std::string::npos) { - return product; + if (minor == CONFIG_STATUS::MISMATCHED_VALUE) { + return {}; + } + numeration.push_back(minor); + if (minorPos == std::string::npos) { + return numeration; } - auto revision = parseProductConfigFromString(device, minorPos + 1, device.size()); if (revision == CONFIG_STATUS::MISMATCHED_VALUE) { - return product; + return {}; } - product.ProductConfigID.Major = major; - product.ProductConfigID.Minor = minor; - product.ProductConfigID.Revision = revision; - return product; + numeration.push_back(revision); + return numeration; } -bool OclocArgHelper::isRelease(const std::string &device) { - auto release = ProductConfigHelper::returnReleaseForAcronym(device); - if (release == AOT::UNKNOWN_RELEASE) { - return false; +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); } - return std::any_of(deviceMap.begin(), deviceMap.end(), findRelease(release)); + if (numeration.size() > 2) { + config |= numeration.at(2); + } + + return config; } -bool OclocArgHelper::isFamily(const std::string &device) { - auto family = ProductConfigHelper::returnFamilyForAcronym(device); - if (family == AOT::UNKNOWN_FAMILY) { - return false; +uint32_t OclocArgHelper::getMaskForConfig(std::vector &numeration) { + uint32_t mask = 0xffffff; + if (numeration.size() == 1) { + mask = 0xff0000; + } else if (numeration.size() == 2) { + mask = 0xffff00; } - return std::any_of(deviceMap.begin(), deviceMap.end(), findFamily(family)); + return mask; } -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::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::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 7efcfac92c..c974093464 100644 --- a/shared/offline_compiler/source/ocloc_arg_helper.h +++ b/shared/offline_compiler/source/ocloc_arg_helper.h @@ -9,8 +9,6 @@ #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" @@ -50,15 +48,13 @@ struct DeviceProduct { }; struct DeviceMapping { + PRODUCT_CONFIG config = UNKNOWN_ISA; const NEO::HardwareInfo *hwInfo = nullptr; const std::vector *deviceIds = nullptr; - AOT::FAMILY family = AOT::UNKNOWN_FAMILY; - AOT::RELEASE release = AOT::UNKNOWN_RELEASE; - AheadOfTimeConfig aotConfig = {0}; - std::vector acronyms{}; + unsigned int revId = 0U; bool operator==(const DeviceMapping &rhs) { - return aotConfig.ProductConfig == rhs.aotConfig.ProductConfig && family == rhs.family && release == rhs.release; + return config == rhs.config && hwInfo == rhs.hwInfo && revId == rhs.revId; } }; @@ -74,6 +70,9 @@ 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; @@ -83,22 +82,11 @@ class OclocArgHelper { } static bool compareConfigs(DeviceMapping deviceMap0, DeviceMapping deviceMap1) { - return deviceMap0.aotConfig.ProductConfig < deviceMap1.aotConfig.ProductConfig; + 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; }; + static bool isDuplicateConfig(DeviceMapping deviceMap0, DeviceMapping deviceMap1) { + return deviceMap0.config == deviceMap1.config; } public: @@ -117,13 +105,16 @@ 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 getEnabledProductAcronyms(); - std::vector getEnabledReleasesAcronyms(); - std::vector getEnabledFamiliesAcronyms(); - std::string getAllSupportedAcronyms(); - AheadOfTimeConfig getMajorMinorRevision(const std::string &device); - bool setAcronymForDeviceId(std::string &device); + 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 headersToVectorOfStrings(); MOCKABLE_VIRTUAL void readFileToVectorOfStrings(const std::string &filename, std::vector &lines); MOCKABLE_VIRTUAL std::vector readBinaryFile(const std::string &filename); @@ -139,6 +130,13 @@ 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); @@ -151,10 +149,8 @@ class OclocArgHelper { messagePrinter.printf(format, std::forward(args)...); } - 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); + bool isGen(const std::string &device); + unsigned int returnIGFXforGen(const std::string &device); + bool areQuotesRequired(const std::string_view &argName); }; diff --git a/shared/offline_compiler/source/ocloc_fatbinary.cpp b/shared/offline_compiler/source/ocloc_fatbinary.cpp index bdbde9318a..fb382f5fbd 100644 --- a/shared/offline_compiler/source/ocloc_fatbinary.cpp +++ b/shared/offline_compiler/source/ocloc_fatbinary.cpp @@ -23,195 +23,295 @@ #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 retVal = deviceArg.contains("*"); - retVal |= deviceArg.contains(":"); - retVal |= deviceArg.contains(","); - retVal |= helper->isFamily(deviceArg.str()); - retVal |= helper->isRelease(deviceArg.str()); - - return retVal; + auto products = getAllMatchedConfigs(deviceArg.str(), helper); + if (products.size() > 1) { + return true; + } + return deviceArg.contains("*") || deviceArg.contains("-") || deviceArg.contains(",") || helper->isGen(deviceArg.str()); } } return false; } -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()); +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::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 target = rangeFromStr + ":" + rangeToStr; - argHelper->printf("Failed to parse target : %s.\n", target.c_str()); - return {}; - } - - return requestedProducts; -} - -std::vector getProductForOpenRange(ConstStringRef openRange, OclocArgHelper *argHelper, bool rangeTo) { - std::vector requestedProducts = {}; - auto openRangeStr = openRange.str(); - - 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 { - 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; -} - -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()); + 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 getTargetProductsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) { - std::vector retVal; - if (deviceArg == "*") { - return argHelper->getEnabledProductAcronyms(); +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 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()); + 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()); + 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); +} + +std::vector getPlatformsForOpenRange(ConstStringRef openRange, PRODUCT_FAMILY prodId, OclocArgHelper *argHelper, bool rangeTo) { + std::vector requestedPlatforms; + std::vector allSupportedPlatforms = getAllSupportedTargetPlatforms(); + + 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); + } 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 {}; } - if (range.size() == 1) { - bool rangeTo = (':' == sets[0][0]); - retVal = getProductForOpenRange(range[0], argHelper, rangeTo); - - } else { - retVal = getProductForClosedRange(range[0], range[1], argHelper); + auto configLastEl = argHelper->findConfigMatch(target.str(), false); + for (auto &deviceConfig : allSupportedDeviceConfigs) { + if (deviceConfig.config >= configFirstEl && deviceConfig.config <= configLastEl) { + requestedConfigs.push_back(deviceConfig); + } } - } else { - retVal = getProductForSpecificTarget(sets, argHelper); } } + 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 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); + } + } else { + retVal = getProductConfigsForSpecificTargets(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 &product) { + OfflineCompiler *pCompiler, OclocArgHelper *argHelper, const std::string &deviceConfig) { if (retVal == 0) { retVal = buildWithSafetyGuard(pCompiler); @@ -221,9 +321,9 @@ int buildFatBinaryForTarget(int retVal, const std::vector &argsCopy } if (retVal == 0) { if (!pCompiler->isQuiet()) - argHelper->printf("Build succeeded for : %s.\n", product.c_str()); + argHelper->printf("Build succeeded for : %s.\n", deviceConfig.c_str()); } else { - argHelper->printf("Build failed for : %s with error code: %d\n", product.c_str(), retVal); + argHelper->printf("Build failed for : %s with error code: %d\n", deviceConfig.c_str(), retVal); argHelper->printf("Command was:"); for (const auto &arg : argsCopy) argHelper->printf(" %s", arg.c_str()); @@ -233,8 +333,7 @@ int buildFatBinaryForTarget(int retVal, const std::vector &argsCopy if (retVal) { return retVal; } - auto productConfig = ProductConfigHelper::parseMajorMinorRevisionValue(ProductConfigHelper::returnProductConfigForAcronym(product)); - fatbinary.appendFileEntry(pointerSize + "." + productConfig, pCompiler->getPackedDeviceBinaryOutput()); + fatbinary.appendFileEntry(pointerSize + "." + deviceConfig, pCompiler->getPackedDeviceBinaryOutput()); return retVal; } @@ -285,25 +384,56 @@ int buildFatBinary(const std::vector &args, OclocArgHelper *argHelp } Ar::ArEncoder fatbinary(true); - 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(); + 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::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::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; + } } - retVal = buildFatBinaryForTarget(retVal, argsCopy, pointerSizeInBits, fatbinary, pCompiler.get(), argHelper, product.str()); - if (retVal) { - 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; + } } } diff --git a/shared/offline_compiler/source/ocloc_fatbinary.h b/shared/offline_compiler/source/ocloc_fatbinary.h index 6b83cd316f..1636ed4159 100644 --- a/shared/offline_compiler/source/ocloc_fatbinary.h +++ b/shared/offline_compiler/source/ocloc_fatbinary.h @@ -34,9 +34,19 @@ inline int buildFatBinary(int argc, const char *argv[], OclocArgHelper *argHelpe return buildFatBinary(args, argHelper); } -template -void getProductsAcronymsForTarget(std::vector &out, Target target, OclocArgHelper *argHelper); -std::vector getTargetProductsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *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); 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 b5daeb98ff..abceee96df 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::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; -} - -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 (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; } + if (argHelper->isFatbinary()) { + argHelper->setHwInfoForFatbinaryTarget(hwInfo); + setFamilyType(); + retVal = SUCCESS; + return retVal; + } + overridePlatformName(deviceName); std::transform(deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower); const char hexPrefix = 2; - int deviceId = -1; + auto deviceId = -1; + std::string product(""); - retVal = initHardwareInfoForProductConfig(deviceName); - if (retVal == SUCCESS) { + 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()); return retVal; } if (deviceName.substr(0, hexPrefix) == "0x" && std::all_of(deviceName.begin() + hexPrefix, deviceName.end(), (::isxdigit))) { - deviceId = std::stoi(deviceName, 0, 16); - if (!argHelper->setAcronymForDeviceId(deviceName)) { + 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()); return retVal; } } - retVal = initHardwareInfoForDeprecatedAcronyms(deviceName, deviceId); + + 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; + } + } + } return retVal; } @@ -756,52 +756,51 @@ std::string OfflineCompiler::getFileNameTrunk(std::string &filePath) { return fileTrunk; } -template -auto findDuplicate(const EqComparableT &lhs) { - return [&lhs](const auto &rhs) { return lhs == rhs; }; -} - -std::string OfflineCompiler::getDeprecatedDevicesTypes() { - std::vector prefixes; +std::string getDevicesTypes() { + std::list prefixes; for (int j = 0; j < IGFX_MAX_PRODUCT; j++) { if (hardwarePrefix[j] == nullptr) continue; prefixes.push_back(hardwarePrefix[j]); } - std::vector enabledAcronyms{}; - auto enabledConfigs = argHelper->getAllSupportedDeviceConfigs(); - for (const auto &device : enabledConfigs) { - enabledAcronyms.insert(enabledAcronyms.end(), device.acronyms.begin(), device.acronyms.end()); - } - std::ostringstream os; - for (const auto &prefix : prefixes) { - if (std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), findDuplicate(prefix))) - continue; - if (os.tellp()) + for (auto it = prefixes.begin(); it != prefixes.end(); it++) { + if (it != prefixes.begin()) os << ", "; - os << prefix; + os << *it; } return os.str(); } -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::string getDevicesFamilies() { + std::list prefixes; + for (unsigned int i = 0; i < IGFX_MAX_CORE; ++i) { + if (familyName[i] == nullptr) + continue; + prefixes.push_back(familyName[i]); } std::ostringstream os; - for (const auto &acronym : acronyms) { - if (os.tellp()) + for (auto it = prefixes.begin(); it != prefixes.end(); it++) { + if (it != prefixes.begin()) os << ", "; - os << acronym.str(); + os << *it; + } + + return os.str(); +} + +std::string OfflineCompiler::getDevicesConfigs() { + std::list configNum; + auto allSupportedConfigs = argHelper->getAllSupportedProductConfigs(); + + std::ostringstream os; + for (auto it = allSupportedConfigs.begin(); it != allSupportedConfigs.end(); it++) { + if (it != allSupportedConfigs.begin()) + os << ", "; + os << ProductConfigHelper::parseMajorMinorRevisionValue(*it); } return os.str(); @@ -819,9 +818,14 @@ Usage: ocloc [compile] -file -device [-output Target device. - 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. + 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. The hexadecimal value represents device ID. If such value is provided, ocloc will try to match it with corresponding device type. @@ -832,31 +836,41 @@ Usage: ocloc [compile] -file -device [-output can be: %s - - can be single target device. + - 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 -output Optional output file base name. Default is input file's base name. @@ -948,9 +962,9 @@ Examples : Compile file to Intel Compute GPU device binary (out = source_file_Gen9core.bin) ocloc -file source_file.cl -device skl )===", - argHelper->getAllSupportedAcronyms().c_str(), - getDevicesReleasesAndFamilies().c_str(), - getDeprecatedDevicesTypes().c_str()); + getDevicesConfigs().c_str(), + NEO::getDevicesFamilies().c_str(), + NEO::getDevicesTypes().c_str()); } void OfflineCompiler::storeBinary( diff --git a/shared/offline_compiler/source/offline_compiler.h b/shared/offline_compiler/source/offline_compiler.h index c1dbb1e210..3e2cab7fc6 100644 --- a/shared/offline_compiler/source/offline_compiler.h +++ b/shared/offline_compiler/source/offline_compiler.h @@ -29,6 +29,7 @@ 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: @@ -38,8 +39,7 @@ class OfflineCompiler { MOCKABLE_VIRTUAL int build(); std::string &getBuildLog(); void printUsage(); - std::string getDevicesReleasesAndFamilies(); - std::string getDeprecatedDevicesTypes(); + std::string getDevicesConfigs(); static constexpr ConstStringRef queryHelp = "Depending on will generate file\n" @@ -91,9 +91,6 @@ 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); @@ -123,7 +120,7 @@ class OfflineCompiler { void enforceFormat(std::string &format); HardwareInfo hwInfo; - AOT::PRODUCT_CONFIG deviceConfig = AOT::UNKNOWN_ISA; + PRODUCT_CONFIG deviceConfig = 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 04c9742ae7..77cfac561a 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 + "." + ProductConfigHelper::parseMajorMinorRevisionValue(requestedTargetDevice.aotConfig); - std::string filterPointerSizeAndMajorMinor = pointerSize + "." + ProductConfigHelper::parseMajorMinorValue(requestedTargetDevice.aotConfig); + std::string filterPointerSizeAndMajorMinorRevision = pointerSize + "." + NEO::ProductConfigHelper::parseMajorMinorRevisionValue(requestedTargetDevice.productConfig); + std::string filterPointerSizeAndMajorMinor = pointerSize + "." + NEO::ProductConfigHelper::parseMajorMinorValue(requestedTargetDevice.productConfig); 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 349b8f24b0..a4330c0f86 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.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + targetDevice.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 9e968468c3..f940cee130 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; - AheadOfTimeConfig aotConfig = {0}; + PRODUCT_CONFIG productConfig = UNKNOWN_ISA; 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 new file mode 100644 index 0000000000..2ea3200b83 --- /dev/null +++ b/shared/source/dll/devices/platforms.h @@ -0,0 +1,44 @@ +/* + * 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, + 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 a177a0c5b6..aeb542afeb 100644 --- a/shared/source/dll/devices/product_config_base.inl +++ b/shared/source/dll/devices/product_config_base.inl @@ -7,86 +7,82 @@ #if SUPPORT_XE_HPC_CORE #ifdef SUPPORT_PVC -DEVICE_CONFIG_IDS(PVC_XL_A0, PVC_CONFIG, PVC_XL_IDS, XE_FAMILY, XE_HPC_RELEASE) -DEVICE_CONFIG_IDS(PVC_XL_A0P, PVC_CONFIG, PVC_XL_IDS, XE_FAMILY, XE_HPC_RELEASE) -DEVICE_CONFIG_IDS(PVC_XT_A0, PVC_CONFIG, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) -DEVICE_CONFIG_IDS(PVC_XT_B0, PVC_CONFIG, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) -DEVICE_CONFIG_IDS(PVC_XT_B1, PVC_CONFIG, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) -DEVICE_CONFIG_IDS(PVC_XT_C0, PVC_CONFIG, PVC_XT_IDS, XE_FAMILY, XE_HPC_RELEASE) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_A0, PVC_CONFIG, PVC_XL_IDS, 0x00) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XL_A0P, PVC_CONFIG, PVC_XL_IDS, 0x01) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_A0, PVC_CONFIG, PVC_XT_IDS, 0x03) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_B0, PVC_CONFIG, PVC_XT_IDS, 0x05) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_B1, PVC_CONFIG, PVC_XT_IDS, 0x06) +DEVICE_CONFIG_IDS_AND_REVISION(PVC_XT_C0, PVC_CONFIG, PVC_XT_IDS, 0x07) #endif #endif #ifdef SUPPORT_XE_HPG_CORE #ifdef SUPPORT_DG2 -DEVICE_CONFIG_IDS(DG2_G10_A0, DG2_CONFIG, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) -DEVICE_CONFIG_IDS(DG2_G10_A1, DG2_CONFIG, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) -DEVICE_CONFIG_IDS(DG2_G10_B0, DG2_CONFIG, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) -DEVICE_CONFIG_IDS(DG2_G10_C0, DG2_CONFIG, DG2_G10_IDS, XE_FAMILY, XE_HPG_RELEASE) -DEVICE_CONFIG_IDS(DG2_G11_A0, DG2_CONFIG, DG2_G11_IDS, XE_FAMILY, XE_HPG_RELEASE) -DEVICE_CONFIG_IDS(DG2_G11_B0, DG2_CONFIG, DG2_G11_IDS, XE_FAMILY, XE_HPG_RELEASE) -DEVICE_CONFIG_IDS(DG2_G11_B1, DG2_CONFIG, DG2_G11_IDS, XE_FAMILY, XE_HPG_RELEASE) +DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_A0, DG2_CONFIG, DG2_G10_IDS, 0x00) +DEVICE_CONFIG_IDS_AND_REVISION(DG2_G10_B0, DG2_CONFIG, DG2_G10_IDS, 0x04) +DEVICE_CONFIG_IDS(DG2_G11, DG2_CONFIG, DG2_G11_IDS) #endif #endif #ifdef SUPPORT_XE_HP_CORE #ifdef SUPPORT_XE_HP_SDV -DEVICE_CONFIG(XEHP_SDV, XE_HP_SDV_CONFIG, XE_FAMILY, XE_HP_RELEASE) +DEVICE_CONFIG(XEHP_SDV, XE_HP_SDV_CONFIG) #endif #endif #ifdef SUPPORT_GEN12LP #ifdef SUPPORT_TGLLP -DEVICE_CONFIG(TGL, TGLLP_1x6x16, GEN12LP_FAMILY, GEN12LP_RELEASE) +DEVICE_CONFIG(TGL, TGLLP_1x6x16) #endif #ifdef SUPPORT_DG1 -DEVICE_CONFIG(DG1, DG1_CONFIG, GEN12LP_FAMILY, GEN12LP_RELEASE) +DEVICE_CONFIG(DG1, DG1_CONFIG) #endif #ifdef SUPPORT_RKL -DEVICE_CONFIG(RKL, RKL_HW_CONFIG, GEN12LP_FAMILY, GEN12LP_RELEASE) +DEVICE_CONFIG(RKL, RKL_HW_CONFIG) #endif #ifdef SUPPORT_ADLS -DEVICE_CONFIG(ADL_S, ADLS_HW_CONFIG, GEN12LP_FAMILY, GEN12LP_RELEASE) +DEVICE_CONFIG(ADL_S, ADLS_HW_CONFIG) #endif #ifdef SUPPORT_ADLP -DEVICE_CONFIG(ADL_P, ADLP_CONFIG, GEN12LP_FAMILY, GEN12LP_RELEASE) +DEVICE_CONFIG(ADL_P, ADLP_CONFIG) #endif #endif #ifdef SUPPORT_GEN11 #ifdef SUPPORT_ICLLP -DEVICE_CONFIG(ICL, ICLLP_1x8x8, GEN11_FAMILY, GEN11_RELEASE) +DEVICE_CONFIG(ICL, ICLLP_1x8x8) #endif #ifdef SUPPORT_EHL -DEVICE_CONFIG(EHL, EHL_HW_CONFIG, GEN11_FAMILY, GEN11_RELEASE) +DEVICE_CONFIG(EHL, EHL_HW_CONFIG) #endif #ifdef SUPPORT_LKF -DEVICE_CONFIG(LKF, LKF_1x8x8, GEN11_FAMILY, GEN11_RELEASE) +DEVICE_CONFIG(LKF, LKF_1x8x8) #endif #endif #ifdef SUPPORT_GEN9 #ifdef SUPPORT_SKL -DEVICE_CONFIG(SKL, SKL_1x3x8, GEN9_FAMILY, GEN9_RELEASE) +DEVICE_CONFIG(SKL, SKL_1x3x8) #endif #ifdef SUPPORT_KBL -DEVICE_CONFIG(KBL, KBL_1x3x6, GEN9_FAMILY, GEN9_RELEASE) +DEVICE_CONFIG(KBL, KBL_1x3x6) #endif #ifdef SUPPORT_CFL -DEVICE_CONFIG(CFL, CFL_1x3x6, GEN9_FAMILY, GEN9_RELEASE) +DEVICE_CONFIG(CFL, CFL_1x3x6) #endif #ifdef SUPPORT_GLK -DEVICE_CONFIG(GLK, GLK_1x3x6, GEN9_FAMILY, GEN9_RELEASE) +DEVICE_CONFIG(GLK, GLK_1x3x6) #endif #ifdef SUPPORT_BXT -DEVICE_CONFIG(APL, BXT_1x3x6, GEN9_FAMILY, GEN9_RELEASE) +DEVICE_CONFIG(BXT, BXT_1x3x6) #endif #endif #ifdef SUPPORT_GEN8 -DEVICE_CONFIG(BDW, BDW_1x3x8, GEN8_FAMILY, GEN8_RELEASE) +DEVICE_CONFIG(BDW, BDW_1x3x8) #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 b1145b955e..0abd53c642 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::EHL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::EHL; } \ No newline at end of file diff --git a/shared/source/gen11/enable_gen11.cpp b/shared/source/gen11/enable_gen11.cpp index 07c4f88b07..2287fa03b0 100644 --- a/shared/source/gen11/enable_gen11.cpp +++ b/shared/source/gen11/enable_gen11.cpp @@ -6,7 +6,6 @@ */ #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 3e8d9913ab..f24fb7a399 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::ICL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 a9ed280afe..2370962e4d 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::LKF; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::LKF; } \ No newline at end of file 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 0cff5f1186..75f4353c2a 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::ADL_P; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 91c88c1cd0..7069d3880f 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::ADL_S; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 32d2cba750..2a5f347580 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::DG1; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::DG1; } template <> diff --git a/shared/source/gen12lp/enable_gen12lp.cpp b/shared/source/gen12lp/enable_gen12lp.cpp index 39951c19ad..dcdece63ab 100644 --- a/shared/source/gen12lp/enable_gen12lp.cpp +++ b/shared/source/gen12lp/enable_gen12lp.cpp @@ -6,7 +6,6 @@ */ #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 0d10b50fbb..5db9238a77 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::RKL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 2b1227c199..3d59cf5801 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::TGL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 6b7b4dc83c..aa221c51d4 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::BDW; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::BDW; } \ No newline at end of file diff --git a/shared/source/gen8/enable_gen8.cpp b/shared/source/gen8/enable_gen8.cpp index 5c24bfa78a..968e36fbc7 100644 --- a/shared/source/gen8/enable_gen8.cpp +++ b/shared/source/gen8/enable_gen8.cpp @@ -6,7 +6,6 @@ */ #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 322b89e36b..3ad3aa1a22 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::APL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::BXT; } \ 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 9fa6a33869..13a448a843 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::CFL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::CFL; } \ No newline at end of file diff --git a/shared/source/gen9/enable_gen9.cpp b/shared/source/gen9/enable_gen9.cpp index ebfe3d0dff..bbdf2c2004 100644 --- a/shared/source/gen9/enable_gen9.cpp +++ b/shared/source/gen9/enable_gen9.cpp @@ -6,7 +6,6 @@ */ #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 cbf40c4cc5..f9aa44d0d0 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::GLK; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 fa253b8d08..125f1076af 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::KBL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 261a654226..40e8b0c5c9 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::SKL; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::SKL; } \ No newline at end of file diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index da7ded8c0e..154586972d 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -34,7 +34,6 @@ 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 @@ -106,7 +105,6 @@ 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 deleted file mode 100644 index 108505501c..0000000000 --- a/shared/source/helpers/compiler_aot_config_bdw_and_later.inl +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 ca84e09e7f..c387bb904d 100644 --- a/shared/source/helpers/compiler_hw_info_config.h +++ b/shared/source/helpers/compiler_hw_info_config.h @@ -8,7 +8,6 @@ #pragma once #include "shared/source/helpers/hw_info.h" -#include "shared/source/helpers/product_config_helper.h" #include "igfxfmid.h" @@ -28,7 +27,6 @@ class CompilerHwInfoConfig { virtual bool isForceEmuInt32DivRemSPRequired() const = 0; virtual bool isStatelessToStatefulBufferOffsetSupported() const = 0; virtual bool isForceToStatelessRequired() const = 0; - virtual void setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const = 0; }; template @@ -43,7 +41,6 @@ class CompilerHwInfoConfigHw : public CompilerHwInfoConfig { bool isForceEmuInt32DivRemSPRequired() const override; bool isStatelessToStatefulBufferOffsetSupported() const override; bool isForceToStatelessRequired() 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 77d7265740..2cc58555dd 100644 --- a/shared/source/helpers/constants.h +++ b/shared/source/helpers/constants.h @@ -89,7 +89,6 @@ 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 deleted file mode 100644 index 0c4414cf73..0000000000 --- a/shared/source/helpers/product_config_helper.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 e6197d496c..08d8d392b1 100644 --- a/shared/source/helpers/product_config_helper.h +++ b/shared/source/helpers/product_config_helper.h @@ -6,38 +6,36 @@ */ #pragma once -#include "shared/source/utilities/const_stringref.h" - #include "platforms.h" #include #include -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 uint32_t getMajor(PRODUCT_CONFIG config) { + return (static_cast(config) & 0xff0000) >> 16; } - 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); + 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(); + } }; + +} // namespace NEO diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index 9dcc3933ed..e260c944a9 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -57,7 +57,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 AOT::PRODUCT_CONFIG getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const = 0; + virtual 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; @@ -154,7 +154,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; - AOT::PRODUCT_CONFIG getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const override; + 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 2e55fda3fa..9185302d16 100644 --- a/shared/source/xe_hp_core/enable_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/enable_xe_hp_core.cpp @@ -5,7 +5,6 @@ * */ -#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 45e832e991..2b4f68a151 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::XEHP_SDV; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return PRODUCT_CONFIG::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 c608579f17..df9a631eb7 100644 --- a/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp @@ -5,7 +5,6 @@ * */ -#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 2706388136..11f4898062 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { uint32_t stepping = getSteppingFromHwRevId(hwInfo); if (stepping == CommonConstants::invalidStepping) { - return AOT::UNKNOWN_ISA; + return PRODUCT_CONFIG::UNKNOWN_ISA; } if (PVC::isXl(hwInfo)) { switch (hwInfo.platform.usRevId) { case 0x0: - return AOT::PVC_XL_A0; + return PRODUCT_CONFIG::PVC_XL_A0; default: case 0x1: - return AOT::PVC_XL_A0P; + return PRODUCT_CONFIG::PVC_XL_A0P; } } else { switch (hwInfo.platform.usRevId) { case 0x3: - return AOT::PVC_XT_A0; - case 05: - return AOT::PVC_XT_B0; - case 06: - return AOT::PVC_XT_B1; + return PRODUCT_CONFIG::PVC_XT_A0; + case 0x5: + return PRODUCT_CONFIG::PVC_XT_B0; + case 0x6: + return PRODUCT_CONFIG::PVC_XT_B1; default: - case 07: - return AOT::PVC_XT_C0; + case 0x7: + return PRODUCT_CONFIG::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 0308cc3247..9fdbb0f354 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,27 +6,21 @@ */ template <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + uint32_t stepping = getSteppingFromHwRevId(hwInfo); + if (stepping == CommonConstants::invalidStepping) { + return PRODUCT_CONFIG::UNKNOWN_ISA; + } if (DG2::isG10(hwInfo)) { - 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; + switch (stepping) { + case REVISION_A0: + case REVISION_A1: + return PRODUCT_CONFIG::DG2_G10_A0; + default: + case REVISION_B: + return PRODUCT_CONFIG::DG2_G10_B0; } } else { - 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 PRODUCT_CONFIG::DG2_G11; } - 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 7c5569086f..97d433da63 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 @@ -33,9 +33,8 @@ uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, c return 0x4; case REVISION_C: return 0x8; - default: - return CommonConstants::invalidStepping; } + return CommonConstants::invalidStepping; } template <> @@ -49,9 +48,8 @@ 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 d1f8ed0973..4d474f955f 100644 --- a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp @@ -5,7 +5,6 @@ * */ -#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 c79b7d757e..fbb294752f 100644 --- a/shared/test/common/fixtures/product_config_fixture.h +++ b/shared/test/common/fixtures/product_config_fixture.h @@ -7,39 +7,20 @@ #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; -template -struct ProductConfigTest : public T { +struct ProductConfigTests : public ::testing::Test { void SetUp() override { - T::SetUp(); hwInfo = *NEO::defaultHwInfo; hwInfoConfig = NEO::HwInfoConfig::get(productFamily); } NEO::HwInfoConfig *hwInfoConfig = nullptr; NEO::HardwareInfo hwInfo = {}; - 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; + PRODUCT_CONFIG productConfig = UNKNOWN_ISA; +}; \ No newline at end of file diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index 31756f431c..30165234c9 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 <> -AOT::PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { - return AOT::UNKNOWN_ISA; +PRODUCT_CONFIG HwInfoConfigHw::getProductConfigFromHwInfo(const HardwareInfo &hwInfo) const { + return 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 deleted file mode 100644 index bef8c4a90c..0000000000 --- a/shared/test/common/xe_hpc_core/pvc/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# -# 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 deleted file mode 100644 index aa9a8d2e2f..0000000000 --- a/shared/test/common/xe_hpc_core/pvc/product_configs_pvc.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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 1fdacbbb91..9045ad54e8 100644 --- a/shared/test/common/xe_hpg_core/dg2/CMakeLists.txt +++ b/shared/test/common/xe_hpg_core/dg2/CMakeLists.txt @@ -13,7 +13,6 @@ 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_dispatch_kernel_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_hw_helper_dg2.cpp @@ -22,5 +21,4 @@ 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 deleted file mode 100644 index 407835c08e..0000000000 --- a/shared/test/common/xe_hpg_core/dg2/product_configs_dg2.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 4b5dd26dee..5f963784a0 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,12 +59,11 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenChooseItA PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - AheadOfTimeConfig aotConfig = {0}; - aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); NEO::Ar::ArEncoder encoder; std::string requiredProduct = NEO::hardwarePrefix[productFamily]; - std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -75,7 +74,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenChooseItA NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.aotConfig = aotConfig; + target.productConfig = productConfig; target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -100,12 +99,11 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenPackedTar PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - AheadOfTimeConfig aotConfig = {0}; - aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); NEO::Ar::ArEncoder encoder; std::string requiredProduct = NEO::hardwarePrefix[productFamily]; - std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -116,7 +114,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenBinaryWithProductConfigIsFoundThenPackedTar NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.aotConfig = aotConfig; + target.productConfig = productConfig; target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -131,14 +129,13 @@ TEST(UnpackSingleDeviceBinaryAr, WhenMultipleBinariesMatchedThenChooseBestMatch) PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - AheadOfTimeConfig aotConfig = {0}; - aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + auto 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 = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize, programTokens.storage)); ASSERT_TRUE(encoder.appendFileEntry(requiredPointerSize + "." + requiredProduct, programTokens.storage)); @@ -147,7 +144,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenMultipleBinariesMatchedThenChooseBestMatch) NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -240,10 +237,9 @@ TEST(UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithProductConfigThenTry const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - AheadOfTimeConfig aotConfig = {0}; - aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); - std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); programTokensWrongTokenVersion.headerMutable->Version -= 1; NEO::Ar::ArEncoder encoder; @@ -258,7 +254,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithProductConfigThenTry NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; @@ -348,10 +344,9 @@ TEST(UnpackSingleDeviceBinaryAr, WhenDeviceBinaryNotMatchedButIrWithProductConfi PatchTokensTestData::ValidEmptyProgram programTokens; const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - AheadOfTimeConfig aotConfig = {0}; - aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); - std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); std::string requiredProduct = NEO::hardwarePrefix[productFamily]; std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -368,7 +363,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenDeviceBinaryNotMatchedButIrWithProductConfi target.coreFamily = static_cast(programTokens.header->Device); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; - target.aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + target.productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); auto arData = encoder.encode(); std::string unpackErrors; @@ -572,10 +567,9 @@ TEST(UnpackSingleDeviceBinaryAr, WhenCouldNotFindBinaryWithRightPointerSizeThenU const auto &hwInfoConfig = *NEO::HwInfoConfig::get(productFamily); NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo; - AheadOfTimeConfig aotConfig = {0}; - aotConfig.ProductConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); + auto productConfig = hwInfoConfig.getProductConfigFromHwInfo(hwInfo); - std::string requiredProductConfig = ProductConfigHelper::parseMajorMinorRevisionValue(aotConfig); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(productConfig); std::string requiredProduct = NEO::hardwarePrefix[productFamily]; std::string requiredStepping = std::to_string(programTokens.header->SteppingId); std::string requiredPointerSize = (programTokens.header->GPUPointerSizeInBytes == 4) ? "32" : "64"; @@ -591,7 +585,7 @@ TEST(UnpackSingleDeviceBinaryAr, WhenCouldNotFindBinaryWithRightPointerSizeThenU target.coreFamily = static_cast(programTokens.header->Device); target.stepping = programTokens.header->SteppingId; target.maxPointerSizeInBytes = programTokens.header->GPUPointerSizeInBytes; - target.aotConfig = aotConfig; + target.productConfig = productConfig; 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 cc0dff85e0..8c5ff86bad 100644 --- a/shared/test/unit_test/helpers/CMakeLists.txt +++ b/shared/test/unit_test/helpers/CMakeLists.txt @@ -23,7 +23,6 @@ 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 deleted file mode 100644 index 7704f4c58b..0000000000 --- a/shared/test/unit_test/helpers/product_config_helper_tests.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 e4ef5bea3a..42efbc676c 100644 --- a/shared/test/unit_test/helpers/test_hw_info_config.cpp +++ b/shared/test/unit_test/helpers/test_hw_info_config.cpp @@ -5,7 +5,6 @@ * */ -#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" @@ -48,6 +47,11 @@ 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()); @@ -84,17 +88,3 @@ 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 c15f54fdfc..fb2eae6204 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,12 +24,8 @@ PVCTEST_F(PvcUnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithPvcProductCo PatchTokensTestData::ValidEmptyProgram programTokens; PatchTokensTestData::ValidEmptyProgram programTokensWrongTokenVersion; - 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); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(PVC_XL_A0); + std::string anotherProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(PVC_XL_A0P); programTokensWrongTokenVersion.headerMutable->Version -= 1; NEO::Ar::ArEncoder encoder; @@ -45,7 +41,7 @@ PVCTEST_F(PvcUnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithPvcProductCo NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.aotConfig = aotConfig0; + target.productConfig = PVC_XL_A0; 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 d0ddf63a91..0f4239ba55 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,12 +5,9 @@ * */ -#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" @@ -65,12 +62,3 @@ 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 53a2bc9052..d1a6f892c6 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, AOT::PVC_XL_A0); + EXPECT_EQ(productConfig, PVC_XL_A0); hwInfo.platform.usRevId = 0x1; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::PVC_XL_A0P); + EXPECT_EQ(productConfig, PVC_XL_A0P); hwInfo.platform.usRevId = 0x6; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::PVC_XL_A0P); + EXPECT_EQ(productConfig, PVC_XL_A0P); } } @@ -39,19 +39,19 @@ PVCTEST_F(ProductConfigTests, givenPvcXtDeviceIdWhenDifferentRevisionIsPassedThe hwInfo.platform.usRevId = 0x3; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::PVC_XT_A0); + EXPECT_EQ(productConfig, PVC_XT_A0); hwInfo.platform.usRevId = 0x5; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::PVC_XT_B0); + EXPECT_EQ(productConfig, PVC_XT_B0); hwInfo.platform.usRevId = 0x6; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::PVC_XT_B1); + EXPECT_EQ(productConfig, PVC_XT_B1); hwInfo.platform.usRevId = 0x7; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::PVC_XT_C0); + EXPECT_EQ(productConfig, PVC_XT_C0); } } @@ -60,15 +60,15 @@ PVCTEST_F(ProductConfigTests, givenDefaultDeviceAndRevisionIdWhenGetProductConfi hwInfo.platform.usDeviceID = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::PVC_XT_C0); + EXPECT_EQ(productConfig, PVC_XT_C0); } PVCTEST_F(ProductConfigTests, givenInvalidRevisionIdWhenGetProductConfigThenUnknownIsaIsReturned) { hwInfo.platform.usRevId = 0x2; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::UNKNOWN_ISA); + EXPECT_EQ(productConfig, UNKNOWN_ISA); hwInfo.platform.usRevId = 0x4; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::UNKNOWN_ISA); -} + EXPECT_EQ(productConfig, UNKNOWN_ISA); +} \ No newline at end of file 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 611b9cf648..6e78d34b9a 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,12 +24,8 @@ DG2TEST_F(Dg2UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithDg2ProductCo PatchTokensTestData::ValidEmptyProgram programTokens; PatchTokensTestData::ValidEmptyProgram programTokensWrongTokenVersion; - 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); + std::string requiredProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(DG2_G10_A0); + std::string anotherProductConfig = NEO::ProductConfigHelper::parseMajorMinorRevisionValue(DG2_G10_B0); programTokensWrongTokenVersion.headerMutable->Version -= 1; NEO::Ar::ArEncoder encoder; @@ -45,7 +41,7 @@ DG2TEST_F(Dg2UnpackSingleDeviceBinaryAr, WhenFailedToUnpackMatchWithDg2ProductCo NEO::TargetDevice target; target.coreFamily = static_cast(programTokens.header->Device); - target.aotConfig = aotConfig0; + target.productConfig = DG2_G10_A0; 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 5593287efe..5930aa7428 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,7 +6,6 @@ */ #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" @@ -14,7 +13,6 @@ #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; @@ -411,10 +409,10 @@ DG2TEST_F(ProductConfigTests, givenDg2G11DeviceIdsWhenConfigIsCheckedThenCorrect DG2TEST_F(ProductConfigTests, givenInvalidRevisionIdWhenDeviceIdIsDefaultThenUnknownIsaIsReturned) { hwInfo.platform.usDeviceID = 0; - hwInfo.platform.usRevId = CommonConstants::invalidRevisionID; + hwInfo.platform.usRevId = 0xffff; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::UNKNOWN_ISA); + EXPECT_EQ(productConfig, UNKNOWN_ISA); } DG2TEST_F(ProductConfigTests, givenDg2G10DeviceIdWhenDifferentRevisionIsPassedThenCorrectProductConfigIsReturned) { @@ -423,30 +421,19 @@ DG2TEST_F(ProductConfigTests, givenDg2G10DeviceIdWhenDifferentRevisionIsPassedTh hwInfo.platform.usRevId = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::DG2_G10_A0); + EXPECT_EQ(productConfig, DG2_G10_A0); hwInfo.platform.usRevId = 0x1; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::DG2_G10_A1); + EXPECT_EQ(productConfig, DG2_G10_A0); hwInfo.platform.usRevId = 0x4; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::DG2_G10_B0); + EXPECT_EQ(productConfig, DG2_G10_B0); hwInfo.platform.usRevId = 0x8; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - 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); - } + EXPECT_EQ(productConfig, DG2_G10_B0); } } @@ -456,23 +443,10 @@ DG2TEST_F(ProductConfigTests, givenDg2G11DeviceIdWhenDifferentRevisionIsPassedTh hwInfo.platform.usRevId = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::DG2_G11_A0); + EXPECT_EQ(productConfig, DG2_G11); hwInfo.platform.usRevId = 0x4; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - 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); + EXPECT_EQ(productConfig, DG2_G11); } } 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 41b8131cfa..c79d19bf8c 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, givenDefaultDeviceAndRevisionIdWhenGetProductConfigThenDg2G11A0ConfigIsReturned) { +DG2TEST_F(ProductConfigTests, givenDefaultDeviceAndRevisionIdWhenGetProductConfigThenLastKnownDg2ConfigIsReturned) { hwInfo.platform.usRevId = 0x0; hwInfo.platform.usDeviceID = 0x0; productConfig = hwInfoConfig->getProductConfigFromHwInfo(hwInfo); - EXPECT_EQ(productConfig, AOT::DG2_G11_A0); + EXPECT_EQ(productConfig, DG2_G11); } \ No newline at end of file diff --git a/third_party/aot_config_headers/platforms.h b/third_party/aot_config_headers/platforms.h deleted file mode 100644 index 2d79188d3a..0000000000 --- a/third_party/aot_config_headers/platforms.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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