@@ -351,10 +351,10 @@ class queue_impl {
351
351
const v1::SubmissionInfo &SubmitInfo,
352
352
const detail::code_location &Loc, bool IsTopCodeLoc) {
353
353
354
- event ResEvent =
354
+ detail::EventImplPtr ResEvent =
355
355
submit_impl (CGF, Self, SubmitInfo.SecondaryQueue ().get (),
356
356
/* CallerNeedsEvent=*/ true , Loc, IsTopCodeLoc, SubmitInfo);
357
- return ResEvent;
357
+ return createSyclObjFromImpl<event>( ResEvent) ;
358
358
}
359
359
360
360
void submit_without_event (const detail::type_erased_cgfo_ty &CGF,
@@ -701,6 +701,15 @@ class queue_impl {
701
701
Handler.depends_on (*ExternalEvent);
702
702
}
703
703
704
+ #ifdef __INTEL_PREVIEW_BREAKING_CHANGES
705
+ #define parseEvent (arg ) (arg)
706
+ #else
707
+ inline detail::EventImplPtr parseEvent (const event &Event) {
708
+ const detail::EventImplPtr &EventImpl = getSyclObjImpl (Event);
709
+ return EventImpl->isDiscarded () ? nullptr : EventImpl;
710
+ }
711
+ #endif
712
+
704
713
bool trySwitchingToNoEventsMode () {
705
714
if (MNoEventMode.load (std::memory_order_relaxed))
706
715
return true ;
@@ -719,7 +728,8 @@ class queue_impl {
719
728
}
720
729
721
730
template <typename HandlerType = handler>
722
- event finalizeHandlerInOrderNoEventsUnlocked (HandlerType &Handler) {
731
+ detail::EventImplPtr
732
+ finalizeHandlerInOrderNoEventsUnlocked (HandlerType &Handler) {
723
733
assert (isInOrder ());
724
734
assert (MGraph.expired ());
725
735
assert (MDefaultGraphDeps.LastEventPtr == nullptr ||
@@ -732,18 +742,19 @@ class queue_impl {
732
742
733
743
if (MContext->getBackend () == backend::opencl && MGraph.expired ()) {
734
744
// This is needed to support queue_empty() call
735
- auto Event = Handler.finalize ();
736
- if (! getSyclObjImpl ( Event)-> isDiscarded () ) {
737
- MDefaultGraphDeps.LastEventPtr = getSyclObjImpl ( Event) ;
745
+ auto Event = parseEvent ( Handler.finalize () );
746
+ if (Event) {
747
+ MDefaultGraphDeps.LastEventPtr = Event;
738
748
}
739
749
return Event;
740
750
} else {
741
- return Handler.finalize ();
751
+ return parseEvent ( Handler.finalize () );
742
752
}
743
753
}
744
754
745
755
template <typename HandlerType = handler>
746
- event finalizeHandlerInOrderHostTaskUnlocked (HandlerType &Handler) {
756
+ detail::EventImplPtr
757
+ finalizeHandlerInOrderHostTaskUnlocked (HandlerType &Handler) {
747
758
assert (isInOrder ());
748
759
assert (Handler.getType () == CGType::CodeplayHostTask);
749
760
@@ -769,14 +780,14 @@ class queue_impl {
769
780
770
781
synchronizeWithExternalEvent (Handler);
771
782
772
- auto Event = Handler.finalize ();
773
- EventToBuildDeps = getSyclObjImpl (Event);
774
- assert (!EventToBuildDeps->isDiscarded ());
775
- return Event;
783
+ EventToBuildDeps = parseEvent (Handler.finalize ());
784
+ assert (EventToBuildDeps);
785
+ return EventToBuildDeps;
776
786
}
777
787
778
788
template <typename HandlerType = handler>
779
- event finalizeHandlerInOrderWithDepsUnlocked (HandlerType &Handler) {
789
+ detail::EventImplPtr
790
+ finalizeHandlerInOrderWithDepsUnlocked (HandlerType &Handler) {
780
791
// this is handled by finalizeHandlerInOrderHostTask
781
792
assert (Handler.getType () != CGType::CodeplayHostTask);
782
793
@@ -804,25 +815,20 @@ class queue_impl {
804
815
805
816
synchronizeWithExternalEvent (Handler);
806
817
807
- auto EventRet = Handler.finalize ();
808
-
809
- if (getSyclObjImpl (EventRet)->isDiscarded ()) {
810
- EventToBuildDeps = nullptr ;
811
- } else {
818
+ EventToBuildDeps = parseEvent (Handler.finalize ());
819
+ if (EventToBuildDeps)
812
820
MNoEventMode = false ;
813
- EventToBuildDeps = getSyclObjImpl (EventRet);
814
821
815
- // TODO: if the event is NOP we should be able to discard it as well.
816
- // However, NOP events are used to describe ordering for graph operations
817
- // Once https://github.com/intel/llvm/issues/18330 is fixed, we can
818
- // start relying on command buffer in-order property instead.
819
- }
822
+ // TODO: if the event is NOP we should be able to discard it.
823
+ // However, NOP events are used to describe ordering for graph operations
824
+ // Once https://github.com/intel/llvm/issues/18330 is fixed, we can
825
+ // start relying on command buffer in-order property instead.
820
826
821
- return EventRet ;
827
+ return EventToBuildDeps ;
822
828
}
823
829
824
830
template <typename HandlerType = handler>
825
- event finalizeHandlerOutOfOrder (HandlerType &Handler) {
831
+ detail::EventImplPtr finalizeHandlerOutOfOrder (HandlerType &Handler) {
826
832
const CGType Type = getSyclObjImpl (Handler)->MCGType ;
827
833
std::lock_guard<std::mutex> Lock{MMutex};
828
834
@@ -847,18 +853,17 @@ class queue_impl {
847
853
(Type == CGType::CodeplayHostTask || (!Deps.LastBarrier ->isEnqueued ())))
848
854
Handler.depends_on (Deps.LastBarrier );
849
855
850
- auto EventRet = Handler.finalize ();
851
- const EventImplPtr &EventRetImpl = getSyclObjImpl (EventRet);
856
+ EventImplPtr EventRetImpl = parseEvent (Handler.finalize ());
852
857
if (Type == CGType::CodeplayHostTask)
853
- Deps.UnenqueuedCmdEvents .push_back (std::move ( EventRetImpl) );
858
+ Deps.UnenqueuedCmdEvents .push_back (EventRetImpl);
854
859
else if (Type == CGType::Barrier || Type == CGType::BarrierWaitlist) {
855
- Deps.LastBarrier = std::move ( EventRetImpl) ;
860
+ Deps.LastBarrier = EventRetImpl;
856
861
Deps.UnenqueuedCmdEvents .clear ();
857
862
} else if (!EventRetImpl->isEnqueued ()) {
858
- Deps.UnenqueuedCmdEvents .push_back (std::move ( EventRetImpl) );
863
+ Deps.UnenqueuedCmdEvents .push_back (EventRetImpl);
859
864
}
860
865
861
- return EventRet ;
866
+ return EventRetImpl ;
862
867
}
863
868
864
869
template <typename HandlerType = handler>
@@ -893,12 +898,13 @@ class queue_impl {
893
898
// / \param Loc is the code location of the submit call (default argument)
894
899
// / \param SubmitInfo is additional optional information for the submission.
895
900
// / \return a SYCL event representing submitted command group.
896
- event submit_impl (const detail::type_erased_cgfo_ty &CGF,
897
- const std::shared_ptr<queue_impl> &Self,
898
- const std::shared_ptr<queue_impl> &PrimaryQueue,
899
- const std::shared_ptr<queue_impl> &SecondaryQueue,
900
- bool CallerNeedsEvent, const detail::code_location &Loc,
901
- bool IsTopCodeLoc, const SubmissionInfo &SubmitInfo);
901
+ detail::EventImplPtr
902
+ submit_impl (const detail::type_erased_cgfo_ty &CGF,
903
+ const std::shared_ptr<queue_impl> &Self,
904
+ const std::shared_ptr<queue_impl> &PrimaryQueue,
905
+ const std::shared_ptr<queue_impl> &SecondaryQueue,
906
+ bool CallerNeedsEvent, const detail::code_location &Loc,
907
+ bool IsTopCodeLoc, const SubmissionInfo &SubmitInfo);
902
908
#endif
903
909
904
910
// / Performs command group submission to the queue.
@@ -911,11 +917,13 @@ class queue_impl {
911
917
// / \param Loc is the code location of the submit call (default argument)
912
918
// / \param SubmitInfo is additional optional information for the submission.
913
919
// / \return a SYCL event representing submitted command group.
914
- event submit_impl (const detail::type_erased_cgfo_ty &CGF,
915
- const std::shared_ptr<queue_impl> &Self,
916
- queue_impl *SecondaryQueue, bool CallerNeedsEvent,
917
- const detail::code_location &Loc, bool IsTopCodeLoc,
918
- const v1::SubmissionInfo &SubmitInfo);
920
+ detail::EventImplPtr submit_impl (const detail::type_erased_cgfo_ty &CGF,
921
+ const std::shared_ptr<queue_impl> &Self,
922
+ queue_impl *SecondaryQueue,
923
+ bool CallerNeedsEvent,
924
+ const detail::code_location &Loc,
925
+ bool IsTopCodeLoc,
926
+ const v1::SubmissionInfo &SubmitInfo);
919
927
920
928
// / Helper function for submitting a memory operation with a handler.
921
929
// / \param Self is a shared_ptr to this queue.
@@ -974,8 +982,8 @@ class queue_impl {
974
982
975
983
// / Stores an event that should be associated with the queue
976
984
// /
977
- // / \param Event is the event to be stored
978
- void addEvent (const event &Event );
985
+ // / \param EventImpl is the event to be stored
986
+ void addEvent (const detail::EventImplPtr &EventImpl );
979
987
980
988
// / Protects all the fields that can be changed by class' methods.
981
989
mutable std::mutex MMutex;
0 commit comments