feature: support binary compatibility across multiple HW targets

- EnableCompatibilityMode flag added
- validateTergetDevice func modified to take into account the flag

Related-To: NEO-11568

Signed-off-by: Wojciech Konior <wojciech.konior@intel.com>
This commit is contained in:
Wojciech Konior
2024-11-04 15:42:09 +00:00
committed by Compute-Runtime-Automation
parent 8aa5331bc1
commit c65b45471b
4 changed files with 89 additions and 1 deletions

View File

@@ -601,6 +601,7 @@ DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingPrefetch, false, "Enables prefetchi
DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingDevMemPrefetch, false, "Enables prefetching of Device Memory chunks")
DECLARE_DEBUG_VARIABLE(bool, EnableBOChunkingPreferredLocationHint, false, "Enables preferred location advise on chunks")
DECLARE_DEBUG_VARIABLE(bool, DestroyAllocationsViaGmm, false, "Use DeAllocate2 wrapper instead of raw GDI destroy allocations")
DECLARE_DEBUG_VARIABLE(bool, EnableCompatibilityMode, true, "Enables compatibility mode for platforms which can use precompiled base platform configuration")
DECLARE_DEBUG_VARIABLE(int32_t, EnableBOChunking, -1, "Enables use of chunking of BOs in the KMD, mask: -1 = default, 0 = no chunking, 1 = shared allocations only, 2 = multi-tile device allocations only, 3 = shared and multi-tile device allocations .")
DECLARE_DEBUG_VARIABLE(int32_t, NumberOfBOChunks, 2, "Number of chunks to use")
DECLARE_DEBUG_VARIABLE(int32_t, SetBOChunkingSize, -1, "Size of chunk in bytes: -1 = default, otherwise power of two chunk size in bytes")

View File

@@ -43,13 +43,30 @@ bool isZebin(ArrayRef<const uint8_t> binary) {
fileHeader->type == Elf::ET_ZEBIN_EXE);
}
bool isTargetProductConfigCompatibleWithProductConfig(const AOT::PRODUCT_CONFIG &targetDeviceProductConfig,
const AOT::PRODUCT_CONFIG &productConfig) {
auto compatProdConfPairItr = AOT::compatibilityMapping.find(productConfig);
if (compatProdConfPairItr != AOT::compatibilityMapping.end()) {
for (auto &compatibleConfig : compatProdConfPairItr->second)
if (targetDeviceProductConfig == compatibleConfig)
return true;
}
return false;
}
bool validateTargetDevice(const TargetDevice &targetDevice, Elf::ElfIdentifierClass numBits, PRODUCT_FAMILY productFamily, GFXCORE_FAMILY gfxCore, AOT::PRODUCT_CONFIG productConfig, Elf::ZebinTargetFlags targetMetadata) {
if (targetDevice.maxPointerSizeInBytes == 4 && static_cast<uint32_t>(numBits == Elf::EI_CLASS_64)) {
return false;
}
if (productConfig != AOT::UNKNOWN_ISA) {
return targetDevice.aotConfig.value == productConfig;
auto targetDeviceProductConfig = static_cast<AOT::PRODUCT_CONFIG>(targetDevice.aotConfig.value);
if (targetDeviceProductConfig == productConfig)
return true;
else if (debugManager.flags.EnableCompatibilityMode.get() == true) {
return isTargetProductConfigCompatibleWithProductConfig(targetDeviceProductConfig, productConfig);
} else
return false;
}
if (gfxCore == IGFX_UNKNOWN_CORE && productFamily == IGFX_UNKNOWN) {

View File

@@ -542,6 +542,7 @@ EnableBOChunkingPrefetch = 0
EnableBOChunkingDevMemPrefetch = 0
EnableBOChunkingPreferredLocationHint = 0
DestroyAllocationsViaGmm = 0
EnableCompatibilityMode = 1
NumberOfBOChunks = 2
SetBOChunkingSize = -1
EnableBOChunking = -1

View File

@@ -6566,6 +6566,75 @@ TEST(ValidateTargetDeviceTests, givenSteppingBiggerThanMaxHwRevisionWhenValidati
EXPECT_FALSE(res);
}
TEST(ValidateTargetDeviceTests, givenDeviceInCompatModeWhenValidatingTargetDeviceThenUseItOnlyForValidation) {
for (auto &currentDevice : AOT::deviceAcronyms) {
TargetDevice targetDevice;
targetDevice.aotConfig.value = currentDevice.second;
targetDevice.maxPointerSizeInBytes = 8u;
Zebin::Elf::ZebinTargetFlags targetMetadata;
for (auto &deviceToCompare : AOT::deviceAcronyms) {
auto productConfigToCompare = deviceToCompare.second;
auto res = validateTargetDevice(targetDevice,
Zebin::Elf::EI_CLASS_64,
productFamily,
renderCoreFamily,
productConfigToCompare,
targetMetadata);
auto prodConfCompatPairItr = AOT::compatibilityMapping.find(productConfigToCompare);
if (targetDevice.aotConfig.value == productConfigToCompare) {
EXPECT_TRUE(res);
} else if (prodConfCompatPairItr != AOT::compatibilityMapping.end()) {
auto prodConfVec = prodConfCompatPairItr->second;
auto found = std::find(prodConfVec.begin(), prodConfVec.end(), currentDevice.second);
if (found != prodConfVec.end()) {
EXPECT_TRUE(res);
} else {
EXPECT_FALSE(res);
}
} else {
EXPECT_FALSE(res);
}
}
}
}
TEST(ValidateTargetDeviceTests, givenDeviceWithoutCompatModeWhenValidatingTargetDeviceThenUseItOnlyForValidation) {
bool compatModeInitState = debugManager.flags.EnableCompatibilityMode.get();
debugManager.flags.EnableCompatibilityMode.set(false);
for (auto &currentDevice : AOT::deviceAcronyms) {
TargetDevice targetDevice;
targetDevice.aotConfig.value = currentDevice.second;
targetDevice.maxPointerSizeInBytes = 8u;
Zebin::Elf::ZebinTargetFlags targetMetadata;
for (auto &deviceToCompare : AOT::deviceAcronyms) {
auto productConfigToCompare = deviceToCompare.second;
auto res = validateTargetDevice(targetDevice,
Zebin::Elf::EI_CLASS_64,
productFamily,
renderCoreFamily,
productConfigToCompare,
targetMetadata);
if (targetDevice.aotConfig.value == productConfigToCompare) {
EXPECT_TRUE(res);
} else {
EXPECT_FALSE(res);
}
}
}
debugManager.flags.EnableCompatibilityMode.set(compatModeInitState);
}
TEST(PopulateGlobalDeviceHostNameMapping, givenValidZebinWithGlobalHostAccessTableSectionThenPopulateHostDeviceNameMapCorrectly) {
NEO::MockExecutionEnvironment mockExecutionEnvironment{};
auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper<NEO::GfxCoreHelper>();