@@ -486,10 +486,14 @@ Command *Command::processDepEvent(EventImplPtr DepEvent, const DepDesc &Dep) {
486
486
const ContextImplPtr &WorkerContext = WorkerQueue->getContextImplPtr ();
487
487
488
488
// 1. Async work is not supported for host device.
489
- // 2. The event handle can be null in case of, for example, alloca command,
490
- // which is currently synchronous, so don't generate OpenCL event.
491
- // Though, this event isn't host one as it's context isn't host one.
492
- if (DepEvent->is_host () || DepEvent->getHandleRef () == nullptr ) {
489
+ // 2. Some types of commands do not produce PI events after they are enqueued
490
+ // (e.g. alloca). Note that we can't check the pi event to make that
491
+ // distinction since the command might still be unenqueued at this point.
492
+ bool PiEventExpected = !DepEvent->is_host ();
493
+ if (auto *DepCmd = static_cast <Command *>(DepEvent->getCommand ()))
494
+ PiEventExpected &= DepCmd->producesPiEvent ();
495
+
496
+ if (!PiEventExpected) {
493
497
// call to waitInternal() is in waitForPreparedHostEvents() as it's called
494
498
// from enqueue process functions
495
499
MPreparedHostDepsEvents.push_back (DepEvent);
@@ -520,6 +524,8 @@ const ContextImplPtr &Command::getWorkerContext() const {
520
524
521
525
const QueueImplPtr &Command::getWorkerQueue () const { return MQueue; }
522
526
527
+ bool Command::producesPiEvent () const { return true ; }
528
+
523
529
Command *Command::addDep (DepDesc NewDep) {
524
530
Command *ConnectionCmd = nullptr ;
525
531
@@ -731,6 +737,8 @@ void AllocaCommandBase::emitInstrumentationData() {
731
737
#endif
732
738
}
733
739
740
+ bool AllocaCommandBase::producesPiEvent () const { return false ; }
741
+
734
742
AllocaCommand::AllocaCommand (QueueImplPtr Queue, Requirement Req,
735
743
bool InitFromUserData,
736
744
AllocaCommandBase *LinkedAllocaCmd)
@@ -998,6 +1006,8 @@ void ReleaseCommand::printDot(std::ostream &Stream) const {
998
1006
}
999
1007
}
1000
1008
1009
+ bool ReleaseCommand::producesPiEvent () const { return false ; }
1010
+
1001
1011
MapMemObject::MapMemObject (AllocaCommandBase *SrcAllocaCmd, Requirement Req,
1002
1012
void **DstPtr, QueueImplPtr Queue,
1003
1013
access::mode MapMode)
@@ -1392,6 +1402,8 @@ void EmptyCommand::printDot(std::ostream &Stream) const {
1392
1402
}
1393
1403
}
1394
1404
1405
+ bool EmptyCommand::producesPiEvent () const { return false ; }
1406
+
1395
1407
void MemCpyCommandHost::printDot (std::ostream &Stream) const {
1396
1408
Stream << " \" " << this << " \" [style=filled, fillcolor=\" #B6A2EB\" , label=\" " ;
1397
1409
@@ -2193,6 +2205,10 @@ cl_int ExecCGCommand::enqueueImp() {
2193
2205
return PI_INVALID_OPERATION;
2194
2206
}
2195
2207
2208
+ bool ExecCGCommand::producesPiEvent () const {
2209
+ return MCommandGroup->getType () != CG::CGTYPE::CODEPLAY_HOST_TASK;
2210
+ }
2211
+
2196
2212
} // namespace detail
2197
2213
} // namespace sycl
2198
2214
} // __SYCL_INLINE_NAMESPACE(cl)
0 commit comments