@@ -52,7 +52,7 @@ static bool IsSuitableSubReq(const Requirement *Req) {
5252 return Req->MIsSubBuffer ;
5353}
5454
55- static bool isOnSameContext (const ContextImplPtr Context, queue_impl *Queue) {
55+ static bool isOnSameContext (context_impl * Context, queue_impl *Queue) {
5656 // Covers case for host usage (nullptr == nullptr) and existing device
5757 // contexts comparison.
5858 return Context == queue_impl::getContext (Queue);
@@ -233,8 +233,8 @@ Scheduler::GraphBuilder::getOrInsertMemObjRecord(queue_impl *Queue,
233233 " shouldn't lead to any enqueuing (no linked "
234234 " alloca or exceeding the leaf limit)." );
235235 } else
236- MemObject->MRecord .reset (new MemObjRecord{
237- queue_impl::getContext (Queue). get (), LeafLimit, AllocateDependency});
236+ MemObject->MRecord .reset (new MemObjRecord{queue_impl::getContext (Queue),
237+ LeafLimit, AllocateDependency});
238238
239239 MMemObjs.push_back (MemObject);
240240 return MemObject->MRecord .get ();
@@ -346,15 +346,16 @@ Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
346346 }
347347
348348 AllocaCommandBase *AllocaCmdSrc =
349- findAllocaForReq (Record, Req, Record->MCurContext );
349+ findAllocaForReq (Record, Req, Record->getCurContext () );
350350 if (!AllocaCmdSrc && IsSuitableSubReq (Req)) {
351351 // Since no alloca command for the sub buffer requirement was found in the
352352 // current context, need to find a parent alloca command for it (it must be
353353 // there)
354354 auto IsSuitableAlloca = [Record](AllocaCommandBase *AllocaCmd) {
355- bool Res = isOnSameContext (Record->MCurContext , AllocaCmd->getQueue ()) &&
356- // Looking for a parent buffer alloca command
357- AllocaCmd->getType () == Command::CommandType::ALLOCA;
355+ bool Res =
356+ isOnSameContext (Record->getCurContext (), AllocaCmd->getQueue ()) &&
357+ // Looking for a parent buffer alloca command
358+ AllocaCmd->getType () == Command::CommandType::ALLOCA;
358359 return Res;
359360 };
360361 const auto It =
@@ -384,10 +385,9 @@ Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
384385 NewCmd = insertMapUnmapForLinkedCmds (AllocaCmdSrc, AllocaCmdDst, MapMode);
385386 Record->MHostAccess = MapMode;
386387 } else {
387-
388388 if ((Req->MAccessMode == access::mode::discard_write) ||
389389 (Req->MAccessMode == access::mode::discard_read_write)) {
390- Record->MCurContext = Context;
390+ Record->setCurContext ( Context) ;
391391 return nullptr ;
392392 } else {
393393 // Full copy of buffer is needed to avoid loss of data that may be caused
@@ -409,7 +409,7 @@ Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
409409 addNodeToLeaves (Record, NewCmd, access::mode::read_write, ToEnqueue);
410410 for (Command *Cmd : ToCleanUp)
411411 cleanupCommand (Cmd);
412- Record->MCurContext = Context;
412+ Record->setCurContext ( Context) ;
413413 return NewCmd;
414414}
415415
@@ -422,7 +422,8 @@ Command *Scheduler::GraphBuilder::remapMemoryObject(
422422 AllocaCommandBase *LinkedAllocaCmd = HostAllocaCmd->MLinkedAllocaCmd ;
423423 assert (LinkedAllocaCmd && " Linked alloca command expected" );
424424
425- std::set<Command *> Deps = findDepsForReq (Record, Req, Record->MCurContext );
425+ std::set<Command *> Deps =
426+ findDepsForReq (Record, Req, Record->getCurContext ());
426427
427428 UnMapMemObject *UnMapCmd = new UnMapMemObject (
428429 LinkedAllocaCmd, *LinkedAllocaCmd->getRequirement (),
@@ -473,7 +474,7 @@ Scheduler::GraphBuilder::addCopyBack(Requirement *Req,
473474
474475 std::set<Command *> Deps = findDepsForReq (Record, Req, nullptr );
475476 AllocaCommandBase *SrcAllocaCmd =
476- findAllocaForReq (Record, Req, Record->MCurContext );
477+ findAllocaForReq (Record, Req, Record->getCurContext () );
477478
478479 auto MemCpyCmdUniquePtr = std::make_unique<MemCpyCommandHost>(
479480 *SrcAllocaCmd->getRequirement (), SrcAllocaCmd, *Req, &Req->MData ,
@@ -525,7 +526,7 @@ Scheduler::GraphBuilder::addHostAccessor(Requirement *Req,
525526 AllocaCommandBase *HostAllocaCmd =
526527 getOrCreateAllocaForReq (Record, Req, nullptr , ToEnqueue);
527528
528- if (isOnSameContext (Record->MCurContext , HostAllocaCmd->getQueue ())) {
529+ if (isOnSameContext (Record->getCurContext () , HostAllocaCmd->getQueue ())) {
529530 if (!isAccessModeAllowed (Req->MAccessMode , Record->MHostAccess )) {
530531 remapMemoryObject (Record, Req,
531532 Req->MIsSubBuffer ? (static_cast <AllocaSubBufCommand *>(
@@ -571,10 +572,8 @@ Command *Scheduler::GraphBuilder::addCGUpdateHost(
571572// / 1. New and examined commands only read -> can bypass
572573// / 2. New and examined commands has non-overlapping requirements -> can bypass
573574// / 3. New and examined commands have different contexts -> cannot bypass
574- std::set<Command *>
575- Scheduler::GraphBuilder::findDepsForReq (MemObjRecord *Record,
576- const Requirement *Req,
577- const ContextImplPtr &Context) {
575+ std::set<Command *> Scheduler::GraphBuilder::findDepsForReq (
576+ MemObjRecord *Record, const Requirement *Req, context_impl *Context) {
578577 std::set<Command *> RetDeps;
579578 std::vector<Command *> Visited;
580579 const bool ReadOnlyReq = Req->MAccessMode == access::mode::read;
@@ -644,7 +643,7 @@ DepDesc Scheduler::GraphBuilder::findDepForRecord(Command *Cmd,
644643// The function searches for the alloca command matching context and
645644// requirement.
646645AllocaCommandBase *Scheduler::GraphBuilder::findAllocaForReq (
647- MemObjRecord *Record, const Requirement *Req, const ContextImplPtr & Context,
646+ MemObjRecord *Record, const Requirement *Req, context_impl * Context,
648647 bool AllowConst) {
649648 auto IsSuitableAlloca = [&Context, Req,
650649 AllowConst](AllocaCommandBase *AllocaCmd) {
@@ -663,7 +662,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::findAllocaForReq(
663662 return (Record->MAllocaCommands .end () != It) ? *It : nullptr ;
664663}
665664
666- static bool checkHostUnifiedMemory (const ContextImplPtr & Ctx) {
665+ static bool checkHostUnifiedMemory (context_impl * Ctx) {
667666 if (const char *HUMConfig = SYCLConfig<SYCL_HOST_UNIFIED_MEMORY>::get ()) {
668667 if (std::strcmp (HUMConfig, " 0" ) == 0 )
669668 return Ctx == nullptr ;
@@ -744,7 +743,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
744743 Record->MAllocaCommands .push_back (HostAllocaCmd);
745744 Record->MWriteLeaves .push_back (HostAllocaCmd, ToEnqueue);
746745 ++(HostAllocaCmd->MLeafCounter );
747- Record->MCurContext = nullptr ;
746+ Record->setCurContext ( nullptr ) ;
748747 }
749748 }
750749 } else {
@@ -768,11 +767,12 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
768767 bool PinnedHostMemory = MemObj->usesPinnedHostMemory ();
769768
770769 bool HostUnifiedMemoryOnNonHostDevice =
771- Queue == nullptr ? checkHostUnifiedMemory (Record->MCurContext )
772- : HostUnifiedMemory;
770+ Queue == nullptr
771+ ? checkHostUnifiedMemory (Record->getCurContext ())
772+ : HostUnifiedMemory;
773773 if (PinnedHostMemory || HostUnifiedMemoryOnNonHostDevice) {
774774 AllocaCommandBase *LinkedAllocaCmdCand = findAllocaForReq (
775- Record, Req, Record->MCurContext , /* AllowConst=*/ false );
775+ Record, Req, Record->getCurContext () , /* AllowConst=*/ false );
776776
777777 // Cannot setup link if candidate is linked already
778778 if (LinkedAllocaCmdCand &&
@@ -812,7 +812,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
812812 AllocaCmd->MIsActive = false ;
813813 } else {
814814 LinkedAllocaCmd->MIsActive = false ;
815- Record->MCurContext = Context;
815+ Record->setCurContext ( Context) ;
816816
817817 std::set<Command *> Deps = findDepsForReq (Record, Req, Context);
818818 for (Command *Dep : Deps) {
@@ -965,7 +965,7 @@ Command *Scheduler::GraphBuilder::addCG(
965965 AllocaCmd =
966966 getOrCreateAllocaForReq (Record, Req, QueueForAlloca, ToEnqueue);
967967
968- isSameCtx = isOnSameContext (Record->MCurContext , QueueForAlloca);
968+ isSameCtx = isOnSameContext (Record->getCurContext () , QueueForAlloca);
969969 }
970970
971971 // If there is alloca command we need to check if the latest memory is in
@@ -992,7 +992,7 @@ Command *Scheduler::GraphBuilder::addCG(
992992 const detail::CGHostTask &HT =
993993 static_cast <detail::CGHostTask &>(NewCmd->getCG ());
994994
995- if (!isOnSameContext (Record->MCurContext , HT.MQueue .get ())) {
995+ if (!isOnSameContext (Record->getCurContext () , HT.MQueue .get ())) {
996996 NeedMemMoveToHost = true ;
997997 MemMoveTargetQueue = HT.MQueue .get ();
998998 }
@@ -1226,9 +1226,7 @@ Command *Scheduler::GraphBuilder::connectDepEvent(
12261226 try {
12271227 std::shared_ptr<detail::HostTask> HT (new detail::HostTask);
12281228 std::unique_ptr<detail::CG> ConnectCG (new detail::CGHostTask (
1229- std::move (HT),
1230- /* Queue = */ Cmd->getQueue (),
1231- /* Context = */ {},
1229+ std::move (HT), /* Queue = */ Cmd->getQueue (), /* Context = */ nullptr ,
12321230 /* Args = */ {},
12331231 detail::CG::StorageInitHelper (
12341232 /* ArgsStorage = */ {}, /* AccStorage = */ {},
@@ -1302,7 +1300,7 @@ Command *Scheduler::GraphBuilder::addCommandGraphUpdate(
13021300
13031301 AllocaCmd = getOrCreateAllocaForReq (Record, Req, Queue, ToEnqueue);
13041302
1305- isSameCtx = isOnSameContext (Record->MCurContext , Queue);
1303+ isSameCtx = isOnSameContext (Record->getCurContext () , Queue);
13061304 }
13071305
13081306 if (!isSameCtx) {
0 commit comments