From b937b5406420a95f245b8e539a3c0748894a8367 Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Thu, 28 Nov 2019 14:23:32 +0100 Subject: [PATCH] Remove 32 bit code. - Enable local memory in 32 bit scenarios. Change-Id: I091570a3d0aa6043febf2721480196425e058978 Signed-off-by: Michal Mrozek --- core/memory_manager/gfx_partition.h | 2 -- runtime/dll/windows/os_interface.cpp | 2 +- runtime/memory_manager/memory_manager.cpp | 2 +- runtime/memory_manager/memory_manager.h | 2 +- .../os_agnostic_memory_manager.cpp | 2 +- .../os_interface/linux/drm_memory_manager.cpp | 2 +- unit_tests/libult/os_interface.cpp | 2 +- .../memory_manager/memory_manager_tests.cpp | 4 ++-- .../linux/drm_memory_manager_tests.cpp | 12 ++++++------ .../os_interface/windows/wddm20_tests.cpp | 17 ++--------------- .../windows/wddm_memory_manager_tests.cpp | 6 +++--- unit_tests/windows/os_interface_tests.cpp | 2 +- 12 files changed, 20 insertions(+), 35 deletions(-) diff --git a/core/memory_manager/gfx_partition.h b/core/memory_manager/gfx_partition.h index 6193f7abf2..4cd5db1e77 100644 --- a/core/memory_manager/gfx_partition.h +++ b/core/memory_manager/gfx_partition.h @@ -27,8 +27,6 @@ enum class HeapIndex : uint32_t { TOTAL_HEAPS }; -constexpr auto internalHeapIndex = is32bit ? HeapIndex::HEAP_INTERNAL : HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY; - class GfxPartition { public: GfxPartition(); diff --git a/runtime/dll/windows/os_interface.cpp b/runtime/dll/windows/os_interface.cpp index d173c22d13..ab0ec30bda 100644 --- a/runtime/dll/windows/os_interface.cpp +++ b/runtime/dll/windows/os_interface.cpp @@ -10,6 +10,6 @@ #include "core/memory_manager/memory_constants.h" namespace NEO { -bool OSInterface::osEnableLocalMemory = true && is64bit; +bool OSInterface::osEnableLocalMemory = true; } // namespace NEO diff --git a/runtime/memory_manager/memory_manager.cpp b/runtime/memory_manager/memory_manager.cpp index 90401cdac7..09d42a064d 100644 --- a/runtime/memory_manager/memory_manager.cpp +++ b/runtime/memory_manager/memory_manager.cpp @@ -429,7 +429,7 @@ void MemoryManager::unlockResource(GraphicsAllocation *graphicsAllocation) { HeapIndex MemoryManager::selectHeap(const GraphicsAllocation *allocation, bool hasPointer, bool isFullRangeSVM) { if (allocation) { if (useInternal32BitAllocator(allocation->getAllocationType())) { - return internalHeapIndex; + return HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY; } if (allocation->is32BitAllocation()) { return HeapIndex::HEAP_EXTERNAL; diff --git a/runtime/memory_manager/memory_manager.h b/runtime/memory_manager/memory_manager.h index 6ffe4f38dc..8ce1734e2e 100644 --- a/runtime/memory_manager/memory_manager.h +++ b/runtime/memory_manager/memory_manager.h @@ -103,7 +103,7 @@ class MemoryManager { virtual uint64_t getLocalMemorySize() = 0; uint64_t getMaxApplicationAddress() { return is64bit ? MemoryConstants::max64BitAppAddress : MemoryConstants::max32BitAppAddress; }; - uint64_t getInternalHeapBaseAddress(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->getHeapBase(internalHeapIndex); } + 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); } bool isLimitedRange(uint32_t rootDeviceIndex) { return getGfxPartition(rootDeviceIndex)->isLimitedRange(); } diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index 139fe8a3e4..f46bdd06ad 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -104,7 +104,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const Al } GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) { - auto heap = useInternal32BitAllocator(allocationData.type) ? internalHeapIndex : HeapIndex::HEAP_EXTERNAL; + auto heap = useInternal32BitAllocator(allocationData.type) ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL; auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex); if (allocationData.hostPtr) { auto allocationSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size); diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index df45199a61..a953ef5b2c 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -305,7 +305,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) { auto internal = useInternal32BitAllocator(allocationData.type); - auto allocatorToUse = internal ? internalHeapIndex : HeapIndex::HEAP_EXTERNAL; + auto allocatorToUse = internal ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_EXTERNAL; if (allocationData.hostPtr) { uintptr_t inputPtr = reinterpret_cast(allocationData.hostPtr); diff --git a/unit_tests/libult/os_interface.cpp b/unit_tests/libult/os_interface.cpp index 0416ebb777..f8d8163839 100644 --- a/unit_tests/libult/os_interface.cpp +++ b/unit_tests/libult/os_interface.cpp @@ -11,6 +11,6 @@ namespace NEO { -bool OSInterface::osEnableLocalMemory = true && is64bit; +bool OSInterface::osEnableLocalMemory = true; } // namespace NEO diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index bf5aade95e..41704decfb 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -1797,13 +1797,13 @@ TEST(MemoryManagerTest, givenAllocationTypesThatMayNeedL3FlushWhenCallingGetAllo TEST(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; allocation.set32BitAllocation(true); - EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, false, false)); + EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, 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(internalHeapIndex, MemoryManager::selectHeap(&allocation, false, false)); + EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, MemoryManager::selectHeap(&allocation, false, false)); } TEST(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) { diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index dbe120dddb..d79e7adb6e 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -907,10 +907,10 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenLimitedRangeAllocatorSetThenH EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange + sizeBig); EXPECT_EQ(memoryManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange); - auto gpuInternal32BitAlloc = memoryManager->getGfxPartition(0)->heapAllocate(internalHeapIndex, sizeBig); - EXPECT_LT(memoryManager->getGfxPartition(0)->getHeapBase(internalHeapIndex), gpuInternal32BitAlloc); - EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(internalHeapIndex), gpuInternal32BitAlloc + sizeBig); - EXPECT_EQ(memoryManager->getGfxPartition(0)->getHeapMinimalAddress(internalHeapIndex), gpuInternal32BitAlloc); + auto gpuInternal32BitAlloc = memoryManager->getGfxPartition(0)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, sizeBig); + EXPECT_LT(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc); + EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc + sizeBig); + EXPECT_EQ(memoryManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc); } TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForAllocationWithAlignmentAndLimitedRangeAllocatorSetAndAcquireGpuRangeFailsThenNullIsReturned) { @@ -1088,7 +1088,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs std::unique_ptr pDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); size_t size = MemoryConstants::pageSize64k; - auto alloc = memoryManager->getGfxPartition(0)->heapAllocate(internalHeapIndex, size); + auto alloc = memoryManager->getGfxPartition(0)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, size); EXPECT_NE(0llu, alloc); size_t allocationSize = 4 * GB; @@ -2379,7 +2379,7 @@ TEST_F(DrmMemoryManagerBasic, givenDefaultDrmMemoryManagerWhenItIsQueriedForInte true, true, executionEnvironment)); - auto heapBase = memoryManager->getGfxPartition(0)->getHeapBase(internalHeapIndex); + auto heapBase = memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY); EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(0)); } diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index c9e71c82db..5d9a73bcf0 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -307,8 +307,8 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr size_t alignedSize = 0x2000; std::unique_ptr gmm(GmmHelperFunctions::getGmm(alignedPtr, alignedSize)); uint64_t gpuAddress = 0u; - auto heapBase = wddm->getGfxPartition().Heap32[static_cast(internalHeapIndex)].Base; - auto heapLimit = wddm->getGfxPartition().Heap32[static_cast(internalHeapIndex)].Limit; + auto heapBase = wddm->getGfxPartition().Heap32[static_cast(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base; + auto heapLimit = wddm->getGfxPartition().Heap32[static_cast(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Limit; bool ret = wddm->mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, heapBase, heapLimit, 0u, gpuAddress); EXPECT_TRUE(ret); @@ -1022,19 +1022,6 @@ TEST_F(WddmLockWithMakeResidentTests, whenAlllocationNeedsBlockingMakeResidentBe EXPECT_EQ(1u, wddm->lockResult.uint64ParamPassed); memoryManager.unlockResource(&allocation); } - -TEST(WddmInternalHeapTest, whenConfigurationIs64BitThenInternalHeapIndexIsHeapInternalDeviceMemory) { - if (is64bit) { - EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, internalHeapIndex); - } -} - -TEST(WddmInternalHeapTest, whenConfigurationIs32BitThenInternalHeapIndexIsHeapInternal) { - if (is32bit) { - EXPECT_EQ(HeapIndex::HEAP_INTERNAL, internalHeapIndex); - } -} - using WddmGfxPartitionTest = Wddm20Tests; TEST_F(WddmGfxPartitionTest, initGfxPartition) { diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index f98dd6c0fb..1e068103f7 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -1008,7 +1008,7 @@ TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocatio EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress()); auto rootDeviceIndex = wddmAllocation->getRootDeviceIndex(); auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex)); - auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(internalHeapIndex)); + auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)); EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd); @@ -1028,7 +1028,7 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe 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(internalHeapIndex)); + auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)); EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase); EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd); @@ -1299,7 +1299,7 @@ TEST(WddmMemoryManagerDefaults, givenDefaultWddmMemoryManagerWhenItIsQueriedForI auto hwInfoMock = *platformDevices[0]; wddm->init(hwInfoMock); MockWddmMemoryManager memoryManager(*executionEnvironment); - auto heapBase = wddm->getGfxPartition().Heap32[static_cast(internalHeapIndex)].Base; + auto heapBase = wddm->getGfxPartition().Heap32[static_cast(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base; EXPECT_EQ(heapBase, memoryManager.getInternalHeapBaseAddress(0)); } diff --git a/unit_tests/windows/os_interface_tests.cpp b/unit_tests/windows/os_interface_tests.cpp index aae5ffa2be..7795dce668 100644 --- a/unit_tests/windows/os_interface_tests.cpp +++ b/unit_tests/windows/os_interface_tests.cpp @@ -10,5 +10,5 @@ #include "test.h" TEST(osInterfaceTests, osInterfaceLocalMemoryEnabledByDefault) { - EXPECT_EQ(is64bit, NEO::OSInterface::osEnableLocalMemory); + EXPECT_TRUE(NEO::OSInterface::osEnableLocalMemory); }