fix: flush L3 cache and wait for flush to complete when event is completed

Related-To: NEO-8395

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2024-01-15 15:45:45 +00:00
committed by Compute-Runtime-Automation
parent 556645e0c5
commit c49695fa6e
2 changed files with 55 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -722,8 +722,20 @@ bool Event::isCompleted() {
Range<CopyEngineState> states{&bcsState, bcsState.isValid() ? 1u : 0u};
if (cmdQueue->isCompleted(getCompletionStamp(), states) || this->areTimestampsCompleted()) {
if (cmdQueue->isCompleted(getCompletionStamp(), states)) {
gpuStateWaited = true;
} else {
if (this->areTimestampsCompleted()) {
if (cmdQueue->getGpgpuCommandStreamReceiver().getDcFlushSupport()) {
// also flush L3 and wait for cmd queue when L3 flush required
auto waitStatus = cmdQueue->waitUntilComplete(taskCount.load(), states, flushStamp->peekStamp(), false, true, false);
if (waitStatus == WaitStatus::ready) {
this->gpuStateWaited = true;
}
} else {
gpuStateWaited = true;
}
}
}
return gpuStateWaited;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -639,6 +639,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampWaitEnabledWhenEnqueueWithEventThen
csr.callBaseWaitForCompletionWithTimeout = false;
*csr.getTagAddress() = 0u;
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
cmdQ->waitUntilCompleteReturnValue = WaitStatus::ready;
cl_event clEvent1;
cl_event clEvent2;
@@ -703,6 +704,45 @@ HWTEST_F(TimestampPacketTests, givenTimestampWaitEnabledWhenEnqueueWithEventThen
*csr.getTagAddress() = csr.peekTaskCount();
}
HWTEST_F(TimestampPacketTests, givenTimestampWaitEnabledWhenWaitDoesNotReturnReadyThenEventIsReportedAsNotReady) {
DebugManagerStateRestore restorer;
debugManager.flags.UpdateTaskCountFromWait.set(3);
debugManager.flags.EnableTimestampWaitForEvents.set(1);
debugManager.flags.EnableTimestampWaitForQueues.set(1);
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
if (!csr.getDcFlushSupport()) {
GTEST_SKIP();
}
csr.timestampPacketWriteEnabled = true;
csr.callBaseWaitForCompletionWithTimeout = false;
*csr.getTagAddress() = 0u;
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
cmdQ->waitUntilCompleteReturnValue = WaitStatus::notReady;
cl_event clEvent;
TimestampPacketContainer *timestampPacketContainer = cmdQ->timestampPacketContainer.get();
cmdQ->enqueueKernel(kernel->mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, &clEvent);
cmdQ->flush();
EXPECT_EQ(1u, timestampPacketContainer->peekNodes().size());
Event &event = static_cast<Event &>(*clEvent);
EXPECT_FALSE(event.isCompleted());
typename FamilyType::TimestampPacketType timestampData[] = {2, 2, 2, 2};
for (uint32_t i = 0; i < timestampPacketContainer->peekNodes()[0]->getPacketsUsed(); i++) {
timestampPacketContainer->peekNodes()[0]->assignDataToAllTimestamps(i, timestampData);
}
EXPECT_FALSE(event.isCompleted());
cmdQ->waitUntilCompleteReturnValue = WaitStatus::ready;
EXPECT_TRUE(event.isCompleted());
clReleaseEvent(clEvent);
*csr.getTagAddress() = csr.peekTaskCount();
}
HWTEST_F(TimestampPacketTests, givenEnableTimestampWaitForQueuesWhenFinishWithoutEnqueueThenDoNotWaitOnTimestamp) {
DebugManagerStateRestore restorer;
debugManager.flags.UpdateTaskCountFromWait.set(3);