Download tag allocation only if was submitted

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2022-04-12 16:07:22 +00:00
committed by Compute-Runtime-Automation
parent 352583b9d9
commit b67b1bd6fc
3 changed files with 32 additions and 5 deletions

View File

@@ -169,7 +169,7 @@ void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gf
WaitStatus CommandStreamReceiver::waitForTaskCount(uint32_t requiredTaskCount) {
auto address = getTagAddress();
if (address) {
this->downloadTagAllocation();
this->downloadTagAllocation(requiredTaskCount);
return baseWaitFunction(address, WaitParams{false, false, 0}, requiredTaskCount);
}
@@ -812,14 +812,16 @@ bool CommandStreamReceiver::checkImplicitFlushForGpuIdle() {
return false;
}
void CommandStreamReceiver::downloadTagAllocation() {
void CommandStreamReceiver::downloadTagAllocation(uint32_t taskCountToWait) {
if (this->getTagAllocation()) {
this->downloadAllocation(*this->getTagAllocation());
if (taskCountToWait && taskCountToWait <= this->peekLatestFlushedTaskCount()) {
this->downloadAllocation(*this->getTagAllocation());
}
}
}
bool CommandStreamReceiver::testTaskCountReady(volatile uint32_t *pollAddress, uint32_t taskCountToWait) {
this->downloadTagAllocation();
this->downloadTagAllocation(taskCountToWait);
for (uint32_t i = 0; i < activePartitions; i++) {
if (!WaitUtils::waitFunction(pollAddress, taskCountToWait)) {
return false;

View File

@@ -333,7 +333,7 @@ class CommandStreamReceiver {
void printDeviceIndex();
void checkForNewResources(uint32_t submittedTaskCount, uint32_t allocationTaskCount, GraphicsAllocation &gfxAllocation);
bool checkImplicitFlushForGpuIdle();
void downloadTagAllocation();
void downloadTagAllocation(uint32_t taskCountToWait);
MOCKABLE_VIRTUAL std::unique_lock<MutexType> obtainHostPtrSurfaceCreationLock();
std::unique_ptr<FlushStampTracker> flushStamp;

View File

@@ -308,6 +308,31 @@ HWTEST_F(CommandStreamReceiverTest, givenGpuHangWhenWaititingForTaskCountThenGpu
constexpr auto taskCountToWait = 1;
const auto waitStatus = csr.waitForTaskCount(taskCountToWait);
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
EXPECT_FALSE(csr.downloadAllocationCalled);
}
HWTEST_F(CommandStreamReceiverTest, whenDownloadTagAllocationThenDonwloadOnlyIfTagAllocationWasFlushed) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
csr.activePartitions = 1;
*csr.tagAddress = 1u;
auto ret = csr.testTaskCountReady(csr.tagAddress, 0u);
EXPECT_TRUE(ret);
EXPECT_FALSE(csr.downloadAllocationCalled);
constexpr auto taskCountToWait = 1;
ret = csr.testTaskCountReady(csr.tagAddress, taskCountToWait);
EXPECT_TRUE(ret);
EXPECT_FALSE(csr.downloadAllocationCalled);
csr.getTagAllocation()->updateTaskCount(taskCountToWait, csr.osContext->getContextId());
ret = csr.testTaskCountReady(csr.tagAddress, taskCountToWait);
EXPECT_TRUE(ret);
EXPECT_FALSE(csr.downloadAllocationCalled);
csr.setLatestFlushedTaskCount(taskCountToWait);
ret = csr.testTaskCountReady(csr.tagAddress, taskCountToWait);
EXPECT_TRUE(ret);
EXPECT_TRUE(csr.downloadAllocationCalled);
}