Dont force system memory for internal allocations
use HEAP_INTERNAL_DEVICE_MEMORY for internal allocations Change-Id: Id70caa30cd1e9c79df60773227d72b09541e4b77 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
ce4a75e121
commit
fff8be32f4
|
@ -260,8 +260,6 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
|||
case GraphicsAllocation::AllocationType::LINEAR_STREAM:
|
||||
case GraphicsAllocation::AllocationType::FILL_PATTERN:
|
||||
case GraphicsAllocation::AllocationType::TIMESTAMP_TAG_BUFFER:
|
||||
case GraphicsAllocation::AllocationType::KERNEL_ISA:
|
||||
case GraphicsAllocation::AllocationType::INTERNAL_HEAP:
|
||||
allocationData.flags.useSystemMemory = true;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -999,7 +999,7 @@ std::unique_lock<SpinLock> Wddm::acquireLock(SpinLock &lock) {
|
|||
HeapIndex Wddm::selectHeap(const WddmAllocation *allocation, const void *ptr) const {
|
||||
if (allocation) {
|
||||
if (allocation->origin == AllocationOrigin::INTERNAL_ALLOCATION) {
|
||||
return HeapIndex::HEAP_INTERNAL;
|
||||
return HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY;
|
||||
} else if (allocation->is32BitAllocation) {
|
||||
return HeapIndex::HEAP_EXTERNAL;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ class WddmAllocation : public GraphicsAllocation {
|
|||
this->reservedAddressSpace = reserveMem;
|
||||
}
|
||||
void setGpuAddress(uint64_t graphicsAddress) { this->gpuAddress = graphicsAddress; }
|
||||
void setCpuAddress(void *cpuPtr) { this->cpuPtr = cpuPtr; }
|
||||
bool needsMakeResidentBeforeLock = false;
|
||||
AllocationOrigin origin = AllocationOrigin::EXTERNAL_ALLOCATION;
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
|
|||
}
|
||||
|
||||
wddmAllocation->is32BitAllocation = true;
|
||||
auto baseAddress = allocationData.allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit->getBase() : this->wddm->getGfxPartition().Heap32[1].Base;
|
||||
auto baseAddress = allocationData.allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit->getBase() : getInternalHeapBaseAddress();
|
||||
wddmAllocation->gpuBaseAddress = GmmHelper::canonize(baseAddress);
|
||||
|
||||
DebugManager.logAllocation(wddmAllocation.get());
|
||||
|
@ -450,7 +450,7 @@ uint64_t WddmMemoryManager::getMaxApplicationAddress() {
|
|||
}
|
||||
|
||||
uint64_t WddmMemoryManager::getInternalHeapBaseAddress() {
|
||||
return this->wddm->getGfxPartition().Heap32[1].Base;
|
||||
return this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Base;
|
||||
}
|
||||
|
||||
bool WddmMemoryManager::mapAuxGpuVA(GraphicsAllocation *graphicsAllocation) {
|
||||
|
|
|
@ -412,3 +412,24 @@ TEST(MemoryManagerTest, givenAllocationPropertiesWithMultiOsContextCapableFlagDi
|
|||
EXPECT_FALSE(allocation->isMultiOsContextCapable());
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenInternalHeapTypeWhenGetAllocationDataIsCalledThenInternalAllocationIsRequested) {
|
||||
AllocationData allocData;
|
||||
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::INTERNAL_HEAP}, 0, nullptr);
|
||||
EXPECT_EQ(AllocationOrigin::INTERNAL_ALLOCATION, allocData.allocationOrigin);
|
||||
}
|
||||
TEST(MemoryManagerTest, givenInternalHeapTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
|
||||
AllocationData allocData;
|
||||
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::INTERNAL_HEAP}, 0, nullptr);
|
||||
EXPECT_FALSE(allocData.flags.useSystemMemory);
|
||||
}
|
||||
TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
|
||||
AllocationData allocData;
|
||||
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr);
|
||||
EXPECT_FALSE(allocData.flags.useSystemMemory);
|
||||
}
|
||||
TEST(MemoryManagerTest, givenKernelIsaTypeWhenGetAllocationDataIsCalledThenInternalAllocationIsRequested) {
|
||||
AllocationData allocData;
|
||||
MockMemoryManager::getAllocationData(allocData, {1, GraphicsAllocation::AllocationType::KERNEL_ISA}, 0, nullptr);
|
||||
EXPECT_EQ(AllocationOrigin::INTERNAL_ALLOCATION, allocData.allocationOrigin);
|
||||
}
|
|
@ -267,7 +267,7 @@ TEST_F(Wddm20Tests, createAllocation32bit) {
|
|||
delete gmm;
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap1ThenItHasGpuAddressWithingHeap1Limits) {
|
||||
TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddressWithingHeap0Limits) {
|
||||
void *alignedPtr = (void *)0x12000;
|
||||
size_t alignedSize = 0x2000;
|
||||
WddmAllocation allocation(alignedPtr, alignedSize, nullptr, MemoryPool::MemoryNull, 1u, false);
|
||||
|
@ -275,12 +275,13 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap1ThenItHasGpuAddr
|
|||
allocation.handle = ALLOCATION_HANDLE;
|
||||
allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
||||
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, wddm->selectHeap(&allocation, allocation.getAlignedCpuPtr()));
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, wddm->selectHeap(&allocation, allocation.getAlignedCpuPtr()));
|
||||
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Limit);
|
||||
uint32_t heapIndex = static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[heapIndex].Base);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[heapIndex].Limit);
|
||||
|
||||
EXPECT_GE(allocation.gpuPtr, cannonizedHeapBase);
|
||||
EXPECT_LE(allocation.gpuPtr, cannonizedHeapEnd);
|
||||
|
@ -1000,17 +1001,17 @@ TEST_F(Wddm20Tests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheLi
|
|||
|
||||
using WddmHeapSelectorTest = Wddm20Tests;
|
||||
|
||||
TEST_F(WddmHeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
TEST_F(WddmHeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalDeviceMemoryHeapIsUsed) {
|
||||
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
|
||||
allocation.is32BitAllocation = true;
|
||||
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, wddm->selectHeap(&allocation, nullptr));
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, wddm->selectHeap(&allocation, nullptr));
|
||||
}
|
||||
TEST_F(WddmHeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
|
||||
TEST_F(WddmHeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalDeviceMemoryHeapIsUsed) {
|
||||
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
|
||||
allocation.is32BitAllocation = false;
|
||||
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL, wddm->selectHeap(&allocation, nullptr));
|
||||
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, wddm->selectHeap(&allocation, nullptr));
|
||||
}
|
||||
TEST_F(WddmHeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) {
|
||||
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false};
|
||||
|
|
|
@ -868,12 +868,12 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd
|
|||
TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeap1) {
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base));
|
||||
EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress()));
|
||||
EXPECT_NE(nullptr, wddmAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Limit);
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress());
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Limit);
|
||||
|
||||
EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
|
||||
EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd);
|
||||
|
@ -883,16 +883,16 @@ TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocatio
|
|||
memoryManager->freeGraphicsMemory(wddmAllocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeap1) {
|
||||
TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) {
|
||||
auto ptr = reinterpret_cast<void *>(0x1000000);
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, ptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base));
|
||||
EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress()));
|
||||
EXPECT_EQ(ptr, wddmAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Base);
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(this->wddm->getGfxPartition().Heap32[1].Limit);
|
||||
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress());
|
||||
auto cannonizedHeapEnd = GmmHelper::canonize(wddm->getGfxPartition().Heap32[static_cast<uint32_t>(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)].Limit);
|
||||
|
||||
EXPECT_GE(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
|
||||
EXPECT_LE(wddmAllocation->getGpuAddress(), cannonizedHeapEnd);
|
||||
|
|
Loading…
Reference in New Issue