mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +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
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -45,12 +45,12 @@ TEST_P(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGr
|
||||
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, false, false, true);
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, false, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, true, false, true);
|
||||
gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(static_cast<osHandle>(0u), properties, true, false, true, nullptr);
|
||||
ASSERT_NE(gfxAllocation, nullptr);
|
||||
EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(gfxAllocation);
|
||||
|
||||
@@ -232,3 +232,62 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressReservat
|
||||
EXPECT_NE(static_cast<int>(addressRange.address), 0x1234);
|
||||
EXPECT_NE(static_cast<int>(addressRange.size), 0);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, whenCallingCreateGraphicsAllocationFromMultipleSharedHandlesWithBasePointerFromOsAgnosticMemoryManagerThenNullptrIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
OsAgnosticMemoryManager memoryManager(executionEnvironment);
|
||||
uint32_t mockRootDeviceIndex = 0u;
|
||||
DeviceBitfield mockDeviceBitfield(0b1);
|
||||
|
||||
std::vector<osHandle> handles{6, 7};
|
||||
AllocationProperties properties = {mockRootDeviceIndex,
|
||||
true,
|
||||
MemoryConstants::pageSize,
|
||||
AllocationType::BUFFER,
|
||||
false,
|
||||
mockDeviceBitfield};
|
||||
bool requireSpecificBitness{};
|
||||
bool isHostIpcAllocation{};
|
||||
uint64_t basePointer = 0x1234;
|
||||
auto ptr = memoryManager.createGraphicsAllocationFromMultipleSharedHandles(handles, properties, requireSpecificBitness, isHostIpcAllocation, true, reinterpret_cast<void *>(basePointer));
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, whenCallingCreateGraphicsAllocationFromSharedHandleWithNullBasePointerFromOsAgnosticMemoryManagerThenBasicPointerReturned) {
|
||||
uint32_t mockRootDeviceIndex = 0u;
|
||||
DeviceBitfield mockDeviceBitfield(0b1);
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
osHandle handle = 1;
|
||||
auto size = 4096u;
|
||||
AllocationProperties properties(mockRootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto sharedAllocation = memoryManager.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, nullptr);
|
||||
EXPECT_NE(nullptr, sharedAllocation);
|
||||
EXPECT_EQ(reinterpret_cast<void *>(1u), sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_FALSE(sharedAllocation->isCoherent());
|
||||
EXPECT_NE(nullptr, sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(size, sharedAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, sharedAllocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(sharedAllocation);
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, whenCallingCreateGraphicsAllocationFromSharedHandleWithBasePointerFromOsAgnosticMemoryManagerThenBasePointerReturned) {
|
||||
uint32_t mockRootDeviceIndex = 0u;
|
||||
DeviceBitfield mockDeviceBitfield(0b1);
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
|
||||
osHandle handle = 1;
|
||||
auto size = 4096u;
|
||||
uint64_t basePointer = 0x1234;
|
||||
AllocationProperties properties(mockRootDeviceIndex, false, size, AllocationType::SHARED_BUFFER, false, mockDeviceBitfield);
|
||||
auto sharedAllocation = memoryManager.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, true, reinterpret_cast<void *>(basePointer));
|
||||
EXPECT_NE(nullptr, sharedAllocation);
|
||||
EXPECT_EQ(reinterpret_cast<void *>(0x1234), sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_FALSE(sharedAllocation->isCoherent());
|
||||
EXPECT_NE(nullptr, sharedAllocation->getUnderlyingBuffer());
|
||||
EXPECT_EQ(size, sharedAllocation->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(MemoryPool::SystemCpuInaccessible, sharedAllocation->getMemoryPool());
|
||||
|
||||
memoryManager.freeGraphicsMemory(sharedAllocation);
|
||||
}
|
||||
Reference in New Issue
Block a user