diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index f21008aa7c..54093faf67 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -96,7 +96,6 @@ CommandStreamReceiver::CommandStreamReceiver(ExecutionEnvironment &executionEnvi auto &compilerProductHelper = rootDeviceEnvironment.getHelper(); this->heaplessModeEnabled = compilerProductHelper.isHeaplessModeEnabled(hwInfo); this->heaplessStateInitEnabled = compilerProductHelper.isHeaplessStateInitEnabled(heaplessModeEnabled); - this->evictionAllocations.reserve(2 * MemoryConstants::kiloByte); } CommandStreamReceiver::~CommandStreamReceiver() { @@ -173,9 +172,7 @@ void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) { gfxAllocation.updateResidencyTaskCount(submissionTaskCount, osContext->getContextId()); } -void CommandStreamReceiver::processEviction() { - this->getEvictionAllocations().clear(); -} +void CommandStreamReceiver::processEviction() {} void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) { if (gfxAllocation.isResident(osContext->getContextId())) { @@ -632,9 +629,6 @@ ResidencyContainer &CommandStreamReceiver::getResidencyAllocations() { return this->residencyAllocations; } -ResidencyContainer &CommandStreamReceiver::getEvictionAllocations() { - return this->evictionAllocations; -} PrivateAllocsToReuseContainer &CommandStreamReceiver::getOwnedPrivateAllocations() { return this->ownedPrivateAllocations; } @@ -1266,9 +1260,7 @@ void CommandStreamReceiver::ensurePrimaryCsrInitialized(Device &device) { csrToInitialize->initializeDeviceWithFirstSubmission(device); } -void CommandStreamReceiver::addToEvictionContainer(GraphicsAllocation &gfxAllocation) { - this->getEvictionAllocations().push_back(&gfxAllocation); -} +void CommandStreamReceiver::addToEvictionContainer(GraphicsAllocation &gfxAllocation) {} std::function CommandStreamReceiver::debugConfirmationFunction = []() { std::cin.get(); }; } // namespace NEO diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index 95073c5266..4ba8aa78f1 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -139,7 +139,6 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { MemoryManager *getMemoryManager() const; ResidencyContainer &getResidencyAllocations(); - ResidencyContainer &getEvictionAllocations(); PrivateAllocsToReuseContainer &getOwnedPrivateAllocations(); virtual GmmPageTableMngr *createPageTableManager() { return nullptr; } @@ -611,7 +610,6 @@ class CommandStreamReceiver : NEO::NonCopyableAndNonMovableClass { std::unique_ptr globalStatelessHeap; ResidencyContainer residencyAllocations; - ResidencyContainer evictionAllocations; PrivateAllocsToReuseContainer ownedPrivateAllocations; MutexType ownershipMutex; diff --git a/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl b/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl index 6387b78c30..bb41b77f00 100644 --- a/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl @@ -93,7 +93,6 @@ template void CommandStreamReceiverSimulatedCommonHw::makeNonResident(GraphicsAllocation &gfxAllocation) { if (gfxAllocation.isResident(osContext->getContextId())) { dumpAllocation(gfxAllocation); - this->getEvictionAllocations().push_back(&gfxAllocation); gfxAllocation.releaseResidencyInOsContext(this->osContext->getContextId()); } } diff --git a/shared/source/command_stream/tbx_command_stream_receiver_hw.h b/shared/source/command_stream/tbx_command_stream_receiver_hw.h index f8e894ea2d..0486d2b2fc 100644 --- a/shared/source/command_stream/tbx_command_stream_receiver_hw.h +++ b/shared/source/command_stream/tbx_command_stream_receiver_hw.h @@ -56,6 +56,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::waitForCompletionWithTimeout(c template void TbxCommandStreamReceiverHw::processEviction() { auto lockCSR = this->obtainUniqueOwnership(); - this->allocationsForDownload.insert(this->getEvictionAllocations().begin(), this->getEvictionAllocations().end()); BaseClass::processEviction(); } +template +void TbxCommandStreamReceiverHw::makeNonResident(GraphicsAllocation &gfxAllocation) { + if (gfxAllocation.isResident(osContext->getContextId())) { + this->allocationsForDownload.insert(&gfxAllocation); + } + BaseClass::makeNonResident(gfxAllocation); +} + template SubmissionStatus TbxCommandStreamReceiverHw::processResidency(ResidencyContainer &allocationsForResidency, uint32_t handleId) { diff --git a/shared/source/os_interface/windows/trim_callback.cpp b/shared/source/os_interface/windows/trim_callback.cpp index 393f0c1d83..b82da8bab0 100644 --- a/shared/source/os_interface/windows/trim_callback.cpp +++ b/shared/source/os_interface/windows/trim_callback.cpp @@ -61,10 +61,9 @@ void WddmResidencyController::trimResidency(const D3DDDI_TRIMRESIDENCYSET_FLAGS uint64_t sizeToTrim = 0; auto lock = this->acquireLock(); WddmAllocation *wddmAllocation = nullptr; - auto &allocations = csr->getEvictionAllocations(); std::vector handlesToEvict; - handlesToEvict.reserve(allocations.size()); - for (auto allocationIter = allocations.begin(); allocationIter != allocations.end();) { + handlesToEvict.reserve(evictionAllocations.size()); + for (auto allocationIter = evictionAllocations.begin(); allocationIter != evictionAllocations.end();) { wddmAllocation = reinterpret_cast(*allocationIter); DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "lastPeriodicTrimFenceValue = ", lastTrimFenceValue); @@ -75,7 +74,7 @@ void WddmResidencyController::trimResidency(const D3DDDI_TRIMRESIDENCYSET_FLAGS } if (wddmAllocation->isAlwaysResident(osContextId)) { - allocationIter = allocations.erase(allocationIter); + allocationIter = evictionAllocations.erase(allocationIter); continue; } @@ -99,7 +98,7 @@ void WddmResidencyController::trimResidency(const D3DDDI_TRIMRESIDENCYSET_FLAGS DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "Evict allocation, gpu address = ", std::hex, wddmAllocation->getGpuAddress(), "lastFence =", wddmAllocation->getResidencyData().getFenceValueForContextId(osContextId)); wddmAllocation->getResidencyData().resident[osContextId] = false; - allocationIter = allocations.erase(allocationIter); + allocationIter = evictionAllocations.erase(allocationIter); } this->wddm.evict(handlesToEvict.data(), static_cast(handlesToEvict.size()), sizeToTrim, false); @@ -126,11 +125,10 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) { WddmAllocation *wddmAllocation = nullptr; perfLogResidencyTrimToBudget(wddm.getResidencyLogger(), bytes, this); - auto &allocations = csr->getEvictionAllocations(); - auto allocationIter = allocations.begin(); + auto allocationIter = evictionAllocations.begin(); std::vector handlesToEvict; - handlesToEvict.reserve(allocations.size()); - while (numberOfBytesToTrim > 0 && allocationIter != allocations.end()) { + handlesToEvict.reserve(evictionAllocations.size()); + while (numberOfBytesToTrim > 0 && allocationIter != evictionAllocations.end()) { wddmAllocation = reinterpret_cast(*allocationIter); uint64_t lastFence = wddmAllocation->getResidencyData().getFenceValueForContextId(osContextId); auto &monitoredFence = this->getMonitoredFence(); @@ -141,7 +139,7 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) { } if (wddmAllocation->isAlwaysResident(osContextId)) { - allocationIter = allocations.erase(allocationIter); + allocationIter = evictionAllocations.erase(allocationIter); continue; } @@ -175,7 +173,7 @@ bool WddmResidencyController::trimResidencyToBudget(uint64_t bytes) { } wddmAllocation->getResidencyData().resident[osContextId] = false; - allocationIter = allocations.erase(allocationIter); + allocationIter = evictionAllocations.erase(allocationIter); } this->wddm.evict(handlesToEvict.data(), static_cast(handlesToEvict.size()), sizeToTrim, true); diff --git a/shared/source/os_interface/windows/wddm_device_command_stream.inl b/shared/source/os_interface/windows/wddm_device_command_stream.inl index 61a8e711d3..06c6fd3de6 100644 --- a/shared/source/os_interface/windows/wddm_device_command_stream.inl +++ b/shared/source/os_interface/windows/wddm_device_command_stream.inl @@ -219,7 +219,7 @@ template void WddmCommandStreamReceiver::addToEvictionContainer(GraphicsAllocation &gfxAllocation) { // Eviction allocations are shared with trim callback thread. auto lock = static_cast(this->osContext)->getResidencyController().acquireLock(); - this->getEvictionAllocations().push_back(&gfxAllocation); + static_cast(this->osContext)->getResidencyController().getEvictionAllocations().push_back(&gfxAllocation); } template diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 7c6b121be2..6f15a575b1 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -736,7 +736,7 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation auto ®isteredEngines = getRegisteredEngines(gfxAllocation->getRootDeviceIndex()); for (auto &engine : registeredEngines) { auto &residencyController = static_cast(engine.osContext)->getResidencyController(); - auto &evictContainer = engine.commandStreamReceiver->getEvictionAllocations(); + auto &evictContainer = residencyController.getEvictionAllocations(); residencyController.removeAllocation(evictContainer, gfxAllocation); } diff --git a/shared/source/os_interface/windows/wddm_residency_controller.cpp b/shared/source/os_interface/windows/wddm_residency_controller.cpp index 1db48839f4..9039a51058 100644 --- a/shared/source/os_interface/windows/wddm_residency_controller.cpp +++ b/shared/source/os_interface/windows/wddm_residency_controller.cpp @@ -17,6 +17,7 @@ namespace NEO { WddmResidencyController::WddmResidencyController(Wddm &wddm, uint32_t osContextId) : wddm(wddm), osContextId(osContextId) { + this->evictionAllocations.reserve(2 * MemoryConstants::kiloByte); } void WddmResidencyController::registerCallback() { diff --git a/shared/source/os_interface/windows/wddm_residency_controller.h b/shared/source/os_interface/windows/wddm_residency_controller.h index 3753a18a82..1b8d51eb47 100644 --- a/shared/source/os_interface/windows/wddm_residency_controller.h +++ b/shared/source/os_interface/windows/wddm_residency_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation + * Copyright (C) 2018-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -58,6 +58,10 @@ class WddmResidencyController { void removeAllocation(ResidencyContainer &container, GraphicsAllocation *gfxAllocation); + ResidencyContainer &getEvictionAllocations() { + return this->evictionAllocations; + } + protected: size_t fillHandlesContainer(ResidencyContainer &allocationsForResidency, bool &requiresBlockingResidencyHandling); @@ -77,6 +81,8 @@ class WddmResidencyController { CommandStreamReceiver *csr = nullptr; + ResidencyContainer evictionAllocations; + ResidencyContainer backupResidencyContainer; // Stores allocations which should be resident std::vector handlesForResidency; // Stores D3DKMT handles of allocations which are not yet resident }; diff --git a/shared/source/page_fault_manager/windows/cpu_page_fault_manager_windows.cpp b/shared/source/page_fault_manager/windows/cpu_page_fault_manager_windows.cpp index 559b4f7054..2440acdd8c 100644 --- a/shared/source/page_fault_manager/windows/cpu_page_fault_manager_windows.cpp +++ b/shared/source/page_fault_manager/windows/cpu_page_fault_manager_windows.cpp @@ -87,7 +87,7 @@ void PageFaultManagerWindows::allowCPUMemoryEvictionImpl(bool evict, void *ptr, auto &residencyController = static_cast(&csr.getOsContext())->getResidencyController(); auto lock = residencyController.acquireLock(); - auto &evictContainer = csr.getEvictionAllocations(); + auto &evictContainer = residencyController.getEvictionAllocations(); auto iter = std::find(evictContainer.begin(), evictContainer.end(), allocData->cpuAllocation); auto allocInEvictionList = iter != evictContainer.end(); if (evict && !allocInEvictionList) { diff --git a/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp b/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp index 94c7e16117..02804c453a 100644 --- a/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp +++ b/shared/test/unit_test/command_stream/aub_command_stream_receiver_1_tests.cpp @@ -222,12 +222,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenGraphicsAllocationWhenMakeResidentC // First makeNonResident marks the allocation as nonresident aubCsr->makeNonResident(*gfxAllocation); EXPECT_FALSE(gfxAllocation->isResident(osContextId)); - EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size()); // Second makeNonResident should have no impact aubCsr->makeNonResident(*gfxAllocation); EXPECT_FALSE(gfxAllocation->isResident(osContextId)); - EXPECT_EQ(1u, aubCsr->getEvictionAllocations().size()); memoryManager->freeGraphicsMemory(gfxAllocation); } diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 20e7da23c0..f8d585a78f 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -353,21 +353,6 @@ HWTEST_F(CommandStreamReceiverTest, WhenCreatingCsrThenFlagsAreSetCorrectly) { EXPECT_EQ(static_cast(-1), csr.latestSentStatelessMocsConfig); } -TEST_F(CommandStreamReceiverTest, givenBaseDownloadAllocationCalledThenDoesNotChangeAnything) { - auto *memoryManager = commandStreamReceiver->getMemoryManager(); - - GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{commandStreamReceiver->getRootDeviceIndex(), MemoryConstants::pageSize}); - - ASSERT_NE(nullptr, graphicsAllocation); - auto numEvictionAllocsBefore = commandStreamReceiver->getEvictionAllocations().size(); - commandStreamReceiver->CommandStreamReceiver::downloadAllocations(true); - auto numEvictionAllocsAfter = commandStreamReceiver->getEvictionAllocations().size(); - EXPECT_EQ(numEvictionAllocsBefore, numEvictionAllocsAfter); - EXPECT_EQ(0u, numEvictionAllocsAfter); - - memoryManager->freeGraphicsMemory(graphicsAllocation); -} - TEST_F(CommandStreamReceiverTest, WhenCommandStreamReceiverIsCreatedThenItHasATagValue) { EXPECT_NE(nullptr, const_cast(commandStreamReceiver->getTagAddress())); } @@ -1925,9 +1910,6 @@ TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesA commandStreamReceiver1.makeNonResident(graphicsAllocation); EXPECT_FALSE(graphicsAllocation.isResident(csr0ContextId)); EXPECT_FALSE(graphicsAllocation.isResident(csr1ContextId)); - - EXPECT_EQ(1u, commandStreamReceiver0.getEvictionAllocations().size()); - EXPECT_EQ(1u, commandStreamReceiver1.getEvictionAllocations().size()); } struct CreateAllocationForHostSurfaceTest : public ::testing::Test { @@ -6181,9 +6163,6 @@ HWTEST_F(CommandStreamReceiverContextGroupTest, givenSecondaryCsrsWhenSameResour commandStreamReceiver1.makeNonResident(graphicsAllocation); EXPECT_FALSE(graphicsAllocation.isResident(csr0ContextId)); EXPECT_FALSE(graphicsAllocation.isResident(csr1ContextId)); - - EXPECT_EQ(1u, commandStreamReceiver0.getEvictionAllocations().size()); - EXPECT_EQ(1u, commandStreamReceiver1.getEvictionAllocations().size()); } HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenEnqueueWaitForPagingFenceCalledThenEnqueueIfPossibleAndReturnCorrectValue) { @@ -6513,7 +6492,6 @@ TEST(CommandStreamReceiverHostFunctionsTest, givenDestructedCommandStreamReceive } TEST(CommandStreamReceiverHostFunctionsTest, givenCommandStreamReceiverWithHostFunctionDataWhenMakeResidentHostFunctionAllocationIsCalledThenHostAllocationIsResident) { - std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get(), 0u)); auto &csr = *device->commandStreamReceivers[0]; ASSERT_EQ(nullptr, csr.getHostFunctionDataAllocation()); @@ -6529,6 +6507,4 @@ TEST(CommandStreamReceiverHostFunctionsTest, givenCommandStreamReceiverWithHostF csr.makeNonResident(*hostDataAllocation); EXPECT_FALSE(hostDataAllocation->isResident(csrContextId)); - - EXPECT_EQ(1u, csr.getEvictionAllocations().size()); } diff --git a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp index 05c921ed4c..c12f135e95 100644 --- a/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_command_stream_tests.cpp @@ -817,7 +817,6 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenMemObjectCallsDrmCsrWhenMa EXPECT_TRUE(makeNonResidentResult.called); EXPECT_EQ(allocation1, makeNonResidentResult.allocation); - EXPECT_EQ(0u, csr->getEvictionAllocations().size()); mm->freeGraphicsMemory(allocation1); } diff --git a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp index 870893f2af..2b63d40954 100644 --- a/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/device_command_stream_tests.cpp @@ -524,14 +524,14 @@ HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenMakingNonResidentThenAllocationIsP csr->makeNonResident(*commandBuffer); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().size()); - csr->getEvictionAllocations().clear(); + static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().clear(); commandBuffer->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, csr->getOsContext().getContextId()); csr->makeNonResident(*commandBuffer); - EXPECT_EQ(0u, csr->getEvictionAllocations().size()); + EXPECT_EQ(0u, static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().size()); memoryManager->freeGraphicsMemory(commandBuffer); } @@ -540,13 +540,13 @@ HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenProcesssingEvictionThenEvictionAll GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), MemoryConstants::pageSize}); ASSERT_NE(nullptr, allocation); - csr->getEvictionAllocations().push_back(allocation); + static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().push_back(allocation); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().size()); csr->processEviction(); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().size()); memoryManager->freeGraphicsMemory(allocation); } @@ -563,7 +563,7 @@ HWTEST_TEMPLATED_F(WddmCommandStreamTest, WhenMakingResidentAndNonResidentThenAl EXPECT_EQ(gfxAllocation, csr->getResidencyAllocations()[0]); csr->makeNonResident(*gfxAllocation); - EXPECT_EQ(gfxAllocation, csr->getEvictionAllocations()[0]); + EXPECT_EQ(gfxAllocation, static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations()[0]); memoryManager->freeGraphicsMemory(gfxAllocation); } @@ -716,14 +716,14 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, WhenMakingResidentThenResidency csr->makeResident(*commandBuffer); EXPECT_EQ(1u, csr->getResidencyAllocations().size()); - EXPECT_EQ(0u, csr->getEvictionAllocations().size()); + EXPECT_EQ(0u, static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().size()); csr->processResidency(csr->getResidencyAllocations(), 0u); csr->makeSurfacePackNonResident(csr->getResidencyAllocations(), true); EXPECT_EQ(0u, csr->getResidencyAllocations().size()); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().size()); memoryManager->freeGraphicsMemory(commandBuffer); } @@ -819,8 +819,8 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenRecordedCommandBufferWhenI for (auto &alloc : evictAllocs) { // If eviction is required then allocation should be added to container - auto iter = std::find(csr->getEvictionAllocations().begin(), csr->getEvictionAllocations().end(), alloc.gfxAlloc); - EXPECT_EQ(alloc.expectEviction, iter != csr->getEvictionAllocations().end()); + auto iter = std::find(static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().begin(), static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().end(), alloc.gfxAlloc); + EXPECT_EQ(alloc.expectEviction, iter != static_cast(csr->getOsContext()).getResidencyController().getEvictionAllocations().end()); } memoryManager->freeGraphicsMemory(dshAlloc); @@ -1043,7 +1043,6 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnB auto mockCsr = static_cast *>(csr); OsContextWin bcsOsContext(*wddm, 0, 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular})); - bcsOsContext.ensureContextInitialized(false); mockCsr->setupContext(bcsOsContext); debugManager.flags.EnableDirectSubmission.set(1); @@ -1061,6 +1060,8 @@ HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenDirectSubmissionEnabledOnB csr->flushMonitorFence(false); EXPECT_EQ(directSubmission->flushMonitorFenceCalled, 1u); mockCsr->blitterDirectSubmission.reset(); + + device.reset(); } HWTEST_TEMPLATED_F(WddmCommandStreamMockGdiTest, givenLastSubmittedFenceLowerThanFenceValueToWaitWhenWaitFromCpuThenFlushMonitorFenceWithNotifyEnabledFlag) { diff --git a/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp index 8fb2af0931..f3b21b0f2a 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_residency_controller_tests.cpp @@ -283,15 +283,15 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenNotUsedAllocationsFromPreviousPe wddm->evictResult.called = 0; wddm->callBaseEvict = true; - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation2); residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim); // Single evict called EXPECT_EQ(1u, wddm->evictResult.called); EXPECT_EQ(1u, gdi->getEvictArg().Flags.EvictOnlyIfNecessary); - EXPECT_TRUE(csr->getEvictionAllocations().empty()); + EXPECT_TRUE(residencyController->getEvictionAllocations().empty()); // marked nonresident EXPECT_FALSE(allocation1.getResidencyData().resident[osContextId]); EXPECT_FALSE(allocation2.getResidencyData().resident[osContextId]); @@ -318,14 +318,14 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenOneUsedAllocationFromPreviousPer wddm->evictResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation2); residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim); // 1 allocation evicted EXPECT_EQ(1u, wddm->evictResult.called); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, residencyController->getEvictionAllocations().size()); // marked nonresident EXPECT_FALSE(allocation1.getResidencyData().resident[osContextId]); @@ -374,7 +374,7 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, givenTripleAllocation wddm->evictResult.called = 0; wddm->callBaseEvict = true; - csr->getEvictionAllocations().push_back(allocationTriple); + residencyController->getEvictionAllocations().push_back(allocationTriple); residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim); @@ -449,18 +449,18 @@ TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenAllDoneAlloca wddm->evictResult.called = 0; wddm->callBaseEvict = true; - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(&allocation2); - csr->getEvictionAllocations().push_back(&allocation3); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation3); residencyController->trimResidencyToBudget(3 * 4096); EXPECT_EQ(1u, wddm->evictResult.called); EXPECT_EQ(0u, gdi->getEvictArg().Flags.EvictOnlyIfNecessary); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, residencyController->getEvictionAllocations().size()); - auto iter = std::find(csr->getEvictionAllocations().begin(), csr->getEvictionAllocations().end(), &allocation3); - EXPECT_NE(iter, csr->getEvictionAllocations().end()); + auto iter = std::find(residencyController->getEvictionAllocations().begin(), residencyController->getEvictionAllocations().end(), &allocation3); + EXPECT_NE(iter, residencyController->getEvictionAllocations().end()); } TEST_F(WddmResidencyControllerWithGdiTest, GivenNumBytesToTrimIsNotZeroWhenTrimmingToBudgetThenFalseIsReturned) { @@ -476,12 +476,12 @@ TEST_F(WddmResidencyControllerWithGdiTest, GivenNumBytesToTrimIsNotZeroWhenTrimm wddm->evictResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation1); bool status = residencyController->trimResidencyToBudget(3 * 4096); EXPECT_EQ(1u, wddm->evictResult.called); - EXPECT_TRUE(csr->getEvictionAllocations().empty()); + EXPECT_TRUE(residencyController->getEvictionAllocations().empty()); EXPECT_FALSE(status); } @@ -509,17 +509,17 @@ TEST_F(WddmResidencyControllerWithGdiTest, GivenNumBytesToTrimIsZeroWhenTrimming wddm->evictResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(&allocation2); - csr->getEvictionAllocations().push_back(&allocation3); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation3); bool status = residencyController->trimResidencyToBudget(3 * 4096); EXPECT_TRUE(status); EXPECT_EQ(1u, wddm->evictResult.called); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); - auto iter = std::find(csr->getEvictionAllocations().begin(), csr->getEvictionAllocations().end(), &allocation3); - EXPECT_NE(iter, csr->getEvictionAllocations().end()); + EXPECT_EQ(1u, residencyController->getEvictionAllocations().size()); + auto iter = std::find(residencyController->getEvictionAllocations().begin(), residencyController->getEvictionAllocations().end(), &allocation3); + EXPECT_NE(iter, residencyController->getEvictionAllocations().end()); } TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenEvictedAllocationIsMarkedNonResident) { @@ -544,9 +544,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, WhenTrimmingToBudgetThenEvictedAlloca wddm->evictResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(&allocation2); - csr->getEvictionAllocations().push_back(&allocation3); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation3); residencyController->trimResidencyToBudget(3 * 4096); @@ -569,7 +569,7 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenAlwaysResidentAllocationWhenTrim wddm->evictResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation); + residencyController->getEvictionAllocations().push_back(&allocation); allocation.updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, osContextId); residencyController->trimResidencyToBudget(3 * 4096); @@ -591,7 +591,7 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenAlwaysResidentAllocationWhenTrim wddm->evictResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation); + residencyController->getEvictionAllocations().push_back(&allocation); allocation.updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, osContextId); D3DKMT_TRIMNOTIFICATION trimNotification = {0}; @@ -617,7 +617,7 @@ TEST_F(WddmResidencyControllerWithGdiTest, GivenLastFenceIsGreaterThanMonitoredW wddm->evictResult.called = 0; wddm->waitFromCpuResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation1); gdi->getWaitFromCpuArg().hDevice = 0; residencyController->trimResidencyToBudget(3 * 4096); @@ -661,9 +661,9 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, WhenTrimmingToBudgetT // This should not be evicted allocationTriple->fragmentsStorage.fragmentStorageData[1].residency->updateCompletionData(2, osContextId); - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(allocationTriple); - csr->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(allocationTriple); + residencyController->getEvictionAllocations().push_back(&allocation2); *residencyController->getMonitoredFence().cpuAddress = 1; residencyController->getMonitoredFence().lastSubmittedFence = 1; @@ -716,9 +716,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenThreeAllocationsAlignedSizeBigge wddm->evictResult.called = 0; - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(&allocation2); - csr->getEvictionAllocations().push_back(&allocation3); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation3); bool status = residencyController->trimResidencyToBudget(budget); EXPECT_TRUE(status); @@ -948,7 +948,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB allocationToTrim.getResidencyData().updateCompletionData(residencyController->getMonitoredFence().lastSubmittedFence, osContextId); allocationToTrim.getResidencyData().resident[osContextId] = true; - csr->getEvictionAllocations().push_back(&allocationToTrim); + residencyController->getEvictionAllocations().push_back(&allocationToTrim); wddm->makeResidentNumberOfBytesToTrim = allocationSize; wddm->makeResidentResults = {false, true}; @@ -961,7 +961,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB EXPECT_TRUE(allocation1.getResidencyData().resident[osContextId]); EXPECT_FALSE(allocationToTrim.getResidencyData().resident[osContextId]); EXPECT_EQ(2u, wddm->makeResidentResult.called); - EXPECT_EQ(0u, csr->getEvictionAllocations().size()); + EXPECT_EQ(0u, residencyController->getEvictionAllocations().size()); } TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToBudgetSucceedsWhenCallingMakeResidentWithTrimmedAllocationThenSucceed) { @@ -974,7 +974,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB allocationAlreadyResident.getResidencyData().updateCompletionData(residencyController->getMonitoredFence().lastSubmittedFence, osContextId); allocationAlreadyResident.getResidencyData().resident[osContextId] = true; - csr->getEvictionAllocations().push_back(&allocationAlreadyResident); + residencyController->getEvictionAllocations().push_back(&allocationAlreadyResident); wddm->makeResidentNumberOfBytesToTrim = allocationSize; wddm->makeResidentResults = {false, true}; @@ -987,7 +987,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB EXPECT_TRUE(allocation1.getResidencyData().resident[osContextId]); EXPECT_TRUE(allocationAlreadyResident.getResidencyData().resident[osContextId]); EXPECT_EQ(2u, wddm->makeResidentResult.called); - EXPECT_EQ(0u, csr->getEvictionAllocations().size()); + EXPECT_EQ(0u, residencyController->getEvictionAllocations().size()); EXPECT_EQ(2u, residencyPack.size()); } @@ -1128,9 +1128,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, GivenResidencyLoggingEnabledWhenTrimm wddm->evictResult.called = 0; wddm->callBaseEvict = true; - csr->getEvictionAllocations().push_back(&allocation1); - csr->getEvictionAllocations().push_back(&allocation2); - csr->getEvictionAllocations().push_back(&allocation3); + residencyController->getEvictionAllocations().push_back(&allocation1); + residencyController->getEvictionAllocations().push_back(&allocation2); + residencyController->getEvictionAllocations().push_back(&allocation3); constexpr uint64_t trimBudgetSize = 3 * 4096; residencyController->trimResidencyToBudget(trimBudgetSize); diff --git a/shared/test/unit_test/page_fault_manager/windows/cpu_page_fault_manager_windows_tests.cpp b/shared/test/unit_test/page_fault_manager/windows/cpu_page_fault_manager_windows_tests.cpp index f7b68488d5..531760e665 100644 --- a/shared/test/unit_test/page_fault_manager/windows/cpu_page_fault_manager_windows_tests.cpp +++ b/shared/test/unit_test/page_fault_manager/windows/cpu_page_fault_manager_windows_tests.cpp @@ -145,15 +145,15 @@ TEST_F(PageFaultManagerTest, void *cmdQ = reinterpret_cast(0xFFFF); pageFaultManager->insertAllocation(ptr, 10, unifiedMemoryManager.get(), cmdQ, {}); - EXPECT_EQ(0u, csr->getEvictionAllocations().size()); + EXPECT_EQ(0u, osContext->getResidencyController().getEvictionAllocations().size()); pageFaultManager->allowCPUMemoryEvictionImpl(true, ptr, *csr, &osInterface); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, osContext->getResidencyController().getEvictionAllocations().size()); pageFaultManager->allowCPUMemoryEvictionImpl(true, ptr, *csr, &osInterface); - EXPECT_EQ(1u, csr->getEvictionAllocations().size()); + EXPECT_EQ(1u, osContext->getResidencyController().getEvictionAllocations().size()); pageFaultManager->allowCPUMemoryEvictionImpl(false, ptr, *csr, &osInterface); - EXPECT_EQ(0u, csr->getEvictionAllocations().size()); + EXPECT_EQ(0u, osContext->getResidencyController().getEvictionAllocations().size()); unifiedMemoryManager->freeSVMAlloc(ptr); }