@@ -291,18 +291,18 @@ void Scheduler::removeMemoryObject(detail::SYCLMemObjI *MemObj) {
291
291
292
292
EventImplPtr Scheduler::addHostAccessor (Requirement *Req) {
293
293
std::vector<Command *> AuxiliaryCmds;
294
- Command *NewCmd = nullptr ;
294
+ EventImplPtr NewCmdEvent = nullptr ;
295
295
296
296
{
297
297
WriteLockT Lock (MGraphLock, std::defer_lock);
298
298
acquireWriteLock (Lock);
299
299
300
- NewCmd = MGraphBuilder.addHostAccessor (Req, AuxiliaryCmds);
300
+ Command *NewCmd = MGraphBuilder.addHostAccessor (Req, AuxiliaryCmds);
301
+ if (!NewCmd)
302
+ return nullptr ;
303
+ NewCmdEvent = NewCmd->getEvent ();
301
304
}
302
305
303
- if (!NewCmd)
304
- return nullptr ;
305
-
306
306
std::vector<Command *> ToCleanUp;
307
307
{
308
308
ReadLockT ReadLock (MGraphLock);
@@ -315,14 +315,15 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req) {
315
315
throw runtime_error (" Enqueue process failed." , PI_INVALID_OPERATION);
316
316
}
317
317
318
- Enqueued = GraphProcessor::enqueueCommand (NewCmd, Res, ToCleanUp);
319
- if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult )
320
- throw runtime_error (" Enqueue process failed." , PI_INVALID_OPERATION);
318
+ if (Command *NewCmd = static_cast <Command *>(NewCmdEvent->getCommand ())) {
319
+ Enqueued = GraphProcessor::enqueueCommand (NewCmd, Res, ToCleanUp);
320
+ if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult )
321
+ throw runtime_error (" Enqueue process failed." , PI_INVALID_OPERATION);
322
+ }
321
323
}
322
324
323
- EventImplPtr NewEvent = NewCmd->getEvent ();
324
325
cleanupCommands (ToCleanUp);
325
- return NewEvent ;
326
+ return NewCmdEvent ;
326
327
}
327
328
328
329
void Scheduler::releaseHostAccessor (Requirement *Req) {
0 commit comments