Skip to content

Commit a1dd428

Browse files
committed
Use cached command lists instead of created ones
1 parent 384326c commit a1dd428

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ ur_exp_command_buffer_handle_t_::getWaitListView(
4545

4646
ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_(
4747
ur_context_handle_t context, ur_device_handle_t device,
48-
ze_command_list_handle_t commandList,
48+
v2::raii::command_list_unique_handle &&commandList,
4949
const ur_exp_command_buffer_desc_t *desc)
50-
: context(context), device(device), zeCommandList(commandList),
50+
: context(context), device(device),
51+
zeCommandList(
52+
std::forward<v2::raii::command_list_unique_handle>(commandList)),
5153
isUpdatable(desc ? desc->isUpdatable : false) {
5254
UR_CALL_THROWS(ur::level_zero::urContextRetain(context));
5355
UR_CALL_THROWS(ur::level_zero::urDeviceRetain(device));
@@ -115,10 +117,16 @@ urCommandBufferCreateExp(ur_context_handle_t context, ur_device_handle_t device,
115117
UR_RESULT_ERROR_UNSUPPORTED_FEATURE);
116118
}
117119

118-
ze_command_list_handle_t zeCommandList = nullptr;
119-
UR_CALL(createMainCommandList(context, device, isUpdatable, zeCommandList));
120+
using queue_group_type = ur_device_handle_t_::queue_group_info_t::type;
121+
uint32_t queueGroupOrdinal =
122+
device->QueueGroup[queue_group_type::Compute].ZeOrdinal;
123+
v2::raii::command_list_unique_handle zeCommandList =
124+
context->commandListCache.getRegularCommandList(
125+
device->ZeDevice, true, queueGroupOrdinal, true);
126+
120127
*commandBuffer = new ur_exp_command_buffer_handle_t_(
121-
context, device, zeCommandList, commandBufferDesc);
128+
context, device, std::move(zeCommandList), commandBufferDesc);
129+
122130
} catch (const std::bad_alloc &) {
123131
return exceptionToResult(std::current_exception());
124132
}

source/adapters/level_zero/v2/command_buffer.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ struct command_buffer_profiling_t {
2727
};
2828

2929
struct ur_exp_command_buffer_handle_t_ : public _ur_object {
30-
ur_exp_command_buffer_handle_t_(ur_context_handle_t context,
31-
ur_device_handle_t device,
32-
ze_command_list_handle_t commandList,
33-
const ur_exp_command_buffer_desc_t *desc);
30+
ur_exp_command_buffer_handle_t_(
31+
ur_context_handle_t context, ur_device_handle_t device,
32+
v2::raii::command_list_unique_handle &&commandList,
33+
const ur_exp_command_buffer_desc_t *desc);
3434
~ur_exp_command_buffer_handle_t_();
3535
ur_event_handle_t getSignalEvent(ur_event_handle_t *hUserEvent,
3636
ur_command_t commandType);
@@ -43,7 +43,7 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
4343
ur_context_handle_t context;
4444
// Device associated with this command buffer
4545
ur_device_handle_t device;
46-
v2::raii::ze_command_list_handle_t zeCommandList;
46+
v2::raii::command_list_unique_handle zeCommandList;
4747

4848
std::vector<ze_event_handle_t> waitList;
4949
// Indicates if command-buffer commands can be updated after it is closed.

0 commit comments

Comments
 (0)