Skip to content

Commit e739c9c

Browse files
committed
[SYCL][UR] do not call any function on queue in urEventGetProfilingInfo
The queue can already be released.
1 parent 9a1c965 commit e739c9c

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,22 @@ void ur_event_handle_t_::resetQueueAndCommand(ur_queue_t_ *hQueue,
113113
ur_command_t commandType) {
114114
this->hQueue = hQueue;
115115
this->commandType = commandType;
116+
117+
if (hQueue) {
118+
UR_CALL_THROWS(hQueue->queueGetInfo(UR_QUEUE_INFO_DEVICE, sizeof(hDevice),
119+
reinterpret_cast<void *>(&hDevice),
120+
nullptr));
121+
} else {
122+
hDevice = nullptr;
123+
}
124+
116125
profilingData.reset();
117126
}
118127

119128
void ur_event_handle_t_::recordStartTimestamp() {
120-
assert(hQueue); // queue must be set before calling this
121-
122-
ur_device_handle_t hDevice;
123-
UR_CALL_THROWS(hQueue->queueGetInfo(UR_QUEUE_INFO_DEVICE, sizeof(hDevice),
124-
reinterpret_cast<void *>(&hDevice),
125-
nullptr));
129+
// queue and device must be set before calling this
130+
assert(hQueue);
131+
assert(hDevice);
126132

127133
profilingData.recordStartTimestamp(hDevice);
128134
}
@@ -188,6 +194,8 @@ ur_context_handle_t ur_event_handle_t_::getContext() const { return hContext; }
188194

189195
ur_command_t ur_event_handle_t_::getCommandType() const { return commandType; }
190196

197+
ur_device_handle_t ur_event_handle_t_::getDevice() const { return hDevice; }
198+
191199
ur_event_handle_t_::ur_event_handle_t_(
192200
ur_context_handle_t hContext,
193201
v2::raii::cache_borrowed_event eventAllocation, v2::event_pool *pool)
@@ -312,19 +320,14 @@ ur_result_t urEventGetProfilingInfo(
312320
}
313321
}
314322

315-
auto hQueue = hEvent->getQueue();
316-
if (!hQueue) {
323+
auto hDevice = hEvent->getDevice();
324+
if (!hDevice) {
317325
// no command has been enqueued with this event yet
318326
return UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE;
319327
}
320328

321329
ze_kernel_timestamp_result_t tsResult;
322330

323-
ur_device_handle_t hDevice;
324-
UR_CALL_THROWS(hQueue->queueGetInfo(UR_QUEUE_INFO_DEVICE, sizeof(hDevice),
325-
reinterpret_cast<void *>(&hDevice),
326-
nullptr));
327-
328331
auto zeTimerResolution = hDevice->ZeDeviceProperties->timerResolution;
329332
auto timestampMaxValue = hDevice->getTimestampMask();
330333

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ struct ur_event_handle_t_ : _ur_object {
9696
// Get the type of the command that this event is associated with
9797
ur_command_t getCommandType() const;
9898

99+
// Get the device associated with this event
100+
ur_device_handle_t getDevice() const;
101+
99102
// Record the start timestamp of the event, to be obtained by
100103
// urEventGetProfilingInfo. resetQueueAndCommand should be
101104
// called before this.
@@ -123,6 +126,7 @@ struct ur_event_handle_t_ : _ur_object {
123126
// commands
124127
ur_queue_t_ *hQueue = nullptr;
125128
ur_command_t commandType = UR_COMMAND_FORCE_UINT32;
129+
ur_device_handle_t hDevice = nullptr;
126130

127131
v2::event_flags_t flags;
128132
event_profiling_data_t profilingData;

0 commit comments

Comments
 (0)