SWDEV-294591 - Fix hipEventIpc failure on NV

make hipIpcOpenEventHandle has the same behavour of cudaIpcOpenEventHandle.

Change-Id: I3fe6dbc35a7b14ba9119df297b7885df83d28149


[ROCm/clr commit: c87a352288]
Этот коммит содержится в:
Tao Sang
2021-07-28 00:03:29 -04:00
коммит произвёл Tao Sang
родитель 9b27759df1
Коммит eac431380a
2 изменённых файлов: 11 добавлений и 0 удалений
+10
Просмотреть файл
@@ -21,6 +21,9 @@
#include <hip/hip_runtime.h>
#include "hip_event.hpp"
#if !defined(_MSC_VER)
#include <unistd.h>
#endif
void ipcEventCallback(hipStream_t stream, hipError_t status, void* user_data)
{
@@ -413,6 +416,8 @@ hipError_t hipIpcGetEventHandle(hipIpcEventHandle_t* handle, hipEvent_t event) {
if (!createIpcEventShmemIfNeeded(e->ipc_evt_)) {
HIP_RETURN(hipErrorInvalidConfiguration);
}
e->ipc_evt_.ipc_shmem_->owners_device_id = e->deviceId();
e->ipc_evt_.ipc_shmem_->owners_process_id = getpid();
ihipIpcEventHandle_t* iHandle = reinterpret_cast<ihipIpcEventHandle_t*>(handle);
memset(iHandle->shmem_name, 0, HIP_IPC_HANDLE_SIZE);
e->ipc_evt_.ipc_name_.copy(iHandle->shmem_name, std::string::npos);
@@ -443,6 +448,11 @@ hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle)
HIP_RETURN(hipErrorInvalidValue);
}
if (getpid() == ipc_evt.ipc_shmem_->owners_process_id.load()) {
// If this is in the same process, return error.
HIP_RETURN(hipErrorInvalidContext);
}
ipc_evt.ipc_shmem_->owners += 1;
e->setDeviceId(ipc_evt.ipc_shmem_->owners_device_id.load());
+1
Просмотреть файл
@@ -58,6 +58,7 @@ public:
typedef struct ihipIpcEventShmem_s {
std::atomic<int> owners;
std::atomic<int> owners_device_id;
std::atomic<int> owners_process_id;
std::atomic<int> read_index;
std::atomic<int> write_index;
std::atomic<int> signal[IPC_SIGNALS_PER_EVENT];