mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
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:
committed by
Compute-Runtime-Automation
parent
496012d82f
commit
db611962f7
@@ -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;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
|
||||
return commandStreamReceiverType;
|
||||
}
|
||||
|
||||
void downloadAllocations(bool blockingWait) override {
|
||||
void downloadAllocations(bool blockingWait, TaskCountType taskCount) override {
|
||||
downloadAllocationsCalledCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user