Skip to content

Commit 728e5b4

Browse files
[SYCL] Fix depends_on with default-constructed events (#6630)
Using depends_on with default constructed events caused commands to incorrectly expect the events to have associated PI events. Since default-constructed events are automatically considered finished, they can be ignored if they do not have an associated native event. These changes allows commands to ignore uninitialized events in dependency events. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
1 parent f963062 commit 728e5b4

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

sycl/source/detail/event_impl.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ class event_impl {
212212
}
213213
bool needsCleanupAfterWait() { return MNeedsCleanupAfterWait; }
214214

215+
/// Checks if an event is in a fully intialized state. Default-constructed
216+
/// events will return true only after having initialized its native event,
217+
/// while other events will assume that they are fully initialized at
218+
/// construction, relying on external sources to supply member data.
219+
///
220+
/// \return true if the event is considered to be in a fully initialized
221+
/// state.
222+
bool isInitialized() const noexcept { return MIsInitialized; }
223+
215224
private:
216225
// When instrumentation is enabled emits trace event for event wait begin and
217226
// returns the telemetry event generated for the wait

sycl/source/detail/queue_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ class queue_impl {
530530
// Host and interop tasks, however, are not submitted to low-level runtimes
531531
// and require separate dependency management.
532532
const CG::CGTYPE Type = Handler.getType();
533-
event Event;
533+
event Event = detail::createSyclObjFromImpl<event>(
534+
std::make_shared<detail::event_impl>());
534535

535536
if (PostProcess) {
536537
bool IsKernel = Type == CG::Kernel;

sycl/source/detail/scheduler/commands.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,12 @@ Command *Command::processDepEvent(EventImplPtr DepEvent, const DepDesc &Dep,
582582
const ContextImplPtr &WorkerContext = WorkerQueue->getContextImplPtr();
583583

584584
// 1. Async work is not supported for host device.
585-
// 2. Some types of commands do not produce PI events after they are enqueued
586-
// (e.g. alloca). Note that we can't check the pi event to make that
587-
// distinction since the command might still be unenqueued at this point.
588-
bool PiEventExpected =
589-
!DepEvent->is_host() || getType() == CommandType::HOST_TASK;
585+
// 2. Non-host events can be ignored if they are not fully initialized.
586+
// 3. Some types of commands do not produce PI events after they are enqueued
587+
// (e.g. alloca). Note that we can't check the pi event to make that
588+
// distinction since the command might still be unenqueued at this point.
589+
bool PiEventExpected = (!DepEvent->is_host() && DepEvent->isInitialized()) ||
590+
getType() == CommandType::HOST_TASK;
590591
if (auto *DepCmd = static_cast<Command *>(DepEvent->getCommand()))
591592
PiEventExpected &= DepCmd->producesPiEvent();
592593

0 commit comments

Comments
 (0)