From 6dd07bd3bc4de08f647f7f5e89b66754f36734ed Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Wed, 1 Jul 2020 14:03:46 +0200 Subject: [PATCH] Use correct Heap32 index for local memory allocations Change-Id: I068f712ab2b05ee3d5a9716b21de685a7fee3a02 Signed-off-by: Bartosz Dunajski --- .../core/source/cmdqueue/cmdqueue_hw_base.inl | 2 +- .../sources/cmdqueue/test_cmdqueue.cpp | 6 +++--- .../os_agnostic_memory_manager.cpp | 5 +++-- .../os_agnostic_memory_manager.h | 2 +- .../enqueue_copy_buffer_rect_tests.cpp | 4 ++-- .../enqueue_copy_buffer_tests.cpp | 2 +- .../enqueue_copy_buffer_to_image_tests.cpp | 2 +- .../enqueue_copy_image_tests.cpp | 2 +- .../enqueue_copy_image_to_buffer_tests.cpp | 2 +- .../enqueue_fill_buffer_tests.cpp | 2 +- .../enqueue_fill_image_tests.cpp | 2 +- .../command_queue/enqueue_kernel_2_tests.cpp | 6 +++--- .../enqueue_read_buffer_rect_tests.cpp | 2 +- .../enqueue_read_buffer_tests.cpp | 2 +- .../enqueue_read_image_tests.cpp | 2 +- .../enqueue_write_buffer_rect_tests.cpp | 2 +- .../enqueue_write_buffer_tests.cpp | 2 +- .../enqueue_write_image_tests.cpp | 2 +- ...and_stream_receiver_flush_task_1_tests.cpp | 2 +- ...and_stream_receiver_flush_task_2_tests.cpp | 4 ++-- .../memory_manager/memory_manager_tests.cpp | 16 +++++++++++---- .../mocks/linux/mock_drm_memory_manager.cpp | 3 ++- .../unit_test/mocks/mock_memory_manager.cpp | 7 ++++--- .../unit_test/mocks/mock_memory_manager.h | 4 ++-- .../linux/drm_memory_manager_tests.cpp | 12 +++++------ .../windows/mock_wddm_memory_manager.h | 3 ++- .../windows/wddm_memory_manager_tests.cpp | 20 +++++++++---------- .../unit_test/program/kernel_info_tests.cpp | 2 +- .../test/unit_test/program/program_tests.cpp | 2 +- .../source/command_container/cmdcontainer.cpp | 2 +- .../command_stream_receiver_hw_base.inl | 5 +++-- .../memory_manager/graphics_allocation.h | 2 ++ .../source/memory_manager/memory_manager.cpp | 6 +++--- shared/source/memory_manager/memory_manager.h | 9 ++++++--- .../os_interface/linux/drm_memory_manager.cpp | 6 +++--- .../os_interface/linux/drm_memory_manager.h | 2 +- ...ry_manager_allocate_in_device_pool_dg1.cpp | 2 +- .../windows/wddm_memory_manager.cpp | 7 ++++--- .../windows/wddm_memory_manager.h | 2 +- .../command_container_tests.cpp | 9 ++++++--- 40 files changed, 99 insertions(+), 77 deletions(-) diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl index d88bfd844b..91f7db4978 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw_base.inl @@ -53,7 +53,7 @@ void CommandQueueHw::programGeneralStateBaseAddress(uint64_t gsba gsba, true, (device->getMOCS(true, false) >> 1), - neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex()), + neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), false), true, neoDevice->getGmmHelper(), false); diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp index 74138f1125..e8f643135a 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp @@ -124,7 +124,7 @@ using CommandQueueSBASupport = IsWithinProducts struct MockMemoryManagerCommandQueueSBA : public MemoryManagerMock { MockMemoryManagerCommandQueueSBA(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast(executionEnvironment)) {} - MOCK_METHOD1(getInternalHeapBaseAddress, uint64_t(uint32_t rootDeviceIndex)); + MOCK_METHOD2(getInternalHeapBaseAddress, uint64_t(uint32_t rootDeviceIndex, bool useLocalMemory)); }; struct CommandQueueProgramSBATest : public ::testing::Test { @@ -169,7 +169,7 @@ HWTEST2_F(CommandQueueProgramSBATest, whenCreatingCommandQueueThenItIsInitialize uint32_t alignedSize = 4096u; NEO::LinearStream child(commandQueue->commandStream->getSpace(alignedSize), alignedSize); - EXPECT_CALL(*memoryManager, getInternalHeapBaseAddress(rootDeviceIndex)) + EXPECT_CALL(*memoryManager, getInternalHeapBaseAddress(rootDeviceIndex, false)) .Times(1); commandQueue->programGeneralStateBaseAddress(0u, child); @@ -346,4 +346,4 @@ HWTEST_F(CommandQueueIndirectAllocations, givenCommandQueueWhenExecutingCommandL } } // namespace ult -} // namespace L0 \ No newline at end of file +} // namespace L0 diff --git a/opencl/source/memory_manager/os_agnostic_memory_manager.cpp b/opencl/source/memory_manager/os_agnostic_memory_manager.cpp index bfdb77eecb..a948143d4d 100644 --- a/opencl/source/memory_manager/os_agnostic_memory_manager.cpp +++ b/opencl/source/memory_manager/os_agnostic_memory_manager.cpp @@ -102,8 +102,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const Al return memoryAllocation; } -GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) { - auto heap = useInternal32BitAllocator(allocationData.type) ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL; +GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) { + auto heap = useInternal32BitAllocator(allocationData.type) ? selectInternalHeap(useLocalMemory) + : selectExternalHeap(useLocalMemory); auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex); if (allocationData.hostPtr) { auto allocationSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size); diff --git a/opencl/source/memory_manager/os_agnostic_memory_manager.h b/opencl/source/memory_manager/os_agnostic_memory_manager.h index ae9cfea91a..eb44122aca 100644 --- a/opencl/source/memory_manager/os_agnostic_memory_manager.h +++ b/opencl/source/memory_manager/os_agnostic_memory_manager.h @@ -89,7 +89,7 @@ class OsAgnosticMemoryManager : public MemoryManager { void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override { return graphicsAllocation.getUnderlyingBuffer(); } void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override {} - GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override; + GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override; GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override; MemoryAllocation *createMemoryAllocation(GraphicsAllocation::AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, uint64_t count, MemoryPool::Type pool, uint32_t rootDeviceIndex, bool uncacheable, bool flushL3Required, bool requireSpecificBitness); diff --git a/opencl/test/unit_test/command_queue/enqueue_copy_buffer_rect_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_copy_buffer_rect_tests.cpp index 92c1419e7a..23bad2a597 100644 --- a/opencl/test/unit_test/command_queue/enqueue_copy_buffer_rect_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_copy_buffer_rect_tests.cpp @@ -222,7 +222,7 @@ HWTEST_F(EnqueueCopyBufferRectTest, WhenCopyingBufferRect2DThenL3ProgrammingIsCo HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferRectTest, When2DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueCopyBufferRect2D(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } @@ -342,7 +342,7 @@ HWTEST_F(EnqueueCopyBufferRectTest, WhenCopyingBufferRect3DThenL3ProgrammingIsCo HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferRectTest, When3DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueCopyBufferRect3D(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_copy_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_copy_buffer_tests.cpp index bc06234ae3..43e36a3fdc 100644 --- a/opencl/test/unit_test/command_queue/enqueue_copy_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_copy_buffer_tests.cpp @@ -190,7 +190,7 @@ HWTEST_F(EnqueueCopyBufferTest, WhenCopyingBufferThenL3ProgrammingIsCorrect) { HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueCopyBufferAndParse(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_copy_buffer_to_image_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_copy_buffer_to_image_tests.cpp index 659a50049c..1364f35018 100644 --- a/opencl/test/unit_test/command_queue/enqueue_copy_buffer_to_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_copy_buffer_to_image_tests.cpp @@ -96,7 +96,7 @@ HWTEST_F(EnqueueCopyBufferToImageTest, WhenCopyingBufferToImageThenL3Programming HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyBufferToImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueCopyBufferToImage(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_copy_image_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_copy_image_tests.cpp index 532e831e50..65940b687d 100644 --- a/opencl/test/unit_test/command_queue/enqueue_copy_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_copy_image_tests.cpp @@ -98,7 +98,7 @@ HWTEST_F(EnqueueCopyImageTest, WhenCopyingImageThenL3ProgrammingIsCorrect) { HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueCopyImage(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_copy_image_to_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_copy_image_to_buffer_tests.cpp index 2b66456498..c0b09807ea 100644 --- a/opencl/test/unit_test/command_queue/enqueue_copy_image_to_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_copy_image_to_buffer_tests.cpp @@ -97,7 +97,7 @@ HWTEST_F(EnqueueCopyImageToBufferTest, WhenCopyingImageToBufferThenL3Programming HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueCopyImageToBufferTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueCopyImageToBuffer(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_fill_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_fill_buffer_tests.cpp index 1e68a55873..b325cc4d6e 100644 --- a/opencl/test/unit_test/command_queue/enqueue_fill_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_fill_buffer_tests.cpp @@ -209,7 +209,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenL3ProgrammingIsCorrect) HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillBufferCmdTests, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueFillBuffer(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_fill_image_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_fill_image_tests.cpp index 3331aaaac9..052176d745 100644 --- a/opencl/test/unit_test/command_queue/enqueue_fill_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_fill_image_tests.cpp @@ -105,7 +105,7 @@ HWTEST_F(EnqueueFillImageTest, WhenFillingImageThenL3ProgrammingIsCorrect) { HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueFillImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueFillImage(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp index d4957f004f..b6fd63afc3 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_2_tests.cpp @@ -186,9 +186,9 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueWorkItemTestsWithLimitedParamSet, LoadRegiste HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueWorkItemTestsWithLimitedParamSet, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueKernel(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, - context->getMemoryManager()->peekForce32BitAllocations() ? context->getMemoryManager()->getExternalHeapBaseAddress(ultCsr.rootDeviceIndex) : 0llu); + context->getMemoryManager()->peekForce32BitAllocations() ? context->getMemoryManager()->getExternalHeapBaseAddress(ultCsr.rootDeviceIndex, false) : 0llu); } HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueWorkItemTestsWithLimitedParamSet, MediaInterfaceDescriptorLoad) { @@ -510,7 +510,7 @@ HWCMDTEST_P(IGFX_GEN8_CORE, EnqueueKernelWithScratch, givenDeviceForcing32bitAll auto GSHaddress = sba->getGeneralStateBaseAddress(); - EXPECT_EQ(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex()), GSHaddress); + EXPECT_EQ(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), graphicsAllocation->isAllocatedInLocalMemoryPool()), GSHaddress); //now re-try to see if SBA is not programmed diff --git a/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp index 29bd45e99d..416ea73bdb 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_buffer_rect_tests.cpp @@ -208,7 +208,7 @@ HWTEST_F(EnqueueReadBufferRectTest, WhenReadingBufferThenL3ProgrammingIsCorrect) HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadBufferRectTest, When2DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueReadBufferRect2D(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp index e1f3a8f1d8..f11bcaaa00 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp @@ -172,7 +172,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadBufferTypeTest, WhenEnqueueIsDoneThenStat srcBuffer->forceDisallowCPUCopy = true; enqueueReadBuffer(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp index 46447f89af..c327a11ae0 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp @@ -108,7 +108,7 @@ HWTEST_F(EnqueueReadImageTest, WhenReadingImageThenL3ProgrammingIsCorrect) { HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueReadImage(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp index 2a3dc545c3..9dba1fb143 100644 --- a/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_write_buffer_rect_tests.cpp @@ -182,7 +182,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, WhenWritingBufferThenL3ProgrammingIsCorrect HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueWriteBufferRectTest, When2DEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueWriteBufferRect2D(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp index 841cc54508..87f948400e 100644 --- a/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_write_buffer_tests.cpp @@ -170,7 +170,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueWriteBufferTypeTest, WhenEnqueueIsDoneThenSta srcBuffer->forceDisallowCPUCopy = true; enqueueWriteBuffer(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } diff --git a/opencl/test/unit_test/command_queue/enqueue_write_image_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_write_image_tests.cpp index fc0337ea90..7dcb436341 100644 --- a/opencl/test/unit_test/command_queue/enqueue_write_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_write_image_tests.cpp @@ -108,7 +108,7 @@ HWTEST_F(EnqueueWriteImageTest, WhenWritingImageThenL3ProgrammingIsCorrect) { HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueWriteImageTest, WhenEnqueueIsDoneThenStateBaseAddressIsProperlyProgrammed) { enqueueWriteImage(); auto &ultCsr = this->pDevice->getUltCommandStreamReceiver(); - validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex), + validateStateBaseAddress(ultCsr.getMemoryManager()->getInternalHeapBaseAddress(ultCsr.rootDeviceIndex, pIOH->getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), pDSH, pIOH, pSSH, itorPipelineSelect, itorWalker, cmdList, 0llu); } 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 781df67e38..9aedf052de 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 @@ -457,7 +457,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, stateBaseAddressProgrammingShouldM auto &cmd = *reinterpret_cast(cmdStateBaseAddress); EXPECT_EQ(dsh.getCpuBase(), reinterpret_cast(cmd.getDynamicStateBaseAddress())); - EXPECT_EQ(commandStreamReceiver.getMemoryManager()->getInternalHeapBaseAddress(commandStreamReceiver.rootDeviceIndex), cmd.getInstructionBaseAddress()); + EXPECT_EQ(commandStreamReceiver.getMemoryManager()->getInternalHeapBaseAddress(commandStreamReceiver.rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), cmd.getInstructionBaseAddress()); EXPECT_EQ(ioh.getCpuBase(), reinterpret_cast(cmd.getIndirectObjectBaseAddress())); EXPECT_EQ(ssh.getCpuBase(), reinterpret_cast(cmd.getSurfaceStateBaseAddress())); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp index a9ab5c594b..4b117b2645 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -638,7 +638,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu } if (sharedDeviceInfo.force32BitAddressess) { - EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex()), GSHaddress); + EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex(), false), GSHaddress); } else { if (is64bit) { EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress); @@ -752,7 +752,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNDRangeKer EXPECT_EQ(highPartGraphicsAddress, scratchBaseHighPart); if (sharedDeviceInfo.force32BitAddressess) { - EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex()), GSHaddress); + EXPECT_EQ(pDevice->getMemoryManager()->getExternalHeapBaseAddress(graphicsAllocationScratch->getRootDeviceIndex(), false), GSHaddress); } else { if (is64bit) { EXPECT_EQ(graphicsAddress - ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, GSHaddress); diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index 3bc4b497ce..bbe6528487 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -76,6 +76,14 @@ TEST(MemoryManagerTest, givenDebugVariableWhenCreatingMemoryManagerThenSetSuppor } } +TEST(MemoryManagerTest, givenLocalMemoryRequiredWhenSelectingHeapThenPickDeviceHeapIndex) { + EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectInternalHeap(true)); + EXPECT_EQ(HeapIndex::HEAP_INTERNAL, MemoryManager::selectInternalHeap(false)); + + EXPECT_EQ(HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY, MemoryManager::selectExternalHeap(true)); + EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectExternalHeap(false)); +} + TEST(MemoryManagerTest, whenCreatingAllocPropertiesForMultiStorageResourceThenMultiStorageResourcesFlagIsSetToTrue) { AllocationProperties properties{0, false, 0u, GraphicsAllocation::AllocationType::SCRATCH_SURFACE, false, true, 0}; EXPECT_TRUE(properties.multiStorageResource); @@ -649,7 +657,7 @@ TEST(OsAgnosticMemoryManager, givenMemoryManagerWhenAskedFor32BitAllocationWhenL auto gfxAllocation = memoryManager.allocateGraphicsMemoryWithAlignment(allocationData); ASSERT_NE(gfxAllocation, nullptr); EXPECT_NE(gfxAllocation->getGpuBaseAddress(), 0ull); - EXPECT_EQ(gfxAllocation->getGpuBaseAddress(), memoryManager.getExternalHeapBaseAddress(gfxAllocation->getRootDeviceIndex())); + EXPECT_EQ(gfxAllocation->getGpuBaseAddress(), memoryManager.getExternalHeapBaseAddress(gfxAllocation->getRootDeviceIndex(), gfxAllocation->isAllocatedInLocalMemoryPool())); memoryManager.freeGraphicsMemory(gfxAllocation); } @@ -2029,19 +2037,19 @@ TEST(MemoryManagerTest, givenForcedLinearImages3DImageAndProperDescriptorValuesW TEST(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; allocation.set32BitAllocation(true); - EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectHeap(&allocation, false, false)); + EXPECT_EQ(MemoryManager::selectInternalHeap(allocation.isAllocatedInLocalMemoryPool()), MemoryManager::selectHeap(&allocation, false, false)); } TEST(HeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; allocation.set32BitAllocation(false); - EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectHeap(&allocation, false, false)); + EXPECT_EQ(MemoryManager::selectInternalHeap(allocation.isAllocatedInLocalMemoryPool()), MemoryManager::selectHeap(&allocation, false, false)); } TEST(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; allocation.set32BitAllocation(true); - EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectHeap(&allocation, false, false)); + EXPECT_EQ(MemoryManager::selectExternalHeap(allocation.isAllocatedInLocalMemoryPool()), MemoryManager::selectHeap(&allocation, false, false)); } TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenStandardHeapIsUsed) { diff --git a/opencl/test/unit_test/mocks/linux/mock_drm_memory_manager.cpp b/opencl/test/unit_test/mocks/linux/mock_drm_memory_manager.cpp index 1f9f62f468..c3cab52e77 100644 --- a/opencl/test/unit_test/mocks/linux/mock_drm_memory_manager.cpp +++ b/opencl/test/unit_test/mocks/linux/mock_drm_memory_manager.cpp @@ -69,7 +69,8 @@ DrmAllocation *TestedDrmMemoryManager::allocate32BitGraphicsMemory(uint32_t root AllocationData allocationData; MockAllocationProperties properties(rootDeviceIndex, allocateMemory, size, allocationType); getAllocationData(allocationData, properties, ptr, createStorageInfoFromProperties(properties)); - return allocate32BitGraphicsMemoryImpl(allocationData); + bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex]; + return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory); } TestedDrmMemoryManager::~TestedDrmMemoryManager() { DrmMemoryManager::commonCleanup(); diff --git a/opencl/test/unit_test/mocks/mock_memory_manager.cpp b/opencl/test/unit_test/mocks/mock_memory_manager.cpp index 34a4862731..0f9685409b 100644 --- a/opencl/test/unit_test/mocks/mock_memory_manager.cpp +++ b/opencl/test/unit_test/mocks/mock_memory_manager.cpp @@ -102,14 +102,15 @@ GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemory(uint32_t root AllocationData allocationData{}; MockAllocationProperties properties(rootDeviceIndex, allocateMemory, size, allocationType); getAllocationData(allocationData, properties, ptr, createStorageInfoFromProperties(properties)); - return allocate32BitGraphicsMemoryImpl(allocationData); + bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex]; + return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory); } -GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) { +GraphicsAllocation *MockMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) { if (failAllocate32Bit) { return nullptr; } - return OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(allocationData); + return OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory); } FailMemoryManager::FailMemoryManager(int32_t failedAllocationsCount, ExecutionEnvironment &executionEnvironment) : MockMemoryManager(executionEnvironment) { diff --git a/opencl/test/unit_test/mocks/mock_memory_manager.h b/opencl/test/unit_test/mocks/mock_memory_manager.h index 3dcf0aa23e..9e94465054 100644 --- a/opencl/test/unit_test/mocks/mock_memory_manager.h +++ b/opencl/test/unit_test/mocks/mock_memory_manager.h @@ -107,7 +107,7 @@ class MockMemoryManager : public MemoryManagerCreate { bool isCpuCopyRequired(const void *ptr) override { return cpuCopyRequired; } GraphicsAllocation *allocate32BitGraphicsMemory(uint32_t rootDeviceIndex, size_t size, const void *ptr, GraphicsAllocation::AllocationType allocationType); - GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override; + GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override; void forceLimitedRangeAllocator(uint32_t rootDeviceIndex, uint64_t range) { getGfxPartition(rootDeviceIndex)->init(range, 0, 0, gfxPartitions.size()); } @@ -186,7 +186,7 @@ class FailMemoryManager : public MockMemoryManager { GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties, const void *ptr) override { return nullptr; } - GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override { + GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override { return nullptr; } GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness) override { diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index e6a495fad7..176f3e3877 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -926,7 +926,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32 EXPECT_LT(address64bit, MemoryConstants::max32BitAddress); EXPECT_TRUE(allocation->is32BitAllocation()); - EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(allocation->getRootDeviceIndex())), allocation->getGpuBaseAddress()); + EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), allocation->isAllocatedInLocalMemoryPool())), allocation->getGpuBaseAddress()); memoryManager->freeGraphicsMemory(allocation); } @@ -2029,7 +2029,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBi auto drmAllocation = static_cast(graphicsAllocation); EXPECT_TRUE(graphicsAllocation->is32BitAllocation()); EXPECT_EQ(1, lseekCalledCount); - EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex())), drmAllocation->getGpuBaseAddress()); + EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())), drmAllocation->getGpuBaseAddress()); memoryManager->freeGraphicsMemory(graphicsAllocation); } @@ -2482,7 +2482,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit auto gpuPtr = drmAllocation->getGpuAddress(); - auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex())); + auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())); auto heapSize = 4 * GB; EXPECT_GE(gpuPtr, heapBase); @@ -2515,7 +2515,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc auto gpuPtr = drmAllocation->getGpuAddress(); - auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex())); + auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())); auto heapSize = 4 * GB; EXPECT_GE(gpuPtr, heapBase); @@ -2572,7 +2572,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit auto gpuPtr = drmAllocation->getGpuAddress(); - auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex())); + auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())); auto heapSize = 4 * GB; EXPECT_GE(gpuPtr, heapBase); @@ -2689,7 +2689,7 @@ TEST_F(DrmMemoryManagerBasic, givenDefaultDrmMemoryManagerWhenItIsQueriedForInte true, executionEnvironment)); auto heapBase = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY); - EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(rootDeviceIndex)); + EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, true)); } TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWithEnabledHostMemoryValidationWhenFeatureIsQueriedThenTrueIsReturned) { diff --git a/opencl/test/unit_test/os_interface/windows/mock_wddm_memory_manager.h b/opencl/test/unit_test/os_interface/windows/mock_wddm_memory_manager.h index c3f55d9385..acadf26789 100644 --- a/opencl/test/unit_test/os_interface/windows/mock_wddm_memory_manager.h +++ b/opencl/test/unit_test/os_interface/windows/mock_wddm_memory_manager.h @@ -52,7 +52,8 @@ class MockWddmMemoryManager : public MemoryManagerCreate { AllocationData allocationData; MockAllocationProperties properties(rootDeviceIndex, allocateMemory, size, allocationType); getAllocationData(allocationData, properties, ptr, createStorageInfoFromProperties(properties)); - return allocate32BitGraphicsMemoryImpl(allocationData); + bool useLocalMemory = !allocationData.flags.useSystemMemory && this->localMemorySupported[rootDeviceIndex]; + return allocate32BitGraphicsMemoryImpl(allocationData, useLocalMemory); } void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) override { diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index e801eedf7a..7a96b01bfa 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -122,7 +122,7 @@ TEST(WddmMemoryManagerExternalHeapTest, WhenExternalHeapIsCreatedThenItHasCorrec std::unique_ptr memoryManager = std::unique_ptr(new WddmMemoryManager(*executionEnvironment)); - EXPECT_EQ(base, memoryManager->getExternalHeapBaseAddress(0)); + EXPECT_EQ(base, memoryManager->getExternalHeapBaseAddress(0, false)); } TEST(WddmMemoryManagerWithDeferredDeleterTest, givenWmmWhenAsyncDeleterIsEnabledAndWaitForDeletionsIsCalledThenDeleterInWddmIsSetToNullptr) { @@ -566,7 +566,7 @@ TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndRequireSpecificBitness if (is64bit) { EXPECT_TRUE(gpuAllocation->is32BitAllocation()); - uint64_t base = memoryManager->getExternalHeapBaseAddress(gpuAllocation->getRootDeviceIndex()); + uint64_t base = memoryManager->getExternalHeapBaseAddress(gpuAllocation->getRootDeviceIndex(), gpuAllocation->isAllocatedInLocalMemoryPool()); EXPECT_EQ(GmmHelper::canonize(base), gpuAllocation->getGpuBaseAddress()); } @@ -970,7 +970,7 @@ TEST_F(WddmMemoryManagerTest, WhenAllocating32BitMemoryThenGpuBaseAddressIsCanno ASSERT_NE(nullptr, gpuAllocation); - uint64_t cannonizedAddress = GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)); + uint64_t cannonizedAddress = GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(MemoryManager::selectExternalHeap(gpuAllocation->isAllocatedInLocalMemoryPool()))); EXPECT_EQ(cannonizedAddress, gpuAllocation->getGpuBaseAddress()); memoryManager->freeGraphicsMemory(gpuAllocation); @@ -1087,12 +1087,12 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) { auto wddmAllocation = static_cast(memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, MemoryConstants::pageSize, nullptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP)); ASSERT_NE(nullptr, wddmAllocation); - EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex()))); + EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex(), wddmAllocation->isAllocatedInLocalMemoryPool()))); EXPECT_NE(nullptr, wddmAllocation->getUnderlyingBuffer()); EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize()); EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress()); - auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex)); - auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)); + auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool())); + auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool()))); EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd); @@ -1106,12 +1106,12 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe auto ptr = reinterpret_cast(0x1000000); auto wddmAllocation = static_cast(memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, MemoryConstants::pageSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP)); ASSERT_NE(nullptr, wddmAllocation); - EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex))); + EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool()))); EXPECT_EQ(ptr, wddmAllocation->getUnderlyingBuffer()); EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize()); EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress()); - auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex)); - auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)); + auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool())); + auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool()))); EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd); @@ -1386,7 +1386,7 @@ TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForI wddm->init(); MockWddmMemoryManager memoryManager(*executionEnvironment); auto heapBase = wddm->getGfxPartition().Heap32[static_cast(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base; - EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress(0)); + EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress(0, true)); } TEST_F(MockWddmMemoryManagerTest, givenValidateAllocationFunctionWhenItIsCalledWithTripleAllocationThenSuccessIsReturned) { diff --git a/opencl/test/unit_test/program/kernel_info_tests.cpp b/opencl/test/unit_test/program/kernel_info_tests.cpp index 7e8eb12d68..ff2054efd0 100644 --- a/opencl/test/unit_test/program/kernel_info_tests.cpp +++ b/opencl/test/unit_test/program/kernel_info_tests.cpp @@ -128,7 +128,7 @@ TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationThenCopyWholeKerne class MyMemoryManager : public OsAgnosticMemoryManager { public: using OsAgnosticMemoryManager::OsAgnosticMemoryManager; - GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override { return nullptr; } + GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override { return nullptr; } }; TEST(KernelInfoTest, givenKernelInfoWhenCreateKernelAllocationAndCannotAllocateMemoryThenReturnsFalse) { diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 60a04a2afa..80c70d3a8d 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -652,7 +652,7 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi EXPECT_NE(kernelInfo->heapInfo.pKernelHeap, kernelIsa); EXPECT_EQ(0, memcmp(kernelIsa, kernelInfo->heapInfo.pKernelHeap, kernelInfo->heapInfo.KernelHeapSize)); auto rootDeviceIndex = graphicsAllocation->getRootDeviceIndex(); - EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pProgram->getDevice().getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex)); + EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pProgram->getDevice().getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, graphicsAllocation->isAllocatedInLocalMemoryPool())); } TEST_P(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffersAreFreed) { diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index 78694ba93d..8afc001ab8 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -82,7 +82,7 @@ bool CommandContainer::initialize(Device *device) { indirectHeaps[i] = std::make_unique(allocationIndirectHeaps[i], requireInternalHeap); } - instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex()); + instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), allocationIndirectHeaps[IndirectHeap::Type::INDIRECT_OBJECT]->isAllocatedInLocalMemoryPool()); iddBlock = nullptr; nextIddInBlock = this->getNumIddPerBlock(); 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 dd1d2a8055..35e7798459 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -350,7 +350,8 @@ CompletionStamp CommandStreamReceiverHw::flushTask( if (is64bit && scratchSpaceController->getScratchSpaceAllocation() && !force32BitAllocations) { newGSHbase = scratchSpaceController->calculateNewGSH(); } else if (is64bit && force32BitAllocations && dispatchFlags.gsba32BitRequired) { - newGSHbase = getMemoryManager()->getExternalHeapBaseAddress(rootDeviceIndex); + bool useLocalMemory = scratchSpaceController->getScratchSpaceAllocation() ? scratchSpaceController->getScratchSpaceAllocation()->isAllocatedInLocalMemoryPool() : false; + newGSHbase = getMemoryManager()->getExternalHeapBaseAddress(rootDeviceIndex, useLocalMemory); GSBAFor32BitProgrammed = true; } @@ -364,7 +365,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( newGSHbase, true, mocsIndex, - getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex), + getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()), true, device.getGmmHelper(), isMultiOsContextCapable()); diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index c896cbf248..252582555f 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -233,6 +233,8 @@ class GraphicsAllocation : public IDNode { uint32_t getUsedPageSize() const; + bool isAllocatedInLocalMemoryPool() const { return (this->memoryPool == MemoryPool::LocalMemory); } + OsHandleStorage fragmentsStorage; StorageInfo storageInfo = {}; diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 118918cfc1..577aaebdd0 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -401,7 +401,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData & } if (useInternal32BitAllocator(allocationData.type) || (force32bitAllocations && allocationData.flags.allow32Bit && is64bit)) { - return allocate32BitGraphicsMemoryImpl(allocationData); + return allocate32BitGraphicsMemoryImpl(allocationData, false); } if (allocationData.hostPtr) { return allocateGraphicsMemoryWithHostPtr(allocationData); @@ -480,10 +480,10 @@ void MemoryManager::unlockResource(GraphicsAllocation *graphicsAllocation) { HeapIndex MemoryManager::selectHeap(const GraphicsAllocation *allocation, bool hasPointer, bool isFullRangeSVM) { if (allocation) { if (useInternal32BitAllocator(allocation->getAllocationType())) { - return HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY; + return selectInternalHeap(allocation->isAllocatedInLocalMemoryPool()); } if (allocation->is32BitAllocation()) { - return HeapIndex::HEAP_EXTERNAL; + return selectExternalHeap(allocation->isAllocatedInLocalMemoryPool()); } } if (isFullRangeSVM) { diff --git a/shared/source/memory_manager/memory_manager.h b/shared/source/memory_manager/memory_manager.h index 9153c297a1..995170d5bc 100644 --- a/shared/source/memory_manager/memory_manager.h +++ b/shared/source/memory_manager/memory_manager.h @@ -98,8 +98,8 @@ class MemoryManager { virtual uint64_t getLocalMemorySize(uint32_t rootDeviceIndex) = 0; uint64_t getMaxApplicationAddress() { return is64bit ? MemoryConstants::max64BitAppAddress : MemoryConstants::max32BitAppAddress; }; - MOCKABLE_VIRTUAL uint64_t getInternalHeapBaseAddress(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY); } - uint64_t getExternalHeapBaseAddress(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTERNAL); } + MOCKABLE_VIRTUAL uint64_t getInternalHeapBaseAddress(uint32_t rootDeviceIndex, bool useLocalMemory) { return getGfxPartition(rootDeviceIndex)->getHeapBase(selectInternalHeap(useLocalMemory)); } + uint64_t getExternalHeapBaseAddress(uint32_t rootDeviceIndex, bool useLocalMemory) { return getGfxPartition(rootDeviceIndex)->getHeapBase(selectExternalHeap(useLocalMemory)); } bool isLimitedRange(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->isLimitedRange(); } @@ -162,6 +162,8 @@ class MemoryManager { virtual void releaseReservedCpuAddressRange(void *reserved, size_t size, uint32_t rootDeviceIndex){}; void *getReservedMemory(size_t size, size_t alignment); GfxPartition *getGfxPartition(uint32_t rootDeviceIndex) { return gfxPartitions.at(rootDeviceIndex).get(); } + static HeapIndex selectInternalHeap(bool useLocalMemory) { return useLocalMemory ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_INTERNAL; } + static HeapIndex selectExternalHeap(bool useLocalMemory) { return useLocalMemory ? HeapIndex::HEAP_EXTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL; } static uint32_t maxOsContextCount; virtual void commonCleanup(){}; @@ -174,6 +176,7 @@ class MemoryManager { return allocationType == GraphicsAllocation::AllocationType::KERNEL_ISA || allocationType == GraphicsAllocation::AllocationType::INTERNAL_HEAP; } + static bool isCopyRequired(ImageInfo &imgInfo, const void *hostPtr); bool useNonSvmHostPtrAlloc(GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex); @@ -185,7 +188,7 @@ class MemoryManager { virtual GraphicsAllocation *allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData); virtual GraphicsAllocation *allocateGraphicsMemoryWithAlignment(const AllocationData &allocationData) = 0; virtual GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) = 0; - virtual GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) = 0; + virtual GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) = 0; virtual GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) = 0; GraphicsAllocation *allocateGraphicsMemoryForImageFromHostPtr(const AllocationData &allocationData); MOCKABLE_VIRTUAL GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData); diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 1ef3a104cf..6077ac700f 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -357,9 +357,9 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A return allocation; } -DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) { +DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) { auto internal = useInternal32BitAllocator(allocationData.type); - auto allocatorToUse = internal ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL; + auto allocatorToUse = internal ? selectInternalHeap(useLocalMemory) : selectExternalHeap(useLocalMemory); if (allocationData.hostPtr) { uintptr_t inputPtr = reinterpret_cast(allocationData.hostPtr); @@ -490,7 +490,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o if (requireSpecificBitness && this->force32bitAllocations) { drmAllocation->set32BitAllocation(true); - drmAllocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex))); + drmAllocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex, drmAllocation->isAllocatedInLocalMemoryPool()))); } if (properties.imgInfo) { diff --git a/shared/source/os_interface/linux/drm_memory_manager.h b/shared/source/os_interface/linux/drm_memory_manager.h index 5e70160c24..7cdb2f51b9 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.h +++ b/shared/source/os_interface/linux/drm_memory_manager.h @@ -81,7 +81,7 @@ class DrmMemoryManager : public MemoryManager { MOCKABLE_VIRTUAL void *lockResourceInLocalMemoryImpl(BufferObject *bo); MOCKABLE_VIRTUAL void unlockResourceInLocalMemoryImpl(BufferObject *bo); void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override; - DrmAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override; + DrmAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override; GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override; Drm &getDrm(uint32_t rootDeviceIndex) const; diff --git a/shared/source/os_interface/linux/drm_memory_manager_allocate_in_device_pool_dg1.cpp b/shared/source/os_interface/linux/drm_memory_manager_allocate_in_device_pool_dg1.cpp index 293fe60ceb..31263c9837 100644 --- a/shared/source/os_interface/linux/drm_memory_manager_allocate_in_device_pool_dg1.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager_allocate_in_device_pool_dg1.cpp @@ -170,7 +170,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A allocation->setCpuPtrAndGpuAddress(cpuAddress, gpuAddress); } if (useInternal32BitAllocator(allocationData.type)) { - allocation->setGpuBaseAddress(GmmHelper::canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex))); + allocation->setGpuBaseAddress(GmmHelper::canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex, true))); } status = AllocationStatus::Success; diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 10288790da..cc56b9bc78 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -250,7 +250,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A return MemoryManager::allocateGraphicsMemoryWithHostPtr(allocationData); } -GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) { +GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) { Gmm *gmm = nullptr; const void *ptrAligned = nullptr; size_t sizeAligned = allocationData.size; @@ -285,7 +285,8 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All return nullptr; } - auto baseAddress = useInternal32BitAllocator(allocationData.type) ? getInternalHeapBaseAddress(allocationData.rootDeviceIndex) : getExternalHeapBaseAddress(allocationData.rootDeviceIndex); + auto baseAddress = useInternal32BitAllocator(allocationData.type) ? getInternalHeapBaseAddress(allocationData.rootDeviceIndex, useLocalMemory) + : getExternalHeapBaseAddress(allocationData.rootDeviceIndex, useLocalMemory); wddmAllocation->setGpuBaseAddress(GmmHelper::canonize(baseAddress)); return wddmAllocation.release(); @@ -313,7 +314,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl allocation->setReservedAddressRange(ptr, size); } else if (requireSpecificBitness && this->force32bitAllocations) { allocation->set32BitAllocation(true); - allocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex()))); + allocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false))); } status = mapGpuVirtualAddress(allocation.get(), allocation->getReservedAddressPtr()); DEBUG_BREAK_IF(!status); diff --git a/shared/source/os_interface/windows/wddm_memory_manager.h b/shared/source/os_interface/windows/wddm_memory_manager.h index 57a561abe0..8746eb7eed 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.h +++ b/shared/source/os_interface/windows/wddm_memory_manager.h @@ -73,7 +73,7 @@ class WddmMemoryManager : public MemoryManager { void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override; void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override; void freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) override; - GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override; + GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData, bool useLocalMemory) override; GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override; MOCKABLE_VIRTUAL size_t getHugeGfxMemoryChunkSize() const { return 4 * MemoryConstants::gigaByte - MemoryConstants::pageSize64k; } diff --git a/shared/test/unit_test/command_container/command_container_tests.cpp b/shared/test/unit_test/command_container/command_container_tests.cpp index 1ce53bc334..abd005e241 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -114,7 +114,8 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIs auto heapAllocation = cmdContainer.getIndirectHeapAllocation(static_cast(i)); EXPECT_EQ(indirectHeap->getGraphicsAllocation(), heapAllocation); } - EXPECT_EQ(cmdContainer.getInstructionHeapBaseAddress(), pDevice->getMemoryManager()->getInternalHeapBaseAddress(0)); + EXPECT_EQ(cmdContainer.getInstructionHeapBaseAddress(), + pDevice->getMemoryManager()->getInternalHeapBaseAddress(0, cmdContainer.getIndirectHeap(HeapType::INDIRECT_OBJECT)->getGraphicsAllocation()->isAllocatedInLocalMemoryPool())); } TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeWithoutDeviceThenReturnedFalse) { @@ -445,12 +446,14 @@ TEST_F(CommandContainerHeaps, givenCommandContainerForDifferentRootDevicesThenIn CommandContainer cmdContainer0; cmdContainer0.initialize(device0.get()); - uint64_t baseAddressHeapDevice0 = device0.get()->getMemoryManager()->getInternalHeapBaseAddress(device0->getRootDeviceIndex()); + bool useLocalMemory0 = cmdContainer0.getIndirectHeap(HeapType::INDIRECT_OBJECT)->getGraphicsAllocation()->isAllocatedInLocalMemoryPool(); + uint64_t baseAddressHeapDevice0 = device0.get()->getMemoryManager()->getInternalHeapBaseAddress(device0->getRootDeviceIndex(), useLocalMemory0); EXPECT_EQ(cmdContainer0.getInstructionHeapBaseAddress(), baseAddressHeapDevice0); CommandContainer cmdContainer1; cmdContainer1.initialize(device1.get()); - uint64_t baseAddressHeapDevice1 = device1.get()->getMemoryManager()->getInternalHeapBaseAddress(device1->getRootDeviceIndex()); + bool useLocalMemory1 = cmdContainer0.getIndirectHeap(HeapType::INDIRECT_OBJECT)->getGraphicsAllocation()->isAllocatedInLocalMemoryPool(); + uint64_t baseAddressHeapDevice1 = device1.get()->getMemoryManager()->getInternalHeapBaseAddress(device1->getRootDeviceIndex(), useLocalMemory1); EXPECT_EQ(cmdContainer1.getInstructionHeapBaseAddress(), baseAddressHeapDevice1); }