mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Release reference to mem_object after command submission.
Change-Id: I1d3899ee3320869dd245dc1af22bd9b0dbfce9cf Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
5a0be86b04
commit
1022ad4aac
@ -42,12 +42,9 @@ CommandMapUnmap::CommandMapUnmap(MapOperationType op, MemObj &memObj, MemObjSize
|
||||
memObj.incRefInternal();
|
||||
}
|
||||
|
||||
CommandMapUnmap::~CommandMapUnmap() {
|
||||
memObj.decRefInternal();
|
||||
}
|
||||
|
||||
CompletionStamp &CommandMapUnmap::submit(uint32_t taskLevel, bool terminated) {
|
||||
if (terminated) {
|
||||
memObj.decRefInternal();
|
||||
return completionStamp;
|
||||
}
|
||||
|
||||
@ -90,6 +87,8 @@ CompletionStamp &CommandMapUnmap::submit(uint32_t taskLevel, bool terminated) {
|
||||
}
|
||||
}
|
||||
|
||||
memObj.decRefInternal();
|
||||
|
||||
return completionStamp;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class CommandMapUnmap : public Command {
|
||||
public:
|
||||
CommandMapUnmap(MapOperationType op, MemObj &memObj, MemObjSizeArray ©Size, MemObjOffsetArray ©Offset, bool readOnly,
|
||||
CommandStreamReceiver &csr, CommandQueue &cmdQ);
|
||||
~CommandMapUnmap() override;
|
||||
~CommandMapUnmap() override = default;
|
||||
CompletionStamp &submit(uint32_t taskLevel, bool terminated) override;
|
||||
|
||||
private:
|
||||
|
@ -738,6 +738,26 @@ TEST_F(InternalsEventTest, processBlockedCommandsUnMapOperation) {
|
||||
delete pCmdQ;
|
||||
}
|
||||
|
||||
TEST_F(InternalsEventTest, givenBlockedMapCommandWhenSubmitIsCalledItReleasesMemObjectReference) {
|
||||
MockEvent<Event> event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
|
||||
auto pCmdQ = std::make_unique<CommandQueue>(mockContext, pDevice, props);
|
||||
|
||||
auto &csr = pCmdQ->getCommandStreamReceiver();
|
||||
auto buffer = new UnalignedBuffer;
|
||||
|
||||
auto currentBufferRefInternal = buffer->getRefInternalCount();
|
||||
|
||||
MemObjSizeArray size = {{1, 1, 1}};
|
||||
MemObjOffsetArray offset = {{0, 0, 0}};
|
||||
event.setCommand(std::unique_ptr<Command>(new CommandMapUnmap(UNMAP, *buffer, size, offset, false, csr, *pCmdQ)));
|
||||
EXPECT_EQ(currentBufferRefInternal + 1, buffer->getRefInternalCount());
|
||||
|
||||
event.submitCommand(false);
|
||||
|
||||
EXPECT_EQ(currentBufferRefInternal, buffer->getRefInternalCount());
|
||||
buffer->decRefInternal();
|
||||
}
|
||||
TEST_F(InternalsEventTest, processBlockedCommandsUnMapOperationNonZeroCopyBuffer) {
|
||||
MockEvent<Event> event(nullptr, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
|
||||
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
|
||||
|
Reference in New Issue
Block a user