performance: Store pattern allocations on reset and sync

Related-To: NEO-9729

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2025-06-26 12:10:18 +00:00
committed by Compute-Runtime-Automation
parent 100bec3fa8
commit 198762baa8
4 changed files with 51 additions and 0 deletions

View File

@@ -112,6 +112,11 @@ void CommandListCoreFamily<gfxCoreFamily>::postInitComputeSetup() {
template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamily<gfxCoreFamily>::reset() {
for (auto &patternAlloc : this->patternAllocations) {
device->storeReusableAllocation(*patternAlloc);
}
this->patternAllocations.clear();
removeDeallocationContainerData();
removeHostPtrAllocations();
removeMemoryPrefetchAllocations();

View File

@@ -57,6 +57,7 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFami
using BaseClass::isInOrderExecutionEnabled;
using BaseClass::isSkippingInOrderBarrierAllowed;
using BaseClass::isTbxMode;
using BaseClass::patternAllocations;
using ComputeFlushMethodType = NEO::CompletionStamp (CommandListCoreFamilyImmediate<gfxCoreFamily>::*)(NEO::LinearStream &, size_t, bool, bool, NEO::AppendOperations, bool);

View File

@@ -1197,6 +1197,11 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::hostSynchronize(uint6
if (inOrderExecInfo) {
inOrderExecInfo->releaseNotUsedTempTimestampNodes(false);
}
for (auto &patternAlloc : this->patternAllocations) {
this->device->storeReusableAllocation(*patternAlloc);
}
this->patternAllocations.clear();
}
bool hangDetected = status == ZE_RESULT_ERROR_DEVICE_LOST;

View File

@@ -1864,6 +1864,46 @@ HWTEST2_F(InOrderRegularCmdListTests, givenInOrderModeWhenDispatchingRegularCmdL
EXPECT_FALSE(regularCmdList->latestOperationRequiredNonWalkerInOrderCmdsChaining);
}
HWTEST2_F(InOrderRegularCmdListTests, givenAppendMemoryFillWhenHostSynchronizeThenStoreFillAllocationsInReusableContainer, IsAtLeastXeCore) {
auto immCmdList = createImmCmdList<FamilyType::gfxCoreFamily>();
EXPECT_EQ(immCmdList->patternAllocations.size(), 0u);
EXPECT_TRUE(static_cast<DeviceImp *>(immCmdList->device)->allocationsForReuse->peekIsEmpty());
constexpr size_t size = 128 * sizeof(uint32_t);
auto data = allocDeviceMem(size);
uint64_t pattern = 0u;
immCmdList->appendMemoryFill(data, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, copyParams);
EXPECT_EQ(immCmdList->patternAllocations.size(), 1u);
EXPECT_TRUE(static_cast<DeviceImp *>(immCmdList->device)->allocationsForReuse->peekIsEmpty());
immCmdList->hostSynchronize(std::numeric_limits<uint64_t>::max());
EXPECT_EQ(immCmdList->patternAllocations.size(), 0u);
EXPECT_FALSE(static_cast<DeviceImp *>(immCmdList->device)->allocationsForReuse->peekIsEmpty());
context->freeMem(data);
}
HWTEST2_F(InOrderRegularCmdListTests, givenAppendMemoryFillWhenResetThenStoreFillAllocationsInReusableContainer, IsAtLeastXeCore) {
auto regularCmdList = createRegularCmdList<FamilyType::gfxCoreFamily>(false);
EXPECT_EQ(regularCmdList->patternAllocations.size(), 0u);
EXPECT_TRUE(static_cast<DeviceImp *>(regularCmdList->device)->allocationsForReuse->peekIsEmpty());
constexpr size_t size = 128 * sizeof(uint32_t);
auto data = allocDeviceMem(size);
uint64_t pattern = 0u;
regularCmdList->appendMemoryFill(data, &pattern, sizeof(pattern), size, nullptr, 0, nullptr, copyParams);
EXPECT_EQ(regularCmdList->patternAllocations.size(), 1u);
EXPECT_TRUE(static_cast<DeviceImp *>(regularCmdList->device)->allocationsForReuse->peekIsEmpty());
regularCmdList->reset();
EXPECT_EQ(regularCmdList->patternAllocations.size(), 0u);
EXPECT_FALSE(static_cast<DeviceImp *>(regularCmdList->device)->allocationsForReuse->peekIsEmpty());
context->freeMem(data);
}
HWTEST2_F(InOrderRegularCmdListTests, givenInOrderModeWhenDispatchingRegularCmdListThenUpdateCounterAllocation, IsAtLeastXeCore) {
using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM;