diff --git a/runtime/command_stream/command_stream_receiver.cpp b/runtime/command_stream/command_stream_receiver.cpp index 4b547e4537..c53b778147 100644 --- a/runtime/command_stream/command_stream_receiver.cpp +++ b/runtime/command_stream/command_stream_receiver.cpp @@ -95,7 +95,7 @@ void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) { } void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer *allocationsForResidency) { - auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getMemoryManager()->getResidencyAllocations(); + auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getResidencyAllocations(); this->waitBeforeMakingNonResidentWhenRequired(); for (auto &surface : residencyAllocations) { diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index aff1645115..2aa323776b 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -449,7 +449,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( } else { auto commandBuffer = new CommandBuffer(device); commandBuffer->batchBuffer = batchBuffer; - commandBuffer->surfaces.swap(getMemoryManager()->getResidencyAllocations()); + commandBuffer->surfaces.swap(this->getResidencyAllocations()); commandBuffer->batchBufferEndLocation = bbEndLocation; commandBuffer->taskCount = this->taskCount + 1; commandBuffer->flushStamp->replaceStampObject(dispatchFlags.flushStampReference); diff --git a/runtime/os_interface/linux/drm_command_stream.inl b/runtime/os_interface/linux/drm_command_stream.inl index b1af31338e..b3a7b78268 100644 --- a/runtime/os_interface/linux/drm_command_stream.inl +++ b/runtime/os_interface/linux/drm_command_stream.inl @@ -124,7 +124,7 @@ void DrmCommandStreamReceiver::makeResident(BufferObject *bo) { template void DrmCommandStreamReceiver::processResidency(ResidencyContainer *inputAllocationsForResidency, OsContext &osContext) { - auto &allocationsForResidency = inputAllocationsForResidency ? *inputAllocationsForResidency : getMemoryManager()->getResidencyAllocations(); + auto &allocationsForResidency = inputAllocationsForResidency ? *inputAllocationsForResidency : this->getResidencyAllocations(); for (uint32_t a = 0; a < allocationsForResidency.size(); a++) { DrmAllocation *drmAlloc = reinterpret_cast(allocationsForResidency[a]); if (drmAlloc->fragmentsStorage.fragmentCount) { diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index 398b910dfe..c690123582 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -224,7 +224,7 @@ void WddmCommandStreamReceiver::initPageTableManagerRegisters(LinearS template void WddmCommandStreamReceiver::kmDafLockAllocations(ResidencyContainer *allocationsForResidency) { - auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : getMemoryManager()->getResidencyAllocations(); + auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getResidencyAllocations(); for (uint32_t i = 0; i < residencyAllocations.size(); i++) { auto graphicsAllocation = residencyAllocations[i]; diff --git a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp index bf0f2567bf..08b34edb61 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -275,14 +275,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount); EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->taskCount); EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount); - EXPECT_EQ(1u, memoryManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, aubCsr->getResidencyAllocations().size()); // Second makeResident should have no impact aubCsr->makeResident(*gfxAllocation); EXPECT_NE(ObjectNotResident, gfxAllocation->residencyTaskCount); EXPECT_EQ(aubCsr->peekTaskCount() + 1, gfxAllocation->taskCount); EXPECT_EQ((int)aubCsr->peekTaskCount() + 1, gfxAllocation->residencyTaskCount); - EXPECT_EQ(1u, memoryManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, aubCsr->getResidencyAllocations().size()); // First makeNonResident marks the allocation as nonresident aubCsr->makeNonResident(*gfxAllocation); @@ -336,7 +336,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIsCalledThenItShouldLeaveProperRingTailAlignment) { auto aubExecutionEnvironment = getEnvironment>(true, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>(); - auto allocationsForResidency = aubExecutionEnvironment->executionEnvironment->memoryManager->getResidencyAllocations(); + auto allocationsForResidency = aubCsr->getResidencyAllocations(); LinearStream cs(aubExecutionEnvironment->commandBuffer); auto engineType = OCLRT::ENGINE_RCS; @@ -476,7 +476,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandaloneModeWhenFlushIsCalledThenItShouldCallMakeResidentOnCommandBufferAllocation) { auto aubExecutionEnvironment = getEnvironment>(true, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>(); - auto allocationsForResidency = aubExecutionEnvironment->executionEnvironment->memoryManager->getResidencyAllocations(); + auto allocationsForResidency = aubCsr->getResidencyAllocations(); auto commandBuffer = aubExecutionEnvironment->commandBuffer; LinearStream cs(commandBuffer); @@ -499,7 +499,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInStandalon HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInNoneStandaloneModeWhenFlushIsCalledThenItShouldNotCallMakeResidentOnCommandBufferAllocation) { auto aubExecutionEnvironment = getEnvironment>(false, true, false); auto aubCsr = aubExecutionEnvironment->template getCsr>(); - auto allocationsForResidency = aubExecutionEnvironment->executionEnvironment->memoryManager->getResidencyAllocations(); + auto allocationsForResidency = aubCsr->getResidencyAllocations(); LinearStream cs(aubExecutionEnvironment->commandBuffer); BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; @@ -1283,7 +1283,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF auto aubExecutionEnvironment = getEnvironment>(true, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>(); - auto allocationsForResidency = aubExecutionEnvironment->executionEnvironment->memoryManager->getResidencyAllocations(); + auto allocationsForResidency = aubCsr->getResidencyAllocations(); LinearStream cs(aubExecutionEnvironment->commandBuffer); auto mockHelper = new MockFlatBatchBufferHelper(aubCsr->getMemoryManager()); @@ -1314,7 +1314,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF auto aubExecutionEnvironment = getEnvironment>(true, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>(); - auto allocationsForResidency = aubExecutionEnvironment->executionEnvironment->memoryManager->getResidencyAllocations(); + auto allocationsForResidency = aubCsr->getResidencyAllocations(); LinearStream cs(aubExecutionEnvironment->commandBuffer); auto mockHelper = new MockFlatBatchBufferHelper(aubCsr->getMemoryManager()); diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp index a079a66bca..82d60d6ee4 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_tests.cpp @@ -1962,7 +1962,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInNonDirtyStateAndBatching EXPECT_TRUE(mockedSubmissionsAggregator->peekCmdBufferList().peekIsEmpty()); //surfaces are non resident - auto &surfacesForResidency = mockCsr->getMemoryManager()->getResidencyAllocations(); + auto &surfacesForResidency = mockCsr->getResidencyAllocations(); EXPECT_EQ(0u, surfacesForResidency.size()); } @@ -2310,7 +2310,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenRecorded EXPECT_EQ(0, mockCsr->flushCalledCount); - auto &surfacesForResidency = mockCsr->getMemoryManager()->getResidencyAllocations(); + auto &surfacesForResidency = mockCsr->getResidencyAllocations(); EXPECT_EQ(0u, surfacesForResidency.size()); auto &cmdBufferList = mockedSubmissionsAggregator->peekCommandBuffers(); diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index e75905f44f..56d190d2e9 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -245,7 +245,7 @@ TEST_F(CommandStreamReceiverTest, makeResidentPushesAllocationToMemoryManagerRes commandStreamReceiver->makeResident(*graphicsAllocation); - auto &residencyAllocations = memoryManager->getResidencyAllocations(); + auto &residencyAllocations = commandStreamReceiver->getResidencyAllocations(); ASSERT_EQ(1u, residencyAllocations.size()); EXPECT_EQ(graphicsAllocation, residencyAllocations[0]); @@ -254,9 +254,8 @@ TEST_F(CommandStreamReceiverTest, makeResidentPushesAllocationToMemoryManagerRes } TEST_F(CommandStreamReceiverTest, makeResidentWithoutParametersDoesNothing) { - auto *memoryManager = commandStreamReceiver->getMemoryManager(); commandStreamReceiver->processResidency(nullptr, *pDevice->getOsContext()); - auto &residencyAllocations = memoryManager->getResidencyAllocations(); + auto &residencyAllocations = commandStreamReceiver->getResidencyAllocations(); EXPECT_EQ(0u, residencyAllocations.size()); } diff --git a/unit_tests/command_stream/tbx_command_stream_tests.cpp b/unit_tests/command_stream/tbx_command_stream_tests.cpp index d352072ca7..5692502560 100644 --- a/unit_tests/command_stream/tbx_command_stream_tests.cpp +++ b/unit_tests/command_stream/tbx_command_stream_tests.cpp @@ -182,11 +182,11 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsC auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096); ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_EQ(0u, memoryManager->getResidencyAllocations().size()); + EXPECT_EQ(0u, tbxCsr->getResidencyAllocations().size()); tbxCsr->makeResident(*graphicsAllocation); - EXPECT_EQ(1u, memoryManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, tbxCsr->getResidencyAllocations().size()); memoryManager->freeGraphicsMemory(graphicsAllocation); } @@ -199,15 +199,15 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentHas auto graphicsAllocation = memoryManager->allocateGraphicsMemory(4096); ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_EQ(0u, memoryManager->getResidencyAllocations().size()); + EXPECT_EQ(0u, tbxCsr->getResidencyAllocations().size()); tbxCsr->makeResident(*graphicsAllocation); - EXPECT_EQ(1u, memoryManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, tbxCsr->getResidencyAllocations().size()); tbxCsr->makeResident(*graphicsAllocation); - EXPECT_EQ(1u, memoryManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, tbxCsr->getResidencyAllocations().size()); memoryManager->freeGraphicsMemory(graphicsAllocation); } diff --git a/unit_tests/mocks/mock_csr.h b/unit_tests/mocks/mock_csr.h index af8a0a9a10..d120b7f978 100644 --- a/unit_tests/mocks/mock_csr.h +++ b/unit_tests/mocks/mock_csr.h @@ -57,7 +57,7 @@ class MockCsrBase : public UltCommandStreamReceiver { void makeResident(GraphicsAllocation &gfxAllocation) override { madeResidentGfxAllocations.push_back(&gfxAllocation); if (this->getMemoryManager()) { - this->getMemoryManager()->getResidencyAllocations().push_back(&gfxAllocation); + this->getResidencyAllocations().push_back(&gfxAllocation); } gfxAllocation.residencyTaskCount = this->taskCount; } @@ -188,7 +188,7 @@ class MockCsrHw2 : public CommandStreamReceiverHw { if (allocationsForResidency) { copyOfAllocations = *allocationsForResidency; } else { - copyOfAllocations = this->getMemoryManager()->getResidencyAllocations(); + copyOfAllocations = this->getResidencyAllocations(); } flushStamp->setStamp(flushStamp->peekStamp() + 1); return flushStamp->peekStamp(); diff --git a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp index 35892aea4d..8088dc2dd5 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -1640,11 +1640,11 @@ TEST_F(DrmCommandStreamLeaksTest, MakeResidentClearResidencyAllocationsInMemoryM csr->makeResident(*allocation1); csr->makeResident(*allocation2); - EXPECT_NE(0u, mm->getResidencyAllocations().size()); + EXPECT_NE(0u, csr->getResidencyAllocations().size()); csr->processResidency(nullptr, *device->getOsContext()); csr->makeSurfacePackNonResident(nullptr); - EXPECT_EQ(0u, mm->getResidencyAllocations().size()); + EXPECT_EQ(0u, csr->getResidencyAllocations().size()); mm->freeGraphicsMemory(allocation1); mm->freeGraphicsMemory(allocation2); @@ -1658,12 +1658,12 @@ TEST_F(DrmCommandStreamLeaksTest, givenMultipleMakeResidentWhenMakeNonResidentIs csr->makeResident(*allocation1); csr->makeResident(*allocation1); - EXPECT_NE(0u, mm->getResidencyAllocations().size()); + EXPECT_NE(0u, csr->getResidencyAllocations().size()); csr->processResidency(nullptr, *device->getOsContext()); csr->makeSurfacePackNonResident(nullptr); - EXPECT_EQ(0u, mm->getResidencyAllocations().size()); + EXPECT_EQ(0u, csr->getResidencyAllocations().size()); EXPECT_FALSE(allocation1->isResident()); mm->freeGraphicsMemory(allocation1); diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index 4a0a1310dd..cbff8d026e 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -444,8 +444,8 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi linearStreamAllocation->setAllocationType(GraphicsAllocation::AllocationType::LINEAR_STREAM); csr->makeResident(*linearStreamAllocation); - EXPECT_EQ(1u, memManager->getResidencyAllocations().size()); - EXPECT_EQ(linearStreamAllocation, memManager->getResidencyAllocations()[0]); + EXPECT_EQ(1u, csr->getResidencyAllocations().size()); + EXPECT_EQ(linearStreamAllocation, csr->getResidencyAllocations()[0]); wddm->setKmDafEnabled(true); auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &csr->getResidencyAllocations(), *device->getOsContext()); @@ -532,8 +532,8 @@ TEST_F(WddmCommandStreamTest, makeResident) { csr->makeResident(*commandBuffer); EXPECT_EQ(0u, wddm->makeResidentResult.called); - EXPECT_EQ(1u, memManager->getResidencyAllocations().size()); - EXPECT_EQ(commandBuffer, memManager->getResidencyAllocations()[0]); + EXPECT_EQ(1u, csr->getResidencyAllocations().size()); + EXPECT_EQ(commandBuffer, csr->getResidencyAllocations()[0]); memManager->freeGraphicsMemory(commandBuffer); } @@ -599,8 +599,8 @@ TEST_F(WddmCommandStreamTest, makeResidentNonResidentMemObj) { csr->makeResident(*buffer->getGraphicsAllocation()); EXPECT_EQ(0u, wddm->makeResidentResult.called); - EXPECT_EQ(1u, memManager->getResidencyAllocations().size()); - EXPECT_EQ(gfxAllocation, memManager->getResidencyAllocations()[0]); + EXPECT_EQ(1u, csr->getResidencyAllocations().size()); + EXPECT_EQ(gfxAllocation, csr->getResidencyAllocations()[0]); csr->makeNonResident(*buffer->getGraphicsAllocation()); EXPECT_EQ(gfxAllocation, memManager->getEvictionAllocations()[0]); @@ -617,7 +617,7 @@ TEST_F(WddmCommandStreamTest, createAllocationAndMakeResident) { ASSERT_NE(nullptr, gfxAllocation); - EXPECT_EQ(1u, memManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, csr->getResidencyAllocations().size()); EXPECT_EQ(hostPtr, gfxAllocation->getUnderlyingBuffer()); } @@ -632,7 +632,7 @@ TEST_F(WddmCommandStreamTest, givenHostPtrWhenPtrBelowRestrictionThenCreateAlloc ASSERT_NE(nullptr, gfxAllocation); - EXPECT_EQ(1u, memManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, csr->getResidencyAllocations().size()); EXPECT_EQ(hostPtr, gfxAllocation->getUnderlyingBuffer()); EXPECT_EQ(expectedReserve, gfxAllocation->getReservedAddress()); @@ -689,7 +689,7 @@ TEST_F(WddmCommandStreamMockGdiTest, FlushCallsWddmMakeResidentForResidencyAlloc csr->makeResident(*commandBuffer); - EXPECT_EQ(1u, memManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, csr->getResidencyAllocations().size()); gdi->getMakeResidentArg().NumAllocations = 0; @@ -708,7 +708,7 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) { csr->makeResident(*commandBuffer); - EXPECT_EQ(1u, memManager->getResidencyAllocations().size()); + EXPECT_EQ(1u, csr->getResidencyAllocations().size()); EXPECT_EQ(0u, memManager->getEvictionAllocations().size()); EXPECT_EQ(trimListUnusedPosition, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition()); @@ -717,7 +717,7 @@ TEST_F(WddmCommandStreamMockGdiTest, makeResidentClearsResidencyAllocations) { csr->makeSurfacePackNonResident(nullptr); - EXPECT_EQ(0u, memManager->getResidencyAllocations().size()); + EXPECT_EQ(0u, csr->getResidencyAllocations().size()); EXPECT_EQ(0u, memManager->getEvictionAllocations().size()); EXPECT_EQ(0u, ((WddmAllocation *)commandBuffer)->getTrimCandidateListPosition()); diff --git a/unit_tests/program/program_tests.cpp b/unit_tests/program/program_tests.cpp index a18da3d867..b055d6cf09 100644 --- a/unit_tests/program/program_tests.cpp +++ b/unit_tests/program/program_tests.cpp @@ -1317,9 +1317,6 @@ class CommandStreamReceiverMock : public UltCommandStreamReceiver { residency.erase(graphicsAllocation.getUnderlyingBuffer()); CommandStreamReceiver::makeNonResident(graphicsAllocation); } - ResidencyContainer &getResidencyContainer() { - return this->memoryManager->getResidencyAllocations(); - } std::map residency; }; @@ -1364,7 +1361,7 @@ HWTEST_F(PatchTokenTests, givenKernelRequiringConstantAllocationWhenMakeResident pKernel->makeResident(*pCommandStreamReceiver); EXPECT_EQ(2u, pCommandStreamReceiver->residency.size()); - auto &residencyVector = pCommandStreamReceiver->getResidencyContainer(); + auto &residencyVector = pCommandStreamReceiver->getResidencyAllocations(); //we expect kernel ISA here and constant allocation auto kernelIsa = pKernel->getKernelInfo().getGraphicsAllocation();