@@ -627,17 +627,18 @@ DepDesc Scheduler::GraphBuilder::findDepForRecord(Command *Cmd,
627627
628628// The function searches for the alloca command matching context and
629629// requirement.
630- AllocaCommandBase *
631- Scheduler::GraphBuilder::findAllocaForReq ( MemObjRecord *Record,
632- const Requirement *Req,
633- const ContextImplPtr &Context) {
634- auto IsSuitableAlloca = [&Context, Req ](AllocaCommandBase *AllocaCmd) {
630+ AllocaCommandBase *Scheduler::GraphBuilder::findAllocaForReq (
631+ MemObjRecord *Record, const Requirement *Req, const ContextImplPtr &Context ,
632+ bool AllowConst) {
633+ auto IsSuitableAlloca = [ &Context, Req,
634+ AllowConst ](AllocaCommandBase *AllocaCmd) {
635635 bool Res = sameCtx (AllocaCmd->getQueue ()->getContextImplPtr (), Context);
636636 if (IsSuitableSubReq (Req)) {
637637 const Requirement *TmpReq = AllocaCmd->getRequirement ();
638638 Res &= AllocaCmd->getType () == Command::CommandType::ALLOCA_SUB_BUF;
639639 Res &= TmpReq->MOffsetInBytes == Req->MOffsetInBytes ;
640640 Res &= TmpReq->MSYCLMemObj ->getSize () == Req->MSYCLMemObj ->getSize ();
641+ Res &= AllowConst || !AllocaCmd->MIsConst ;
641642 }
642643 return Res;
643644 };
@@ -668,8 +669,8 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
668669 MemObjRecord *Record, const Requirement *Req, QueueImplPtr Queue,
669670 std::vector<Command *> &ToEnqueue) {
670671
671- AllocaCommandBase *AllocaCmd =
672- findAllocaForReq ( Record, Req, Queue->getContextImplPtr ());
672+ AllocaCommandBase *AllocaCmd = findAllocaForReq (
673+ Record, Req, Queue->getContextImplPtr (), /* AllowConst= */ false );
673674
674675 if (!AllocaCmd) {
675676 std::vector<Command *> ToCleanUp;
@@ -722,7 +723,8 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
722723 Scheduler::getInstance ().getDefaultHostQueue ();
723724 AllocaCommand *HostAllocaCmd = new AllocaCommand (
724725 DefaultHostQueue, FullReq, true /* InitFromUserData */ ,
725- nullptr /* LinkedAllocaCmd */ );
726+ nullptr /* LinkedAllocaCmd */ ,
727+ MemObj->isHostPointerReadOnly () /* IsConst */ );
726728 Record->MAllocaCommands .push_back (HostAllocaCmd);
727729 Record->MWriteLeaves .push_back (HostAllocaCmd, ToEnqueue);
728730 ++(HostAllocaCmd->MLeafCounter );
@@ -754,8 +756,8 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
754756 Queue->is_host () ? checkHostUnifiedMemory (Record->MCurContext )
755757 : HostUnifiedMemory;
756758 if (PinnedHostMemory || HostUnifiedMemoryOnNonHostDevice) {
757- AllocaCommandBase *LinkedAllocaCmdCand =
758- findAllocaForReq ( Record, Req, Record->MCurContext );
759+ AllocaCommandBase *LinkedAllocaCmdCand = findAllocaForReq (
760+ Record, Req, Record->MCurContext , /* AllowConst= */ false );
759761
760762 // Cannot setup link if candidate is linked already
761763 if (LinkedAllocaCmdCand &&
0 commit comments