@@ -129,7 +129,7 @@ MemObjRecord *Scheduler::GraphBuilder::getMemObjRecord(SYCLMemObjI *MemObject) {
129
129
130
130
MemObjRecord *
131
131
Scheduler::GraphBuilder::getOrInsertMemObjRecord (const QueueImplPtr &Queue,
132
- Requirement *Req) {
132
+ const Requirement *Req) {
133
133
SYCLMemObjI *MemObject = Req->MSYCLMemObj ;
134
134
MemObjRecord *Record = getMemObjRecord (MemObject);
135
135
@@ -416,8 +416,8 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req,
416
416
Command *UpdateHostAccCmd = insertUpdateHostReqCmd (Record, Req, HostQueue);
417
417
418
418
// Need empty command to be blocked until host accessor is destructed
419
- EmptyCommand *EmptyCmd = addEmptyCmd (UpdateHostAccCmd, {Req}, HostQueue,
420
- Command::BlockReason::HostAccessor);
419
+ EmptyCommand *EmptyCmd = addEmptyCmd<Requirement>(
420
+ UpdateHostAccCmd, {Req}, HostQueue, Command::BlockReason::HostAccessor);
421
421
422
422
Req->MBlockedCmd = EmptyCmd;
423
423
@@ -446,7 +446,7 @@ Command *Scheduler::GraphBuilder::addCGUpdateHost(
446
446
// / 2. New and examined commands has non-overlapping requirements -> can bypass
447
447
// / 3. New and examined commands have different contexts -> cannot bypass
448
448
std::set<Command *>
449
- Scheduler::GraphBuilder::findDepsForReq (MemObjRecord *Record, Requirement *Req,
449
+ Scheduler::GraphBuilder::findDepsForReq (MemObjRecord *Record, const Requirement *Req,
450
450
const ContextImplPtr &Context) {
451
451
std::set<Command *> RetDeps;
452
452
std::set<Command *> Visited;
@@ -514,7 +514,7 @@ DepDesc Scheduler::GraphBuilder::findDepForRecord(Command *Cmd,
514
514
// The function searches for the alloca command matching context and
515
515
// requirement.
516
516
AllocaCommandBase *Scheduler::GraphBuilder::findAllocaForReq (
517
- MemObjRecord *Record, Requirement *Req, const ContextImplPtr &Context) {
517
+ MemObjRecord *Record, const Requirement *Req, const ContextImplPtr &Context) {
518
518
auto IsSuitableAlloca = [&Context, Req](AllocaCommandBase *AllocaCmd) {
519
519
bool Res = sameCtx (AllocaCmd->getQueue ()->getContextImplPtr (), Context);
520
520
if (IsSuitableSubReq (Req)) {
@@ -535,7 +535,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::findAllocaForReq(
535
535
// Note, creation of new allocation command can lead to the current context
536
536
// (Record->MCurContext) change.
537
537
AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq (
538
- MemObjRecord *Record, Requirement *Req, QueueImplPtr Queue) {
538
+ MemObjRecord *Record, const Requirement *Req, QueueImplPtr Queue) {
539
539
540
540
AllocaCommandBase *AllocaCmd =
541
541
findAllocaForReq (Record, Req, Queue->getContextImplPtr ());
@@ -640,9 +640,14 @@ void Scheduler::GraphBuilder::markModifiedIfWrite(MemObjRecord *Record,
640
640
}
641
641
}
642
642
643
- EmptyCommand *Scheduler::GraphBuilder::addEmptyCmd (
644
- Command *Cmd, const std::vector<Requirement *> &Reqs,
645
- const QueueImplPtr &Queue, Command::BlockReason Reason) {
643
+ template <typename T>
644
+ typename std::enable_if<std::is_same<typename std::remove_cv<T>::type,
645
+ Requirement>::value,
646
+ EmptyCommand *>::type
647
+ Scheduler::GraphBuilder::addEmptyCmd (Command *Cmd,
648
+ const std::vector<T *> &Reqs,
649
+ const QueueImplPtr &Queue,
650
+ Command::BlockReason Reason) {
646
651
EmptyCommand *EmptyCmd =
647
652
new EmptyCommand (Scheduler::getInstance ().getDefaultHostQueue ());
648
653
@@ -653,7 +658,7 @@ EmptyCommand *Scheduler::GraphBuilder::addEmptyCmd(
653
658
EmptyCmd->MEnqueueStatus = EnqueueResultT::SyclEnqueueBlocked;
654
659
EmptyCmd->MBlockReason = Reason;
655
660
656
- for (Requirement *Req : Reqs) {
661
+ for (T *Req : Reqs) {
657
662
MemObjRecord *Record = getOrInsertMemObjRecord (Queue, Req);
658
663
AllocaCommandBase *AllocaCmd = getOrCreateAllocaForReq (Record, Req, Queue);
659
664
EmptyCmd->addRequirement (Cmd, AllocaCmd, Req);
@@ -941,23 +946,19 @@ void Scheduler::GraphBuilder::connectDepEvent(Command *const Cmd,
941
946
EmptyCommand *EmptyCmd = nullptr ;
942
947
943
948
if (Dep.MDepRequirement ) {
944
- Requirement *Req = const_cast <Requirement *>(Dep.MDepRequirement );
945
-
946
949
// make ConnectCmd depend on requirement
947
- {
948
- ConnectCmd->addDep (Dep);
949
- assert (reinterpret_cast <Command *>(DepEvent->getCommand ()) ==
950
- Dep.MDepCommand );
951
- // add user to Dep.MDepCommand is already performed beyond this if branch
950
+ ConnectCmd->addDep (Dep);
951
+ assert (reinterpret_cast <Command *>(DepEvent->getCommand ()) ==
952
+ Dep.MDepCommand );
953
+ // add user to Dep.MDepCommand is already performed beyond this if branch
952
954
953
- MemObjRecord *Record = getMemObjRecord (Req ->MSYCLMemObj );
955
+ MemObjRecord *Record = getMemObjRecord (Dep. MDepRequirement ->MSYCLMemObj );
954
956
955
- updateLeaves ({ Dep.MDepCommand }, Record, Req->MAccessMode );
956
- addNodeToLeaves (Record, ConnectCmd, Req->MAccessMode );
957
- }
957
+ updateLeaves ({ Dep.MDepCommand }, Record, Dep.MDepRequirement ->MAccessMode );
958
+ addNodeToLeaves (Record, ConnectCmd, Dep.MDepRequirement ->MAccessMode );
958
959
959
- const std::vector<Requirement *> Reqs (1 , Req );
960
- EmptyCmd = addEmptyCmd (ConnectCmd, Reqs,
960
+ const std::vector<const Requirement *> Reqs (1 , Dep. MDepRequirement );
961
+ EmptyCmd = addEmptyCmd<> (ConnectCmd, Reqs,
961
962
Scheduler::getInstance ().getDefaultHostQueue (),
962
963
Command::BlockReason::HostTask);
963
964
// Dependencies for EmptyCmd are set in addEmptyCmd for provided Reqs.
@@ -970,9 +971,9 @@ void Scheduler::GraphBuilder::connectDepEvent(Command *const Cmd,
970
971
Cmd->addDep (CmdDep);
971
972
}
972
973
} else {
973
- EmptyCmd = addEmptyCmd (ConnectCmd, {},
974
- Scheduler::getInstance ().getDefaultHostQueue (),
975
- Command::BlockReason::HostTask);
974
+ EmptyCmd = addEmptyCmd<Requirement>(
975
+ ConnectCmd, {}, Scheduler::getInstance ().getDefaultHostQueue (),
976
+ Command::BlockReason::HostTask);
976
977
977
978
// There is no requirement thus, empty command will only depend on
978
979
// ConnectCmd via its event.
0 commit comments