diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index b67725c3f6..5cb4a0405b 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -488,6 +488,8 @@ inline ze_result_t CommandListCoreFamilyImmediate::executeCommand } static_cast *>(this->cmdQImmediate)->patchCommands(*this, 0u, false); + } else { + cmdQImp->makeResidentForResidencyContainer(this->commandContainer.getResidencyContainer()); } NEO::CompletionStamp completionStamp; diff --git a/level_zero/core/source/cmdqueue/cmdqueue.cpp b/level_zero/core/source/cmdqueue/cmdqueue.cpp index 168e7cc723..bed478f8b3 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue.cpp +++ b/level_zero/core/source/cmdqueue/cmdqueue.cpp @@ -385,4 +385,11 @@ QueueProperties CommandQueue::extractQueueProperties(const ze_command_queue_desc return queueProperties; } +void CommandQueueImp::makeResidentForResidencyContainer(const NEO::ResidencyContainer &residencyContainer) { + for (auto alloc : residencyContainer) { + alloc->prepareHostPtrForResidency(csr); + csr->makeResident(*alloc); + } +} + } // namespace L0 diff --git a/level_zero/core/source/cmdqueue/cmdqueue_imp.h b/level_zero/core/source/cmdqueue/cmdqueue_imp.h index 4f29ef8474..eced42b232 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_imp.h +++ b/level_zero/core/source/cmdqueue/cmdqueue_imp.h @@ -117,6 +117,7 @@ struct CommandQueueImp : public CommandQueue { void triggerBbStartJump() { forceBbStartJump = true; } + void makeResidentForResidencyContainer(const NEO::ResidencyContainer &residencyContainer); protected: MOCKABLE_VIRTUAL NEO::SubmissionStatus submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr, diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp index d146bed243..e9b94d04d0 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp @@ -1821,5 +1821,39 @@ HWTEST_F(ImmediateCommandListTest, EXPECT_EQ(1u, kernel->printPrintfOutputCalledTimes); } +HWTEST_F(ImmediateCommandListTest, + givenImmediateCmdListWhenAppendingRegularCmdListThenInternalResidencyContainerProcessed) { + ze_result_t returnValue = ZE_RESULT_SUCCESS; + + ze_event_pool_desc_t eventPoolDesc = {}; + eventPoolDesc.count = 1; + + ze_event_desc_t eventDesc = {}; + eventDesc.index = 0; + eventDesc.signal = ZE_EVENT_SCOPE_FLAG_HOST; + + auto eventPool = std::unique_ptr(EventPool::create(driverHandle.get(), context, 0, nullptr, &eventPoolDesc, returnValue)); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + auto event = std::unique_ptr(Event::create(eventPool.get(), &eventDesc, device)); + ASSERT_NE(nullptr, event.get()); + + auto eventAllocation = event->getAllocation(device); + auto cmdBufferAllocation = commandListImmediate->getCmdContainer().getCommandStream()->getGraphicsAllocation(); + + auto &ultCsr = neoDevice->getUltCommandStreamReceiver(); + ultCsr.storeMakeResidentAllocations = true; + + returnValue = commandList->close(); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + + auto commandListHandle = commandList->toHandle(); + auto eventHandle = event->toHandle(); + returnValue = commandListImmediate->appendCommandLists(1, &commandListHandle, eventHandle, 0, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + + EXPECT_TRUE(ultCsr.isMadeResident(eventAllocation)); + EXPECT_TRUE(ultCsr.isMadeResident(cmdBufferAllocation)); +} + } // namespace ult } // namespace L0