@@ -221,9 +221,8 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
221
221
return UR_RESULT_SUCCESS;
222
222
}
223
223
224
- ur_event_handle_t InternalEvent ;
224
+ ur_event_handle_t ResultEvent = nullptr ;
225
225
bool IsInternal = OutEvent == nullptr ;
226
- ur_event_handle_t *Event = OutEvent ? OutEvent : &InternalEvent;
227
226
228
227
// For in-order queue and wait-list which is empty or has events from
229
228
// the same queue just use the last command event as the barrier event.
@@ -234,7 +233,10 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
234
233
EventWaitList) &&
235
234
Queue->LastCommandEvent && !Queue->LastCommandEvent ->IsDiscarded ) {
236
235
UR_CALL (ur::level_zero::urEventRetain (Queue->LastCommandEvent ));
237
- *Event = Queue->LastCommandEvent ;
236
+ ResultEvent = Queue->LastCommandEvent ;
237
+ if (OutEvent) {
238
+ *OutEvent = ResultEvent;
239
+ }
238
240
return UR_RESULT_SUCCESS;
239
241
}
240
242
@@ -264,16 +266,20 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
264
266
EventWaitList, OkToBatch));
265
267
266
268
// Insert the barrier into the command-list and execute.
267
- UR_CALL (insertBarrierIntoCmdList (CmdList, TmpWaitList, *Event , IsInternal));
269
+ UR_CALL (insertBarrierIntoCmdList (CmdList, TmpWaitList, ResultEvent , IsInternal));
268
270
269
271
UR_CALL (Queue->executeCommandList (CmdList, false , OkToBatch));
270
272
271
273
// Because of the dependency between commands in the in-order queue we don't
272
274
// need to keep track of any active barriers if we have in-order queue.
273
275
if (UseMultipleCmdlistBarriers && !Queue->isInOrderQueue ()) {
274
- auto UREvent = reinterpret_cast <ur_event_handle_t >(*Event );
276
+ auto UREvent = reinterpret_cast <ur_event_handle_t >(ResultEvent );
275
277
Queue->ActiveBarriers .add (UREvent);
276
278
}
279
+
280
+ if (OutEvent) {
281
+ *OutEvent = ResultEvent;
282
+ }
277
283
return UR_RESULT_SUCCESS;
278
284
}
279
285
@@ -361,13 +367,13 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
361
367
// Insert a barrier with the events from each command-queue into the
362
368
// convergence command list. The resulting event signals the convergence of
363
369
// all barriers.
364
- UR_CALL (insertBarrierIntoCmdList (ConvergenceCmdList, BaseWaitList, *Event ,
370
+ UR_CALL (insertBarrierIntoCmdList (ConvergenceCmdList, BaseWaitList, ResultEvent ,
365
371
IsInternal));
366
372
} else {
367
373
// If there is only a single queue then insert a barrier and the single
368
374
// result event can be used as our active barrier and used as the return
369
375
// event. Take into account whether output event is discarded or not.
370
- UR_CALL (insertBarrierIntoCmdList (CmdLists[0 ], _ur_ze_event_list_t {}, *Event ,
376
+ UR_CALL (insertBarrierIntoCmdList (CmdLists[0 ], _ur_ze_event_list_t {}, ResultEvent ,
371
377
IsInternal));
372
378
}
373
379
@@ -384,8 +390,10 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
384
390
}
385
391
386
392
UR_CALL (Queue->ActiveBarriers .clear ());
387
- auto UREvent = reinterpret_cast <ur_event_handle_t >(*Event);
388
- Queue->ActiveBarriers .add (UREvent);
393
+ Queue->ActiveBarriers .add (ResultEvent);
394
+ if (OutEvent) {
395
+ *OutEvent = ResultEvent;
396
+ }
389
397
return UR_RESULT_SUCCESS;
390
398
}
391
399
0 commit comments