SWDEV-432977 - Set the correct device id in hipIpcOpenMemHandle

hipIpcOpenMemHandle can be used to open memory handle and fetch
  a device pointer on a different device than the actual device
  where the memory was allocated. The device Id must be set to
  the current device in such cases and not the original device.

Change-Id: Ie1c7eada928d02124a41125876876f96015552e5
This commit is contained in:
Satyanvesh Dittakavi
2023-11-20 13:40:18 +00:00
parent 3f2f7252aa
commit c398c75512
+4
View File
@@ -3492,6 +3492,7 @@ hipError_t hipIpcOpenMemHandle(void** dev_ptr, hipIpcMemHandle_t handle, unsigne
amd::Memory* amd_mem_obj = nullptr;
amd::Device* device = nullptr;
ihipIpcMemHandle_t* ihandle = nullptr;
size_t offset = 0;
if (dev_ptr == nullptr || flags != hipIpcMemLazyEnablePeerAccess) {
HIP_RETURN(hipErrorInvalidValue);
@@ -3516,6 +3517,9 @@ hipError_t hipIpcOpenMemHandle(void** dev_ptr, hipIpcMemHandle_t handle, unsigne
HIP_RETURN(hipErrorInvalidDevicePointer);
}
amd_mem_obj = getMemoryObject(*dev_ptr, offset);
amd_mem_obj->getUserData().deviceId = hip::getCurrentDevice()->deviceId();
HIP_RETURN(hipSuccess);
}