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:
Neil R Spruit
2023-05-04 01:40:52 +00:00
committed by Compute-Runtime-Automation
parent f98ac7098b
commit ded9d7bff2
65 changed files with 618 additions and 304 deletions

View File

@ -775,10 +775,12 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared
AllocationProperties &properties,
bool requireSpecificBitness,
bool isHostIpcAllocation,
bool reuseSharedAllocation) {
bool reuseSharedAllocation,
void *mapPointer) {
BufferObjects bos;
std::vector<size_t> sizes;
size_t totalSize = 0;
uint64_t gpuRange = 0;
std::unique_lock<std::mutex> lock(mtx);
@ -828,10 +830,14 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared
sizes.push_back(bo->peekSize());
}
auto gfxPartition = getGfxPartition(properties.rootDeviceIndex);
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0);
auto heapIndex = prefer57bitAddressing ? HeapIndex::HEAP_EXTENDED : HeapIndex::HEAP_STANDARD2MB;
auto gpuRange = acquireGpuRange(totalSize, properties.rootDeviceIndex, heapIndex);
if (mapPointer) {
gpuRange = reinterpret_cast<uint64_t>(mapPointer);
} else {
auto gfxPartition = getGfxPartition(properties.rootDeviceIndex);
auto prefer57bitAddressing = (gfxPartition->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0);
auto heapIndex = prefer57bitAddressing ? HeapIndex::HEAP_EXTENDED : HeapIndex::HEAP_STANDARD2MB;
gpuRange = acquireGpuRange(totalSize, properties.rootDeviceIndex, heapIndex);
}
if (reuseSharedAllocation) {
lock.unlock();
@ -928,7 +934,8 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
const AllocationProperties &properties,
bool requireSpecificBitness,
bool isHostIpcAllocation,
bool reuseSharedAllocation) {
bool reuseSharedAllocation,
void *mapPointer) {
if (isHostIpcAllocation) {
return createUSMHostAllocationFromSharedHandle(handle, properties, false, reuseSharedAllocation);
}
@ -936,6 +943,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
std::unique_lock<std::mutex> lock(mtx);
PrimeHandle openFd{};
uint64_t gpuRange = 0;
openFd.fileDescriptor = handle;
auto &drm = this->getDrm(properties.rootDeviceIndex);
@ -986,8 +994,12 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
return HeapIndex::HEAP_STANDARD;
};
auto heapIndex = getHeapIndex();
auto gpuRange = acquireGpuRange(size, properties.rootDeviceIndex, heapIndex);
if (mapPointer) {
gpuRange = reinterpret_cast<uint64_t>(mapPointer);
} else {
auto heapIndex = getHeapIndex();
gpuRange = acquireGpuRange(size, properties.rootDeviceIndex, heapIndex);
}
bo->setAddress(gpuRange);
bo->setUnmapSize(size);

View File

@ -38,8 +38,8 @@ class DrmMemoryManager : public MemoryManager {
void freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation, bool isImportedAllocation) override;
void handleFenceCompletion(GraphicsAllocation *allocation) override;
GraphicsAllocation *createGraphicsAllocationFromExistingStorage(AllocationProperties &properties, void *ptr, MultiGraphicsAllocation &multiGraphicsAllocation) override;
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation) override;
GraphicsAllocation *createGraphicsAllocationFromMultipleSharedHandles(const std::vector<osHandle> &handles, AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
GraphicsAllocation *createGraphicsAllocationFromSharedHandle(osHandle handle, const AllocationProperties &properties, bool requireSpecificBitness, bool isHostIpcAllocation, bool reuseSharedAllocation, void *mapPointer) override;
void closeSharedHandle(GraphicsAllocation *gfxAllocation) override;
void closeInternalHandle(uint64_t &handle, uint32_t handleId, GraphicsAllocation *graphicsAllocation) override;