mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
feature: Get Peer Allocation with specified base Pointer
Related-To: LOCI-4176 - Given a Base Pointer passed into Get Peer Allocation, then the base pointer is used in the map of the new allocation to the virtual memory. - Enables users to use the same pointer for all devices in Peer To Peer. - Currently unsupported on reserved memory due to mapped and exec resiedency of Virtual addresses. Signed-off-by: Neil R Spruit <neil.r.spruit@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f98ac7098b
commit
ded9d7bff2
@@ -2037,7 +2037,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenSettingNumHandlesThenTheyAreRetrievedCorr
|
||||
size_t size = 65536u * 2;
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
uint32_t numHandlesExpected = 8;
|
||||
@@ -2060,10 +2060,10 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle2);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
@@ -2082,6 +2082,40 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocationFromReferencedHandle);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandlesWithSharingResourcesWithBasePointerThenUnderlyingPointerIsTheSame) {
|
||||
mock->ioctlExpected.primeFdToHandle = 4;
|
||||
mock->ioctlExpected.gemWait = 2;
|
||||
mock->ioctlExpected.gemClose = 2;
|
||||
|
||||
std::vector<NEO::osHandle> handles{6, 7};
|
||||
size_t size = 65536u * 2;
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, reinterpret_cast<void *>(graphicsAllocationFromReferencedHandle->getGpuAddress()));
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle2);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
auto boFromReferencedHandle = drmAllocationFromReferencedHandle->getBO();
|
||||
EXPECT_EQ(boFromReferencedHandle->peekHandle(), (int)this->mock->outputHandle);
|
||||
EXPECT_NE(0llu, boFromReferencedHandle->peekAddress());
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle2 = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle2);
|
||||
auto boFromReferencedHandle2 = drmAllocationFromReferencedHandle2->getBO();
|
||||
EXPECT_EQ(boFromReferencedHandle2->peekHandle(), (int)this->mock->outputHandle);
|
||||
EXPECT_NE(0llu, boFromReferencedHandle2->peekAddress());
|
||||
|
||||
EXPECT_EQ(boFromReferencedHandle->peekAddress(), boFromReferencedHandle2->peekAddress());
|
||||
|
||||
EXPECT_EQ(graphicsAllocationFromReferencedHandle->getGpuAddress(), graphicsAllocationFromReferencedHandle2->getGpuAddress());
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocationFromReferencedHandle2);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocationFromReferencedHandle);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandlesWithNoSharingResourcesThenDifferentAllocationsAreReturned) {
|
||||
mock->ioctlExpected.primeFdToHandle = 4;
|
||||
mock->ioctlExpected.gemWait = 2;
|
||||
@@ -2093,10 +2127,10 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false);
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false);
|
||||
auto graphicsAllocationFromReferencedHandle2 = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle2);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
@@ -2125,7 +2159,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
DrmAllocation *drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
@@ -2133,7 +2167,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
EXPECT_EQ(bo->peekHandle(), (int)this->mock->outputHandle);
|
||||
EXPECT_NE(0llu, bo->peekAddress());
|
||||
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocationFromReferencedHandle = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocationFromReferencedHandle);
|
||||
|
||||
DrmAllocation *drmAllocationFromReferencedHandle = static_cast<DrmAllocation *>(graphicsAllocationFromReferencedHandle);
|
||||
@@ -2155,7 +2189,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
const bool prefer57bitAddressing = memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0;
|
||||
@@ -2187,7 +2221,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
memoryManager->failOnfindAndReferenceSharedBufferObject = false;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
@@ -2200,7 +2234,7 @@ TEST_F(DrmMemoryManagerTestPrelim, whenCreatingAllocationFromMultipleSharedHandl
|
||||
size_t size = 65536u * 2;
|
||||
AllocationProperties properties(rootDeviceIndex, true, size, AllocationType::BUFFER_HOST_MEMORY, false, device->getDeviceBitfield());
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromMultipleSharedHandles(handles, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
DrmAllocation *drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
@@ -2253,7 +2287,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2285,7 +2319,7 @@ TEST_F(DrmMemoryManagerTestPrelim,
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2325,7 +2359,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2354,7 +2388,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -2369,7 +2403,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
EXPECT_EQ(1u, bo->getRefCount());
|
||||
EXPECT_EQ(size, bo->peekSize());
|
||||
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation2);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation2->getUnderlyingBuffer());
|
||||
@@ -2396,7 +2430,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsC
|
||||
|
||||
mock->returnIoctlExtraErrorValue = true;
|
||||
mock->failOnMmapOffset = true;
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -2414,7 +2448,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndUseMmapObjectSetToFal
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
properties.useMmapObject = false;
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
EXPECT_EQ(static_cast<int>(handle), static_cast<DrmAllocation *>(graphicsAllocation)->getBO()->peekHandle());
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -2433,7 +2467,7 @@ TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerWithoutMemoryInfoThenDrm
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
EXPECT_EQ(static_cast<int>(handle), static_cast<DrmAllocation *>(graphicsAllocation)->getBO()->peekHandle());
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -2451,7 +2485,7 @@ TEST_F(DrmMemoryManagerTestPrelim, MmapFailWhenUSMHostAllocationFromSharedHandle
|
||||
return MAP_FAILED;
|
||||
};
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
|
||||
ASSERT_EQ(nullptr, graphicsAllocation);
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ TEST_F(DrmMemoryManagerUsmSharedHandleTest, givenDrmMemoryManagerAndOsHandleWhen
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::BUFFER_HOST_MEMORY, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(this->mock->inputFd, (int)handle);
|
||||
|
||||
@@ -61,14 +61,14 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 0;
|
||||
uint32_t rootDeviceIndex1 = 0;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -85,14 +85,14 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 0;
|
||||
uint32_t rootDeviceIndex1 = 1;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -105,18 +105,43 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation1);
|
||||
}
|
||||
|
||||
TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromSharedHandleWithSameHandleAndDifferentRootDeviceWithBasePointerOnSecondDeviceThenSamePointerIsUsed) {
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 0;
|
||||
uint32_t rootDeviceIndex1 = 1;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, reinterpret_cast<void *>(gfxAllocation0->getUnderlyingBuffer()));
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
DrmAllocation *drmAllocation0 = static_cast<DrmAllocation *>(gfxAllocation0);
|
||||
DrmAllocation *drmAllocation1 = static_cast<DrmAllocation *>(gfxAllocation1);
|
||||
|
||||
EXPECT_NE(drmAllocation0->getBO(), drmAllocation1->getBO());
|
||||
EXPECT_EQ(gfxAllocation0->getUnderlyingBuffer(), gfxAllocation1->getUnderlyingBuffer());
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation0);
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation1);
|
||||
}
|
||||
|
||||
TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromSharedHandleWithDifferentHandleAndSameRootDeviceThenDifferentBOIsUsed) {
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 1;
|
||||
uint32_t rootDeviceIndex1 = 0;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -133,14 +158,14 @@ TEST_P(MemoryManagerMultiDeviceSharedHandleTest, whenCreatingAllocationFromShare
|
||||
uint32_t handle0 = 0;
|
||||
uint32_t rootDeviceIndex0 = 0;
|
||||
AllocationProperties properties0{rootDeviceIndex0, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true);
|
||||
auto gfxAllocation0 = memoryManager->createGraphicsAllocationFromSharedHandle(handle0, properties0, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation0, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex0, gfxAllocation0->getRootDeviceIndex());
|
||||
|
||||
uint32_t handle1 = 1;
|
||||
uint32_t rootDeviceIndex1 = 1;
|
||||
AllocationProperties properties1{rootDeviceIndex1, true, MemoryConstants::pageSize, AllocationType::BUFFER, false, false, mockDeviceBitfield};
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true);
|
||||
auto gfxAllocation1 = memoryManager->createGraphicsAllocationFromSharedHandle(handle1, properties1, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation1, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex1, gfxAllocation1->getRootDeviceIndex());
|
||||
|
||||
@@ -915,7 +940,7 @@ TEST_F(DrmMemoryManagerTest, GivenAllocationWhenClosingSharedHandleThenSucceeds)
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
|
||||
|
||||
memoryManager->closeSharedHandle(graphicsAllocation);
|
||||
@@ -936,7 +961,7 @@ TEST_F(DrmMemoryManagerTest, GivenAllocationWhenClosingInternalHandleThenSucceed
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(0, graphicsAllocation->createInternalHandle(this->memoryManager, 0u, handleVal));
|
||||
|
||||
memoryManager->closeInternalHandle(handleVal, 0u, graphicsAllocation);
|
||||
@@ -1020,7 +1045,7 @@ TEST_F(DrmMemoryManagerTest, GivenDeviceSharedAllocationWhichRequiresHostMapThen
|
||||
this->mock->queryEngineInfo();
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, false);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, true, false, nullptr);
|
||||
DrmAllocation *drmAlloc = (DrmAllocation *)graphicsAllocation;
|
||||
|
||||
EXPECT_TRUE(isAligned<MemoryConstants::pageSize64k>(drmAlloc->getMmapPtr()));
|
||||
@@ -1792,7 +1817,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledT
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -1822,7 +1847,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
|
||||
size_t size = 4096u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
@@ -1863,7 +1888,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledA
|
||||
AllocationProperties properties(rootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, false, 0u);
|
||||
ASSERT_TRUE(properties.subDevicesBitfield.none());
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, graphicsAllocation);
|
||||
|
||||
EXPECT_EQ(rootDeviceIndex, graphicsAllocation->getRootDeviceIndex());
|
||||
@@ -1890,7 +1915,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndOsHandleWhenAllocationFails
|
||||
InjectedFunction method = [this, &handle](size_t failureIndex) {
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
if (MemoryManagement::nonfailingAllocation == failureIndex) {
|
||||
EXPECT_NE(nullptr, graphicsAllocation);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
@@ -1924,7 +1949,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndThreeOsHandlesWhenReuseCrea
|
||||
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
|
||||
graphicsAllocations[i] = memoryManager->createGraphicsAllocationFromSharedHandle(handles[i], properties, false, false, true);
|
||||
graphicsAllocations[i] = memoryManager->createGraphicsAllocationFromSharedHandle(handles[i], properties, false, false, true, nullptr);
|
||||
// Clang-tidy false positive WA
|
||||
if (graphicsAllocations[i] == nullptr) {
|
||||
ASSERT_FALSE(true);
|
||||
@@ -1965,7 +1990,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBi
|
||||
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true, nullptr);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
EXPECT_TRUE(graphicsAllocation->is32BitAllocation());
|
||||
EXPECT_EQ(1, lseekCalledCount);
|
||||
@@ -1983,7 +2008,7 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleIsCre
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
@@ -2003,7 +2028,7 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenBufferFromSharedHandl
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
|
||||
@@ -2021,7 +2046,7 @@ TEST_F(DrmMemoryManagerTest, givenNon32BitAddressingWhenBufferFromSharedHandleIs
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, true, false, true, nullptr);
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
|
||||
EXPECT_FALSE(graphicsAllocation->is32BitAllocation());
|
||||
EXPECT_EQ(1, lseekCalledCount);
|
||||
@@ -2037,7 +2062,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedHandleWhenAllocationIsCreatedAndIoctlPri
|
||||
osHandle handle = 1u;
|
||||
this->mock->outputHandle = 2u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_EQ(nullptr, graphicsAllocation);
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
@@ -2050,8 +2075,8 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatShareTheSameBufferOb
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
|
||||
auto currentResidentSize = testedCsr->getResidencyAllocations().size();
|
||||
testedCsr->makeResident(*graphicsAllocation);
|
||||
@@ -2076,9 +2101,9 @@ TEST_F(DrmMemoryManagerTest, givenTwoGraphicsAllocationsThatDoesnShareTheSameBuf
|
||||
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
mock->outputHandle++;
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation2 = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
|
||||
auto currentResidentSize = testedCsr->getResidencyAllocations().size();
|
||||
testedCsr->makeResident(*graphicsAllocation);
|
||||
@@ -2341,7 +2366,7 @@ TEST_F(DrmMemoryManagerTest, givenSharedAllocationWithSmallerThenRealSizeWhenCre
|
||||
osHandle sharedHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true);
|
||||
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(sharedHandle, properties, false, false, true, nullptr);
|
||||
|
||||
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(realSize, graphicsAllocation->getUnderlyingBufferSize());
|
||||
@@ -2709,7 +2734,7 @@ TEST_F(DrmMemoryManagerBasic, givenMemoryManagerWhenCreateAllocationFromHandleIs
|
||||
executionEnvironment));
|
||||
auto osHandle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, false, false, true);
|
||||
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, properties, false, false, true, nullptr);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, allocation->getMemoryPool());
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
@@ -3585,10 +3610,10 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false);
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
|
||||
EXPECT_NE(allocation->getGpuAddress(), allocation2->getGpuAddress());
|
||||
@@ -3615,7 +3640,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
std::stringstream expectedOutput;
|
||||
@@ -3645,10 +3670,10 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto allocation2 = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, allocation2);
|
||||
|
||||
EXPECT_EQ(allocation->getGpuAddress(), allocation2->getGpuAddress());
|
||||
@@ -3669,7 +3694,7 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest, givenDrmMemoryManagerAnd
|
||||
|
||||
osHandle handle = 1u;
|
||||
AllocationProperties properties(rootDeviceIndex, false, MemoryConstants::pageSize, AllocationType::SHARED_BUFFER, false, {});
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true);
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
memoryManger.freeGraphicsMemory(allocation);
|
||||
|
||||
Reference in New Issue
Block a user