Skip to content

Commit 946e9b8

Browse files
[UR][L0] Release parent of sub-buffer when sub-buffer dies (#17489)
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 <[email protected]>
1 parent d9ba32d commit 946e9b8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,11 @@ _ur_buffer::_ur_buffer(ur_context_handle_t Context, size_t Size,
23412341
LastDeviceWithValidAllocation = Device;
23422342
}
23432343

2344+
_ur_buffer::~_ur_buffer() {
2345+
if (isSubBuffer())
2346+
ur::level_zero::urMemRelease(SubBuffer->Parent);
2347+
}
2348+
23442349
ur_result_t ur_mem_handle_t_::getZeHandle(char *&ZeHandle, access_mode_t mode,
23452350
ur_device_handle_t Device,
23462351
const ur_event_handle_t *phWaitEvents,

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

+2
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)