@@ -630,14 +630,16 @@ DepDesc Scheduler::GraphBuilder::findDepForRecord(Command *Cmd,
630630AllocaCommandBase *
631631Scheduler::GraphBuilder::findAllocaForReq (MemObjRecord *Record,
632632 const Requirement *Req,
633- const ContextImplPtr &Context) {
634- auto IsSuitableAlloca = [&Context, Req](AllocaCommandBase *AllocaCmd) {
633+ const ContextImplPtr &Context,
634+ bool allowConst) {
635+ auto IsSuitableAlloca = [&Context, Req, allowConst](AllocaCommandBase *AllocaCmd) {
635636 bool Res = sameCtx (AllocaCmd->getQueue ()->getContextImplPtr (), Context);
636637 if (IsSuitableSubReq (Req)) {
637638 const Requirement *TmpReq = AllocaCmd->getRequirement ();
638639 Res &= AllocaCmd->getType () == Command::CommandType::ALLOCA_SUB_BUF;
639640 Res &= TmpReq->MOffsetInBytes == Req->MOffsetInBytes ;
640641 Res &= TmpReq->MSYCLMemObj ->getSize () == Req->MSYCLMemObj ->getSize ();
642+ Res &= allowConst || !AllocaCmd->MIsConst ;
641643 }
642644 return Res;
643645 };
@@ -669,7 +671,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
669671 std::vector<Command *> &ToEnqueue) {
670672
671673 AllocaCommandBase *AllocaCmd =
672- findAllocaForReq (Record, Req, Queue->getContextImplPtr ());
674+ findAllocaForReq (Record, Req, Queue->getContextImplPtr (), false );
673675
674676 if (!AllocaCmd) {
675677 std::vector<Command *> ToCleanUp;
@@ -722,7 +724,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
722724 Scheduler::getInstance ().getDefaultHostQueue ();
723725 AllocaCommand *HostAllocaCmd = new AllocaCommand (
724726 DefaultHostQueue, FullReq, true /* InitFromUserData */ ,
725- nullptr /* LinkedAllocaCmd */ );
727+ nullptr /* LinkedAllocaCmd */ , MemObj-> isHostPointerReadOnly () /* IsConst */ );
726728 Record->MAllocaCommands .push_back (HostAllocaCmd);
727729 Record->MWriteLeaves .push_back (HostAllocaCmd, ToEnqueue);
728730 ++(HostAllocaCmd->MLeafCounter );
@@ -755,7 +757,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
755757 : HostUnifiedMemory;
756758 if (PinnedHostMemory || HostUnifiedMemoryOnNonHostDevice) {
757759 AllocaCommandBase *LinkedAllocaCmdCand =
758- findAllocaForReq (Record, Req, Record->MCurContext );
760+ findAllocaForReq (Record, Req, Record->MCurContext , false );
759761
760762 // Cannot setup link if candidate is linked already
761763 if (LinkedAllocaCmdCand &&
0 commit comments