Skip to content

Commit 384326c

Browse files
committed
Move command buffer cleanup to destructor
1 parent 895f5c6 commit 384326c

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

scripts/templates/queue_api.hpp.mako

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ struct ur_queue_handle_t_ {
3636
%endfor
3737

3838
virtual ur_result_t
39-
enqueueNativeCommandExp(ur_exp_enqueue_native_command_function_t, void *,
40-
uint32_t, const ur_mem_handle_t *,
41-
const ur_exp_enqueue_native_command_properties_t *,
42-
uint32_t, const ur_event_handle_t *,
43-
ur_event_handle_t *) = 0;
39+
enqueueCommandBuffer(ze_command_list_handle_t, ur_event_handle_t *,
40+
uint32_t, const ur_event_handle_t *) = 0;
4441
};

source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_(
5353
UR_CALL_THROWS(ur::level_zero::urDeviceRetain(device));
5454
}
5555

56-
void ur_exp_command_buffer_handle_t_::cleanupCommandBufferResources() {
56+
ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
5757
// Release the memory allocated to the Context stored in the command_buffer
58-
UR_CALL_THROWS(ur::level_zero::urContextRelease(context));
58+
ur::level_zero::urContextRelease(context);
5959

6060
// Release the device
61-
UR_CALL_THROWS(ur::level_zero::urDeviceRelease(device));
61+
ur::level_zero::urDeviceRelease(device);
6262

6363
for (auto &associatedKernel : kernelsList) {
64-
UR_CALL_THROWS(ur::level_zero::urKernelRelease(associatedKernel));
64+
ur::level_zero::urKernelRelease(associatedKernel);
6565
}
6666
}
6767

@@ -140,12 +140,10 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
140140
if (!hCommandBuffer->RefCount.decrementAndTest())
141141
return UR_RESULT_SUCCESS;
142142

143-
hCommandBuffer->cleanupCommandBufferResources();
144-
} catch (...) {
145143
delete hCommandBuffer;
144+
} catch (...) {
146145
return exceptionToResult(std::current_exception());
147146
}
148-
delete hCommandBuffer;
149147
return UR_RESULT_SUCCESS;
150148
}
151149

source/adapters/level_zero/v2/command_buffer.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
3131
ur_device_handle_t device,
3232
ze_command_list_handle_t commandList,
3333
const ur_exp_command_buffer_desc_t *desc);
34+
~ur_exp_command_buffer_handle_t_();
3435
ur_event_handle_t getSignalEvent(ur_event_handle_t *hUserEvent,
3536
ur_command_t commandType);
3637

3738
std::pair<ze_event_handle_t *, uint32_t>
3839
getWaitListView(const ur_event_handle_t *phWaitEvents,
3940
uint32_t numWaitEvents);
40-
// Releases the resources associated with the command-buffer before the
41-
// command-buffer object is destroyed.
42-
void cleanupCommandBufferResources();
4341

4442
// UR context associated with this command-buffer
4543
ur_context_handle_t context;

0 commit comments

Comments
 (0)