Do not flush tag update if already flushed

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2022-08-08 12:20:44 +00:00
committed by Compute-Runtime-Automation
parent 8f8370be32
commit eb8cd33dc6
2 changed files with 44 additions and 1 deletions

View File

@@ -26,7 +26,9 @@ bool DeferrableAllocationDeletion::apply() {
graphicsAllocation.releaseUsageInOsContext(contextId); graphicsAllocation.releaseUsageInOsContext(contextId);
} else { } else {
isStillUsed = true; isStillUsed = true;
engine.commandStreamReceiver->updateTagFromWait(); if (engine.commandStreamReceiver->peekLatestFlushedTaskCount() < graphicsAllocation.getTaskCount(contextId)) {
engine.commandStreamReceiver->updateTagFromWait();
}
} }
} }
} }

View File

@@ -79,6 +79,47 @@ TEST_F(DeferrableAllocationDeletionTest, givenDeferrableAllocationWhenApplyThenW
EXPECT_EQ(1u, memoryManager->freeGraphicsMemoryCalled); EXPECT_EQ(1u, memoryManager->freeGraphicsMemoryCalled);
} }
HWTEST_F(DeferrableAllocationDeletionTest, givenDeferrableAllocationDeletionWhenTaskCountAlreadyFlushedThenDoNotProgrammTagUpdate) {
struct DeferrableAllocationDeletionApplyCall : public DeferrableAllocationDeletion {
using DeferrableAllocationDeletion::DeferrableAllocationDeletion;
bool apply() override {
auto ret = DeferrableAllocationDeletion::apply();
applyCalled = true;
return ret;
}
bool applyCalled = false;
};
auto &nonDefaultCommandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> &>(*device->commandStreamReceivers[1]);
auto nonDefaultOsContextId = nonDefaultCommandStreamReceiver.getOsContext().getContextId();
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{device->getRootDeviceIndex(), MemoryConstants::pageSize});
*hwTag = 0u;
*nonDefaultCommandStreamReceiver.getTagAddress() = 0u;
nonDefaultCommandStreamReceiver.setLatestFlushedTaskCount(2u);
static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver)->setLatestFlushedTaskCount(2u);
nonDefaultCommandStreamReceiver.taskCount = 2u;
static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver)->taskCount = 2u;
allocation->updateTaskCount(1u, nonDefaultOsContextId);
allocation->updateTaskCount(1u, defaultOsContextId);
auto used = nonDefaultCommandStreamReceiver.getCS(0u).getUsed();
EXPECT_FALSE(nonDefaultCommandStreamReceiver.flushBatchedSubmissionsCalled);
auto usedDefault = device->getDefaultEngine().commandStreamReceiver->getCS(0u).getUsed();
EXPECT_FALSE(static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver)->flushBatchedSubmissionsCalled);
auto deferrableAlloc = new DeferrableAllocationDeletionApplyCall(*memoryManager, *allocation);
EXPECT_FALSE(deferrableAlloc->applyCalled);
asyncDeleter->deferDeletion(deferrableAlloc);
while (!deferrableAlloc->applyCalled)
std::this_thread::yield();
*hwTag = 2u;
*nonDefaultCommandStreamReceiver.getTagAddress() = 2u;
EXPECT_FALSE(nonDefaultCommandStreamReceiver.flushBatchedSubmissionsCalled);
EXPECT_EQ(used, nonDefaultCommandStreamReceiver.getCS(0u).getUsed());
EXPECT_FALSE(static_cast<UltCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver)->flushBatchedSubmissionsCalled);
EXPECT_EQ(usedDefault, device->getDefaultEngine().commandStreamReceiver->getCS(0u).getUsed());
asyncDeleter->allowExit = true;
*hwTag = 2u;
*nonDefaultCommandStreamReceiver.getTagAddress() = 2u;
}
HWTEST_F(DeferrableAllocationDeletionTest, givenAllocationUsedByTwoOsContextsWhenApplyDeletionThenWaitForBothContextsAndFlushNotReadyCsr) { HWTEST_F(DeferrableAllocationDeletionTest, givenAllocationUsedByTwoOsContextsWhenApplyDeletionThenWaitForBothContextsAndFlushNotReadyCsr) {
auto &nonDefaultCommandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> &>(*device->commandStreamReceivers[1]); auto &nonDefaultCommandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> &>(*device->commandStreamReceivers[1]);
auto nonDefaultOsContextId = nonDefaultCommandStreamReceiver.getOsContext().getContextId(); auto nonDefaultOsContextId = nonDefaultCommandStreamReceiver.getOsContext().getContextId();