diff --git a/shared/offline_compiler/source/CMakeLists.txt b/shared/offline_compiler/source/CMakeLists.txt index 90aca00108..da90ae71a7 100644 --- a/shared/offline_compiler/source/CMakeLists.txt +++ b/shared/offline_compiler/source/CMakeLists.txt @@ -10,6 +10,10 @@ set(OCLOC_NAME "ocloc") set(OCLOC_FOLDER_NAME "offline_compiler") set(CLOC_LIB_SRCS_LIB + ${NEO_SHARED_DIRECTORY}/ail/ail_configuration.h + ${NEO_SHARED_DIRECTORY}/ail/ail_configuration.cpp + ${NEO_SHARED_DIRECTORY}/ail${BRANCH_DIR_SUFFIX}ail_configuration_extra.cpp + ${NEO_SHARED_DIRECTORY}/ail//ail_configuration_base.inl ${NEO_SHARED_DIRECTORY}/compiler_interface/compiler_options.cpp ${NEO_SHARED_DIRECTORY}/compiler_interface/compiler_options.h ${NEO_SHARED_DIRECTORY}/compiler_interface/compiler_options_extra.h @@ -136,6 +140,7 @@ endif() if(WIN32) list(APPEND CLOC_LIB_SRCS_LIB + ${NEO_SHARED_DIRECTORY}/ail/windows/ail_configuration_windows.cpp ${NEO_SHARED_DIRECTORY}/compiler_interface/windows/compiler_cache_windows.cpp ${NEO_SHARED_DIRECTORY}/compiler_interface/windows/os_compiler_cache_helper.cpp ${NEO_SHARED_DIRECTORY}/dll/windows/options_windows.cpp @@ -147,6 +152,7 @@ if(WIN32) ) else() list(APPEND CLOC_LIB_SRCS_LIB + ${NEO_SHARED_DIRECTORY}/ail/linux/ail_configuration_linux.cpp ${NEO_SHARED_DIRECTORY}/compiler_interface/linux/compiler_cache_linux.cpp ${NEO_SHARED_DIRECTORY}/compiler_interface/linux/os_compiler_cache_helper.cpp ${NEO_SHARED_DIRECTORY}/dll/linux/options_linux.cpp @@ -179,6 +185,7 @@ macro(macro_for_each_platform) ${NEO_SOURCE_DIR}/shared/source${BRANCH}${CORE_TYPE_LOWER}${BRANCH_DIR}hw_info_${PLATFORM_IT_LOWER}.cpp ${NEO_SOURCE_DIR}/shared/source${BRANCH}${CORE_TYPE_LOWER}${BRANCH_DIR}compiler_product_helper_${PLATFORM_IT_LOWER}.inl ${NEO_SOURCE_DIR}/shared/source${BRANCH}${CORE_TYPE_LOWER}${BRANCH_DIR}enable_compiler_product_helper_${PLATFORM_IT_LOWER}.cpp + ${NEO_SOURCE_DIR}/shared/source/ail${BRANCH_DIR}${CORE_TYPE_LOWER}${BRANCH}${PLATFORM_IT_LOWER}/ail_configuration_${PLATFORM_IT_LOWER}.cpp ) if(EXISTS ${SRC_FILE}) list(APPEND CLOC_LIB_SRCS_LIB ${SRC_FILE}) diff --git a/shared/source/ail/ail_configuration.h b/shared/source/ail/ail_configuration.h index 3877dd558d..481d6b5799 100644 --- a/shared/source/ail/ail_configuration.h +++ b/shared/source/ail/ail_configuration.h @@ -72,6 +72,8 @@ class AILConfiguration { virtual ~AILConfiguration() = default; + virtual bool useLegacyValidationLogic() = 0; + protected: virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0; std::string processName; @@ -95,6 +97,7 @@ class AILConfigurationHw : public AILConfiguration { void modifyKernelIfRequired(std::string &kernel) override; bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override; bool isContextSyncFlagRequired() override; + bool useLegacyValidationLogic() override; }; template diff --git a/shared/source/ail/ail_configuration_base.inl b/shared/source/ail/ail_configuration_base.inl index 6033b5dd98..1a06da47ca 100644 --- a/shared/source/ail/ail_configuration_base.inl +++ b/shared/source/ail/ail_configuration_base.inl @@ -45,4 +45,9 @@ inline bool AILConfigurationHw::isContextSyncFlagRequired() { return false; } +template +inline bool AILConfigurationHw::useLegacyValidationLogic() { + return false; +} + } // namespace NEO diff --git a/shared/source/ail/xe_hpg_core/dg2/ail_configuration_dg2.cpp b/shared/source/ail/xe_hpg_core/dg2/ail_configuration_dg2.cpp index e6f135b192..20707d2586 100644 --- a/shared/source/ail/xe_hpg_core/dg2/ail_configuration_dg2.cpp +++ b/shared/source/ail/xe_hpg_core/dg2/ail_configuration_dg2.cpp @@ -30,6 +30,9 @@ const std::vector applicationsKernelFixesDG2 = {{"FAHBench-gui", "findBlocksWithInteractions", 0xa39732fc26656899, 12651u, "else { SYNC_WARPS; }"}, {"FAHBench-cmd", "findBlocksWithInteractions", 0xa39732fc26656899, 12651u, "else { SYNC_WARPS; }"}}; +constexpr std::array applicationsLegacyValidationPathDg2 = { + "blender", "bforartists", "cycles"}; + template <> void AILConfigurationHw::modifyKernelIfRequired(std::string &kernelsSources) { @@ -45,6 +48,14 @@ void AILConfigurationHw::modifyKernelIfRequired(std::string &kernelsSo } } +template <> +bool AILConfigurationHw::useLegacyValidationLogic() { + auto it = std::find_if(applicationsLegacyValidationPathDg2.begin(), applicationsLegacyValidationPathDg2.end(), [this](const auto &appName) { + return this->processName == appName; + }); + return it != applicationsLegacyValidationPathDg2.end() ? true : false; +} + template class AILConfigurationHw; } // namespace NEO diff --git a/shared/source/ail/xe_hpg_core/mtl/ail_configuration_mtl.cpp b/shared/source/ail/xe_hpg_core/mtl/ail_configuration_mtl.cpp index ea013716b7..b31046f51f 100644 --- a/shared/source/ail/xe_hpg_core/mtl/ail_configuration_mtl.cpp +++ b/shared/source/ail/xe_hpg_core/mtl/ail_configuration_mtl.cpp @@ -10,6 +10,7 @@ #include "aubstream/engine_node.h" +#include #include #include @@ -19,6 +20,9 @@ extern std::map> applicationMapMTL static EnableAIL enableAILMTL; +constexpr std::array applicationsLegacyValidationPathMtl = { + "blender", "bforartists", "cycles"}; + template <> void AILConfigurationHw::applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) { auto search = applicationMapMTL.find(processName); @@ -40,6 +44,14 @@ bool AILConfigurationHw::isContextSyncFlagRequired() { return iterator != applicationsContextSyncFlag.end(); } +template <> +bool AILConfigurationHw::useLegacyValidationLogic() { + auto it = std::find_if(applicationsLegacyValidationPathMtl.begin(), applicationsLegacyValidationPathMtl.end(), [this](const auto &appName) { + return this->processName == appName; + }); + return it != applicationsLegacyValidationPathMtl.end() ? true : false; +} + template class AILConfigurationHw; } // namespace NEO diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 4ba09fe743..0e22110840 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -583,3 +583,4 @@ DECLARE_DEBUG_VARIABLE(bool, BinaryCacheTrace, false, "enable cl_cache to produc /* WORKAROUND FLAGS */ DECLARE_DEBUG_VARIABLE(int32_t, ForceDummyBlitWa, -1, "-1: default, 0: disabled, 1: enabled, Forces a workaround with dummy blits, driver adds an extra blit before command MI_ARB_CHECK on bcs") DECLARE_DEBUG_VARIABLE(bool, VfBarResourceAllocationWa, true, "Enables/disables WA for resizing VF BAR to 2GB on Warm Reset.") +DECLARE_DEBUG_VARIABLE(bool, DoNotUseProductConfigForValidationWa, false, "Forces a workaround with legacy device binary validation usage (skip checking PRODUCT_CONFIG even if passed"); diff --git a/shared/source/device_binary_format/device_binary_formats.cpp b/shared/source/device_binary_format/device_binary_formats.cpp index 0847b65371..c87d43dfbd 100644 --- a/shared/source/device_binary_format/device_binary_formats.cpp +++ b/shared/source/device_binary_format/device_binary_formats.cpp @@ -7,6 +7,8 @@ #include "shared/source/device_binary_format/device_binary_formats.h" +#include "shared/source/ail/ail_configuration.h" +#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/compiler_product_helper.h" #include "shared/source/helpers/gfx_core_helper.h" @@ -36,6 +38,12 @@ TargetDevice getTargetDevice(const RootDeviceEnvironment &rootDeviceEnvironment) targetDevice.maxPointerSizeInBytes = sizeof(uintptr_t); targetDevice.grfSize = hwInfo.capabilityTable.grfSize; targetDevice.minScratchSpaceSize = gfxCoreHelper.getMinimalScratchSpaceSize(); + + if (auto ail = rootDeviceEnvironment.getAILConfigurationHelper(); nullptr != ail) { + targetDevice.applyValidationWorkaround = ail->useLegacyValidationLogic(); + } else if (DebugManager.flags.DoNotUseProductConfigForValidationWa.get()) { + targetDevice.applyValidationWorkaround = true; + } return targetDevice; } } // namespace NEO diff --git a/shared/source/device_binary_format/device_binary_formats.h b/shared/source/device_binary_format/device_binary_formats.h index 768de62a9c..92860d00e7 100644 --- a/shared/source/device_binary_format/device_binary_formats.h +++ b/shared/source/device_binary_format/device_binary_formats.h @@ -67,6 +67,7 @@ struct TargetDevice { uint32_t maxPointerSizeInBytes = 4U; uint32_t grfSize = 32U; uint32_t minScratchSpaceSize = 0U; + bool applyValidationWorkaround = false; }; TargetDevice getTargetDevice(const RootDeviceEnvironment &rootDeviceEnvironment); diff --git a/shared/source/device_binary_format/zebin/zebin_decoder.cpp b/shared/source/device_binary_format/zebin/zebin_decoder.cpp index b347035f91..1ca0520ecb 100644 --- a/shared/source/device_binary_format/zebin/zebin_decoder.cpp +++ b/shared/source/device_binary_format/zebin/zebin_decoder.cpp @@ -124,9 +124,12 @@ bool validateTargetDevice(const Elf::Elf &elf, const TargetDevice &targ break; } case Elf::IntelGTSectionType::ProductConfig: { - DEBUG_BREAK_IF(sizeof(uint32_t) != intelGTNote.data.size()); - auto productConfigData = reinterpret_cast(intelGTNote.data.begin()); - productConfig = static_cast(*productConfigData); + if (false == targetDevice.applyValidationWorkaround) { + DEBUG_BREAK_IF(sizeof(uint32_t) != intelGTNote.data.size()); + auto productConfigData = reinterpret_cast(intelGTNote.data.begin()); + productConfig = static_cast(*productConfigData); + break; + } break; } case Elf::IntelGTSectionType::vISAAbiVersion: { diff --git a/shared/test/common/mocks/mock_ail_configuration.h b/shared/test/common/mocks/mock_ail_configuration.h index 13194341b1..257ef94949 100644 --- a/shared/test/common/mocks/mock_ail_configuration.h +++ b/shared/test/common/mocks/mock_ail_configuration.h @@ -26,6 +26,11 @@ class MockAILConfiguration : public AILConfiguration { return contextSyncFlagReturn; } + bool fallbackToLegacyValidationLogic = false; + bool useLegacyValidationLogic() override { + return fallbackToLegacyValidationLogic; + } + protected: void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override {} }; diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index b8bf8c12f9..2b028b981a 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -563,4 +563,5 @@ SetAmountOfReusableAllocationsPerCmdQueue = -1 ForceThreadGroupDispatchSizeAlgorithm = -1 EnableImplicitConvertionToCounterBasedEvents = -1 SetAmountOfInternalHeapsToPreallocate = -1 +DoNotUseProductConfigForValidationWa = 0 # Please don't edit below this line diff --git a/shared/test/unit_test/device_binary_format/device_binary_formats_tests.cpp b/shared/test/unit_test/device_binary_format/device_binary_formats_tests.cpp index 75afcade09..9c69cceb01 100644 --- a/shared/test/unit_test/device_binary_format/device_binary_formats_tests.cpp +++ b/shared/test/unit_test/device_binary_format/device_binary_formats_tests.cpp @@ -14,6 +14,8 @@ #include "shared/source/program/kernel_info.h" #include "shared/source/program/program_info.h" #include "shared/test/common/device_binary_format/patchtokens_tests.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/mocks/mock_ail_configuration.h" #include "shared/test/common/mocks/mock_execution_environment.h" #include "shared/test/common/mocks/mock_modules_zebin.h" #include "shared/test/common/test_macros/test.h" @@ -50,6 +52,34 @@ TEST(IsAnyDeviceBinaryFormat, GivenZebinFormatThenReturnsTrue) { EXPECT_TRUE(NEO::isAnyDeviceBinaryFormat(zebinProgram.storage)); } +TEST(GetTargetDeviceTests, givenAILAvailableAndUseLegacyValidationLogicReturningTrueWhenGettingTargetDeviceThenSetApplyValidationWaFlagToTrue) { + NEO::MockExecutionEnvironment executionEnvironment; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + rootDeviceEnvironment.ailConfiguration.reset(new MockAILConfiguration()); + auto mockAIL = static_cast(rootDeviceEnvironment.ailConfiguration.get()); + + auto targetDevice = getTargetDevice(rootDeviceEnvironment); + EXPECT_FALSE(targetDevice.applyValidationWorkaround); + + mockAIL->fallbackToLegacyValidationLogic = true; + targetDevice = getTargetDevice(rootDeviceEnvironment); + EXPECT_TRUE(targetDevice.applyValidationWorkaround); +} + +TEST(GetTargetDeviceTests, givenDoNotUseProductConfigForValidationWaFlagSetToTrueWhenGettingTargetDeviceThenSetApplyValidationWaFlagToTrue) { + DebugManagerStateRestore restore; + NEO::MockExecutionEnvironment executionEnvironment; + auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0]; + rootDeviceEnvironment.ailConfiguration.reset(nullptr); + + auto targetDevice = getTargetDevice(rootDeviceEnvironment); + EXPECT_FALSE(targetDevice.applyValidationWorkaround); + + NEO::DebugManager.flags.DoNotUseProductConfigForValidationWa.set(true); + targetDevice = getTargetDevice(rootDeviceEnvironment); + EXPECT_TRUE(targetDevice.applyValidationWorkaround); +} + TEST(UnpackSingleDeviceBinary, GivenUnknownBinaryThenReturnError) { const uint8_t data[] = "none of known formats"; auto requestedProductAbbreviation = "unk"; diff --git a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp index c2eb4960de..c3c6f2ded7 100644 --- a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp +++ b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp @@ -5696,6 +5696,54 @@ TEST_F(IntelGTNotesFixture, givenAotConfigInIntelGTNotesSectionWhenValidatingTar EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator)); } +TEST_F(IntelGTNotesFixture, givenRequestedTargetDeviceWithApplyValidationWorkaroundFlagSetToTrueWhenValidatingDeviceBinaryThenDoNotUseProductConfigForValidation) { + NEO::HardwareIpVersion aotConfig = {0}; + aotConfig.value = 0x00001234; + + TargetDevice targetDevice; + targetDevice.productFamily = productFamily; + targetDevice.maxPointerSizeInBytes = 8; + targetDevice.aotConfig.value = aotConfig.value + 0x10; // ensure mismatch and valiation error if AOT config is used + targetDevice.applyValidationWorkaround = true; + + std::vector elfNoteSections; + for (int i = 0; i < 2; i++) { + auto &inserted = elfNoteSections.emplace_back(); + inserted.descSize = 4u; + inserted.nameSize = 8u; + } + + // Minimum passing configuration - required i.e. proper product family passed + // Product config data should get ignored and not be used at all + elfNoteSections.at(0).type = Zebin::Elf::IntelGTSectionType::ProductFamily; + elfNoteSections.at(1).type = Zebin::Elf::IntelGTSectionType::ProductConfig; + std::vector descData; + + uint8_t productFamilyData[4]; + memcpy_s(productFamilyData, 4, &targetDevice.productFamily, 4); + descData.push_back(productFamilyData); + + uint8_t productConfigData[4]; + memcpy_s(productConfigData, 4, &targetDevice.aotConfig.value, 4); + descData.push_back(productConfigData); + + const auto sectionDataSize = std::accumulate(elfNoteSections.begin(), elfNoteSections.end(), size_t{0u}, + [](auto totalSize, const auto &elfNoteSection) { + return totalSize + sizeof(NEO::Elf::ElfNoteSection) + elfNoteSection.nameSize + elfNoteSection.descSize; + }); + auto noteIntelGTSectionData = std::make_unique(sectionDataSize); + appendIntelGTSectionData(elfNoteSections, noteIntelGTSectionData.get(), descData, sectionDataSize); + zebin.appendSection(NEO::Elf::SHT_NOTE, Zebin::Elf::SectionNames::noteIntelGT, ArrayRef::fromAny(noteIntelGTSectionData.get(), sectionDataSize)); + + std::string outErrReason, outWarning; + auto elf = NEO::Elf::decodeElf(zebin.storage, outErrReason, outWarning); + EXPECT_TRUE(outWarning.empty()); + EXPECT_TRUE(outErrReason.empty()); + + GeneratorType generator{}; + EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator)); +} + TEST(ValidateTargetDevice32BitZebin, Given32BitZebinAndValidIntelGTNotesWhenValidatingTargetDeviceThenReturnTrue) { TargetDevice targetDevice; targetDevice.productFamily = productFamily; diff --git a/shared/test/unit_test/xe_hpg_core/dg2/ail_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/ail_tests_dg2.cpp index 38885a8615..977bfb7170 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/ail_tests_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/ail_tests_dg2.cpp @@ -8,6 +8,7 @@ #include "shared/source/ail/ail_configuration.h" #include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/helpers/variable_backup.h" +#include "shared/test/common/mocks/mock_ail_configuration.h" #include "shared/test/common/test_macros/hw_test.h" namespace NEO { @@ -103,4 +104,17 @@ HWTEST2_F(AILTestsDg2, givenFixesForApplicationsWhenModifyKernelIfRequiredIsCall EXPECT_STREQ(copyKernelSources.c_str(), kernelSources.c_str()); } } + +HWTEST2_F(AILTestsDg2, givenApplicationNameRequiringCrossTargetCompabilityWhenCallingUseValidationLogicThenReturnProperValue, IsDG2) { + AILWhitebox ail; + ail.processName = "unknown"; + EXPECT_FALSE(ail.useLegacyValidationLogic()); + + std::array applicationNamesRequiringLegacyValidation = { + "blender", "bforartists", "cycles"}; + for (auto appName : applicationNamesRequiringLegacyValidation) { + ail.processName = appName; + EXPECT_TRUE(ail.useLegacyValidationLogic()); + } +} } // namespace NEO diff --git a/shared/test/unit_test/xe_hpg_core/mtl/ail_tests_mtl.cpp b/shared/test/unit_test/xe_hpg_core/mtl/ail_tests_mtl.cpp index 1ec27b5e78..1d69026635 100644 --- a/shared/test/unit_test/xe_hpg_core/mtl/ail_tests_mtl.cpp +++ b/shared/test/unit_test/xe_hpg_core/mtl/ail_tests_mtl.cpp @@ -28,4 +28,17 @@ HWTEST2_F(AILTestsMTL, givenMtlWhenSvchostAppIsDetectedThenDisableDirectSubmissi EXPECT_FALSE(capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_CCS].engineSupported); } +HWTEST2_F(AILTestsMTL, givenApplicationNameRequiringCrossTargetCompabilityWhenCallingUseValidationLogicThenReturnProperValue, IsMTL) { + AILWhitebox ail; + ail.processName = "unknown"; + EXPECT_FALSE(ail.useLegacyValidationLogic()); + + std::array applicationNamesRequiringLegacyValidation = { + "blender", "bforartists", "cycles"}; + for (auto appName : applicationNamesRequiringLegacyValidation) { + ail.processName = appName; + EXPECT_TRUE(ail.useLegacyValidationLogic()); + } +} + } // namespace NEO