@@ -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,21 @@ 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,
270
+ IsInternal));
268
271
269
272
UR_CALL (Queue->executeCommandList (CmdList, false , OkToBatch));
270
273
271
274
// Because of the dependency between commands in the in-order queue we don't
272
275
// need to keep track of any active barriers if we have in-order queue.
273
276
if (UseMultipleCmdlistBarriers && !Queue->isInOrderQueue ()) {
274
- auto UREvent = reinterpret_cast <ur_event_handle_t >(*Event );
277
+ auto UREvent = reinterpret_cast <ur_event_handle_t >(ResultEvent );
275
278
Queue->ActiveBarriers .add (UREvent);
276
279
}
280
+
281
+ if (OutEvent) {
282
+ *OutEvent = ResultEvent;
283
+ }
277
284
return UR_RESULT_SUCCESS;
278
285
}
279
286
@@ -361,14 +368,14 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
361
368
// Insert a barrier with the events from each command-queue into the
362
369
// convergence command list. The resulting event signals the convergence of
363
370
// all barriers.
364
- UR_CALL (insertBarrierIntoCmdList (ConvergenceCmdList, BaseWaitList, *Event,
365
- IsInternal));
371
+ UR_CALL (insertBarrierIntoCmdList (ConvergenceCmdList, BaseWaitList,
372
+ ResultEvent, IsInternal));
366
373
} else {
367
374
// If there is only a single queue then insert a barrier and the single
368
375
// result event can be used as our active barrier and used as the return
369
376
// event. Take into account whether output event is discarded or not.
370
- UR_CALL (insertBarrierIntoCmdList (CmdLists[0 ], _ur_ze_event_list_t {}, *Event,
371
- IsInternal));
377
+ UR_CALL (insertBarrierIntoCmdList (CmdLists[0 ], _ur_ze_event_list_t {},
378
+ ResultEvent, IsInternal));
372
379
}
373
380
374
381
// Execute each command list so the barriers can be encountered.
@@ -384,8 +391,10 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
384
391
}
385
392
386
393
UR_CALL (Queue->ActiveBarriers .clear ());
387
- auto UREvent = reinterpret_cast <ur_event_handle_t >(*Event);
388
- Queue->ActiveBarriers .add (UREvent);
394
+ Queue->ActiveBarriers .add (ResultEvent);
395
+ if (OutEvent) {
396
+ *OutEvent = ResultEvent;
397
+ }
389
398
return UR_RESULT_SUCCESS;
390
399
}
391
400
0 commit comments