@@ -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
119128void 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
189195ur_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+
191199ur_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
0 commit comments