diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index f542f9d20a25d..bc343ea662413 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -212,6 +212,15 @@ class event_impl { } bool needsCleanupAfterWait() { return MNeedsCleanupAfterWait; } + /// Checks if an event is in a fully intialized state. Default-constructed + /// events will return true only after having initialized its native event, + /// while other events will assume that they are fully initialized at + /// construction, relying on external sources to supply member data. + /// + /// \return true if the event is considered to be in a fully initialized + /// state. + bool isInitialized() const noexcept { return MIsInitialized; } + private: // When instrumentation is enabled emits trace event for event wait begin and // returns the telemetry event generated for the wait diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index ae0cd7e390ca6..ec98c3ac3d8b6 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -530,7 +530,8 @@ class queue_impl { // Host and interop tasks, however, are not submitted to low-level runtimes // and require separate dependency management. const CG::CGTYPE Type = Handler.getType(); - event Event; + event Event = detail::createSyclObjFromImpl( + std::make_shared()); if (PostProcess) { bool IsKernel = Type == CG::Kernel; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index dc802ba3d82e6..800fa40490015 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -582,11 +582,12 @@ Command *Command::processDepEvent(EventImplPtr DepEvent, const DepDesc &Dep, const ContextImplPtr &WorkerContext = WorkerQueue->getContextImplPtr(); // 1. Async work is not supported for host device. - // 2. Some types of commands do not produce PI events after they are enqueued - // (e.g. alloca). Note that we can't check the pi event to make that - // distinction since the command might still be unenqueued at this point. - bool PiEventExpected = - !DepEvent->is_host() || getType() == CommandType::HOST_TASK; + // 2. Non-host events can be ignored if they are not fully initialized. + // 3. Some types of commands do not produce PI events after they are enqueued + // (e.g. alloca). Note that we can't check the pi event to make that + // distinction since the command might still be unenqueued at this point. + bool PiEventExpected = (!DepEvent->is_host() && DepEvent->isInitialized()) || + getType() == CommandType::HOST_TASK; if (auto *DepCmd = static_cast(DepEvent->getCommand())) PiEventExpected &= DepCmd->producesPiEvent();