fix: check for new submission before releasing TSP nodes in wait call.

Related-To: NEO-8318

Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2023-08-31 10:42:16 +00:00
committed by Compute-Runtime-Automation
parent 5833d65bc0
commit f1fc273cfc
3 changed files with 54 additions and 4 deletions

View File

@@ -1291,9 +1291,13 @@ WaitStatus CommandQueue::waitForAllEngines(bool blockedQueue, PrintfHandler *pri
}
}
waitStatus = waitUntilComplete(taskCount, activeBcsStates, flushStamp->peekStamp(), false, cleanTemporaryAllocationsList, waitedOnTimestamps);
auto taskCountToWait = taskCount;
handlePostCompletionOperations(false);
waitStatus = waitUntilComplete(taskCountToWait, activeBcsStates, flushStamp->peekStamp(), false, cleanTemporaryAllocationsList, waitedOnTimestamps);
TakeOwnershipWrapper<CommandQueue> queueOwnership(*this);
handlePostCompletionOperations(this->taskCount != taskCountToWait);
if (printfHandler) {
if (!printfHandler->printEnqueueOutput()) {
@@ -1382,8 +1386,6 @@ bool CommandQueue::migrateMultiGraphicsAllocationsIfRequired(const BuiltinOpPara
}
void CommandQueue::handlePostCompletionOperations(bool checkQueueCompletion) {
TakeOwnershipWrapper<CommandQueue> queueOwnership(*this);
if (checkQueueCompletion && !isCompleted(this->taskCount, this->bcsStates)) {
return;
}

View File

@@ -454,6 +454,8 @@ inline WaitStatus Event::wait(bool blocking, bool useQuickKmdSleep) {
DEBUG_BREAK_IF(this->taskLevel == CompletionStamp::notReady && this->executionStatus >= 0);
TakeOwnershipWrapper<CommandQueue> queueOwnership(*cmdQueue);
bool checkQueueCompletionForPostSyncOperations = !(waitedOnTimestamps && !cmdQueue->isOOQEnabled() &&
(this->timestampPacketContainer->peekNodes() == cmdQueue->getTimestampPacketContainer()->peekNodes()));

View File

@@ -878,6 +878,52 @@ HWTEST_F(TimestampPacketTests, givenAllEnginesReadyWhenWaitingForEventThenClearD
cmdQ.reset();
}
HWTEST_F(TimestampPacketTests, givenNewSubmissionWhileWaitingThenDontReleaseDeferredNodes) {
class MyMockCmdQ : public MockCommandQueueHw<FamilyType> {
public:
using MockCommandQueueHw<FamilyType>::MockCommandQueueHw;
WaitStatus waitUntilComplete(TaskCountType gpgpuTaskCountToWait, Range<CopyEngineState> copyEnginesToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool cleanTemporaryAllocationList, bool skipWait) override {
this->taskCount++;
return MockCommandQueueHw<FamilyType>::waitUntilComplete(gpgpuTaskCountToWait, copyEnginesToWait, flushStampToWait, useQuickKmdSleep, cleanTemporaryAllocationList, skipWait);
}
};
DebugManagerStateRestore restorer;
DebugManager.flags.UpdateTaskCountFromWait.set(3);
DebugManager.flags.EnableTimestampWaitForQueues.set(0);
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketWriteEnabled = true;
csr.callBaseWaitForCompletionWithTimeout = false;
auto cmdQ = std::make_unique<MyMockCmdQ>(context, device.get(), nullptr);
TimestampPacketContainer *deferredTimestampPackets = cmdQ->deferredTimestampPackets.get();
TimestampPacketContainer *timestampPacketContainer = cmdQ->timestampPacketContainer.get();
cmdQ->enqueueKernel(kernel->mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
cmdQ->enqueueKernel(kernel->mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);
cmdQ->flush();
EXPECT_EQ(2u, csr.taskCount);
EXPECT_EQ(2u, cmdQ->taskCount);
auto tagAddress = csr.getTagAddress();
*tagAddress = 2;
cmdQ->finish();
EXPECT_EQ(1u, deferredTimestampPackets->peekNodes().size());
EXPECT_EQ(1u, timestampPacketContainer->peekNodes().size());
*tagAddress = 3;
cmdQ.reset();
}
namespace CpuIntrinsicsTests {
extern std::atomic<uint32_t> pauseCounter;
extern volatile TagAddressType *pauseAddress;