Release mem objects after submission in blocked path.

Change-Id: Ie5951ec681c117161e40016887680489e1eaacb8
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:
Mrozek, Michal
2019-07-19 08:06:40 +02:00
committed by sys_ocldev
parent 4dd6c96618
commit b5cbbba234
2 changed files with 22 additions and 10 deletions

View File

@ -105,10 +105,6 @@ CommandComputeKernel::CommandComputeKernel(CommandQueue &commandQueue, std::uniq
}
CommandComputeKernel::~CommandComputeKernel() {
for (auto surface : surfaces) {
delete surface;
}
surfaces.clear();
if (kernelOperation->ioh.get() == kernelOperation->dsh.get()) {
kernelOperation->doNotFreeISH = true;
}
@ -125,6 +121,10 @@ CommandComputeKernel::~CommandComputeKernel() {
CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminated) {
if (terminated) {
for (auto surface : surfaces) {
delete surface;
}
surfaces.clear();
return completionStamp;
}
auto &commandStreamReceiver = commandQueue.getGpgpuCommandStreamReceiver();
@ -230,6 +230,11 @@ CompletionStamp &CommandComputeKernel::submit(uint32_t taskLevel, bool terminate
printfHandler.get()->printEnqueueOutput();
}
for (auto surface : surfaces) {
delete surface;
}
surfaces.clear();
return completionStamp;
}

View File

@ -475,24 +475,31 @@ TEST_F(InternalsEventTest, processBlockedCommandsKernelOperation) {
auto &csr = cmdQ.getGpgpuCommandStreamReceiver();
std::vector<Surface *> v;
SurfaceMock *surface = new SurfaceMock;
surface->graphicsAllocation = new MockGraphicsAllocation((void *)0x1234, 100u);
MockBuffer buffer;
buffer.retain();
auto bufferSurf = new MemObjSurface(&buffer);
PreemptionMode preemptionMode = pDevice->getPreemptionMode();
v.push_back(surface);
v.push_back(bufferSurf);
auto cmd = new CommandComputeKernel(cmdQ, std::unique_ptr<KernelOperation>(blockedCommandsData), v, false, false, false, nullptr, preemptionMode, pKernel, 1);
event.setCommand(std::unique_ptr<Command>(cmd));
auto taskLevelBefore = csr.peekTaskLevel();
auto refCount = buffer.getRefApiCount();
auto refInternal = buffer.getRefInternalCount();
event.submitCommand(false);
EXPECT_EQ(refCount - 1, buffer.getRefApiCount());
EXPECT_EQ(refInternal - 1, buffer.getRefInternalCount());
auto taskLevelAfter = csr.peekTaskLevel();
EXPECT_EQ(taskLevelBefore + 1, taskLevelAfter);
EXPECT_EQ(surface->resident, 1u);
EXPECT_FALSE(surface->graphicsAllocation->isResident(csr.getOsContext().getContextId()));
delete surface->graphicsAllocation;
auto graphicsAllocation = buffer.getGraphicsAllocation();
EXPECT_FALSE(graphicsAllocation->isResident(csr.getOsContext().getContextId()));
}
TEST_F(InternalsEventTest, processBlockedCommandsAbortKernelOperation) {