From 0eb4ba9883364477971dbb8a799b021c74054182 Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Fri, 17 May 2024 17:41:38 +0100 Subject: [PATCH] SWDEV-462570 - synchronize the streams before ipcDetach Change-Id: Ic007be31913496af0414d983f906b704c32ac02c --- hipamd/src/hip_memory.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 7bcc1ba48a..a6d9a1b1ed 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -3552,6 +3552,12 @@ hipError_t hipIpcCloseMemHandle(void* dev_ptr) { HIP_RETURN(hipErrorInvalidValue); } + amd_mem_obj = amd::MemObjMap::FindMemObj(dev_ptr); + if (amd_mem_obj != nullptr) { + auto device_id = amd_mem_obj->getUserData().deviceId; + g_devices[device_id]->SyncAllStreams(); + } + /* Call IPC Detach from Device class */ device = hip::getCurrentDevice()->devices()[0]; if (device == nullptr) { @@ -3560,7 +3566,7 @@ hipError_t hipIpcCloseMemHandle(void* dev_ptr) { /* detach the memory */ if (!device->IpcDetach(dev_ptr)){ - HIP_RETURN(hipErrorInvalidValue); + HIP_RETURN(hipErrorInvalidValue); } HIP_RETURN(hipSuccess);