Add finish before command queue is released

Related-To: NEO-5279

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe 2022-07-19 19:32:15 +00:00 committed by Compute-Runtime-Automation
parent 4d35a76931
commit 50fae92ea2
7 changed files with 32 additions and 2 deletions

View File

@ -358,6 +358,8 @@ class CommandQueue : public BaseObject<_cl_command_queue> {
bool isTextureCacheFlushNeeded(uint32_t commandType) const;
void finishBeforeRelease();
protected:
void *enqueueReadMemObjForMap(TransferProperties &transferProperties, EventsRequest &eventsRequest, cl_int &errcodeRet);
cl_int enqueueWriteMemObjForUnmap(MemObj *memObj, void *mappedPtr, EventsRequest &eventsRequest);

View File

@ -17,4 +17,8 @@ bool CommandQueue::isTimestampWaitEnabled() {
return true;
}
void CommandQueue::finishBeforeRelease() {
this->finish();
}
} // namespace NEO

View File

@ -48,6 +48,7 @@ inline void releaseQueue(cl_command_queue commandQueue, cl_int &retVal) {
if (queue) {
queue->flush();
releaseVirtualEvent(*queue);
queue->finishBeforeRelease();
queue->release();
retVal = CL_SUCCESS;
}

View File

@ -1531,6 +1531,17 @@ TEST(CommandQueueDestructorTest, whenCommandQueueIsDestroyedThenDestroysTimestam
EXPECT_EQ(1, context->getRefInternalCount()); // NOLINT(clang-analyzer-cplusplus.NewDelete)
}
TEST(CommandQueueDestructorTest, GivenCommandQueueWhenDeletedThenFinishIsCalled) {
auto context = std::make_unique<MockContext>();
EXPECT_EQ(1, context->getRefInternalCount());
auto queue = new MockCommandQueue(context.get(), context->getDevice(0), nullptr, false);
cl_int ret = 0;
bool finishCalled = false;
queue->finishCalled = &finishCalled;
releaseQueue(queue, ret);
EXPECT_TRUE(finishCalled); // NOLINT
}
TEST(CommandQueuePropertiesTests, whenGetEngineIsCalledThenQueueEngineIsReturned) {
MockCommandQueue queue;
EngineControl engineControl;

View File

@ -16,7 +16,8 @@ using namespace NEO;
TEST(QueueHelpersTest, givenCommandQueueWithoutVirtualEventWhenReleaseQueueIsCalledThenCmdQInternalRefCountIsNotDecremented) {
cl_int retVal = CL_SUCCESS;
MockCommandQueue *cmdQ = new MockCommandQueue;
MockContext context;
MockCommandQueue *cmdQ = new MockCommandQueue(&context, context.getDevice(0), 0, false);
EXPECT_EQ(1, cmdQ->getRefInternalCount());
EXPECT_EQ(1, cmdQ->getRefInternalCount());

View File

@ -19,4 +19,9 @@ bool CommandQueue::isTimestampWaitEnabled() {
return ultHwConfig.useWaitForTimestamps;
}
void CommandQueue::finishBeforeRelease() {
*this->getHwTagAddress() = this->taskCount;
this->finish();
}
} // namespace NEO

View File

@ -206,7 +206,12 @@ class MockCommandQueue : public CommandQueue {
cl_int enqueueResourceBarrier(BarrierCommand *resourceBarrier, cl_uint numEventsInWaitList, const cl_event *eventWaitList,
cl_event *event) override { return CL_SUCCESS; }
cl_int finish() override { return CL_SUCCESS; }
cl_int finish() override {
if (finishCalled) {
*finishCalled = true;
}
return CL_SUCCESS;
}
cl_int flush() override { return CL_SUCCESS; }
@ -227,6 +232,7 @@ class MockCommandQueue : public CommandQueue {
std::atomic<uint32_t> latestTaskCountWaited{std::numeric_limits<uint32_t>::max()};
std::optional<WaitStatus> waitUntilCompleteReturnValue{};
int waitUntilCompleteCalledCount{0};
bool *finishCalled = nullptr;
};
template <typename GfxFamily>