Skip to content

Commit de53693

Browse files
Merge pull request #1840 from Bensuo/ewan/cmd_buf_resource_cleanup
Refactor L0 command-buffer cleanup.
2 parents 0f4e47e + a3d84be commit de53693

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,7 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_(
424424
urDeviceRetain(Device);
425425
}
426426

427-
// The ur_exp_command_buffer_handle_t_ destructor releases all the memory
428-
// objects allocated for command_buffer management.
429-
ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
427+
void ur_exp_command_buffer_handle_t_::cleanupCommandBufferResources() {
430428
// Release the memory allocated to the Context stored in the command_buffer
431429
urContextRelease(Context);
432430

@@ -703,6 +701,7 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t CommandBuffer) {
703701
if (!CommandBuffer->RefCount.decrementAndTest())
704702
return UR_RESULT_SUCCESS;
705703

704+
CommandBuffer->cleanupCommandBufferResources();
706705
delete CommandBuffer;
707706
return UR_RESULT_SUCCESS;
708707
}

source/adapters/level_zero/command_buffer.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
3434
ur_event_handle_t WaitEvent, ur_event_handle_t AllResetEvent,
3535
const ur_exp_command_buffer_desc_t *Desc, const bool IsInOrderCmdList);
3636

37-
~ur_exp_command_buffer_handle_t_();
38-
3937
void registerSyncPoint(ur_exp_command_buffer_sync_point_t SyncPoint,
4038
ur_event_handle_t Event);
4139

@@ -65,6 +63,10 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
6563
*/
6664
ze_command_list_handle_t chooseCommandList(bool PreferCopyEngine);
6765

66+
// Releases the resources associated with the command-buffer before the
67+
// command-buffer object is destroyed.
68+
void cleanupCommandBufferResources();
69+
6870
// UR context associated with this command-buffer
6971
ur_context_handle_t Context;
7072
// Device associated with this command buffer

0 commit comments

Comments
 (0)