Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions sycl/source/detail/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) {

EventImplPtr Scheduler::addCG(std::unique_ptr<detail::CG> CommandGroup,
QueueImplPtr Queue) {
Command *NewCmd = nullptr;
EventImplPtr NewEvent = nullptr;
const bool IsKernel = CommandGroup->getType() == CG::KERNEL;
{
std::unique_lock<std::shared_timed_mutex> Lock(MGraphLock, std::defer_lock);
lockSharedTimedMutex(Lock);

Command *NewCmd = nullptr;
switch (CommandGroup->getType()) {
case CG::UPDATE_HOST:
NewCmd = MGraphBuilder.addCGUpdateHost(std::move(CommandGroup),
Expand All @@ -80,22 +81,27 @@ EventImplPtr Scheduler::addCG(std::unique_ptr<detail::CG> CommandGroup,
default:
NewCmd = MGraphBuilder.addCG(std::move(CommandGroup), std::move(Queue));
}
NewEvent = NewCmd->getEvent();
}

{
std::shared_lock<std::shared_timed_mutex> Lock(MGraphLock);
std::unique_lock<std::shared_timed_mutex> Lock(MGraphLock, std::defer_lock);
lockSharedTimedMutex(Lock);

// TODO: Check if lazy mode.
EnqueueResultT Res;
bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res);
if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult)
throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION);
}
Command *Cmd = static_cast<Command *>(NewEvent->getCommand());
if (Cmd) {
// TODO: Check if lazy mode.
EnqueueResultT Res;
bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res);
if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult)
throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION);

if (IsKernel)
((ExecCGCommand *)NewCmd)->flushStreams();
if (IsKernel)
((ExecCGCommand *)Cmd)->flushStreams();
}
}

return NewCmd->getEvent();
return NewEvent;
}

EventImplPtr Scheduler::addCopyBack(Requirement *Req) {
Expand Down