10
10
#include < CL/sycl/device_selector.hpp>
11
11
#include < detail/queue_impl.hpp>
12
12
#include < detail/scheduler/scheduler.hpp>
13
+ #include < detail/stream_impl.hpp>
13
14
14
15
#include < memory>
15
16
#include < mutex>
@@ -63,12 +64,14 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) {
63
64
64
65
EventImplPtr Scheduler::addCG (std::unique_ptr<detail::CG> CommandGroup,
65
66
QueueImplPtr Queue) {
66
- Command *NewCmd = nullptr ;
67
+ EventImplPtr NewEvent = nullptr ;
67
68
const bool IsKernel = CommandGroup->getType () == CG::KERNEL;
69
+ vector_class<StreamImplPtr> Streams;
68
70
{
69
71
std::unique_lock<std::shared_timed_mutex> Lock (MGraphLock, std::defer_lock);
70
72
lockSharedTimedMutex (Lock);
71
73
74
+ Command *NewCmd = nullptr ;
72
75
switch (CommandGroup->getType ()) {
73
76
case CG::UPDATE_HOST:
74
77
NewCmd = MGraphBuilder.addCGUpdateHost (std::move (CommandGroup),
@@ -80,22 +83,30 @@ EventImplPtr Scheduler::addCG(std::unique_ptr<detail::CG> CommandGroup,
80
83
default :
81
84
NewCmd = MGraphBuilder.addCG (std::move (CommandGroup), std::move (Queue));
82
85
}
86
+ NewEvent = NewCmd->getEvent ();
83
87
}
84
88
85
89
{
86
90
std::shared_lock<std::shared_timed_mutex> Lock (MGraphLock);
87
91
88
- // TODO: Check if lazy mode.
89
- EnqueueResultT Res;
90
- bool Enqueued = GraphProcessor::enqueueCommand (NewCmd, Res);
91
- if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult )
92
- throw runtime_error (" Enqueue process failed." , PI_INVALID_OPERATION);
92
+ Command *NewCmd = static_cast <Command *>(NewEvent->getCommand ());
93
+ if (NewCmd) {
94
+ // TODO: Check if lazy mode.
95
+ EnqueueResultT Res;
96
+ bool Enqueued = GraphProcessor::enqueueCommand (NewCmd, Res);
97
+ if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult )
98
+ throw runtime_error (" Enqueue process failed." , PI_INVALID_OPERATION);
99
+
100
+ if (IsKernel)
101
+ Streams = ((ExecCGCommand *)NewCmd)->getStreams ();
102
+ }
93
103
}
94
104
95
- if (IsKernel)
96
- ((ExecCGCommand *)NewCmd)->flushStreams ();
105
+ for (auto StreamImplPtr : Streams) {
106
+ StreamImplPtr->flush ();
107
+ }
97
108
98
- return NewCmd-> getEvent () ;
109
+ return NewEvent ;
99
110
}
100
111
101
112
EventImplPtr Scheduler::addCopyBack (Requirement *Req) {
0 commit comments