mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 20:54:47 +08:00
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:
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@@ -2,4 +2,4 @@
|
|||||||
neoDependenciesRev='726029-739'
|
neoDependenciesRev='726029-739'
|
||||||
strategy='EQUAL'
|
strategy='EQUAL'
|
||||||
allowedF=49
|
allowedF=49
|
||||||
allowedCD=375
|
allowedCD=374
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ CommandComputeKernel::CommandComputeKernel(CommandQueue &commandQueue, CommandSt
|
|||||||
this->surfaces.push_back(surface);
|
this->surfaces.push_back(surface);
|
||||||
}
|
}
|
||||||
this->kernel = kernel;
|
this->kernel = kernel;
|
||||||
|
if (kernel) {
|
||||||
|
kernel->incRefInternal();
|
||||||
|
}
|
||||||
this->kernelCount = kernelCount;
|
this->kernelCount = kernelCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,6 +119,9 @@ CommandComputeKernel::~CommandComputeKernel() {
|
|||||||
if (kernelOperation->ioh.get() == kernelOperation->dsh.get()) {
|
if (kernelOperation->ioh.get() == kernelOperation->dsh.get()) {
|
||||||
kernelOperation->doNotFreeISH = true;
|
kernelOperation->doNotFreeISH = true;
|
||||||
}
|
}
|
||||||
|
if (kernel) {
|
||||||
|
kernel->decRefInternal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminated) {
|
CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminated) {
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ class ReferenceTrackedObject {
|
|||||||
unique_ptr_if_unused<DerivedClass> decRefInternal() {
|
unique_ptr_if_unused<DerivedClass> decRefInternal() {
|
||||||
auto customDeleter = tryGetCustomDeleter();
|
auto customDeleter = tryGetCustomDeleter();
|
||||||
bool unused = refInternal.dec();
|
bool unused = refInternal.dec();
|
||||||
|
UNRECOVERABLE_IF(refInternal.peek() < 0);
|
||||||
return unique_ptr_if_unused<DerivedClass>(static_cast<DerivedClass *>(this), unused, customDeleter);
|
return unique_ptr_if_unused<DerivedClass>(static_cast<DerivedClass *>(this), unused, customDeleter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -412,6 +412,23 @@ HWTEST_F(BlockedCommandQueueTest, givenCommandQueueWhichHasSomeUnusedHeapsWhenBl
|
|||||||
EXPECT_EQ(sshBase, ssh.getBase());
|
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;
|
typedef CommandQueueHwTest CommandQueueHwRefCountTest;
|
||||||
|
|
||||||
HWTEST_F(CommandQueueHwRefCountTest, givenBlockedCmdQWhenNewBlockedEnqueueReplacesVirtualEventThenPreviousVirtualEventDecrementsCmdQRefCount) {
|
HWTEST_F(CommandQueueHwRefCountTest, givenBlockedCmdQWhenNewBlockedEnqueueReplacesVirtualEventThenPreviousVirtualEventDecrementsCmdQRefCount) {
|
||||||
|
|||||||
@@ -620,8 +620,8 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut
|
|||||||
|
|
||||||
delete pPrintfSurface;
|
delete pPrintfSurface;
|
||||||
delete pKernelInfo;
|
delete pKernelInfo;
|
||||||
delete pKernel;
|
pKernel->decRefInternal();
|
||||||
delete pProgram;
|
pProgram->decRefInternal();
|
||||||
delete pCmdQ;
|
delete pCmdQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ class MockKernelWithInternals {
|
|||||||
mockKernel->setSshLocal(&sshLocal, sizeof(sshLocal));
|
mockKernel->setSshLocal(&sshLocal, sizeof(sshLocal));
|
||||||
}
|
}
|
||||||
~MockKernelWithInternals() {
|
~MockKernelWithInternals() {
|
||||||
delete mockKernel;
|
mockKernel->decRefInternal();
|
||||||
delete mockProgram;
|
mockProgram->decRefInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
operator MockKernel *() {
|
operator MockKernel *() {
|
||||||
|
|||||||
Reference in New Issue
Block a user