mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
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:
@@ -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);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "runtime/command_stream/preemption.h"
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/os_interface/windows/wddm/wddm.h"
|
||||
#include "runtime/os_interface/windows/wddm_allocation.h"
|
||||
#include "unit_tests/fixtures/gmm_environment_fixture.h"
|
||||
@@ -84,7 +85,8 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDaf
|
||||
auto gmm = std::unique_ptr<Gmm>(new Gmm(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
|
||||
wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.handle, allocation.getUnderlyingBuffer(), allocation.gpuPtr, wddmWithKmDafMock->selectHeap(&allocation, allocation.getUnderlyingBuffer()));
|
||||
auto heapIndex = MemoryManager::selectHeap(&allocation, allocation.getUnderlyingBuffer(), *platformDevices[0]);
|
||||
wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.handle, allocation.getUnderlyingBuffer(), allocation.gpuPtr, heapIndex);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter);
|
||||
|
||||
@@ -1306,12 +1306,12 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(1).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
|
||||
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, wddm.selectHeap(nullptr, nullptr));
|
||||
auto hwInfo = hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily];
|
||||
ASSERT_NE(nullptr, hwInfo);
|
||||
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, MemoryManager::selectHeap(nullptr, nullptr, *hwInfo));
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
auto productFamily = wddm.getGfxPlatform()->eProductFamily;
|
||||
UNRECOVERABLE_IF(!hardwareInfoTable[productFamily]);
|
||||
auto gpuAddressRange = hardwareInfoTable[productFamily]->capabilityTable.gpuAddressSpace;
|
||||
auto gpuAddressRange = hwInfo->capabilityTable.gpuAddressSpace;
|
||||
if (gpuAddressRange == MemoryConstants::max48BitAddress) {
|
||||
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
|
||||
} else {
|
||||
@@ -1376,7 +1376,8 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGp
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, wddm.selectHeap(nullptr, nullptr));
|
||||
auto heapIndex = MemoryManager::selectHeap(nullptr, nullptr, *hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily]);
|
||||
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), ALLOCATION_HANDLE, nullptr, gpuVa, heapIndex);
|
||||
ASSERT_TRUE(result);
|
||||
}
|
||||
|
||||
@@ -1387,7 +1388,8 @@ TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenRetur
|
||||
WddmMock wddm;
|
||||
EXPECT_TRUE(wddm.init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
|
||||
|
||||
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), 0, nullptr, gpuVa, wddm.selectHeap(nullptr, nullptr));
|
||||
auto heapIndex = MemoryManager::selectHeap(nullptr, nullptr, *hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily]);
|
||||
auto result = wddm.mapGpuVirtualAddressImpl(gmm.get(), 0, nullptr, gpuVa, heapIndex);
|
||||
ASSERT_FALSE(result);
|
||||
}
|
||||
|
||||
@@ -1410,7 +1412,8 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnse
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto result = wddm->mapGpuVirtualAddressImpl(myGmm, ALLOCATION_HANDLE, nullptr, gpuVa, wddm->selectHeap(nullptr, nullptr));
|
||||
auto heapIndex = MemoryManager::selectHeap(nullptr, nullptr, *hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]);
|
||||
auto result = wddm->mapGpuVirtualAddressImpl(myGmm, ALLOCATION_HANDLE, nullptr, gpuVa, heapIndex);
|
||||
EXPECT_TRUE(result);
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user