fix: improve task count handling in tbx download path

Related-To: HSD-18039789178

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2024-08-28 13:59:25 +00:00
committed by Compute-Runtime-Automation
parent 496012d82f
commit db611962f7
11 changed files with 124 additions and 32 deletions

View File

@@ -273,7 +273,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, publ
}
void setPreemptionAllocation(GraphicsAllocation *allocation) { this->preemptionAllocation = allocation; }
void downloadAllocations(bool blockingWait) override {
void downloadAllocations(bool blockingWait, TaskCountType taskCount) override {
downloadAllocationsCalledCount++;
latestDownloadAllocationsBlocking = blockingWait;
}

View File

@@ -177,7 +177,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
return commandStreamReceiverType;
}
void downloadAllocations(bool blockingWait) override {
void downloadAllocations(bool blockingWait, TaskCountType taskCount) override {
downloadAllocationsCalledCount++;
}

View File

@@ -79,6 +79,8 @@ class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
template <typename GfxFamily>
struct MockTbxCsrRegisterDownloadedAllocations : TbxCommandStreamReceiverHw<GfxFamily> {
using CommandStreamReceiver::downloadAllocationImpl;
using CommandStreamReceiver::downloadAllocations;
using CommandStreamReceiver::latestFlushedTaskCount;
using CommandStreamReceiver::tagsMultiAllocation;
using TbxCommandStreamReceiverHw<GfxFamily>::flushSubmissionsAndDownloadAllocations;

View File

@@ -489,9 +489,14 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenUpdatingTaskCountDuringWaitTh
MockTbxCsrRegisterDownloadedAllocations<FamilyType> tbxCsr{*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()};
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor(pDevice->getDeviceBitfield()));
tbxCsr.downloadAllocationImpl = nullptr;
tbxCsr.setupContext(osContext);
tbxCsr.initializeTagAllocation();
*tbxCsr.getTagAddress() = 0u;
auto tagAddress = tbxCsr.getTagAddress();
*tagAddress = 0u;
tbxCsr.latestFlushedTaskCount = 1;
MockGraphicsAllocation allocation1, allocation2, allocation3;
@@ -507,7 +512,7 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenUpdatingTaskCountDuringWaitTh
EXPECT_EQ(0u, tbxCsr.obtainUniqueOwnershipCalled);
EXPECT_EQ(3u, tbxCsr.allocationsForDownload.size());
*tbxCsr.getTagAddress() = 1u;
*tagAddress = 1u;
tbxCsr.downloadAllocations(false);
EXPECT_EQ(1u, tbxCsr.obtainUniqueOwnershipCalled);
@@ -515,6 +520,65 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenUpdatingTaskCountDuringWaitTh
EXPECT_NE(tbxCsr.allocationsForDownload.find(&allocation2), tbxCsr.allocationsForDownload.end());
}
HWTEST_F(TbxCommandSteamSimpleTest, givenAllocationWithBiggerTaskCountThanWaitingTaskCountThenDontRemoveFromContainer) {
MockTbxCsrRegisterDownloadedAllocations<FamilyType> tbxCsr{*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()};
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor(pDevice->getDeviceBitfield()));
tbxCsr.setupContext(osContext);
tbxCsr.initializeTagAllocation();
*tbxCsr.getTagAddress() = 0u;
tbxCsr.latestFlushedTaskCount = 1;
MockGraphicsAllocation allocation1, allocation2, allocation3;
tbxCsr.allocationsForDownload = {&allocation1, &allocation2, &allocation3};
tbxCsr.makeResident(allocation1);
tbxCsr.makeResident(allocation2);
tbxCsr.makeResident(allocation3);
auto contextId = tbxCsr.getOsContext().getContextId();
allocation1.updateTaskCount(2, contextId);
allocation2.updateTaskCount(1, contextId);
allocation3.updateTaskCount(2, contextId);
*tbxCsr.getTagAddress() = 1u;
tbxCsr.downloadAllocations(false, 1);
EXPECT_EQ(1u, tbxCsr.obtainUniqueOwnershipCalled);
EXPECT_EQ(2u, tbxCsr.allocationsForDownload.size());
EXPECT_NE(tbxCsr.allocationsForDownload.find(&allocation1), tbxCsr.allocationsForDownload.end());
EXPECT_NE(tbxCsr.allocationsForDownload.find(&allocation3), tbxCsr.allocationsForDownload.end());
}
HWTEST_F(TbxCommandSteamSimpleTest, givenDifferentTaskCountThanLatestFlushedWhenDownloadingThenPickSmallest) {
MockTbxCsrRegisterDownloadedAllocations<FamilyType> tbxCsr{*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()};
MockOsContext osContext(0, EngineDescriptorHelper::getDefaultDescriptor(pDevice->getDeviceBitfield()));
tbxCsr.downloadAllocationImpl = nullptr;
tbxCsr.setupContext(osContext);
tbxCsr.initializeTagAllocation();
*tbxCsr.getTagAddress() = 0;
tbxCsr.latestFlushedTaskCount = 1;
tbxCsr.downloadAllocations(false, 2);
EXPECT_EQ(0u, tbxCsr.obtainUniqueOwnershipCalled);
*tbxCsr.getTagAddress() = 1;
tbxCsr.downloadAllocations(false, 2);
EXPECT_EQ(1u, tbxCsr.obtainUniqueOwnershipCalled);
tbxCsr.latestFlushedTaskCount = 3;
tbxCsr.downloadAllocations(false, 2);
EXPECT_EQ(1u, tbxCsr.obtainUniqueOwnershipCalled);
*tbxCsr.getTagAddress() = 3;
tbxCsr.downloadAllocations(false, 2);
EXPECT_EQ(2u, tbxCsr.obtainUniqueOwnershipCalled);
}
HWTEST_F(TbxCommandSteamSimpleTest, whenTbxCommandStreamReceiverIsCreatedThenPPGTTAndGGTTCreatedHavePhysicalAddressAllocatorSet) {
MockTbxCsr<FamilyType> tbxCsr(*pDevice->executionEnvironment, pDevice->getDeviceBitfield());