Add reference on kernel in blocked scenarios.

- Prevents kernel destruction while it may still be in use.

Change-Id: I1f87d09c5cabf29644a1b06b63f1789dbb15985a
This commit is contained in:
Mrozek, Michal
2018-01-04 16:34:25 +01:00
parent 57137fea84
commit 3eb856b192
6 changed files with 29 additions and 5 deletions

View File

@ -412,6 +412,23 @@ HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWhichHasSomeUnusedHeapsWhenBl
EXPECT_EQ(sshBase, ssh.getBase());
}
HWTEST_F(BlockedCommandQueueTest, givenEnqueueBlockedByUserEventWhenItIsEnqueuedThenKernelReferenceCountIsIncreased) {
UserEvent userEvent(context);
MockKernelWithInternals mockKernelWithInternals(*pDevice);
auto mockKernel = mockKernelWithInternals.mockKernel;
size_t offset = 0;
size_t size = 1;
cl_event blockedEvent = &userEvent;
auto currentRefCount = mockKernel->getRefInternalCount();
pCmdQ->enqueueKernel(mockKernel, 1, &offset, &size, &size, 1, &blockedEvent, nullptr);
EXPECT_EQ(currentRefCount + 1, mockKernel->getRefInternalCount());
userEvent.setStatus(CL_COMPLETE);
EXPECT_EQ(currentRefCount, mockKernel->getRefInternalCount());
}
typedef CommandQueueHwTest CommandQueueHwRefCountTest;
HWTEST_F(CommandQueueHwRefCountTest, givenBlockedCmdQWhenNewBlockedEnqueueReplacesVirtualEventThenPreviousVirtualEventDecrementsCmdQRefCount) {