mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-12 17:33:00 +08:00
Simplify code by removing AllocationOrigin.
Change-Id: Ie73cefc1ae1ee846fb9a5ef1054af01cd1867a4d
This commit is contained in:
@@ -762,7 +762,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32
|
||||
|
||||
auto size = 10u;
|
||||
memoryManager->setForce32BitAllocations(true);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, nullptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
|
||||
EXPECT_GE(allocation->getUnderlyingBufferSize(), size);
|
||||
@@ -1002,7 +1002,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationWithHo
|
||||
auto size = 10u;
|
||||
void *host_ptr = reinterpret_cast<void *>(0x1000);
|
||||
memoryManager->setForce32BitAllocations(true);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, host_ptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, host_ptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
mock->ioctl_res_ext = &mock->NONE;
|
||||
@@ -1016,7 +1016,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationAndAll
|
||||
|
||||
auto size = 10u;
|
||||
memoryManager->setForce32BitAllocations(true);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, nullptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
mock->ioctl_res_ext = &mock->NONE;
|
||||
@@ -1030,7 +1030,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternal32Bit
|
||||
|
||||
auto size = 10u;
|
||||
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, nullptr, AllocationOrigin::INTERNAL_ALLOCATION);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, nullptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP);
|
||||
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
mock->ioctl_res_ext = &mock->NONE;
|
||||
@@ -1142,7 +1142,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs
|
||||
EXPECT_NE(0llu, alloc);
|
||||
|
||||
size_t allocationSize = 4 * 1024 * 1024 * 1024llu;
|
||||
auto graphicsAllocation = memoryManager->allocate32BitGraphicsMemory(allocationSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION);
|
||||
auto graphicsAllocation = memoryManager->allocate32BitGraphicsMemory(allocationSize, nullptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
EXPECT_TRUE(pDevice->getDeviceInfo().force32BitAddressess);
|
||||
}
|
||||
@@ -2014,7 +2014,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAllocatorWithHeapAllocatorWhenLargerFragm
|
||||
size_t pages3size = 3 * MemoryConstants::pageSize;
|
||||
|
||||
void *host_ptr = reinterpret_cast<void *>(0x1000);
|
||||
DrmAllocation *graphicsAlloaction = memoryManager->allocate32BitGraphicsMemory(pages3size, host_ptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
DrmAllocation *graphicsAlloaction = memoryManager->allocate32BitGraphicsMemory(pages3size, host_ptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
auto bo = graphicsAlloaction->getBO();
|
||||
EXPECT_EQ(allocationSize, bo->peekUnmapSize());
|
||||
@@ -2097,7 +2097,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
|
||||
|
||||
auto bufferSize = MemoryConstants::pageSize;
|
||||
void *ptr = nullptr;
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_NE(nullptr, drmAllocation);
|
||||
|
||||
auto internalAllocator = memoryManager->getDrmInternal32BitAllocator();
|
||||
@@ -2134,7 +2134,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc
|
||||
|
||||
auto bufferSize = MemoryConstants::pageSize;
|
||||
void *ptr = nullptr;
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_NE(nullptr, drmAllocation);
|
||||
|
||||
auto internalAllocator = memoryManager->getDrmInternal32BitAllocator();
|
||||
@@ -2175,7 +2175,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForExternalAlloc
|
||||
|
||||
auto bufferSize = MemoryConstants::pageSize;
|
||||
void *ptr = nullptr;
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, AllocationOrigin::EXTERNAL_ALLOCATION));
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, GraphicsAllocation::AllocationType::BUFFER));
|
||||
ASSERT_NE(nullptr, drmAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, drmAllocation->getUnderlyingBuffer());
|
||||
@@ -2189,7 +2189,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc
|
||||
|
||||
auto bufferSize = 128 * MemoryConstants::megaByte + 4 * MemoryConstants::pageSize;
|
||||
void *ptr = nullptr;
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_EQ(nullptr, drmAllocation);
|
||||
}
|
||||
|
||||
@@ -2200,7 +2200,7 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
|
||||
|
||||
auto bufferSize = MemoryConstants::pageSize;
|
||||
void *ptr = reinterpret_cast<void *>(0x100000);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(memoryManager->allocate32BitGraphicsMemory(bufferSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_NE(nullptr, drmAllocation);
|
||||
|
||||
auto internalAllocator = memoryManager->getDrmInternal32BitAllocator();
|
||||
@@ -2606,7 +2606,7 @@ TEST(DrmMemoryManager, givenMemoryManagerWhenAllocate32BitGraphicsMemoryWithPtrI
|
||||
void *ptr = reinterpret_cast<void *>(0x1001);
|
||||
auto size = MemoryConstants::pageSize;
|
||||
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryPool::System4KBPagesWith32BitGpuAddressing, allocation->getMemoryPool());
|
||||
|
||||
@@ -33,14 +33,10 @@ class MockWddmMemoryManager : public WddmMemoryManager {
|
||||
bool validateAllocationMock(WddmAllocation *graphicsAllocation) {
|
||||
return this->validateAllocation(graphicsAllocation);
|
||||
}
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) {
|
||||
GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, GraphicsAllocation::AllocationType allocationType) {
|
||||
bool allocateMemory = ptr == nullptr;
|
||||
AllocationData allocationData;
|
||||
if (allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION) {
|
||||
getAllocationData(allocationData, MockAllocationProperties::getPropertiesFor32BitExternalAllocation(size, allocateMemory), {}, ptr);
|
||||
} else {
|
||||
getAllocationData(allocationData, MockAllocationProperties::getPropertiesFor32BitInternalAllocation(size, allocateMemory), {}, ptr);
|
||||
}
|
||||
getAllocationData(allocationData, MockAllocationProperties(allocateMemory, size, allocationType), {}, ptr);
|
||||
return allocate32BitGraphicsMemoryImpl(allocationData);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -265,14 +265,14 @@ TEST_F(Wddm20Tests, createAllocation32bit) {
|
||||
delete gmm;
|
||||
}
|
||||
|
||||
TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddressWithingHeapInternalLimits) {
|
||||
TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddressWithinHeapInternalLimits) {
|
||||
void *alignedPtr = (void *)0x12000;
|
||||
size_t alignedSize = 0x2000;
|
||||
WddmAllocation allocation(alignedPtr, alignedSize, nullptr, MemoryPool::MemoryNull, false);
|
||||
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
allocation.gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
|
||||
allocation.origin = AllocationOrigin::INTERNAL_ALLOCATION;
|
||||
allocation.setAllocationType(GraphicsAllocation::AllocationType::KERNEL_ISA);
|
||||
EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, allocation.getAlignedCpuPtr(), *hardwareInfoTable[wddm->getGfxPlatform()->eProductFamily]));
|
||||
bool ret = wddm->mapGpuVirtualAddress(&allocation, allocation.getAlignedCpuPtr());
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
@@ -154,7 +154,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocate32BitGraphicsM
|
||||
void *ptr = reinterpret_cast<void *>(0x1001);
|
||||
auto size = MemoryConstants::pageSize;
|
||||
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto allocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryPool::System4KBPagesWith32BitGpuAddressing, allocation->getMemoryPool());
|
||||
@@ -665,7 +665,7 @@ TEST_F(WddmMemoryManagerTest, GivenAlignedPointerWhenAllocate32BitMemoryThenGmmC
|
||||
MockWddmAllocation allocation;
|
||||
uint32_t size = 4096;
|
||||
void *ptr = reinterpret_cast<void *>(4096);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_EQ(ptr, reinterpret_cast<void *>(gpuAllocation->gmm->resourceParams.pExistingSysMem));
|
||||
EXPECT_EQ(size, gpuAllocation->gmm->resourceParams.ExistingSysMemSize);
|
||||
memoryManager->freeGraphicsMemory(gpuAllocation);
|
||||
@@ -675,7 +675,7 @@ TEST_F(WddmMemoryManagerTest, GivenUnAlignedPointerAndSizeWhenAllocate32BitMemor
|
||||
MockWddmAllocation allocation;
|
||||
uint32_t size = 0x1001;
|
||||
void *ptr = reinterpret_cast<void *>(0x1001);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(size, ptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
EXPECT_EQ(reinterpret_cast<void *>(0x1000), reinterpret_cast<void *>(gpuAllocation->gmm->resourceParams.pExistingSysMem));
|
||||
EXPECT_EQ(0x2000, gpuAllocation->gmm->resourceParams.ExistingSysMemSize);
|
||||
memoryManager->freeGraphicsMemory(gpuAllocation);
|
||||
@@ -696,7 +696,7 @@ TEST_F(WddmMemoryManagerTest, getMaxApplicationAddress) {
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithNullptr) {
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
EXPECT_LE(GmmHelper::canonize(wddm->getExternalHeapBase()), gpuAllocation->getGpuAddress());
|
||||
@@ -707,7 +707,7 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithNullptr) {
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, given32BitAllocationWhenItIsCreatedThenItHasNonZeroGpuAddressToPatch) {
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
EXPECT_NE(0llu, gpuAllocation->getGpuAddressToPatch());
|
||||
@@ -718,7 +718,7 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithMisalignedHostPtrDoesNotDoT
|
||||
size_t misalignedSize = 0x2500;
|
||||
void *misalignedPtr = reinterpret_cast<void *>(0x12500);
|
||||
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(misalignedSize, misalignedPtr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(misalignedSize, misalignedPtr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
|
||||
@@ -737,7 +737,7 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithMisalignedHostPtrDoesNotDoT
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, Allocate32BitMemorySetsCannonizedGpuBaseAddress) {
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
|
||||
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, GraphicsAllocation::AllocationType::BUFFER);
|
||||
|
||||
ASSERT_NE(nullptr, gpuAllocation);
|
||||
|
||||
@@ -856,7 +856,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) {
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, nullptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, nullptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress()));
|
||||
EXPECT_NE(nullptr, wddmAllocation->getUnderlyingBuffer());
|
||||
@@ -875,7 +875,7 @@ TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocatio
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) {
|
||||
auto ptr = reinterpret_cast<void *>(0x1000000);
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, ptr, AllocationOrigin::INTERNAL_ALLOCATION));
|
||||
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(MemoryConstants::pageSize, ptr, GraphicsAllocation::AllocationType::INTERNAL_HEAP));
|
||||
ASSERT_NE(nullptr, wddmAllocation);
|
||||
EXPECT_EQ(wddmAllocation->gpuBaseAddress, GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress()));
|
||||
EXPECT_EQ(ptr, wddmAllocation->getUnderlyingBuffer());
|
||||
|
||||
Reference in New Issue
Block a user