mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 01:48:50 +08:00
Do not flush tag update if already flushed
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
8f8370be32
commit
eb8cd33dc6
@@ -26,10 +26,12 @@ bool DeferrableAllocationDeletion::apply() {
|
|||||||
graphicsAllocation.releaseUsageInOsContext(contextId);
|
graphicsAllocation.releaseUsageInOsContext(contextId);
|
||||||
} else {
|
} else {
|
||||||
isStillUsed = true;
|
isStillUsed = true;
|
||||||
|
if (engine.commandStreamReceiver->peekLatestFlushedTaskCount() < graphicsAllocation.getTaskCount(contextId)) {
|
||||||
engine.commandStreamReceiver->updateTagFromWait();
|
engine.commandStreamReceiver->updateTagFromWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (isStillUsed) {
|
if (isStillUsed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user