Skip to content

Commit b67b1bd

Browse files
Download tag allocation only if was submitted
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
1 parent 352583b commit b67b1bd

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

shared/source/command_stream/command_stream_receiver.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gf
169169
WaitStatus CommandStreamReceiver::waitForTaskCount(uint32_t requiredTaskCount) {
170170
auto address = getTagAddress();
171171
if (address) {
172-
this->downloadTagAllocation();
172+
this->downloadTagAllocation(requiredTaskCount);
173173
return baseWaitFunction(address, WaitParams{false, false, 0}, requiredTaskCount);
174174
}
175175

@@ -812,14 +812,16 @@ bool CommandStreamReceiver::checkImplicitFlushForGpuIdle() {
812812
return false;
813813
}
814814

815-
void CommandStreamReceiver::downloadTagAllocation() {
815+
void CommandStreamReceiver::downloadTagAllocation(uint32_t taskCountToWait) {
816816
if (this->getTagAllocation()) {
817-
this->downloadAllocation(*this->getTagAllocation());
817+
if (taskCountToWait && taskCountToWait <= this->peekLatestFlushedTaskCount()) {
818+
this->downloadAllocation(*this->getTagAllocation());
819+
}
818820
}
819821
}
820822

821823
bool CommandStreamReceiver::testTaskCountReady(volatile uint32_t *pollAddress, uint32_t taskCountToWait) {
822-
this->downloadTagAllocation();
824+
this->downloadTagAllocation(taskCountToWait);
823825
for (uint32_t i = 0; i < activePartitions; i++) {
824826
if (!WaitUtils::waitFunction(pollAddress, taskCountToWait)) {
825827
return false;

shared/source/command_stream/command_stream_receiver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class CommandStreamReceiver {
333333
void printDeviceIndex();
334334
void checkForNewResources(uint32_t submittedTaskCount, uint32_t allocationTaskCount, GraphicsAllocation &gfxAllocation);
335335
bool checkImplicitFlushForGpuIdle();
336-
void downloadTagAllocation();
336+
void downloadTagAllocation(uint32_t taskCountToWait);
337337
MOCKABLE_VIRTUAL std::unique_lock<MutexType> obtainHostPtrSurfaceCreationLock();
338338

339339
std::unique_ptr<FlushStampTracker> flushStamp;

shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,31 @@ HWTEST_F(CommandStreamReceiverTest, givenGpuHangWhenWaititingForTaskCountThenGpu
308308
constexpr auto taskCountToWait = 1;
309309
const auto waitStatus = csr.waitForTaskCount(taskCountToWait);
310310
EXPECT_EQ(WaitStatus::GpuHang, waitStatus);
311+
EXPECT_FALSE(csr.downloadAllocationCalled);
312+
}
313+
314+
HWTEST_F(CommandStreamReceiverTest, whenDownloadTagAllocationThenDonwloadOnlyIfTagAllocationWasFlushed) {
315+
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
316+
csr.activePartitions = 1;
317+
*csr.tagAddress = 1u;
318+
319+
auto ret = csr.testTaskCountReady(csr.tagAddress, 0u);
320+
EXPECT_TRUE(ret);
321+
EXPECT_FALSE(csr.downloadAllocationCalled);
322+
323+
constexpr auto taskCountToWait = 1;
324+
ret = csr.testTaskCountReady(csr.tagAddress, taskCountToWait);
325+
EXPECT_TRUE(ret);
326+
EXPECT_FALSE(csr.downloadAllocationCalled);
327+
328+
csr.getTagAllocation()->updateTaskCount(taskCountToWait, csr.osContext->getContextId());
329+
ret = csr.testTaskCountReady(csr.tagAddress, taskCountToWait);
330+
EXPECT_TRUE(ret);
331+
EXPECT_FALSE(csr.downloadAllocationCalled);
332+
333+
csr.setLatestFlushedTaskCount(taskCountToWait);
334+
ret = csr.testTaskCountReady(csr.tagAddress, taskCountToWait);
335+
EXPECT_TRUE(ret);
311336
EXPECT_TRUE(csr.downloadAllocationCalled);
312337
}
313338

0 commit comments

Comments
 (0)