Virtual address space partitioning on Linux [2/n]

Move selectHeap from Wddm to MemoryManager.
Set DrmAllocation::origin.

Change-Id: I5d412e35d524d1f31174893b9ce1d3b1e98eee96
This commit is contained in:
Piotr Fusik
2019-02-20 11:18:24 +01:00
committed by sys_ocldev
parent 4139e88982
commit 75edea81bb
15 changed files with 137 additions and 119 deletions

View File

@@ -273,7 +273,7 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr
allocation.handle = ALLOCATION_HANDLE;
allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
EXPECT_EQ(internalHeapIndex, wddm->selectHeap(&allocation, allocation.getAlignedCpuPtr()));
EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, allocation.getAlignedCpuPtr(), *hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]));
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
EXPECT_TRUE(ret);
@@ -994,66 +994,6 @@ TEST_F(Wddm20Tests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheLi
EXPECT_EQ(0x3, wddm->temporaryResources.back());
}
using WddmHeapSelectorTest = Wddm20Tests;
TEST_F(WddmHeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
allocation.is32BitAllocation = true;
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
EXPECT_EQ(internalHeapIndex, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
allocation.is32BitAllocation = false;
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
EXPECT_EQ(internalHeapIndex, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
allocation.is32BitAllocation = true;
allocation.origin = AllocationOrigin::EXTERNAL_ALLOCATION;
EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenLimitedHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress) {
return;
}
EXPECT_EQ(HeapIndex::HEAP_LIMITED, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithPtrThenSvmHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
return;
}
EXPECT_EQ(HeapIndex::HEAP_SVM, wddm->selectHeap(&allocation, &allocation));
}
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndCpuAccessIsRequiredThenStandard64kHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM;
allocation.setAllocationType(allocationType);
EXPECT_TRUE(GraphicsAllocation::isCpuAccessRequired(allocationType));
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
return;
}
EXPECT_EQ(HeapIndex::HEAP_STANDARD64Kb, wddm->selectHeap(&allocation, nullptr));
}
TEST_F(WddmHeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndCpuAccessIsNotRequiredThenStandardHeapIsUsed) {
WddmAllocation allocation{nullptr, 0, nullptr, MemoryPool::MemoryNull, false};
EXPECT_EQ(AllocationOrigin::EXTERNAL_ALLOCATION, allocation.origin);
auto allocationType = GraphicsAllocation::AllocationType::UNDECIDED;
allocation.setAllocationType(allocationType);
EXPECT_FALSE(GraphicsAllocation::isCpuAccessRequired(allocationType));
if (hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]->capabilityTable.gpuAddressSpace != MemoryConstants::max48BitAddress) {
return;
}
EXPECT_EQ(HeapIndex::HEAP_STANDARD, wddm->selectHeap(&allocation, nullptr));
}
TEST(WddmInternalHeapTest, whenConfigurationIs64BitThenInternalHeapIndexIsHeapInternalDeviceMemory) {
if (is64bit) {
EXPECT_EQ(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, internalHeapIndex);