Flush printf buffer for immediate command lists.

Do this for asynchronous command lists as well.
Clean container after print.

Related-To: NEO-7653

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2023-01-26 16:27:34 +00:00
committed by Compute-Runtime-Automation
parent b7380237c2
commit 2ebcb5dc0a
2 changed files with 33 additions and 9 deletions

View File

@@ -236,7 +236,7 @@ inline ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommand
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
}
if (this->isSyncModeQueue) {
if (this->isSyncModeQueue || this->printfKernelContainer.size() > 0u) {
auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout;
const auto waitStatus = csr->waitForCompletionWithTimeout(NEO::WaitParams{false, false, timeoutMicroseconds}, completionStamp.taskCount);
if (waitStatus == NEO::WaitStatus::GpuHang) {
@@ -816,6 +816,7 @@ void CommandListCoreFamilyImmediate<gfxCoreFamily>::printKernelsPrintfOutput(boo
for (size_t i = 0; i < size; i++) {
this->printfKernelContainer[i]->printPrintfOutput(hangDetected);
}
this->printfKernelContainer.clear();
}
} // namespace L0

View File

@@ -227,7 +227,7 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfWhenAppendedToSynch
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &queueDesc, false, NEO::EngineGroupType::RenderCompute, returnValue));
commandList->isFlushTaskSubmissionEnabled = true;
Mock<Kernel> kernel;
commandList->getPrintfKernelContainer().push_back(&kernel);
kernel.descriptor.kernelAttributes.flags.usesPrintf = true;
ze_group_count_t groupCount{1, 1, 1};
CmdListKernelLaunchParams launchParams = {};
@@ -235,14 +235,38 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfWhenAppendedToSynch
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(1u, kernel.printPrintfOutputCalledTimes);
EXPECT_FALSE(kernel.hangDetectedPassedToPrintfOutput);
EXPECT_EQ(1u, commandList->getPrintfKernelContainer().size());
EXPECT_EQ(&kernel, commandList->getPrintfKernelContainer()[0]);
EXPECT_EQ(0u, commandList->getPrintfKernelContainer().size());
result = commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(2u, kernel.printPrintfOutputCalledTimes);
EXPECT_FALSE(kernel.hangDetectedPassedToPrintfOutput);
EXPECT_EQ(1u, commandList->getPrintfKernelContainer().size());
EXPECT_EQ(0u, commandList->getPrintfKernelContainer().size());
}
HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfWhenAppendedToAsynchronousImmCommandListThenPrintfBufferIsPrinted) {
ze_result_t returnValue;
ze_command_queue_desc_t queueDesc = {};
queueDesc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &queueDesc, false, NEO::EngineGroupType::RenderCompute, returnValue));
commandList->isFlushTaskSubmissionEnabled = true;
Mock<Kernel> kernel;
kernel.descriptor.kernelAttributes.flags.usesPrintf = true;
ze_group_count_t groupCount{1, 1, 1};
CmdListKernelLaunchParams launchParams = {};
auto result = commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(1u, kernel.printPrintfOutputCalledTimes);
EXPECT_FALSE(kernel.hangDetectedPassedToPrintfOutput);
EXPECT_EQ(0u, commandList->getPrintfKernelContainer().size());
result = commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_EQ(2u, kernel.printPrintfOutputCalledTimes);
EXPECT_FALSE(kernel.hangDetectedPassedToPrintfOutput);
EXPECT_EQ(0u, commandList->getPrintfKernelContainer().size());
}
HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfWhenAppendToSynchronousImmCommandListHangsThenPrintfBufferIsPrinted) {
@@ -258,7 +282,7 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfWhenAppendToSynchro
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(productFamily, device, &queueDesc, false, NEO::EngineGroupType::RenderCompute, returnValue));
commandList->isFlushTaskSubmissionEnabled = true;
Mock<Kernel> kernel;
commandList->getPrintfKernelContainer().push_back(&kernel);
kernel.descriptor.kernelAttributes.flags.usesPrintf = true;
ze_group_count_t groupCount{1, 1, 1};
CmdListKernelLaunchParams launchParams = {};
@@ -266,14 +290,13 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfWhenAppendToSynchro
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
EXPECT_EQ(1u, kernel.printPrintfOutputCalledTimes);
EXPECT_TRUE(kernel.hangDetectedPassedToPrintfOutput);
EXPECT_EQ(1u, commandList->getPrintfKernelContainer().size());
EXPECT_EQ(&kernel, commandList->getPrintfKernelContainer()[0]);
EXPECT_EQ(0u, commandList->getPrintfKernelContainer().size());
result = commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_ERROR_DEVICE_LOST, result);
EXPECT_EQ(2u, kernel.printPrintfOutputCalledTimes);
EXPECT_TRUE(kernel.hangDetectedPassedToPrintfOutput);
EXPECT_EQ(1u, commandList->getPrintfKernelContainer().size());
EXPECT_EQ(0u, commandList->getPrintfKernelContainer().size());
}
HWTEST_F(CommandListAppendLaunchKernel, WhenAppendingMultipleTimesThenSshIsNotDepletedButReallocated) {