Track waitlist TimestampPackets to avoid too early return to the pool

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-05-11 14:34:38 +00:00
committed by Compute-Runtime-Automation
parent 83a9037640
commit e722afbefb
5 changed files with 77 additions and 2 deletions

View File

@@ -355,6 +355,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
if (deferredTimestampPackets.get()) { if (deferredTimestampPackets.get()) {
timestampPacketDependencies.moveNodesToNewContainer(*deferredTimestampPackets); timestampPacketDependencies.moveNodesToNewContainer(*deferredTimestampPackets);
csrDeps.copyNodesToNewContainer(*deferredTimestampPackets);
} }
commandStreamReceiverOwnership.unlock(); commandStreamReceiverOwnership.unlock();
@@ -1179,6 +1180,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueBlit(const MultiDispatchInfo &multiDisp
} }
timestampPacketDependencies.moveNodesToNewContainer(*deferredTimestampPackets); timestampPacketDependencies.moveNodesToNewContainer(*deferredTimestampPackets);
csrDeps.copyNodesToNewContainer(*deferredTimestampPackets);
queueOwnership.unlock(); queueOwnership.unlock();
bcsCommandStreamReceiverOwnership.unlock(); bcsCommandStreamReceiverOwnership.unlock();

View File

@@ -1571,6 +1571,44 @@ HWTEST_TEMPLATED_F(BlitEnqueueTaskCountTests, givenMarkerThatFollowsCopyOperatio
clReleaseEvent(outEvent1); clReleaseEvent(outEvent1);
} }
HWTEST_TEMPLATED_F(BlitEnqueueTaskCountTests, givenWaitlistWithTimestampPacketWhenEnqueueingThenDeferWaitlistNodes) {
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
auto buffer = createBuffer(1, false);
auto mockCmdQueue = static_cast<MockCommandQueueHw<FamilyType> *>(commandQueue.get());
TimestampPacketContainer *deferredTimestampPackets = mockCmdQueue->deferredTimestampPackets.get();
MockTimestampPacketContainer timestamp(*device->getGpgpuCommandStreamReceiver().getTimestampPacketAllocator(), 1);
Event waitlistEvent(mockCmdQueue, 0, 0, 0);
waitlistEvent.addTimestampPacketNodes(timestamp);
cl_event waitlist[] = {&waitlistEvent};
mockCmdQueue->enqueueWriteBuffer(buffer.get(), false, 0, 1, &hostPtr, nullptr, 1, waitlist, nullptr);
auto deferredNodesCount = deferredTimestampPackets->peekNodes().size();
EXPECT_TRUE(deferredNodesCount >= 1);
bool waitlistNodeFound = false;
for (auto &node : deferredTimestampPackets->peekNodes()) {
if (node->getGpuAddress() == timestamp.peekNodes()[0]->getGpuAddress()) {
waitlistNodeFound = true;
}
}
EXPECT_TRUE(waitlistNodeFound);
mockCmdQueue->flush();
EXPECT_EQ(deferredNodesCount, deferredTimestampPackets->peekNodes().size());
mockCmdQueue->finish();
EXPECT_EQ(0u, deferredTimestampPackets->peekNodes().size());
}
HWTEST_TEMPLATED_F(BlitEnqueueTaskCountTests, givenMarkerThatFollowsCopyOperationWhenItIsWaitedItHasProperDependenciesOnWait) { HWTEST_TEMPLATED_F(BlitEnqueueTaskCountTests, givenMarkerThatFollowsCopyOperationWhenItIsWaitedItHasProperDependenciesOnWait) {
auto buffer = createBuffer(1, false); auto buffer = createBuffer(1, false);
int hostPtr = 0; int hostPtr = 0;

View File

@@ -816,6 +816,34 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
EXPECT_EQ(0u, deferredTimestampPackets->peekNodes().size()); EXPECT_EQ(0u, deferredTimestampPackets->peekNodes().size());
} }
HWTEST_F(TimestampPacketTests, givenWaitlistWithTimestampPacketWhenEnqueueingThenDeferWaitlistNodes) {
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
TimestampPacketContainer *deferredTimestampPackets = cmdQ->deferredTimestampPackets.get();
MockTimestampPacketContainer timestamp(*device->getGpgpuCommandStreamReceiver().getTimestampPacketAllocator(), 1);
Event waitlistEvent(cmdQ.get(), 0, 0, 0);
waitlistEvent.addTimestampPacketNodes(timestamp);
cl_event waitlist[] = {&waitlistEvent};
cmdQ->enqueueKernel(kernel->mockKernel, 1, nullptr, gws, nullptr, 1, waitlist, nullptr);
EXPECT_EQ(1u, deferredTimestampPackets->peekNodes().size());
EXPECT_EQ(timestamp.peekNodes()[0]->getGpuAddress(), deferredTimestampPackets->peekNodes()[0]->getGpuAddress());
cmdQ->flush();
EXPECT_EQ(1u, deferredTimestampPackets->peekNodes().size());
EXPECT_EQ(timestamp.peekNodes()[0]->getGpuAddress(), deferredTimestampPackets->peekNodes()[0]->getGpuAddress());
cmdQ->finish();
EXPECT_EQ(0u, deferredTimestampPackets->peekNodes().size());
}
HWTEST_F(TimestampPacketTests, givenTimestampWaitEnabledWhenEnqueueWithEventThenEventHasCorrectTimestampsToCheckForCompletion) { HWTEST_F(TimestampPacketTests, givenTimestampWaitEnabledWhenEnqueueWithEventThenEventHasCorrectTimestampsToCheckForCompletion) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.UpdateTaskCountFromWait.set(3); DebugManager.flags.UpdateTaskCountFromWait.set(3);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2021 Intel Corporation * Copyright (C) 2020-2022 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -16,4 +16,10 @@ void CsrDependencies::makeResident(CommandStreamReceiver &commandStreamReceiver)
timestampPacketContainer->makeResident(commandStreamReceiver); timestampPacketContainer->makeResident(commandStreamReceiver);
} }
} }
void CsrDependencies::copyNodesToNewContainer(TimestampPacketContainer &newTimestampPacketContainer) {
for (auto &timestampPacketContainer : timestampPacketContainer) {
newTimestampPacketContainer.assignAndIncrementNodesRefCounts(*timestampPacketContainer);
}
}
} // namespace NEO } // namespace NEO

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2021 Intel Corporation * Copyright (C) 2020-2022 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -25,5 +25,6 @@ class CsrDependencies {
StackVec<TimestampPacketContainer *, 32> timestampPacketContainer; StackVec<TimestampPacketContainer *, 32> timestampPacketContainer;
void makeResident(CommandStreamReceiver &commandStreamReceiver) const; void makeResident(CommandStreamReceiver &commandStreamReceiver) const;
void copyNodesToNewContainer(TimestampPacketContainer &newTimestampPacketContainer);
}; };
} // namespace NEO } // namespace NEO