Flush print buffer when destroying the command queue

This ensures all pending prints are flushed, in the case
for instance zeCommandQueueSynchronize() is not called.

Change-Id: I4b50c535e4681eff4708242febc948c21c715055
Signed-off: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2020-04-09 23:20:12 -07:00
committed by sys_ocldev
parent 87dccc2c07
commit 04bb54d1ac
4 changed files with 26 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::createFence(const ze_fence_desc_t *de
template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandQueueHw<gfxCoreFamily>::destroy() {
this->printFunctionsPrintfOutput();
delete commandStream;
buffers.destroy(this->getDevice()->getNEODevice()->getMemoryManager());
delete this;

View File

@@ -58,6 +58,7 @@ template <GFXCORE_FAMILY gfxCoreFamily>
struct MockCommandQueueHw : public L0::CommandQueueHw<gfxCoreFamily> {
using BaseClass = ::L0::CommandQueueHw<gfxCoreFamily>;
using BaseClass::commandStream;
using BaseClass::printfFunctionContainer;
MockCommandQueueHw(L0::Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) : L0::CommandQueueHw<gfxCoreFamily>(device, csr, desc) {
}

View File

@@ -86,8 +86,13 @@ struct Mock<::L0::Kernel> : public ::L0::KernelImp {
return nullptr;
}
void printPrintfOutput() override {
printPrintfOutputCalledTimes++;
}
WhiteBox<::L0::KernelImmutableData> immutableData;
NEO::KernelDescriptor descriptor;
uint32_t printPrintfOutputCalledTimes = 0;
};
} // namespace ult

View File

@@ -15,6 +15,7 @@
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h"
#include "level_zero/core/test/unit_tests/mocks/mock_kernel.h"
#include "level_zero/core/test/unit_tests/mocks/mock_memory_manager.h"
namespace L0 {
@@ -156,5 +157,23 @@ TEST_F(CommandQueueCreate, givenCmdQueueWithBlitCopyWhenExecutingCopyBlitCommand
commandQueue->destroy();
}
using CommandQueueDestroySupport = IsAtLeastProduct<IGFX_SKYLAKE>;
using CommandQueueDestroy = Test<DeviceFixture>;
HWTEST2_F(CommandQueueDestroy, whenCommandQueueDestroyIsCalledPrintPrintfOutputIsCalled, CommandQueueDestroySupport) {
ze_command_queue_desc_t desc = {};
desc.version = ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT;
auto csr = std::unique_ptr<NEO::CommandStreamReceiver>(neoDevice->createCommandStreamReceiver());
auto commandQueue = new MockCommandQueueHw<gfxCoreFamily>(device, csr.get(), &desc);
commandQueue->initialize(false);
Mock<Kernel> kernel;
commandQueue->printfFunctionContainer.push_back(&kernel);
EXPECT_EQ(0u, kernel.printPrintfOutputCalledTimes);
commandQueue->destroy();
EXPECT_EQ(1u, kernel.printPrintfOutputCalledTimes);
}
} // namespace ult
} // namespace L0