Skip to content

Commit 2bcdd68

Browse files
committed
Move eventPool member up - it should be destroyed after cmd list manager
1 parent d23b010 commit 2bcdd68

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_(
6666
ur_context_handle_t context, ur_device_handle_t device,
6767
v2::raii::command_list_unique_handle &&commandList,
6868
const ur_exp_command_buffer_desc_t *desc)
69-
: isUpdatable(desc ? desc->isUpdatable : false),
69+
: eventPool(context->getEventPoolCache(PoolCacheType::Regular)
70+
.borrow(device->Id.value(),
71+
isInOrder ? v2::EVENT_FLAGS_COUNTER : 0)),
72+
context(context), device(device),
73+
isUpdatable(desc ? desc->isUpdatable : false),
7074
isInOrder(desc ? desc->isInOrder : false),
7175
commandListManager(
7276
context, device,
73-
std::forward<v2::raii::command_list_unique_handle>(commandList)),
74-
context(context), device(device),
75-
eventPool(context->getEventPoolCache(PoolCacheType::Regular)
76-
.borrow(device->Id.value(),
77-
isInOrder ? v2::EVENT_FLAGS_COUNTER : 0)) {}
77+
std::forward<v2::raii::command_list_unique_handle>(commandList))
78+
{}
7879

7980
ur_exp_command_buffer_sync_point_t
8081
ur_exp_command_buffer_handle_t_::getSyncPoint(ur_event_handle_t event) {

unified-runtime/source/adapters/level_zero/v2/command_buffer.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
3232
ur_result_t
3333
registerExecutionEventUnlocked(ur_event_handle_t nextExecutionEvent);
3434

35-
// Indicates if command-buffer commands can be updated after it is closed.
36-
const bool isUpdatable = false;
37-
const bool isInOrder = true;
38-
39-
// Command-buffer profiling is enabled.
40-
const bool isProfilingEnabled = false;
41-
42-
lockable<ur_command_list_manager> commandListManager;
43-
4435
ur_result_t finalizeCommandBuffer();
4536

4637
ur_result_t
@@ -63,6 +54,8 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
6354
createEventIfRequested(ur_exp_command_buffer_sync_point_t *retSyncPoint);
6455

6556
private:
57+
v2::raii::cache_borrowed_event_pool eventPool;
58+
6659
// Stores all sync points that are created by the command buffer.
6760
std::vector<ur_event_handle_t> syncPoints;
6861

@@ -81,5 +74,13 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
8174

8275
ur_event_handle_t currentExecution = nullptr;
8376

84-
v2::raii::cache_borrowed_event_pool eventPool;
77+
public:
78+
// Indicates if command-buffer commands can be updated after it is closed.
79+
const bool isUpdatable = false;
80+
const bool isInOrder = true;
81+
82+
// Command-buffer profiling is enabled.
83+
const bool isProfilingEnabled = false;
84+
85+
lockable<ur_command_list_manager> commandListManager;
8586
};

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ ur_queue_immediate_in_order_t::ur_queue_immediate_in_order_t(
2828
ze_command_queue_priority_t priority, std::optional<int32_t> index,
2929
event_flags_t eventFlags, ur_queue_flags_t flags)
3030
: hContext(hContext), hDevice(hDevice),
31+
eventPool(hContext->getEventPoolCache(PoolCacheType::Immediate)
32+
.borrow(hDevice->Id.value(), eventFlags)),
3133
commandListManager(
3234
hContext, hDevice,
3335
hContext->getCommandListCache().getImmediateCommandList(
3436
hDevice->ZeDevice,
3537
{true, ordinal, true /* always enable copy offload */},
3638
ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, priority, index)),
37-
flags(flags),
38-
eventPool(hContext->getEventPoolCache(PoolCacheType::Immediate)
39-
.borrow(hDevice->Id.value(), eventFlags)) {}
39+
flags(flags) {}
4040

4141
ur_queue_immediate_in_order_t::ur_queue_immediate_in_order_t(
4242
ur_context_handle_t hContext, ur_device_handle_t hDevice,
4343
raii::command_list_unique_handle commandListHandle,
4444
event_flags_t eventFlags, ur_queue_flags_t flags)
4545
: hContext(hContext), hDevice(hDevice),
46-
commandListManager(hContext, hDevice, std::move(commandListHandle)),
47-
flags(flags),
4846
eventPool(hContext->getEventPoolCache(PoolCacheType::Immediate)
49-
.borrow(hDevice->Id.value(), eventFlags)) {}
47+
.borrow(hDevice->Id.value(), eventFlags)),
48+
commandListManager(hContext, hDevice, std::move(commandListHandle)),
49+
flags(flags) {}
5050

5151
ur_result_t
5252
ur_queue_immediate_in_order_t::queueGetInfo(ur_queue_info_t propName,

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ struct ur_queue_immediate_in_order_t : ur_object, ur_queue_t_ {
2929
private:
3030
ur_context_handle_t hContext;
3131
ur_device_handle_t hDevice;
32+
33+
v2::raii::cache_borrowed_event_pool eventPool;
34+
3235
lockable<ur_command_list_manager> commandListManager;
3336
ur_queue_flags_t flags;
34-
v2::raii::cache_borrowed_event_pool eventPool;
3537

3638
// Only create an event when requested by the user.
3739
ur_event_handle_t createEventIfRequested(ur_event_handle_t *phEvent) {

0 commit comments

Comments
 (0)