fix: allow legacy device binary validation logic for Blender on DG2 and MTL

Temporarily opt-out from additional compatibility checks
on DG2 and MTL for Blender and its derivatives AOT-compiled kernels.
This prevents a long kernel recompilation.

Additionally, same behavior can be enforced for other applications
manually via NEO debug key named DoNotUseProductConfigForValidationWa.

Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
Related-To: NEO-9240
This commit is contained in:
Kacper Nowak
2023-10-18 23:43:21 +00:00
committed by Compute-Runtime-Automation
parent ee6e6cfbab
commit 1b932bf119
15 changed files with 165 additions and 3 deletions

View File

@@ -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})

View File

@@ -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 <PRODUCT_FAMILY product>

View File

@@ -45,4 +45,9 @@ inline bool AILConfigurationHw<Product>::isContextSyncFlagRequired() {
return false;
}
template <PRODUCT_FAMILY Product>
inline bool AILConfigurationHw<Product>::useLegacyValidationLogic() {
return false;
}
} // namespace NEO

View File

@@ -30,6 +30,9 @@ const std::vector<ApplicationKernelFixDg2> applicationsKernelFixesDG2 =
{{"FAHBench-gui", "findBlocksWithInteractions", 0xa39732fc26656899, 12651u, "else { SYNC_WARPS; }"},
{"FAHBench-cmd", "findBlocksWithInteractions", 0xa39732fc26656899, 12651u, "else { SYNC_WARPS; }"}};
constexpr std::array<std::string_view, 3> applicationsLegacyValidationPathDg2 = {
"blender", "bforartists", "cycles"};
template <>
void AILConfigurationHw<IGFX_DG2>::modifyKernelIfRequired(std::string &kernelsSources) {
@@ -45,6 +48,14 @@ void AILConfigurationHw<IGFX_DG2>::modifyKernelIfRequired(std::string &kernelsSo
}
}
template <>
bool AILConfigurationHw<IGFX_DG2>::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<IGFX_DG2>;
} // namespace NEO

View File

@@ -10,6 +10,7 @@
#include "aubstream/engine_node.h"
#include <algorithm>
#include <map>
#include <vector>
@@ -19,6 +20,9 @@ extern std::map<std::string_view, std::vector<AILEnumeration>> applicationMapMTL
static EnableAIL<IGFX_METEORLAKE> enableAILMTL;
constexpr std::array<std::string_view, 3> applicationsLegacyValidationPathMtl = {
"blender", "bforartists", "cycles"};
template <>
void AILConfigurationHw<IGFX_METEORLAKE>::applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) {
auto search = applicationMapMTL.find(processName);
@@ -40,6 +44,14 @@ bool AILConfigurationHw<IGFX_METEORLAKE>::isContextSyncFlagRequired() {
return iterator != applicationsContextSyncFlag.end();
}
template <>
bool AILConfigurationHw<IGFX_METEORLAKE>::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<IGFX_METEORLAKE>;
} // namespace NEO

View File

@@ -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");

View File

@@ -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

View File

@@ -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);

View File

@@ -124,11 +124,14 @@ bool validateTargetDevice(const Elf::Elf<numBits> &elf, const TargetDevice &targ
break;
}
case Elf::IntelGTSectionType::ProductConfig: {
if (false == targetDevice.applyValidationWorkaround) {
DEBUG_BREAK_IF(sizeof(uint32_t) != intelGTNote.data.size());
auto productConfigData = reinterpret_cast<const uint32_t *>(intelGTNote.data.begin());
productConfig = static_cast<AOT::PRODUCT_CONFIG>(*productConfigData);
break;
}
break;
}
case Elf::IntelGTSectionType::vISAAbiVersion: {
break;
}

View File

@@ -26,6 +26,11 @@ class MockAILConfiguration : public AILConfiguration {
return contextSyncFlagReturn;
}
bool fallbackToLegacyValidationLogic = false;
bool useLegacyValidationLogic() override {
return fallbackToLegacyValidationLogic;
}
protected:
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override {}
};

View File

@@ -563,4 +563,5 @@ SetAmountOfReusableAllocationsPerCmdQueue = -1
ForceThreadGroupDispatchSizeAlgorithm = -1
EnableImplicitConvertionToCounterBasedEvents = -1
SetAmountOfInternalHeapsToPreallocate = -1
DoNotUseProductConfigForValidationWa = 0
# Please don't edit below this line

View File

@@ -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<MockAILConfiguration *>(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";

View File

@@ -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<NEO::Elf::ElfNoteSection> 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<uint8_t *> 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<uint8_t[]>(sectionDataSize);
appendIntelGTSectionData(elfNoteSections, noteIntelGTSectionData.get(), descData, sectionDataSize);
zebin.appendSection(NEO::Elf::SHT_NOTE, Zebin::Elf::SectionNames::noteIntelGT, ArrayRef<uint8_t>::fromAny(noteIntelGTSectionData.get(), sectionDataSize));
std::string outErrReason, outWarning;
auto elf = NEO::Elf::decodeElf<NEO::Elf::EI_CLASS_64>(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;

View File

@@ -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<productFamily> ail;
ail.processName = "unknown";
EXPECT_FALSE(ail.useLegacyValidationLogic());
std::array<std::string_view, 3> applicationNamesRequiringLegacyValidation = {
"blender", "bforartists", "cycles"};
for (auto appName : applicationNamesRequiringLegacyValidation) {
ail.processName = appName;
EXPECT_TRUE(ail.useLegacyValidationLogic());
}
}
} // namespace NEO

View File

@@ -28,4 +28,17 @@ HWTEST2_F(AILTestsMTL, givenMtlWhenSvchostAppIsDetectedThenDisableDirectSubmissi
EXPECT_FALSE(capabilityTable.directSubmissionEngines.data[aub_stream::ENGINE_CCS].engineSupported);
}
HWTEST2_F(AILTestsMTL, givenApplicationNameRequiringCrossTargetCompabilityWhenCallingUseValidationLogicThenReturnProperValue, IsMTL) {
AILWhitebox<productFamily> ail;
ail.processName = "unknown";
EXPECT_FALSE(ail.useLegacyValidationLogic());
std::array<std::string_view, 3> applicationNamesRequiringLegacyValidation = {
"blender", "bforartists", "cycles"};
for (auto appName : applicationNamesRequiringLegacyValidation) {
ail.processName = appName;
EXPECT_TRUE(ail.useLegacyValidationLogic());
}
}
} // namespace NEO