Skip to content

Commit 1a4c29f

Browse files
steffenlarsennrspruit
authored andcommitted
[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: Larsen, Steffen <steffen.larsen@intel.com>
1 parent 08a74f9 commit 1a4c29f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

unified-runtime/source/adapters/level_zero/memory.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,11 @@ _ur_buffer::_ur_buffer(ur_context_handle_t Context, size_t Size,
23362336
LastDeviceWithValidAllocation = Device;
23372337
}
23382338

2339+
_ur_buffer::~_ur_buffer() {
2340+
if (isSubBuffer())
2341+
ur::level_zero::urMemRelease(SubBuffer->Parent);
2342+
}
2343+
23392344
ur_result_t ur_mem_handle_t_::getZeHandle(char *&ZeHandle, access_mode_t mode,
23402345
ur_device_handle_t Device,
23412346
const ur_event_handle_t *phWaitEvents,

unified-runtime/source/adapters/level_zero/memory.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ struct _ur_buffer final : ur_mem_handle_t_ {
127127
_ur_buffer(ur_context_handle_t Context, size_t Size,
128128
ur_device_handle_t Device, char *ZeMemHandle, bool OwnZeMemHandle);
129129

130+
~_ur_buffer();
131+
130132
// Returns a pointer to the USM allocation representing this PI buffer
131133
// on the specified Device. If Device is nullptr then the returned
132134
// USM allocation is on the device where this buffer was used the latest.

0 commit comments

Comments
 (0)