fix: Set init zero flag for preemption buffer

Related-To: HSD-16028003349
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-10-08 12:28:37 +00:00
committed by Compute-Runtime-Automation
parent 6d6715bebf
commit 298fcb868b
7 changed files with 38 additions and 0 deletions

View File

@@ -654,6 +654,7 @@ DECLARE_DEBUG_VARIABLE(int64_t, ForceNonSystemMemoryPlacement, 0, "0: default,
DECLARE_DEBUG_VARIABLE(int64_t, ForceUncachedGmmUsageType, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force uncached gmm resource type")
DECLARE_DEBUG_VARIABLE(int64_t, ForceMultiTileAllocPlacement, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force allocation to be replicated across all tiles")
DECLARE_DEBUG_VARIABLE(int64_t, ForceSingleTileAllocPlacement, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force allocation to NOT be replicated")
DECLARE_DEBUG_VARIABLE(int64_t, InitAllocWithZeros, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, set zero init flag to GMM")
DECLARE_DEBUG_VARIABLE(int64_t, DisableIndirectAccess, -1, "0: default, 0: Use indirect access settings provided by application, 1: Disable indirect access and ignore settings provided by application")
DECLARE_DEBUG_VARIABLE(int32_t, UseVmBind, -1, "Use new residency model on Linux (requires kernel support), -1: default, 0: disabled, 1: enabled")
DECLARE_DEBUG_VARIABLE(int32_t, EnableStaticPartitioning, -1, "Divide workload into partitions during dispatch, -1: default, 0: disabled, 1: enabled")

View File

@@ -10,6 +10,7 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/app_resource_helper.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/bit_helpers.h"
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/local_memory_usage.h"
@@ -144,6 +145,17 @@ StorageInfo MemoryManager::createStorageInfoFromProperties(const AllocationPrope
rootDeviceEnv->getReleaseHelper(),
properties.flags.preferCompressed);
storageInfo.needsToBeZeroedAtInit = [](NEO::AllocationType allocType) {
auto out = GraphicsAllocation::isZeroInitRequired(allocType);
auto initWithZerosMask = debugManager.flags.InitAllocWithZeros.get();
if (initWithZerosMask) {
out = isBitSet(initWithZerosMask, static_cast<uint64_t>(allocType) - 1);
}
return out;
}(properties.allocationType);
if (debugManager.flags.ForceMultiTileAllocPlacement.get()) {
UNRECOVERABLE_IF(properties.allocationType == AllocationType::unknown);
if ((1llu << (static_cast<int64_t>(properties.allocationType) - 1)) & debugManager.flags.ForceMultiTileAllocPlacement.get()) {

View File

@@ -36,5 +36,6 @@ struct StorageInfo {
bool systemMemoryForced = false;
char resourceTag[AppResourceDefines::maxStrLen + 1] = "";
bool isChunked = false;
bool needsToBeZeroedAtInit = false;
};
} // namespace NEO

View File

@@ -269,6 +269,9 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation>, NEO::NonCopyableAn
allocationType == AllocationType::ringBuffer ||
allocationType == AllocationType::semaphoreBuffer;
}
static bool isZeroInitRequired(AllocationType allocationType) {
return allocationType == AllocationType::preemption;
}
static uint32_t getNumHandlesForKmdSharedAllocation(uint32_t numBanks);

View File

@@ -309,6 +309,7 @@ DisablePipeControlPrecedingPostSyncCommand = -1
OverrideMultiStoragePlacement = -1
ForceMultiTileAllocPlacement = 0
ForceSingleTileAllocPlacement = 0
InitAllocWithZeros = 0
FormatForStatelessCompressionWithUnifiedMemory = 0xF
BcsCompressionFormatForXe2Plus = -1
ForceBufferCompressionFormat = -1

View File

@@ -537,3 +537,12 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationsWhenAllocationTypeIsRingBuf
graphicsAllocation.allocationType = AllocationType::ringBuffer;
EXPECT_TRUE(graphicsAllocation.hasAllocationReadOnlyType());
}
TEST(GraphicsAllocationTest, givenOtherThanPreemptionAllocationTypeWhenIsZeroInitRequiredIsCalledThenFalseReturned) {
for (std::underlying_type_t<AllocationType> allocType = 0; allocType < static_cast<std::underlying_type_t<AllocationType>>(AllocationType::count); allocType++) {
if (static_cast<AllocationType>(allocType) == AllocationType::preemption) {
EXPECT_TRUE(GraphicsAllocation::isZeroInitRequired(static_cast<AllocationType>(allocType)));
} else {
EXPECT_FALSE(GraphicsAllocation::isZeroInitRequired(static_cast<AllocationType>(allocType)));
}
}
}

View File

@@ -110,6 +110,17 @@ TEST_F(MultiDeviceStorageInfoTest, givenEnabledFlagForForceSingleTileAllocPlacem
}
}
TEST_F(MultiDeviceStorageInfoTest, givenEnabledFlagForInitAllocWithZerosWhenCreatingStorageInfoForAllocationThenZeroedNeededIsSet) {
DebugManagerStateRestore restorer;
for (std::underlying_type_t<AllocationType> allocType = 1; allocType < static_cast<std::underlying_type_t<AllocationType>>(AllocationType::count); allocType++) {
debugManager.flags.InitAllocWithZeros.set(1ull << (allocType - 1));
AllocationProperties properties{mockRootDeviceIndex, false, 0u, static_cast<AllocationType>(allocType), false, false, singleTileMask};
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
EXPECT_TRUE(storageInfo.needsToBeZeroedAtInit);
}
}
TEST_F(MultiDeviceStorageInfoTest, whenCreatingStorageInfoForPrivateSurfaceWithOneTileThenOnlySingleBankIsUsed) {
AllocationProperties properties{mockRootDeviceIndex, false, 0u, AllocationType::privateSurface, false, false, singleTileMask};
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);