20 #include <shared_mutex>
21 #include <unordered_map>
22 #include <unordered_set>
180 class DispatchHostTask;
183 using EventImplPtr = std::shared_ptr<detail::event_impl>;
184 using QueueImplPtr = std::shared_ptr<detail::queue_impl>;
187 using QueueIdT = std::hash<std::shared_ptr<detail::queue_impl>>::result_type;
190 using FusionMap = std::unordered_map<QueueIdT, FusionList>;
201 : MReadLeaves{
this, LeafLimit, AllocateDependency},
202 MWriteLeaves{
this, LeafLimit, AllocateDependency}, MCurContext{Ctx} {}
222 bool MMemModified =
false;
371 EventImplPtr addCG(std::unique_ptr<detail::CG> CommandGroup,
441 void deferMemObjRelease(
const std::shared_ptr<detail::SYCLMemObjI> &MemObj);
449 bool isInFusionMode(
QueueIdT Queue);
453 void releaseResources();
454 bool isDeferredMemObjectsEmpty();
457 std::vector<Command *> &AuxilaryCmds,
470 while (!Lock.try_lock_for(std::chrono::milliseconds(10))) {
474 std::this_thread::yield();
488 void cleanupCommands(
const std::vector<Command *> &Cmds);
490 void NotifyHostTaskCompletion(
Command *Cmd);
492 static void enqueueLeavesOfReqUnlocked(
const Requirement *
const Req,
493 ReadLockT &GraphReadLock,
494 std::vector<Command *> &ToCleanUp);
497 enqueueUnblockedCommands(
const std::vector<EventImplPtr> &CmdsToEnqueue,
498 ReadLockT &GraphReadLock,
499 std::vector<Command *> &ToCleanUp);
502 void cleanupDeferredMemObjects(
BlockingT Blocking);
512 void registerAuxiliaryResources(
513 EventImplPtr &Event, std::vector<std::shared_ptr<const void>> Resources);
514 void cleanupAuxiliaryResources(
BlockingT Blocking);
535 std::vector<Command *> &ToEnqueue);
541 Command *addCGUpdateHost(std::unique_ptr<detail::CG> CommandGroup,
543 std::vector<Command *> &ToEnqueue);
554 std::vector<Command *> &ToEnqueue);
563 void cleanupCommand(
Command *Cmd,
bool AllowUnsubmitted =
false);
581 std::vector<Command *> &ToEnqueue);
584 void decrementLeafCountersForRecord(
MemObjRecord *Record);
590 void removeRecordForMemObj(
SYCLMemObjI *MemObject);
595 std::vector<Command *> &ToEnqueue);
598 void updateLeaves(
const std::set<Command *> &Cmds,
MemObjRecord *Record,
600 std::vector<Command *> &ToCleanUp);
613 std::vector<Command *> &ToCleanUp);
617 void cancelFusion(
QueueImplPtr Queue, std::vector<Command *> &ToEnqueue);
620 std::vector<Command *> &ToEnqueue,
639 std::vector<Command *> &ToEnqueue);
645 std::vector<Command *> &ToEnqueue);
650 std::vector<Command *> &ToEnqueue);
653 std::set<Command *> findDepsForReq(
MemObjRecord *Record,
658 const std::vector<Requirement *> &Req,
661 std::vector<Command *> &ToEnqueue,
662 const bool AddDepsToLeaves =
true);
664 void createGraphForCommand(
Command *NewCmd,
CG &
CG,
bool isInteropTask,
665 std::vector<Requirement *> &Reqs,
666 const std::vector<detail::EventImplPtr> &Events,
668 std::vector<Command *> &ToEnqueue);
678 bool AllowConst =
true);
683 friend class ::MockScheduler;
691 std::vector<Command *> &ToEnqueue);
695 FusionMap::iterator findFusionList(
QueueIdT Id) {
696 return MFusionMap.find(Id);
699 void removeNodeFromGraph(
Command *Node, std::vector<Command *> &ToEnqueue);
703 std::queue<Command *> MCmdsToVisit;
705 std::vector<Command *> MVisitedCmds;
715 void printGraphAsDot(
const char *ModeName);
727 std::array<bool, PrintOptions::Size> MPrintOptionsArray{
false};
813 std::vector<Command *> &ToCleanUp,
814 bool LockTheLock =
true);
827 std::vector<Command *> &ToCleanUp,
867 std::unordered_map<EventImplPtr, std::vector<std::shared_ptr<const void>>>
892 friend class ::MockScheduler;
895 static void printFusionWarning(
const std::string &Message);