Skip to content

Commit 5a24afb

Browse files
committed
[UR][L0] Release parent of sub-buffer when sub-buffer dies
This commit fixes an issue where the sub-buffer object in the L0 V1 adapter would not release its retained parent, causing leaks. Signed-off-by: Neil R. Spruit <[email protected]>
1 parent a6acc9d commit 5a24afb

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

source/adapters/level_zero/memory.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,11 @@ ur_result_t urMemRelease(
16861686
return UR_RESULT_SUCCESS;
16871687
}
16881688

1689+
_ur_buffer::~_ur_buffer() {
1690+
if (isSubBuffer())
1691+
ur::level_zero::urMemRelease(SubBuffer->Parent);
1692+
}
1693+
16891694
ur_result_t urMemBufferPartition(
16901695
ur_mem_handle_t
16911696
Buffer, ///< [in] handle of the buffer object to allocate from

source/adapters/level_zero/memory.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ struct _ur_buffer final : ur_mem_handle_t_ {
116116
Parent->RefCount.increment();
117117
}
118118

119+
~_ur_buffer();
120+
119121
// Interop-buffer constructor
120122
_ur_buffer(ur_context_handle_t Context, size_t Size,
121123
ur_device_handle_t Device, char *ZeMemHandle, bool OwnZeMemHandle);

0 commit comments

Comments
 (0)