1313#include < CL/sycl/handler.hpp>
1414#include < CL/sycl/info/info_desc.hpp>
1515#include < detail/kernel_impl.hpp>
16+ #include < detail/queue_impl.hpp>
1617#include < detail/scheduler/scheduler.hpp>
1718
1819__SYCL_INLINE_NAMESPACE (cl) {
1920namespace sycl {
20- event handler::finalize (const cl::sycl::detail::code_location &Payload) {
21- sycl::event EventRet;
21+
22+ void handler::addEventToQueue (shared_ptr_class<detail::queue_impl> Queue,
23+ cl::sycl::event Event) {
24+ Queue->addEvent (std::move (Event));
25+ }
26+
27+ event handler::finalize () {
28+ // This block of code is needed only for reduction implementation.
29+ // It is harmless (does nothing) for everything else.
30+ if (MIsFinalized)
31+ return MLastEvent;
32+ MIsFinalized = true ;
33+
2234 unique_ptr_class<detail::CG> CommandGroup;
2335 switch (MCGType) {
2436 case detail::CG::KERNEL:
@@ -29,52 +41,52 @@ event handler::finalize(const cl::sycl::detail::code_location &Payload) {
2941 std::move (MSharedPtrStorage), std::move (MRequirements),
3042 std::move (MEvents), std::move (MArgs), std::move (MKernelName),
3143 std::move (MOSModuleHandle), std::move (MStreamStorage), MCGType,
32- Payload ));
44+ MCodeLoc ));
3345 break ;
3446 }
3547 case detail::CG::INTEROP_TASK_CODEPLAY:
3648 CommandGroup.reset (new detail::CGInteropTask (
3749 std::move (MInteropTask), std::move (MArgsStorage),
3850 std::move (MAccStorage), std::move (MSharedPtrStorage),
39- std::move (MRequirements), std::move (MEvents), MCGType, Payload ));
51+ std::move (MRequirements), std::move (MEvents), MCGType, MCodeLoc ));
4052 break ;
4153 case detail::CG::COPY_ACC_TO_PTR:
4254 case detail::CG::COPY_PTR_TO_ACC:
4355 case detail::CG::COPY_ACC_TO_ACC:
4456 CommandGroup.reset (new detail::CGCopy (
4557 MCGType, MSrcPtr, MDstPtr, std::move (MArgsStorage),
4658 std::move (MAccStorage), std::move (MSharedPtrStorage),
47- std::move (MRequirements), std::move (MEvents), Payload ));
59+ std::move (MRequirements), std::move (MEvents), MCodeLoc ));
4860 break ;
4961 case detail::CG::FILL:
5062 CommandGroup.reset (new detail::CGFill (
5163 std::move (MPattern), MDstPtr, std::move (MArgsStorage),
5264 std::move (MAccStorage), std::move (MSharedPtrStorage),
53- std::move (MRequirements), std::move (MEvents), Payload ));
65+ std::move (MRequirements), std::move (MEvents), MCodeLoc ));
5466 break ;
5567 case detail::CG::UPDATE_HOST:
5668 CommandGroup.reset (new detail::CGUpdateHost (
5769 MDstPtr, std::move (MArgsStorage), std::move (MAccStorage),
5870 std::move (MSharedPtrStorage), std::move (MRequirements),
59- std::move (MEvents), Payload ));
71+ std::move (MEvents), MCodeLoc ));
6072 break ;
6173 case detail::CG::COPY_USM:
6274 CommandGroup.reset (new detail::CGCopyUSM (
6375 MSrcPtr, MDstPtr, MLength, std::move (MArgsStorage),
6476 std::move (MAccStorage), std::move (MSharedPtrStorage),
65- std::move (MRequirements), std::move (MEvents), Payload ));
77+ std::move (MRequirements), std::move (MEvents), MCodeLoc ));
6678 break ;
6779 case detail::CG::FILL_USM:
6880 CommandGroup.reset (new detail::CGFillUSM (
6981 std::move (MPattern), MDstPtr, MLength, std::move (MArgsStorage),
7082 std::move (MAccStorage), std::move (MSharedPtrStorage),
71- std::move (MRequirements), std::move (MEvents), Payload ));
83+ std::move (MRequirements), std::move (MEvents), MCodeLoc ));
7284 break ;
7385 case detail::CG::PREFETCH_USM:
7486 CommandGroup.reset (new detail::CGPrefetchUSM (
7587 MDstPtr, MLength, std::move (MArgsStorage), std::move (MAccStorage),
7688 std::move (MSharedPtrStorage), std::move (MRequirements),
77- std::move (MEvents), Payload ));
89+ std::move (MEvents), MCodeLoc ));
7890 break ;
7991 case detail::CG::NONE:
8092 throw runtime_error (" Command group submitted without a kernel or a "
@@ -88,8 +100,8 @@ event handler::finalize(const cl::sycl::detail::code_location &Payload) {
88100 detail::EventImplPtr Event = detail::Scheduler::getInstance ().addCG (
89101 std::move (CommandGroup), std::move (MQueue));
90102
91- EventRet = detail::createSyclObjFromImpl<event>(Event);
92- return EventRet ;
103+ MLastEvent = detail::createSyclObjFromImpl<event>(Event);
104+ return MLastEvent ;
93105}
94106
95107void handler::processArg (void *Ptr, const detail::kernel_param_kind_t &Kind,
0 commit comments