Wait on timestamps in Event::wait

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2022-10-10 10:39:23 +00:00
committed by Compute-Runtime-Automation
parent 63df08664a
commit 1fedaee18c
8 changed files with 25 additions and 10 deletions

View File

@@ -1209,7 +1209,7 @@ WaitStatus CommandQueue::waitForAllEngines(bool blockedQueue, PrintfHandler *pri
}
auto waitStatus = WaitStatus::NotReady;
auto waitedOnTimestamps = waitForTimestamps(activeBcsStates, taskCount, waitStatus);
auto waitedOnTimestamps = waitForTimestamps(activeBcsStates, taskCount, waitStatus, this->timestampPacketContainer.get(), this->deferredTimestampPackets.get());
if (waitStatus == WaitStatus::GpuHang) {
return WaitStatus::GpuHang;
}

View File

@@ -204,7 +204,7 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
bool isCompleted(uint32_t gpgpuTaskCount, CopyEngineState bcsState);
bool isWaitForTimestampsEnabled() const;
virtual bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status) = 0;
virtual bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status, TimestampPacketContainer *mainContainer, TimestampPacketContainer *deferredContainer) = 0;
MOCKABLE_VIRTUAL bool isQueueBlocked();

View File

@@ -427,7 +427,7 @@ class CommandQueueHw : public CommandQueue {
bool isCacheFlushCommand(uint32_t commandType) const override;
bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status) override;
bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status, TimestampPacketContainer *mainContainer, TimestampPacketContainer *deferredContainer) override;
MOCKABLE_VIRTUAL bool isCacheFlushForBcsRequired() const;

View File

@@ -167,14 +167,14 @@ inline bool waitForTimestampsWithinContainer(TimestampPacketContainer *container
}
template <typename Family>
bool CommandQueueHw<Family>::waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status) {
bool CommandQueueHw<Family>::waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status, TimestampPacketContainer *mainContainer, TimestampPacketContainer *deferredContainer) {
using TSPacketType = typename Family::TimestampPacketType;
bool waited = false;
if (isWaitForTimestampsEnabled()) {
waited = waitForTimestampsWithinContainer<TSPacketType>(timestampPacketContainer.get(), getGpgpuCommandStreamReceiver(), status);
waited = waitForTimestampsWithinContainer<TSPacketType>(mainContainer, getGpgpuCommandStreamReceiver(), status);
if (isOOQEnabled()) {
waitForTimestampsWithinContainer<TSPacketType>(deferredTimestampPackets.get(), getGpgpuCommandStreamReceiver(), status);
waitForTimestampsWithinContainer<TSPacketType>(deferredContainer, getGpgpuCommandStreamReceiver(), status);
}
if (waited) {

View File

@@ -428,7 +428,9 @@ inline WaitStatus Event::wait(bool blocking, bool useQuickKmdSleep) {
}
Range<CopyEngineState> states{&bcsState, bcsState.isValid() ? 1u : 0u};
const auto waitStatus = cmdQueue->waitUntilComplete(taskCount.load(), states, flushStamp->peekStamp(), useQuickKmdSleep);
auto waitStatus = WaitStatus::NotReady;
auto waitedOnTimestamps = cmdQueue->waitForTimestamps(states, taskCount.load(), waitStatus, this->timestampPacketContainer.get(), nullptr);
waitStatus = cmdQueue->waitUntilComplete(taskCount.load(), states, flushStamp->peekStamp(), useQuickKmdSleep, true, waitedOnTimestamps);
if (waitStatus == WaitStatus::GpuHang) {
return WaitStatus::GpuHang;
}

View File

@@ -52,7 +52,7 @@ HWTEST_F(CommandQueueHwTest, givenNoTimestampPacketsWhenWaitForTimestampsThenNoW
auto taskCount = device->getUltCommandStreamReceiver<FamilyType>().peekLatestFlushedTaskCount();
auto status = WaitStatus::NotReady;
cmdQ.waitForTimestamps({}, 101u, status);
cmdQ.waitForTimestamps({}, 101u, status, cmdQ.timestampPacketContainer.get(), cmdQ.deferredTimestampPackets.get());
EXPECT_EQ(device->getUltCommandStreamReceiver<FamilyType>().peekLatestFlushedTaskCount(), taskCount);
}

View File

@@ -909,6 +909,16 @@ TEST_F(InternalsEventTest, givenPassingEventWhenWaitingForEventsThenWaititingIsS
EXPECT_NE(Event::executionAbortedDueToGpuHang, passingEvent.peekExecutionStatus());
}
TEST_F(InternalsEventTest, givenEventWhenWaitThenWaitForTimestampsCalled) {
MockCommandQueue cmdQ(mockContext, pClDevice, nullptr, false);
MockEvent<Event> event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
EXPECT_FALSE(cmdQ.waitForTimestampsCalled);
event.wait(false, false);
EXPECT_TRUE(cmdQ.waitForTimestampsCalled);
}
TEST_F(InternalsEventTest, GivenProfilingWHENMapOperationTHENTimesSet) {
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0};
MockCommandQueue *pCmdQ = new MockCommandQueue(mockContext, pClDevice, props, false);

View File

@@ -212,10 +212,13 @@ class MockCommandQueue : public CommandQueue {
bool obtainTimestampPacketForCacheFlush(bool isCacheFlushRequired) const override { return isCacheFlushRequired; }
bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status) override { return false; };
bool waitForTimestamps(Range<CopyEngineState> copyEnginesToWait, uint32_t taskCount, WaitStatus &status, TimestampPacketContainer *mainContainer, TimestampPacketContainer *deferredContainer) override {
waitForTimestampsCalled = true;
return false;
};
bool releaseIndirectHeapCalled = false;
bool waitForTimestampsCalled = false;
cl_int writeBufferRetValue = CL_SUCCESS;
uint32_t writeBufferCounter = 0;
bool writeBufferBlocking = false;