SWDEV-550882 - Add support for hipIpcMemLazyEnablePeerAccess (#817)

This commit is contained in:
Ioannis Assiouras
2025-09-23 00:05:51 +01:00
committed by GitHub
parent 8b52d71cc7
commit 97bc3af918
2 changed files with 10 additions and 1 deletions
+8
View File
@@ -3323,6 +3323,7 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* dev_ptr) {
device = hip::getCurrentDevice()->devices()[0];
ihandle = reinterpret_cast<amd::MemObjMap::IpcMemHandle*>(handle);
ihandle->owners_device_id = hip::getCurrentDevice()->deviceId();
if (!device->IpcCreate(dev_ptr, &(ihandle->psize), ihandle->ipc_handle, &(ihandle->poffset))) {
LogPrintfError("IPC memory creation failed for memory: 0x%x", dev_ptr);
@@ -3356,6 +3357,13 @@ hipError_t hipIpcOpenMemHandle(void** dev_ptr, hipIpcMemHandle_t handle, unsigne
HIP_RETURN(hipErrorInvalidContext);
}
if (ihandle->owners_device_id >= g_devices.size()) {
HIP_RETURN(hipErrorInvalidValue);
}
amd::Device* peer_device = g_devices[ihandle->owners_device_id]->asContext()->devices()[0];
device->enableP2P(peer_device);
amd_mem_obj = amd::MemObjMap::FindIpcHandleMemObj(*ihandle);
if (amd_mem_obj == nullptr) {
if (!device->IpcAttach(ihandle->ipc_handle, ihandle->psize, ihandle->poffset, flags, dev_ptr)) {
+2 -1
View File
@@ -1397,7 +1397,8 @@ class MemObjMap : public AllStatic {
size_t psize; ///< Total size of the device memory allocation
size_t poffset; ///< Offset within the allocation
int owners_process_id; ///< ID of the process that owns the allocation
char reserved[LP64_SWITCH(20, 12)]; ///< Reserved for future extensions
int owners_device_id; ///< ID of the device that owns the allocation
char reserved[LP64_SWITCH(16, 8)]; ///< Reserved for future extensions
bool operator<(const IpcMemHandle& h) const {
int cmp = std::memcmp(ipc_handle, h.ipc_handle, AMD_IPC_MEM_HANDLE_SIZE);