Skip to content

Commit e0176c7

Browse files
committed
Always Store last event if scheduler was not bypassed
1 parent d5716c7 commit e0176c7

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

sycl/source/detail/queue_impl.hpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,9 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
750750

751751
synchronizeWithExternalEvent(Handler);
752752

753-
return parseEvent(Handler.finalize());
753+
auto Event = parseEvent(Handler.finalize());
754+
storeLastEventIfNeeded(Event);
755+
return Event;
754756
}
755757

756758
template <typename HandlerType = handler>
@@ -786,6 +788,17 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
786788
return EventToBuildDeps;
787789
}
788790

791+
void storeLastEventIfNeeded(const EventImplPtr &Event) {
792+
if (!Event || Scheduler::CheckEventReadiness(MContext, Event))
793+
return;
794+
795+
auto &EventToBuildDeps = MGraph.expired() ? MDefaultGraphDeps.LastEventPtr
796+
: MExtGraphDeps.LastEventPtr;
797+
798+
EventToBuildDeps = Event;
799+
MNoLastEventMode = false;
800+
}
801+
789802
template <typename HandlerType = handler>
790803
detail::EventImplPtr
791804
finalizeHandlerInOrderWithDepsUnlocked(HandlerType &Handler) {
@@ -816,16 +829,15 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
816829

817830
synchronizeWithExternalEvent(Handler);
818831

819-
EventToBuildDeps = parseEvent(Handler.finalize());
820-
if (EventToBuildDeps)
821-
MNoLastEventMode = false;
832+
auto Event = parseEvent(Handler.finalize());
833+
storeLastEventIfNeeded(Event);
822834

823835
// TODO: if the event is NOP we should be able to discard it.
824836
// However, NOP events are used to describe ordering for graph operations
825837
// Once https://github.com/intel/llvm/issues/18330 is fixed, we can
826838
// start relying on command buffer in-order property instead.
827839

828-
return EventToBuildDeps;
840+
return Event;
829841
}
830842

831843
template <typename HandlerType = handler>

0 commit comments

Comments
 (0)