diff --git a/level_zero/core/source/cmdqueue/cmdqueue.cpp b/level_zero/core/source/cmdqueue/cmdqueue.cpp index 214d144bd9..923ed079e2 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue.cpp +++ b/level_zero/core/source/cmdqueue/cmdqueue.cpp @@ -196,7 +196,7 @@ CommandQueue *CommandQueue::create(uint32_t productFamily, Device *device, NEO:: osContext.setUmdPowerHintValue(driverHandleImp->powerHint); osContext.reInitializeContext(); } - osContext.ensureContextInitialized(); + csr->initializeResources(); csr->initDirectSubmission(); csr->registerClient(); return commandQueue; diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 4bf788286c..e129989e30 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -195,7 +195,7 @@ void CommandQueue::initializeGpgpuInternals() const { } } - gpgpuEngine->osContext->ensureContextInitialized(); + gpgpuEngine->commandStreamReceiver->initializeResources(); gpgpuEngine->commandStreamReceiver->initDirectSubmission(); if (getCmdQueueProperties(propertiesVector.data(), CL_QUEUE_PROPERTIES) & static_cast(CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) && !this->gpgpuEngine->commandStreamReceiver->isUpdateTagFromWaitEnabled()) { @@ -340,7 +340,7 @@ void CommandQueue::constructBcsEnginesForSplit() { bcsEngines[i] = neoDevice.tryGetEngine(engineType, EngineUsage::Regular); bcsEngineTypes.push_back(engineType); if (bcsEngines[i]) { - bcsEngines[i]->osContext->ensureContextInitialized(); + bcsEngines[i]->commandStreamReceiver->initializeResources(); bcsEngines[i]->commandStreamReceiver->initDirectSubmission(); } } diff --git a/opencl/test/unit_test/command_queue/command_queue_hw_2_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_hw_2_tests.cpp index 237e4a77dc..5295c1d572 100644 --- a/opencl/test/unit_test/command_queue/command_queue_hw_2_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_hw_2_tests.cpp @@ -365,18 +365,18 @@ HWTEST_F(IoqCommandQueueHwBlitTest, givenSplitBcsCopyWhenEnqueueReadThenEnqueueB memoryManager->returnFakeAllocation = true; auto cmdQHw = std::make_unique>(context, pClDevice, nullptr); - auto csr1 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); std::unique_ptr osContext1(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS1, EngineUsage::Regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield()))); + auto csr1 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); csr1->setupContext(*osContext1); csr1->initializeTagAllocation(); EngineControl control1(csr1.get(), osContext1.get()); - auto csr2 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); std::unique_ptr osContext2(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS3, EngineUsage::Regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield()))); + auto csr2 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); csr2->setupContext(*osContext2); csr2->initializeTagAllocation(); EngineControl control2(csr2.get(), osContext2.get()); @@ -415,18 +415,18 @@ HWTEST_F(IoqCommandQueueHwBlitTest, givenSplitBcsCopyWhenEnqueueBlockingReadThen memoryManager->returnFakeAllocation = true; auto cmdQHw = static_cast *>(this->pCmdQ); - auto csr1 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); std::unique_ptr osContext1(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS1, EngineUsage::Regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield()))); + auto csr1 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); csr1->setupContext(*osContext1); csr1->initializeTagAllocation(); EngineControl control1(csr1.get(), osContext1.get()); - auto csr2 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); std::unique_ptr osContext2(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS3, EngineUsage::Regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield()))); + auto csr2 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); csr2->setupContext(*osContext2); csr2->initializeTagAllocation(); EngineControl control2(csr2.get(), osContext2.get()); @@ -464,18 +464,18 @@ HWTEST_F(IoqCommandQueueHwBlitTest, givenSplitBcsCopyWhenEnqueueReadWithEventThe memoryManager->returnFakeAllocation = true; auto cmdQHw = static_cast *>(this->pCmdQ); - auto csr1 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); std::unique_ptr osContext1(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS1, EngineUsage::Regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield()))); + auto csr1 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); csr1->setupContext(*osContext1); csr1->initializeTagAllocation(); EngineControl control1(csr1.get(), osContext1.get()); - auto csr2 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); std::unique_ptr osContext2(OsContext::create(pDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->osInterface.get(), 0, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS3, EngineUsage::Regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield()))); + auto csr2 = std::make_unique>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); csr2->setupContext(*osContext2); csr2->initializeTagAllocation(); EngineControl control2(csr2.get(), osContext2.get()); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp index 0ee5c19120..15e2fcf3c7 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp @@ -324,9 +324,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCommandStr auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); configureCSRtoNonDirtyState(false); - + auto currlockCounter = commandStreamReceiver.recursiveLockCounter.load(); commandStreamReceiver.registerInstructionCacheFlush(); - EXPECT_EQ(1u, commandStreamReceiver.recursiveLockCounter); + EXPECT_EQ(currlockCounter + 1, commandStreamReceiver.recursiveLockCounter); flushTask(commandStreamReceiver); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp index 6291537200..83746b8848 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_hw_1_tests.cpp @@ -1002,7 +1002,7 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC uint32_t newTaskCount = 19; csr.taskCount = newTaskCount - 1; - uint32_t expectedResursiveLockCount = 0u; + uint32_t expectedResursiveLockCount = csr.resourcesInitialized ? 1u : 0u; EXPECT_EQ(expectedResursiveLockCount, csr.recursiveLockCounter.load()); auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::HostPtrToBuffer, csr, buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex()), nullptr, hostPtr, @@ -1013,12 +1013,16 @@ HWTEST_F(BcsTests, givenBltSizeWithLeftoverWhenDispatchedThenProgramAllRequiredC } EXPECT_EQ(expectedResursiveLockCount, csr.recursiveLockCounter.load()); + bool areResourcesInitialized = csr.resourcesInitialized; flushBcsTask(&csr, blitProperties, true, *pDevice); EXPECT_EQ(newTaskCount, csr.taskCount); EXPECT_EQ(newTaskCount, csr.latestFlushedTaskCount); EXPECT_EQ(newTaskCount, csr.latestSentTaskCount); EXPECT_EQ(newTaskCount, csr.latestSentTaskCountValueDuringFlush); expectedResursiveLockCount++; + if (areResourcesInitialized != csr.resourcesInitialized) { + expectedResursiveLockCount++; + } EXPECT_EQ(expectedResursiveLockCount, csr.recursiveLockCounter.load()); HardwareParse hwParser; diff --git a/opencl/test/unit_test/event/event_tests.cpp b/opencl/test/unit_test/event/event_tests.cpp index 4534e58d22..884aa7a123 100644 --- a/opencl/test/unit_test/event/event_tests.cpp +++ b/opencl/test/unit_test/event/event_tests.cpp @@ -1197,7 +1197,7 @@ HWTEST_F(EventTest, givenVirtualEventWhenCommandSubmittedThenLockCsrOccurs) { virtualEvent->submitCommand(false); - uint32_t expectedLockCounter = pDevice->getDefaultEngine().commandStreamReceiver->getClearColorAllocation() ? 3u : 2u; + uint32_t expectedLockCounter = pDevice->getDefaultEngine().commandStreamReceiver->getClearColorAllocation() ? 4u : 3u; EXPECT_EQ(expectedLockCounter, pDevice->getUltCommandStreamReceiver().recursiveLockCounter); } @@ -1212,10 +1212,10 @@ HWTEST_F(EventTest, givenVirtualEventWhenSubmitCommandEventNotReadyAndEventWitho }; auto virtualEvent = makeReleaseable(pCmdQ, CL_COMMAND_NDRANGE_KERNEL, CompletionStamp::notReady, CompletionStamp::notReady); - + auto currLockCounter = pDevice->getUltCommandStreamReceiver().recursiveLockCounter.load(); virtualEvent->submitCommand(false); - EXPECT_EQ(pDevice->getUltCommandStreamReceiver().recursiveLockCounter, 1u); + EXPECT_EQ(pDevice->getUltCommandStreamReceiver().recursiveLockCounter, currLockCounter + 1); } HWTEST_F(InternalsEventTest, GivenBufferWithoutZeroCopyWhenMappingOrUnmappingThenFlushPreviousTasksBeforeMappingOrUnmapping) { diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 1128d70b76..989325bb0f 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -238,13 +238,24 @@ void CommandStreamReceiver::fillReusableAllocationsList() { auto amountToFill = HwHelper::get(peekHwInfo().platform.eRenderCoreFamily).getAmountOfAllocationsToFill(); for (auto i = 0u; i < amountToFill; i++) { const AllocationProperties commandStreamAllocationProperties{rootDeviceIndex, true, MemoryConstants::pageSize64k, AllocationType::COMMAND_BUFFER, - isMultiOsContextCapable(), false, osContext->getDeviceBitfield()}; + isMultiOsContextCapable(), false, deviceBitfield}; auto allocation = this->getMemoryManager()->allocateGraphicsMemoryWithProperties(commandStreamAllocationProperties); getInternalAllocationStorage()->storeAllocation(std::unique_ptr(allocation), REUSABLE_ALLOCATION); this->makeResident(*allocation); } } +void CommandStreamReceiver::initializeResources() { + if (!resourcesInitialized) { + auto lock = obtainUniqueOwnership(); + if (!resourcesInitialized) { + osContext->ensureContextInitialized(); + this->fillReusableAllocationsList(); + this->resourcesInitialized = true; + } + } +} + MemoryManager *CommandStreamReceiver::getMemoryManager() const { DEBUG_BREAK_IF(!executionEnvironment.memoryManager); return executionEnvironment.memoryManager.get(); diff --git a/shared/source/command_stream/command_stream_receiver.h b/shared/source/command_stream/command_stream_receiver.h index 2ccb902da8..dcb5b020e1 100644 --- a/shared/source/command_stream/command_stream_receiver.h +++ b/shared/source/command_stream/command_stream_receiver.h @@ -214,7 +214,7 @@ class CommandStreamReceiver { virtual void fillReusableAllocationsList(); virtual void setupContext(OsContext &osContext) { this->osContext = &osContext; } OsContext &getOsContext() const { return *osContext; } - + void initializeResources(); TagAllocatorBase *getEventTsAllocator(); TagAllocatorBase *getEventPerfCountAllocator(const uint32_t tagSize); virtual TagAllocatorBase *getTimestampPacketAllocator() = 0; @@ -500,6 +500,7 @@ class CommandStreamReceiver { bool useNotifyEnableForPostSync = false; bool dcFlushSupport = false; bool forceSkipResourceCleanupRequired = false; + volatile bool resourcesInitialized = false; }; typedef CommandStreamReceiver *(*CommandStreamReceiverCreateFunc)(bool withAubDump, diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index 7d15265956..07b035ea67 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -1074,7 +1074,7 @@ uint32_t CommandStreamReceiverHw::flushBcsTask(const BlitPropertiesCo auto newTaskCount = taskCount + 1; latestSentTaskCount = newTaskCount; - getOsContext().ensureContextInitialized(); + this->initializeResources(); this->initDirectSubmission(); const auto &hwInfo = this->peekHwInfo(); diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index ef9595aad1..b8a9117d1a 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -349,10 +349,10 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa EngineDescriptor engineDescriptor(engineTypeUsage, getDeviceBitfield(), preemptionMode, false, createAsEngineInstanced); auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(commandStreamReceiver.get(), engineDescriptor); - if (osContext->isImmediateContextInitializationEnabled(isDefaultEngine)) { - osContext->ensureContextInitialized(); - } commandStreamReceiver->setupContext(*osContext); + if (osContext->isImmediateContextInitializationEnabled(isDefaultEngine)) { + commandStreamReceiver->initializeResources(); + } if (!commandStreamReceiver->initializeTagAllocation()) { return false; @@ -383,7 +383,6 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa if (engineUsage == EngineUsage::Regular) { addEngineToEngineGroup(engine); } - commandStreamReceiver->fillReusableAllocationsList(); commandStreamReceivers.push_back(std::move(commandStreamReceiver)); return true; diff --git a/shared/source/device/root_device.cpp b/shared/source/device/root_device.cpp index 6ec1816e3b..47de8c8e19 100644 --- a/shared/source/device/root_device.cpp +++ b/shared/source/device/root_device.cpp @@ -62,8 +62,8 @@ void RootDevice::initializeRootCommandStreamReceiver() { auto osContext = getMemoryManager()->createAndRegisterOsContext(rootCommandStreamReceiver.get(), engineDescriptor); - osContext->ensureContextInitialized(); rootCommandStreamReceiver->setupContext(*osContext); + rootCommandStreamReceiver->initializeResources(); rootCommandStreamReceiver->initializeTagAllocation(); rootCommandStreamReceiver->createGlobalFenceAllocation(); rootCommandStreamReceiver->createWorkPartitionAllocation(*this); diff --git a/shared/source/helpers/blit_commands_helper.cpp b/shared/source/helpers/blit_commands_helper.cpp index bed1320063..ea6d3c0bc7 100644 --- a/shared/source/helpers/blit_commands_helper.cpp +++ b/shared/source/helpers/blit_commands_helper.cpp @@ -200,7 +200,7 @@ BlitOperationResult BlitHelper::blitMemoryToAllocationBanks(const Device &device return BlitOperationResult::Unsupported; } - bcsEngine->osContext->ensureContextInitialized(); + bcsEngine->commandStreamReceiver->initializeResources(); bcsEngine->commandStreamReceiver->initDirectSubmission(); BlitPropertiesContainer blitPropertiesContainer; blitPropertiesContainer.push_back( diff --git a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp index f4147ef4f0..2afab6d11c 100644 --- a/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp +++ b/shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp @@ -28,7 +28,7 @@ DrmMemoryOperationsHandlerBind::~DrmMemoryOperationsHandlerBind() = default; MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResident(Device *device, ArrayRef gfxAllocations) { auto &engines = device->getAllEngines(); for (const auto &engine : engines) { - engine.osContext->ensureContextInitialized(); + engine.commandStreamReceiver->initializeResources(); this->makeResidentWithinOsContext(engine.osContext, gfxAllocations, false); } return MemoryOperationsStatus::SUCCESS; diff --git a/shared/test/common/libult/ult_command_stream_receiver.h b/shared/test/common/libult/ult_command_stream_receiver.h index 93e6d8c6e2..8c5fbc11c5 100644 --- a/shared/test/common/libult/ult_command_stream_receiver.h +++ b/shared/test/common/libult/ult_command_stream_receiver.h @@ -117,6 +117,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw, publ using BaseClass::CommandStreamReceiver::profilingTimeStampAllocator; using BaseClass::CommandStreamReceiver::requiredPrivateScratchSize; using BaseClass::CommandStreamReceiver::requiredScratchSize; + using BaseClass::CommandStreamReceiver::resourcesInitialized; using BaseClass::CommandStreamReceiver::samplerCacheFlushRequired; using BaseClass::CommandStreamReceiver::scratchSpaceController; using BaseClass::CommandStreamReceiver::stallingCommandsOnNextFlushRequired; diff --git a/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h b/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h index 849090068c..cea5f667e5 100644 --- a/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h +++ b/shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h @@ -93,6 +93,10 @@ class TestedDrmCommandStreamReceiver : public DrmCommandStreamReceiver 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 fcada5a302..9602be5bfa 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 @@ -88,12 +88,15 @@ HWTEST_F(CommandStreamReceiverTest, WhenCreatingCsrThenDefaultValuesAreSet) { EXPECT_FALSE(csr.isPreambleSent); } -HWTEST_F(CommandStreamReceiverTest, WhenCreatingCsrThenCallFillReusableAllocationsList) { - auto engineType = pDevice->allEngines[0].getEngineType(); - pDevice->createEngine(0, {engineType, EngineUsage::Regular}); - auto csrIndex = pDevice->commandStreamReceivers.size() - 1; - auto csr = reinterpret_cast *>(pDevice->commandStreamReceivers[csrIndex].get()); - EXPECT_EQ(1u, csr->fillReusableAllocationsListCalled); +HWTEST_F(CommandStreamReceiverTest, WhenInitializeResourcesThenCallFillReusableAllocationsListOnce) { + auto &ultCsr = pDevice->getUltCommandStreamReceiver(); + ultCsr.fillReusableAllocationsListCalled = 0u; + ultCsr.resourcesInitialized = false; + + commandStreamReceiver->initializeResources(); + EXPECT_EQ(1u, pDevice->getUltCommandStreamReceiver().fillReusableAllocationsListCalled); + commandStreamReceiver->initializeResources(); + EXPECT_EQ(1u, pDevice->getUltCommandStreamReceiver().fillReusableAllocationsListCalled); } HWTEST_F(CommandStreamReceiverTest, givenCsrWhenCallFillReusableAllocationsListThenAllocateCommandBufferAndMakeItResident) { diff --git a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp index fb2dbcc4e3..af4cd15473 100644 --- a/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp +++ b/shared/test/unit_test/command_stream/tbx_command_stream_tests.cpp @@ -108,11 +108,11 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentIsC auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pCommandStreamReceiver->getRootDeviceIndex(), MemoryConstants::pageSize}); ASSERT_NE(nullptr, graphicsAllocation); - EXPECT_EQ(0u, tbxCsr->getResidencyAllocations().size()); + auto currResidencyAllocationsSize = tbxCsr->getResidencyAllocations().size(); tbxCsr->makeResident(*graphicsAllocation); - EXPECT_EQ(1u, tbxCsr->getResidencyAllocations().size()); + EXPECT_EQ(currResidencyAllocationsSize + 1, tbxCsr->getResidencyAllocations().size()); memoryManager->freeGraphicsMemory(graphicsAllocation); } @@ -144,16 +144,15 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenMakeResidentHas auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pCommandStreamReceiver->getRootDeviceIndex(), MemoryConstants::pageSize}); ASSERT_NE(nullptr, graphicsAllocation); - - EXPECT_EQ(0u, tbxCsr->getResidencyAllocations().size()); + auto currResidencyAllocationsSize = tbxCsr->getResidencyAllocations().size(); tbxCsr->makeResident(*graphicsAllocation); - EXPECT_EQ(1u, tbxCsr->getResidencyAllocations().size()); + EXPECT_EQ(currResidencyAllocationsSize + 1, tbxCsr->getResidencyAllocations().size()); tbxCsr->makeResident(*graphicsAllocation); - EXPECT_EQ(1u, tbxCsr->getResidencyAllocations().size()); + EXPECT_EQ(currResidencyAllocationsSize + 1, tbxCsr->getResidencyAllocations().size()); memoryManager->freeGraphicsMemory(graphicsAllocation); } 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 7361d4d824..ea073b2046 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 @@ -61,6 +61,7 @@ class WddmCommandStreamFixture { void setUp() { HardwareInfo *hwInfo = nullptr; DebugManager.flags.CsrDispatchMode.set(static_cast(DispatchMode::ImmediateDispatch)); + DebugManager.flags.SetAmountOfReusableAllocations.set(0); auto executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1); memoryManager = new MockWddmMemoryManager(*executionEnvironment); @@ -109,6 +110,10 @@ struct MockWddmCsr : public WddmCommandStreamReceiver { recordedCommandBuffer = std::unique_ptr(new CommandBuffer(device)); } + void fillReusableAllocationsList() override { + fillReusableAllocationsListCalled++; + } + bool initDirectSubmission() override { if (callParentInitDirectSubmission) { return WddmCommandStreamReceiver::initDirectSubmission(); @@ -134,6 +139,7 @@ struct MockWddmCsr : public WddmCommandStreamReceiver { bool callParentInitDirectSubmission = true; bool initBlitterDirectSubmission = false; + uint32_t fillReusableAllocationsListCalled = 0; }; class WddmCommandStreamMockGdiTest : public ::testing::Test {