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
@@ -377,7 +377,14 @@ void ContextImp::freePeerAllocations(const void *ptr, bool blocking, Device *dev
|
||||
auto peerAllocData = &iter->second;
|
||||
auto peerAlloc = peerAllocData->gpuAllocations.getDefaultGraphicsAllocation();
|
||||
auto peerPtr = reinterpret_cast<void *>(peerAlloc->getGpuAddress());
|
||||
this->driverHandle->svmAllocsManager->freeSVMAlloc(peerPtr, blocking);
|
||||
if (peerAllocData->mappedAllocData) {
|
||||
auto gpuAllocations = peerAllocData->gpuAllocations;
|
||||
for (const auto &graphicsAllocation : gpuAllocations.getGraphicsAllocations()) {
|
||||
this->driverHandle->getMemoryManager()->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
} else {
|
||||
this->driverHandle->svmAllocsManager->freeSVMAlloc(peerPtr, blocking);
|
||||
}
|
||||
deviceImp->peerAllocations.allocations.erase(iter);
|
||||
}
|
||||
|
||||
@@ -709,8 +716,8 @@ ze_result_t ContextImp::openIpcMemHandles(ze_device_handle_t hDevice,
|
||||
handles.push_back(static_cast<NEO::osHandle>(handle));
|
||||
}
|
||||
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice()->getRootDevice();
|
||||
|
||||
*pptr = this->driverHandle->importFdHandles(neoDevice, flags, handles, nullptr);
|
||||
NEO::SvmAllocationData allocDataInternal(neoDevice->getRootDeviceIndex());
|
||||
*pptr = this->driverHandle->importFdHandles(neoDevice, flags, handles, nullptr, nullptr, allocDataInternal);
|
||||
if (nullptr == *pptr) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
@@ -1056,6 +1063,7 @@ ze_result_t ContextImp::mapVirtualMem(const void *ptr,
|
||||
allocData.size = size;
|
||||
allocData.pageSizeForAlignment = MemoryConstants::pageSize64k;
|
||||
allocData.setAllocId(this->driverHandle->svmAllocsManager->allocationsCounter++);
|
||||
allocData.memoryType = InternalMemoryType::RESERVED_DEVICE_MEMORY;
|
||||
NEO::MemoryMappedRange *mappedRange = new NEO::MemoryMappedRange;
|
||||
mappedRange->ptr = ptr;
|
||||
mappedRange->size = size;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
@@ -19,7 +22,9 @@ bool ContextImp::isShareableMemory(const void *exportDesc, bool exportableMemory
|
||||
}
|
||||
|
||||
void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, NEO::AllocationType allocationType, ze_ipc_memory_flags_t flags) {
|
||||
return this->driverHandle->importFdHandle(Device::fromHandle(hDevice)->getNEODevice(), flags, handle, allocationType, nullptr);
|
||||
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
||||
NEO::SvmAllocationData allocDataInternal(neoDevice->getRootDeviceIndex());
|
||||
return this->driverHandle->importFdHandle(neoDevice, flags, handle, allocationType, nullptr, nullptr, allocDataInternal);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/driver_model_type.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
|
||||
#include "level_zero/core/source/context/context_imp.h"
|
||||
@@ -47,11 +48,15 @@ void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice,
|
||||
reinterpret_cast<void *>(handle),
|
||||
allocationType);
|
||||
} else if (driverType == NEO::DriverModelType::DRM) {
|
||||
return this->driverHandle->importFdHandle(Device::fromHandle(hDevice)->getNEODevice(),
|
||||
auto neoDevice = Device::fromHandle(hDevice)->getNEODevice();
|
||||
NEO::SvmAllocationData allocDataInternal(neoDevice->getRootDeviceIndex());
|
||||
return this->driverHandle->importFdHandle(neoDevice,
|
||||
flags,
|
||||
handle,
|
||||
allocationType,
|
||||
nullptr);
|
||||
nullptr,
|
||||
nullptr,
|
||||
allocDataInternal);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user