Improve DrmMemoryManager tests - use rootDeviceIndex variable
Related-To: NEO-4512 Change-Id: I8a33cfa5cd9309ba07dabe83963d527fd7161d29 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
0ec2a6ecd6
commit
b9ffd012be
|
@ -62,7 +62,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenFreeGraphicsMemoryIsCa
|
|||
using DrmMemoryManagerWithLocalMemoryTest = Test<DrmMemoryManagerWithLocalMemoryFixture>;
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnAllocationInLocalMemoryThenReturnNullPtr) {
|
||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory);
|
||||
|
||||
auto ptr = memoryManager->lockResource(&drmAllocation);
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
|
@ -79,7 +79,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCopyMemoryToAllocationThen
|
|||
|
||||
std::vector<uint8_t> dataToCopy(MemoryConstants::pageSize, 1u);
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({0, dataToCopy.size(), GraphicsAllocation::AllocationType::BUFFER});
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({rootDeviceIndex, dataToCopy.size(), GraphicsAllocation::AllocationType::BUFFER});
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto ret = memoryManager->copyMemoryToAllocation(allocation, dataToCopy.data(), dataToCopy.size());
|
||||
|
@ -91,5 +91,5 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCopyMemoryToAllocationThen
|
|||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenGetLocalMemoryIsCalledThenSizeOfLocalMemoryIsReturned) {
|
||||
EXPECT_EQ(0 * GB, memoryManager->getLocalMemorySize(0u));
|
||||
EXPECT_EQ(0 * GB, memoryManager->getLocalMemorySize(rootDeviceIndex));
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationTo
|
|||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenforcePinAllowedWhenMemoryManagerIsCreatedThenPinBbIsCreated) {
|
||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, true, false, *executionEnvironment);
|
||||
EXPECT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
EXPECT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, pinBBisCreated) {
|
||||
|
@ -112,7 +112,7 @@ TEST_F(DrmMemoryManagerTest, pinBBisCreated) {
|
|||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, true, false, *executionEnvironment);
|
||||
EXPECT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
EXPECT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenNotAllowedForcePinWhenMemoryManagerIsCreatedThenPinBBIsNotCreated) {
|
||||
|
@ -120,14 +120,14 @@ TEST_F(DrmMemoryManagerTest, givenNotAllowedForcePinWhenMemoryManagerIsCreatedTh
|
|||
false,
|
||||
false,
|
||||
*executionEnvironment));
|
||||
EXPECT_EQ(nullptr, memoryManager->pinBBs[0]);
|
||||
EXPECT_EQ(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, pinBBnotCreatedWhenIoctlFailed) {
|
||||
mock->ioctl_expected.gemUserptr = 1;
|
||||
mock->ioctl_res = -1;
|
||||
auto memoryManager = new (std::nothrow) TestedDrmMemoryManager(false, true, false, *executionEnvironment);
|
||||
EXPECT_EQ(nullptr, memoryManager->pinBBs[0]);
|
||||
EXPECT_EQ(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
mock->ioctl_res = 0;
|
||||
delete memoryManager;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ TEST_F(DrmMemoryManagerTest, pinAfterAllocateWhenAskedAndAllowedAndBigAllocation
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
|
||||
auto alloc = static_cast<DrmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(createAllocationProperties(rootDeviceIndex, 10 * MemoryConstants::megaByte, true)));
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
|
@ -177,7 +177,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmContextIdWhenAllocationIsCreatedThenPinWith
|
|||
engine.osContext->incRefInternal();
|
||||
}
|
||||
auto drmContextId = memoryManager->getDefaultDrmContextId();
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
EXPECT_NE(0u, drmContextId);
|
||||
|
||||
auto alloc = memoryManager->allocateGraphicsMemoryWithProperties(createAllocationProperties(rootDeviceIndex, memoryManager->pinThreshold, true));
|
||||
|
@ -192,7 +192,7 @@ TEST_F(DrmMemoryManagerTest, doNotPinAfterAllocateWhenAskedAndAllowedButSmallAll
|
|||
mock->ioctl_expected.gemClose = 2;
|
||||
|
||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, true, false, *executionEnvironment);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
|
||||
// one page is too small for early pinning
|
||||
auto alloc = static_cast<DrmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(createAllocationProperties(rootDeviceIndex, MemoryConstants::pageSize, true)));
|
||||
|
@ -212,7 +212,7 @@ TEST_F(DrmMemoryManagerTest, doNotPinAfterAllocateWhenNotAskedButAllowed) {
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
|
||||
auto alloc = static_cast<DrmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(createAllocationProperties(rootDeviceIndex, MemoryConstants::pageSize, false)));
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
|
@ -251,7 +251,7 @@ TEST_F(DrmMemoryManagerTest, pinAfterAllocateWhenAskedAndAllowedAndBigAllocation
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
|
||||
allocationData.size = 10 * MB;
|
||||
allocationData.hostPtr = ::alignedMalloc(allocationData.size, 4096);
|
||||
|
@ -274,7 +274,7 @@ TEST_F(DrmMemoryManagerTest, givenSmallAllocationHostPtrAllocationWhenForcePinIs
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
|
||||
// one page is too small for early pinning
|
||||
allocationData.size = 4 * 1024;
|
||||
|
@ -295,7 +295,7 @@ TEST_F(DrmMemoryManagerTest, doNotPinAfterAllocateWhenNotAskedButAllowedHostPtr)
|
|||
mock->ioctl_expected.gemClose = 2;
|
||||
|
||||
auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false, true, false, *executionEnvironment);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
|
||||
allocationData.size = 4 * 1024;
|
||||
allocationData.hostPtr = ::alignedMalloc(allocationData.size, 4096);
|
||||
|
@ -330,7 +330,7 @@ TEST_F(DrmMemoryManagerTest, doNotPinAfterAllocateWhenAskedButNotAllowedHostPtr)
|
|||
TEST_F(DrmMemoryManagerTest, unreference) {
|
||||
mock->ioctl_expected.gemUserptr = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
BufferObject *bo = memoryManager->allocUserptr(0, (size_t)1024, 0ul, 0);
|
||||
BufferObject *bo = memoryManager->allocUserptr(0, (size_t)1024, 0ul, rootDeviceIndex);
|
||||
ASSERT_NE(nullptr, bo);
|
||||
memoryManager->unreference(bo, false);
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ TEST_F(DrmMemoryManagerTest, BoWaitFailure) {
|
|||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
BufferObject *bo = memoryManager->allocUserptr(0, (size_t)1024, 0ul, 0);
|
||||
BufferObject *bo = memoryManager->allocUserptr(0, (size_t)1024, 0ul, rootDeviceIndex);
|
||||
ASSERT_NE(nullptr, bo);
|
||||
mock->ioctl_res = -EIO;
|
||||
EXPECT_THROW(bo->wait(-1), std::exception);
|
||||
|
@ -673,8 +673,9 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
|
|||
AllocationData allocationData;
|
||||
allocationData.size = dummySize;
|
||||
allocationData.hostPtr = reinterpret_cast<const void *>(0x5001);
|
||||
allocationData.rootDeviceIndex = device->getRootDeviceIndex();
|
||||
|
||||
auto gfxPartition = memoryManager->getGfxPartition(0u);
|
||||
auto gfxPartition = memoryManager->getGfxPartition(device->getRootDeviceIndex());
|
||||
|
||||
auto allocatedPointer = gfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, dummySize);
|
||||
gfxPartition->freeGpuAddressRange(allocatedPointer, dummySize);
|
||||
|
@ -714,6 +715,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
|
|||
AllocationData allocationData;
|
||||
allocationData.size = 13u;
|
||||
allocationData.hostPtr = reinterpret_cast<const void *>(0x5001);
|
||||
allocationData.rootDeviceIndex = device->getRootDeviceIndex();
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
|
||||
|
||||
|
@ -747,6 +749,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledHostMemoryValid
|
|||
AllocationData allocationData;
|
||||
allocationData.size = 13u;
|
||||
allocationData.hostPtr = reinterpret_cast<const void *>(0x5001);
|
||||
allocationData.rootDeviceIndex = device->getRootDeviceIndex();
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
|
||||
|
||||
|
@ -859,7 +862,7 @@ TEST_F(DrmMemoryManagerTest, givenRequiresStandard64KBHeapSetToTrueThenStandard6
|
|||
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), range);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, GivenShareableEnabledWhenAskedToCreateGrahicsAllocationThenValidAllocationIsReturnedAndStandard64KBHeapIsUsed) {
|
||||
TEST_F(DrmMemoryManagerTest, GivenShareableEnabledWhenAskedToCreateGraphicsAllocationThenValidAllocationIsReturnedAndStandard64KBHeapIsUsed) {
|
||||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemCreate = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
@ -1086,15 +1089,15 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenLimitedRangeAllocatorSetThenH
|
|||
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
|
||||
|
||||
uint64_t sizeBig = 4 * MemoryConstants::megaByte + MemoryConstants::pageSize;
|
||||
auto gpuAddressLimitedRange = memoryManager->getGfxPartition(0)->heapAllocate(HeapIndex::HEAP_STANDARD, sizeBig);
|
||||
EXPECT_LT(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange);
|
||||
EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange + sizeBig);
|
||||
EXPECT_EQ(memoryManager->getGfxPartition(0)->getHeapMinimalAddress(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange);
|
||||
auto gpuAddressLimitedRange = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_STANDARD, sizeBig);
|
||||
EXPECT_LT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange);
|
||||
EXPECT_GT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange + sizeBig);
|
||||
EXPECT_EQ(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapMinimalAddress(HeapIndex::HEAP_STANDARD), gpuAddressLimitedRange);
|
||||
|
||||
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);
|
||||
auto gpuInternal32BitAlloc = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, sizeBig);
|
||||
EXPECT_LT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc);
|
||||
EXPECT_GT(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc + sizeBig);
|
||||
EXPECT_EQ(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapMinimalAddress(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY), gpuInternal32BitAlloc);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForAllocationWithAlignmentAndLimitedRangeAllocatorSetAndAcquireGpuRangeFailsThenNullIsReturned) {
|
||||
|
@ -1105,10 +1108,11 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForAllocationWithAlignme
|
|||
|
||||
// emulate GPU address space exhaust
|
||||
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
|
||||
memoryManager->getGfxPartition(0)->heapInit(HeapIndex::HEAP_STANDARD, 0x0, 0x10000);
|
||||
memoryManager->getGfxPartition(rootDeviceIndex)->heapInit(HeapIndex::HEAP_STANDARD, 0x0, 0x10000);
|
||||
|
||||
// set size to something bigger than allowed space
|
||||
allocationData.size = 0x20000;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
EXPECT_EQ(nullptr, memoryManager->allocateGraphicsMemoryWithAlignment(allocationData));
|
||||
}
|
||||
|
||||
|
@ -1272,7 +1276,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs
|
|||
std::unique_ptr<Device> pDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
|
||||
size_t size = MemoryConstants::pageSize64k;
|
||||
auto alloc = memoryManager->getGfxPartition(0)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, size);
|
||||
auto alloc = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY, size);
|
||||
EXPECT_NE(0llu, alloc);
|
||||
|
||||
size_t allocationSize = 4 * GB;
|
||||
|
@ -1298,6 +1302,7 @@ TEST_F(DrmMemoryManagerTest, GivenMemoryManagerWhenAllocateGraphicsMemoryForImag
|
|||
|
||||
TestedDrmMemoryManager::AllocationData allocationData;
|
||||
allocationData.imgInfo = &imgInfo;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
auto imageGraphicsAllocation = memoryManager->allocateGraphicsMemoryForImage(allocationData);
|
||||
|
||||
|
@ -1693,6 +1698,7 @@ TEST_F(DrmMemoryManagerTest, givenHostPointerNotRequiringCopyWhenAllocateGraphic
|
|||
TestedDrmMemoryManager::AllocationData allocationData;
|
||||
allocationData.imgInfo = &imgInfo;
|
||||
allocationData.hostPtr = hostPtr;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
auto imageAllocation = memoryManager->allocateGraphicsMemoryForImage(allocationData);
|
||||
ASSERT_NE(nullptr, imageAllocation);
|
||||
|
@ -1710,7 +1716,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledT
|
|||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(0, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
@ -1740,14 +1746,13 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledA
|
|||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(0u, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0u);
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0u);
|
||||
ASSERT_TRUE(properties.subDevicesBitfield.none());
|
||||
ASSERT_EQ(properties.rootDeviceIndex, 0u);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(0u, graphicsAllocation->getRootDeviceIndex());
|
||||
EXPECT_EQ(rootDeviceIndex, graphicsAllocation->getRootDeviceIndex());
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(this->mock->inputFd, (int)handle);
|
||||
|
@ -1791,7 +1796,7 @@ TEST_F(DrmMemoryManagerTest, givenOsHandleWithNonTiledObjectWhenCreateFromShared
|
|||
imgInfo.surfaceFormat = &gmmSurfaceFormat->surfaceFormat;
|
||||
imgInfo.plane = GMM_PLANE_Y;
|
||||
|
||||
AllocationProperties properties(0, false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||
AllocationProperties properties(rootDeviceIndex, false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
@ -1833,7 +1838,7 @@ TEST_F(DrmMemoryManagerTest, givenOsHandleWithTileYObjectWhenCreateFromSharedHan
|
|||
imgInfo.surfaceFormat = &gmmSurfaceFormat->surfaceFormat;
|
||||
imgInfo.plane = GMM_PLANE_Y;
|
||||
|
||||
AllocationProperties properties(0, false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||
AllocationProperties properties(rootDeviceIndex, false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
@ -1875,7 +1880,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenCreateFromSharedHandleFail
|
|||
imgInfo.surfaceFormat = &gmmSurfaceFormat->surfaceFormat;
|
||||
imgInfo.plane = GMM_PLANE_Y;
|
||||
|
||||
AllocationProperties properties(0, false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||
AllocationProperties properties(rootDeviceIndex, false, imgInfo, GraphicsAllocation::AllocationType::SHARED_IMAGE);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
@ -1893,7 +1898,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenAllocationFails
|
|||
osHandle handle = 1u;
|
||||
|
||||
InjectedFunction method = [this, &handle](size_t failureIndex) {
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
if (MemoryManagement::nonfailingAllocation == failureIndex) {
|
||||
|
@ -1928,7 +1933,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndThreeOsHandlesWhenReuseCrea
|
|||
if (i == 2)
|
||||
this->mock->outputHandle = 3u;
|
||||
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
|
||||
graphicsAllocations[i] = memoryManager->createGraphicsAllocationFromSharedHandle(handles[i], properties, false);
|
||||
//Clang-tidy false positive WA
|
||||
|
@ -1969,7 +1974,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBi
|
|||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
|
@ -1987,7 +1992,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleIsCre
|
|||
memoryManager->setForce32BitAllocations(true);
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
|
||||
|
@ -2007,7 +2012,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenBufferFromSharedHandl
|
|||
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
|
@ -2025,7 +2030,7 @@ TEST_F(DrmMemoryManagerTest, givenNon32BitAddressingWhenBufferFromSharedHandleIs
|
|||
memoryManager->setForce32BitAllocations(false);
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
|
@ -2041,7 +2046,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreatedAndIoctlPri
|
|||
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
|
@ -2056,7 +2061,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb
|
|||
mock->ioctl_expected.gemWait = 2;
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
|
||||
|
||||
|
@ -2078,7 +2083,7 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
|
|||
mock->ioctl_expected.gemWait = 2;
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
|
||||
mock->outputHandle++;
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
|
||||
|
@ -2161,6 +2166,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAlloca
|
|||
|
||||
TestedDrmMemoryManager::AllocationData allocationData;
|
||||
allocationData.imgInfo = &imgInfo;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryForImage(allocationData);
|
||||
|
||||
|
@ -2201,7 +2207,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnNullAl
|
|||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationWithoutBufferObjectThenReturnNullPtr) {
|
||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
EXPECT_EQ(nullptr, drmAllocation.getBO());
|
||||
|
||||
auto ptr = memoryManager->lockResource(&drmAllocation);
|
||||
|
@ -2220,7 +2226,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledButFails
|
|||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
||||
};
|
||||
BufferObjectMock bo(&drmMock);
|
||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
EXPECT_NE(nullptr, drmAllocation.getBO());
|
||||
|
||||
auto ptr = memoryManager->lockResource(&drmAllocation);
|
||||
|
@ -2253,7 +2259,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenUnlockResourceIsCalledOnAl
|
|||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
||||
};
|
||||
auto bo = new BufferObjectMock(&drmMock);
|
||||
auto drmAllocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, bo, nullptr, 0u, (osHandle)0u, MemoryPool::LocalMemory);
|
||||
auto drmAllocation = new DrmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, bo, nullptr, 0u, (osHandle)0u, MemoryPool::LocalMemory);
|
||||
|
||||
drmMemoryManager.unlockResourceImpl(*drmAllocation);
|
||||
EXPECT_TRUE(drmMemoryManager.unlockResourceInLocalMemoryImplParam.called);
|
||||
|
@ -2263,7 +2269,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenUnlockResourceIsCalledOnAl
|
|||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledOnAllocationWithoutBufferObjectThenReturnFalse) {
|
||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
EXPECT_EQ(nullptr, drmAllocation.getBO());
|
||||
|
||||
auto success = memoryManager->setDomainCpu(drmAllocation, false);
|
||||
|
@ -2280,7 +2286,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledButFai
|
|||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
||||
};
|
||||
BufferObjectMock bo(&drmMock);
|
||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
EXPECT_NE(nullptr, drmAllocation.getBO());
|
||||
|
||||
auto success = memoryManager->setDomainCpu(drmAllocation, false);
|
||||
|
@ -2296,7 +2302,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledOnAllo
|
|||
BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {}
|
||||
};
|
||||
BufferObjectMock bo(&drmMock);
|
||||
DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
DrmAllocation drmAllocation(rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull);
|
||||
EXPECT_NE(nullptr, drmAllocation.getBO());
|
||||
|
||||
auto success = memoryManager->setDomainCpu(drmAllocation, true);
|
||||
|
@ -2334,12 +2340,12 @@ TEST_F(DrmMemoryManagerTest, given32BitAllocatorWithHeapAllocatorWhenLargerFragm
|
|||
memoryManager->setForce32BitAllocations(true);
|
||||
|
||||
size_t allocationSize = 4 * MemoryConstants::pageSize;
|
||||
auto ptr = memoryManager->getGfxPartition(0)->heapAllocate(HeapIndex::HEAP_EXTERNAL, allocationSize);
|
||||
auto ptr = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_EXTERNAL, allocationSize);
|
||||
size_t smallAllocationSize = MemoryConstants::pageSize;
|
||||
memoryManager->getGfxPartition(0)->heapAllocate(HeapIndex::HEAP_EXTERNAL, smallAllocationSize);
|
||||
memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_EXTERNAL, smallAllocationSize);
|
||||
|
||||
//now free first allocation , this will move it to chunks
|
||||
memoryManager->getGfxPartition(0)->heapFree(HeapIndex::HEAP_EXTERNAL, ptr, allocationSize);
|
||||
memoryManager->getGfxPartition(rootDeviceIndex)->heapFree(HeapIndex::HEAP_EXTERNAL, ptr, allocationSize);
|
||||
|
||||
//now ask for 3 pages, this will give ptr from chunks
|
||||
size_t pages3size = 3 * MemoryConstants::pageSize;
|
||||
|
@ -2361,7 +2367,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedAllocationWithSmallerThenRealSizeWhenCre
|
|||
mock->ioctl_expected.gemWait = 1;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false);
|
||||
|
||||
|
@ -2637,8 +2643,8 @@ TEST_F(DrmMemoryManagerBasic, givenDefaultDrmMemoryManagerWhenItIsQueriedForInte
|
|||
true,
|
||||
true,
|
||||
executionEnvironment));
|
||||
auto heapBase = memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
|
||||
EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(0));
|
||||
auto heapBase = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY);
|
||||
EXPECT_EQ(heapBase, memoryManager->getInternalHeapBaseAddress(rootDeviceIndex));
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWithEnabledHostMemoryValidationWhenFeatureIsQueriedThenTrueIsReturned) {
|
||||
|
@ -2665,7 +2671,7 @@ TEST_F(DrmMemoryManagerBasic, givenEnabledHostMemoryValidationWhenMemoryManagerI
|
|||
true,
|
||||
executionEnvironment));
|
||||
ASSERT_NE(nullptr, memoryManager.get());
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerBasic, givenEnabledHostMemoryValidationAndForcePinWhenMemoryManagerIsCreatedThenPinBBIsCreated) {
|
||||
|
@ -2674,7 +2680,7 @@ TEST_F(DrmMemoryManagerBasic, givenEnabledHostMemoryValidationAndForcePinWhenMem
|
|||
true,
|
||||
executionEnvironment));
|
||||
ASSERT_NE(nullptr, memoryManager.get());
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenAllocateGraphicsMemoryIsCalledThenMemoryPoolIsSystem4KBPages) {
|
||||
|
@ -2732,7 +2738,7 @@ TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenCreateAllocationFromHandleIs
|
|||
true,
|
||||
executionEnvironment));
|
||||
auto osHandle = 1u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, false);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, allocation->getMemoryPool());
|
||||
|
@ -2746,6 +2752,7 @@ TEST_F(DrmMemoryManagerBasic, DISABLED_givenMemoryManagerWith64KBPagesEnabledWhe
|
|||
executionEnvironment));
|
||||
AllocationData allocationData;
|
||||
allocationData.size = 4096u;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
auto allocation = memoryManager->allocateGraphicsMemory64kb(allocationData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryPool::System64KBPages, allocation->getMemoryPool());
|
||||
|
@ -2777,7 +2784,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
|
|||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager.get());
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
|
||||
mock->reset();
|
||||
mock->ioctl_expected.gemUserptr = 1;
|
||||
|
@ -2821,7 +2828,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDisabledForcePinAndEna
|
|||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager.get());
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
|
||||
PinBufferObject *pinBB = new PinBufferObject(this->mock);
|
||||
memoryManager->injectPinBB(pinBB);
|
||||
|
@ -2917,7 +2924,7 @@ TEST_F(DrmMemoryManagerTest, givenForcePinAndHostMemoryValidationEnabledWhenSmal
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
|
||||
// one page is too small for early pinning but pinning is used for host memory validation
|
||||
allocationData.size = 4 * 1024;
|
||||
|
@ -2940,7 +2947,7 @@ TEST_F(DrmMemoryManagerTest, givenForcePinAllowedAndNoPinBBInMemoryManagerWhenAl
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
EXPECT_EQ(nullptr, memoryManager->pinBBs[0]);
|
||||
EXPECT_EQ(nullptr, memoryManager->pinBBs[rootDeviceIndex]);
|
||||
mock->ioctl_res = 0;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(createAllocationProperties(rootDeviceIndex, MemoryConstants::pageSize, true));
|
||||
|
@ -2970,6 +2977,7 @@ TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryFor
|
|||
|
||||
allocationData.size = 13;
|
||||
allocationData.hostPtr = reinterpret_cast<const void *>(0x5001);
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
|
||||
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
|
@ -2982,6 +2990,7 @@ TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryFor
|
|||
|
||||
TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrObjectAlignedSizeIsUsedByAllocUserPtrWhenBiggerSizeAllocatedInHeap) {
|
||||
AllocationData allocationData;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
|
||||
|
||||
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
|
||||
|
@ -3007,6 +3016,7 @@ TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryFor
|
|||
|
||||
TEST_F(DrmMemoryManagerBasic, givenDrmMemoryManagerWhenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledButAllocationFailedThenNullPtrReturned) {
|
||||
AllocationData allocationData;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new (std::nothrow) TestedDrmMemoryManager(false, false, false, executionEnvironment));
|
||||
|
||||
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
|
||||
|
@ -3047,6 +3057,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenForcePinNotAllowedAndH
|
|||
allocationData.size = 4 * 1024;
|
||||
allocationData.hostPtr = ::alignedMalloc(allocationData.size, 4096);
|
||||
allocationData.flags.forcePin = true;
|
||||
allocationData.rootDeviceIndex = device->getRootDeviceIndex();
|
||||
auto alloc = memoryManager->allocateGraphicsMemoryWithHostPtr(allocationData);
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
EXPECT_NE(nullptr, alloc->getBO());
|
||||
|
@ -3072,6 +3083,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenForcePinNotAllowedAndH
|
|||
allocationData.size = 10 * MB; // bigger than threshold
|
||||
allocationData.hostPtr = ::alignedMalloc(allocationData.size, 4096);
|
||||
allocationData.flags.forcePin = true;
|
||||
allocationData.rootDeviceIndex = device->getRootDeviceIndex();
|
||||
auto alloc = memoryManager->allocateGraphicsMemoryWithHostPtr(allocationData);
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
EXPECT_NE(nullptr, alloc->getBO());
|
||||
|
@ -3089,7 +3101,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
|||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager.get());
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
|
||||
mock->reset();
|
||||
|
||||
|
@ -3139,7 +3151,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
|
||||
mock->reset();
|
||||
|
||||
|
@ -3188,7 +3200,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
|||
for (auto engine : memoryManager->registeredEngines) {
|
||||
engine.osContext->incRefInternal();
|
||||
}
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
|
||||
mock->reset();
|
||||
mock->ioctl_expected.gemUserptr = 1;
|
||||
|
@ -3214,7 +3226,7 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenEnabledValidateHostMem
|
|||
|
||||
TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenCleanOsHandlesDeletesHandleDataThenOsHandleStorageAndResidencyIsSetToNullptr) {
|
||||
std::unique_ptr<TestedDrmMemoryManager> memoryManager(new TestedDrmMemoryManager(false, false, true, *executionEnvironment));
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[0]);
|
||||
ASSERT_NE(nullptr, memoryManager->pinBBs[device->getRootDeviceIndex()]);
|
||||
|
||||
OsHandleStorage handleStorage;
|
||||
handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle();
|
||||
|
@ -3244,21 +3256,21 @@ TEST_F(DrmMemoryManagerBasic, ifLimitedRangeAllocatorAvailableWhenAskedForAlloca
|
|||
memoryManager->forceLimitedRangeAllocator(0xFFFFFFFFF);
|
||||
|
||||
size_t size = 100u;
|
||||
auto ptr = memoryManager->getGfxPartition(0)->heapAllocate(HeapIndex::HEAP_STANDARD, size);
|
||||
auto address64bit = ptrDiff(ptr, memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD));
|
||||
auto ptr = memoryManager->getGfxPartition(rootDeviceIndex)->heapAllocate(HeapIndex::HEAP_STANDARD, size);
|
||||
auto address64bit = ptrDiff(ptr, memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD));
|
||||
|
||||
EXPECT_LT(address64bit, defaultHwInfo->capabilityTable.gpuAddressSpace);
|
||||
|
||||
EXPECT_LT(0u, address64bit);
|
||||
|
||||
memoryManager->getGfxPartition(0)->heapFree(HeapIndex::HEAP_STANDARD, ptr, size);
|
||||
memoryManager->getGfxPartition(rootDeviceIndex)->heapFree(HeapIndex::HEAP_STANDARD, ptr, size);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerBasic, givenSpecificAddressSpaceWhenInitializingMemoryManagerThenSetCorrectHeaps) {
|
||||
executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.gpuAddressSpace = maxNBitValue(48);
|
||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getMutableHardwareInfo()->capabilityTable.gpuAddressSpace = maxNBitValue(48);
|
||||
TestedDrmMemoryManager memoryManager(false, false, false, executionEnvironment);
|
||||
|
||||
auto gfxPartition = memoryManager.getGfxPartition(0);
|
||||
auto gfxPartition = memoryManager.getGfxPartition(rootDeviceIndex);
|
||||
auto limit = gfxPartition->getHeapLimit(HeapIndex::HEAP_SVM);
|
||||
|
||||
EXPECT_EQ(maxNBitValue(48 - 1), limit);
|
||||
|
@ -3275,6 +3287,7 @@ TEST_F(DrmMemoryManagerBasic, givenDisabledHostPtrTrackingWhenAllocateGraphicsMe
|
|||
|
||||
allocationData.size = 13;
|
||||
allocationData.hostPtr = reinterpret_cast<const void *>(0x5001);
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(allocationData);
|
||||
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
|
@ -3292,6 +3305,7 @@ TEST_F(DrmMemoryManagerBasic, givenImageOrSharedResourceCopyWhenGraphicsAllocati
|
|||
AllocationData allocData;
|
||||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.allocateMemory = true;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
GraphicsAllocation::AllocationType types[] = {GraphicsAllocation::AllocationType::IMAGE,
|
||||
GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY};
|
||||
|
@ -3312,6 +3326,7 @@ TEST_F(DrmMemoryManagerBasic, givenLocalMemoryDisabledWhenAllocateInDevicePoolIs
|
|||
allocData.size = MemoryConstants::pageSize;
|
||||
allocData.flags.useSystemMemory = false;
|
||||
allocData.flags.allocateMemory = true;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
|
@ -3377,6 +3392,7 @@ TEST_F(DrmMemoryManagerTest, givenSvmCpuAllocationWhenSizeAndAlignmentProvidedTh
|
|||
allocationData.size = 2 * MemoryConstants::megaByte;
|
||||
allocationData.alignment = 2 * MemoryConstants::megaByte;
|
||||
allocationData.type = GraphicsAllocation::AllocationType::SVM_CPU;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
DrmAllocation *allocation = memoryManager->allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
@ -3395,8 +3411,8 @@ TEST_F(DrmMemoryManagerTest, givenSvmCpuAllocationWhenSizeAndAlignmentProvidedTh
|
|||
|
||||
EXPECT_NE(0llu, bo->peekAddress());
|
||||
|
||||
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
|
||||
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
|
||||
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
|
||||
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
|
||||
|
||||
EXPECT_EQ(reinterpret_cast<void *>(allocation->getGpuAddress()), alignUp(allocation->getReservedAddressPtr(), allocationData.alignment));
|
||||
EXPECT_EQ(alignUp(allocationData.size, allocationData.alignment) + allocationData.alignment, allocation->getReservedAddressSize());
|
||||
|
@ -3409,12 +3425,13 @@ TEST_F(DrmMemoryManagerTest, givenSvmCpuAllocationWhenSizeAndAlignmentProvidedBu
|
|||
mock->ioctl_expected.gemWait = 0;
|
||||
mock->ioctl_expected.gemClose = 1;
|
||||
|
||||
memoryManager->getGfxPartition(0)->heapInit(HeapIndex::HEAP_STANDARD, 0, 0);
|
||||
memoryManager->getGfxPartition(rootDeviceIndex)->heapInit(HeapIndex::HEAP_STANDARD, 0, 0);
|
||||
|
||||
TestedDrmMemoryManager::AllocationData allocationData;
|
||||
allocationData.size = 2 * MemoryConstants::megaByte;
|
||||
allocationData.alignment = 2 * MemoryConstants::megaByte;
|
||||
allocationData.type = GraphicsAllocation::AllocationType::SVM_CPU;
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
DrmAllocation *allocation = memoryManager->allocateGraphicsMemoryWithAlignment(allocationData);
|
||||
EXPECT_EQ(nullptr, allocation);
|
||||
|
@ -3482,12 +3499,13 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryCallSequenceTest, givenDrmMemoryManagerAn
|
|||
|
||||
TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, givenDrmMemoryManagerAndFreeGraphicsMemoryIsCalledForSharedAllocationThenUnreferenceBufferObjectIsCalledWithSynchronousDestroySetToFalse) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[0]));
|
||||
const uint32_t rootDeviceIndex = 0u;
|
||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->setDrm(Drm::create(nullptr, *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]));
|
||||
::testing::NiceMock<GMockDrmMemoryManager> gmockDrmMemoryManager(executionEnvironment);
|
||||
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(0, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
auto allocation = gmockDrmMemoryManager.createGraphicsAllocationFromSharedHandle(handle, properties, false);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture {
|
|||
}
|
||||
|
||||
void SetUp(DrmMockCustom *mock, bool localMemoryEnabled) {
|
||||
allocationData.rootDeviceIndex = rootDeviceIndex;
|
||||
this->mock = mock;
|
||||
executionEnvironment = new MockExecutionEnvironment(defaultHwInfo.get(), false, nonDefaultRootDeviceIndex + 1);
|
||||
executionEnvironment->incRefInternal();
|
||||
|
|
Loading…
Reference in New Issue