@@ -764,7 +764,9 @@ exec_graph_impl::enqueue(const std::shared_ptr<sycl::detail::queue_impl> &Queue,
764
764
sycl::detail::CG::StorageInitHelper CGData) {
765
765
WriteLock Lock (MMutex);
766
766
767
- std::vector<sycl::detail::EventImplPtr> PartitionEvents;
767
+ // Map of the partitions to their execution events
768
+ std::unordered_map<std::shared_ptr<partition>, sycl::detail::EventImplPtr>
769
+ PartitionsExecutionEvents;
768
770
769
771
auto CreateNewEvent ([&]() {
770
772
auto NewEvent = std::make_shared<sycl::detail::event_impl>(Queue);
@@ -787,7 +789,7 @@ exec_graph_impl::enqueue(const std::shared_ptr<sycl::detail::queue_impl> &Queue,
787
789
}
788
790
789
791
for (auto const &DepPartition : CurrentPartition->MPredecessors ) {
790
- CGData.MEvents .push_back (MPartitionsExecutionEvents [DepPartition]);
792
+ CGData.MEvents .push_back (PartitionsExecutionEvents [DepPartition]);
791
793
}
792
794
793
795
auto CommandBuffer =
@@ -819,7 +821,13 @@ exec_graph_impl::enqueue(const std::shared_ptr<sycl::detail::queue_impl> &Queue,
819
821
sycl::backend::ext_oneapi_level_zero) {
820
822
Event->wait (Event);
821
823
} else {
824
+ auto &AttachedEventsList = Event->getPostCompleteEvents ();
825
+ CGData.MEvents .reserve (AttachedEventsList.size () + 1 );
822
826
CGData.MEvents .push_back (Event);
827
+ // Add events of the previous execution of all graph partitions.
828
+ for (auto &AttachedEvent : AttachedEventsList) {
829
+ CGData.MEvents .push_back (AttachedEvent);
830
+ }
823
831
}
824
832
++It;
825
833
} else {
@@ -929,15 +937,15 @@ exec_graph_impl::enqueue(const std::shared_ptr<sycl::detail::queue_impl> &Queue,
929
937
NewEvent->setStateIncomplete ();
930
938
NewEvent->getPreparedDepsEvents () = ScheduledEvents;
931
939
}
932
- MPartitionsExecutionEvents [CurrentPartition] = NewEvent;
940
+ PartitionsExecutionEvents [CurrentPartition] = NewEvent;
933
941
}
934
942
935
943
// Keep track of this execution event so we can make sure it's completed in
936
944
// the destructor.
937
945
MExecutionEvents.push_back (NewEvent);
938
946
// Attach events of previous partitions to ensure that when the returned event
939
947
// is complete all execution associated with the graph have been completed.
940
- for (auto const &Elem : MPartitionsExecutionEvents ) {
948
+ for (auto const &Elem : PartitionsExecutionEvents ) {
941
949
if (Elem.second != NewEvent) {
942
950
NewEvent->attachEventToComplete (Elem.second );
943
951
}
0 commit comments