Skip to content

Commit 18cf869

Browse files
authored
Revert "[SYCL][UR][L0 v2] Fix issues with event lifetime" (#19042)
Reverts #18962 This patch likely caused these UR CTS failures: https://github.com/intel/llvm/actions/runs/15727687366/job/44323147798?pr=19035 > urCommandBufferAppendKernelLaunchExpTest.DuplicateSyncPoint/UR_BACKEND_LEVEL_ZERO__Intel_R__oneAPI_Unified_Runtime_over_Level_Zero_V2__Intel_R__Data_Center_GPU_Max_1100_ID0ID____________________ And is also possibly the root cause of #19034
1 parent 776de7d commit 18cf869

File tree

6 files changed

+33
-36
lines changed

6 files changed

+33
-36
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,15 @@ 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-
: 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),
69+
: isUpdatable(desc ? desc->isUpdatable : false),
7470
isInOrder(desc ? desc->isInOrder : false),
7571
commandListManager(
7672
context, device,
77-
std::forward<v2::raii::command_list_unique_handle>(commandList)) {
78-
ur::level_zero::urContextRetain(context);
79-
}
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)) {}
8078

8179
ur_exp_command_buffer_sync_point_t
8280
ur_exp_command_buffer_handle_t_::getSyncPoint(ur_event_handle_t event) {
@@ -175,7 +173,6 @@ ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
175173
for (auto &event : syncPoints) {
176174
event->release();
177175
}
178-
ur::level_zero::urContextRelease(context);
179176
}
180177

181178
ur_result_t ur_exp_command_buffer_handle_t_::applyUpdateCommands(

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ 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+
3544
ur_result_t finalizeCommandBuffer();
3645

3746
ur_result_t
@@ -54,8 +63,6 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
5463
createEventIfRequested(ur_exp_command_buffer_sync_point_t *retSyncPoint);
5564

5665
private:
57-
v2::raii::cache_borrowed_event_pool eventPool;
58-
5966
// Stores all sync points that are created by the command buffer.
6067
std::vector<ur_event_handle_t> syncPoints;
6168

@@ -77,13 +84,5 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
7784

7885
ur_event_handle_t currentExecution = nullptr;
7986

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

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ ur_command_list_manager::ur_command_list_manager(
2121
ur_context_handle_t context, ur_device_handle_t device,
2222
v2::raii::command_list_unique_handle &&commandList)
2323
: hContext(context), hDevice(device),
24-
zeCommandList(std::move(commandList)) {}
24+
zeCommandList(std::move(commandList)) {
25+
UR_CALL_THROWS(ur::level_zero::urContextRetain(context));
26+
UR_CALL_THROWS(ur::level_zero::urDeviceRetain(device));
27+
}
28+
29+
ur_command_list_manager::~ur_command_list_manager() {
30+
ur::level_zero::urContextRelease(hContext);
31+
ur::level_zero::urDeviceRelease(hDevice);
32+
}
2533

2634
ur_result_t ur_command_list_manager::appendGenericFillUnlocked(
2735
ur_mem_buffer_t *dst, size_t offset, size_t patternSize,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct ur_command_list_manager {
4747
operator=(const ur_command_list_manager &src) = delete;
4848
ur_command_list_manager &operator=(ur_command_list_manager &&src) = default;
4949

50-
~ur_command_list_manager() = default;
50+
~ur_command_list_manager();
5151

5252
ze_command_list_handle_t getZeCommandList();
5353

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +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)),
3331
commandListManager(
3432
hContext, hDevice,
3533
hContext->getCommandListCache().getImmediateCommandList(
3634
hDevice->ZeDevice,
3735
{true, ordinal, true /* always enable copy offload */},
3836
ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, priority, index)),
39-
flags(flags) {
40-
ur::level_zero::urContextRetain(hContext);
41-
}
37+
flags(flags),
38+
eventPool(hContext->getEventPoolCache(PoolCacheType::Immediate)
39+
.borrow(hDevice->Id.value(), eventFlags)) {}
4240

4341
ur_queue_immediate_in_order_t::ur_queue_immediate_in_order_t(
4442
ur_context_handle_t hContext, ur_device_handle_t hDevice,
4543
raii::command_list_unique_handle commandListHandle,
4644
event_flags_t eventFlags, ur_queue_flags_t flags)
4745
: hContext(hContext), hDevice(hDevice),
48-
eventPool(hContext->getEventPoolCache(PoolCacheType::Immediate)
49-
.borrow(hDevice->Id.value(), eventFlags)),
5046
commandListManager(hContext, hDevice, std::move(commandListHandle)),
51-
flags(flags) {
52-
ur::level_zero::urContextRetain(hContext);
53-
}
47+
flags(flags),
48+
eventPool(hContext->getEventPoolCache(PoolCacheType::Immediate)
49+
.borrow(hDevice->Id.value(), eventFlags)) {}
5450

5551
ur_result_t
5652
ur_queue_immediate_in_order_t::queueGetInfo(ur_queue_info_t propName,
@@ -126,7 +122,6 @@ ur_result_t ur_queue_immediate_in_order_t::queueFlush() {
126122
ur_queue_immediate_in_order_t::~ur_queue_immediate_in_order_t() {
127123
try {
128124
UR_CALL_THROWS(queueFinish());
129-
ur::level_zero::urContextRelease(hContext);
130125
} catch (...) {
131126
// Ignore errors during destruction
132127
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ 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-
3532
lockable<ur_command_list_manager> commandListManager;
3633
ur_queue_flags_t flags;
34+
v2::raii::cache_borrowed_event_pool eventPool;
3735

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

0 commit comments

Comments
 (0)