From 5eed20be123db9e575efed800512328f21807716 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Tue, 13 Dec 2016 15:07:04 -0600 Subject: [PATCH] Add USE_IPC to disable use of IPC APIs. Set to 0. --- hipamd/src/hip_hcc.h | 3 +++ hipamd/src/hip_memory.cpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hipamd/src/hip_hcc.h b/hipamd/src/hip_hcc.h index 82290bc489..b5417080e0 100644 --- a/hipamd/src/hip_hcc.h +++ b/hipamd/src/hip_hcc.h @@ -34,6 +34,7 @@ THE SOFTWARE. #endif #define USE_DISPATCH_HSA_KERNEL 1 +#define USE_IPC 0 // @@ -375,7 +376,9 @@ struct LockedBase { class ihipIpcMemHandle_t { public: +#if USE_IPC hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr +#endif char reserved[HIP_IPC_HANDLE_SIZE]; size_t psize; }; diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index f2ab6d19a0..7aa6ef4942 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -1056,11 +1056,15 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr){ // Save the size of the pointer to hipIpcMemHandle (*handle)->psize = psize; +#if USE_IPC // Create HSA ipc memory hsa_status_t hsa_status = hsa_amd_ipc_memory_create(devPtr, psize, &(*handle)->ipc_handle); if(hsa_status!= HSA_STATUS_SUCCESS) hipStatus = hipErrorMemoryAllocation; +#else + hipStatus = hipErrorRuntimeOther; +#endif return hipStatus; } @@ -1069,6 +1073,7 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned // HIP_INIT_API ( devPtr, handle.handle , flags); hipError_t hipStatus = hipSuccess; +#if USE_IPC // Get the current device agent. hc::accelerator acc; hsa_agent_t *agent = static_cast(acc.get_hsa_agent()); @@ -1080,7 +1085,9 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned hsa_amd_ipc_memory_attach(&handle->ipc_handle, handle->psize, 1, agent, devPtr); if(hsa_status != HSA_STATUS_SUCCESS) hipStatus = hipErrorMapBufferObjectFailed; - +#else + hipStatus = hipErrorRuntimeOther; +#endif return hipStatus; } @@ -1088,10 +1095,14 @@ hipError_t hipIpcCloseMemHandle(void *devPtr){ HIP_INIT_API ( devPtr ); hipError_t hipStatus = hipSuccess; +#if USE_IPC hsa_status_t hsa_status = hsa_amd_ipc_memory_detach(devPtr); if(hsa_status != HSA_STATUS_SUCCESS) return hipErrorInvalidResourceHandle; +#else + hipStatus = hipErrorRuntimeOther; +#endif return hipStatus; }