IPC supported using ROCR APIs

Change-Id: I0a353b1240098f4b20fa266a871f5f5826290af9
This commit is contained in:
Rahul Garg
2017-03-10 23:45:28 +05:30
parent 37ed319a20
commit 32d8a58f18
3 changed files with 19 additions and 13 deletions
+6 -1
View File
@@ -62,7 +62,12 @@ typedef struct ihipStream_t *hipStream_t;
#define hipIpcMemLazyEnablePeerAccess 0 #define hipIpcMemLazyEnablePeerAccess 0
typedef struct ihipIpcMemHandle_t *hipIpcMemHandle_t; #define HIP_IPC_HANDLE_SIZE 64
typedef struct hipIpcMemHandle_st
{
char reserved[HIP_IPC_HANDLE_SIZE];
}hipIpcMemHandle_t;
//TODO: IPC event handle currently unsupported //TODO: IPC event handle currently unsupported
struct ihipIpcEventHandle_t; struct ihipIpcEventHandle_t;
+3 -3
View File
@@ -36,7 +36,7 @@ THE SOFTWARE.
#error("This version of HIP requires a newer version of HCC."); #error("This version of HIP requires a newer version of HCC.");
#endif #endif
#define USE_IPC 0 #define USE_IPC 1
//--- //---
// Environment variables: // Environment variables:
@@ -326,15 +326,15 @@ const hipStream_t hipStreamNull = 0x0;
/** /**
* HIP IPC Handle Size * HIP IPC Handle Size
*/ */
#define HIP_IPC_HANDLE_SIZE 64 #define HIP_IPC_RESERVED_SIZE 24
class ihipIpcMemHandle_t class ihipIpcMemHandle_t
{ {
public: public:
#if USE_IPC #if USE_IPC
hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr
#endif #endif
char reserved[HIP_IPC_HANDLE_SIZE];
size_t psize; size_t psize;
char reserved[HIP_IPC_RESERVED_SIZE];
}; };
+10 -9
View File
@@ -1143,7 +1143,7 @@ hipError_t hipMemGetAddressRange ( hipDeviceptr_t* pbase, size_t* psize, hipDevi
} }
else else
hipStatus = hipErrorInvalidDevicePointer; hipStatus = hipErrorInvalidDevicePointer;
return hipStatus; return ihipLogStatus(hipStatus);
} }
@@ -1162,25 +1162,25 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr){
} }
else else
hipStatus = hipErrorInvalidResourceHandle; hipStatus = hipErrorInvalidResourceHandle;
ihipIpcMemHandle_t* iHandle = (ihipIpcMemHandle_t*) handle;
// Save the size of the pointer to hipIpcMemHandle // Save the size of the pointer to hipIpcMemHandle
(*handle)->psize = psize; iHandle->psize = psize;
#if USE_IPC #if USE_IPC
// Create HSA ipc memory // Create HSA ipc memory
hsa_status_t hsa_status = hsa_status_t hsa_status =
hsa_amd_ipc_memory_create(devPtr, psize, &(*handle)->ipc_handle); hsa_amd_ipc_memory_create(devPtr, psize, (hsa_amd_ipc_memory_t*) &(iHandle->ipc_handle));
if(hsa_status!= HSA_STATUS_SUCCESS) if(hsa_status!= HSA_STATUS_SUCCESS)
hipStatus = hipErrorMemoryAllocation; hipStatus = hipErrorMemoryAllocation;
#else #else
hipStatus = hipErrorRuntimeOther; hipStatus = hipErrorRuntimeOther;
#endif #endif
return hipStatus; return ihipLogStatus(hipStatus);
} }
hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags){ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags){
// HIP_INIT_API ( devPtr, handle.handle , flags); HIP_INIT_API ( devPtr, &handle , flags);
hipError_t hipStatus = hipSuccess; hipError_t hipStatus = hipSuccess;
#if USE_IPC #if USE_IPC
@@ -1190,15 +1190,16 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned
if(!agent) if(!agent)
return hipErrorInvalidResourceHandle; return hipErrorInvalidResourceHandle;
ihipIpcMemHandle_t* iHandle = (ihipIpcMemHandle_t*) &handle;
//Attach ipc memory //Attach ipc memory
hsa_status_t hsa_status = hsa_status_t hsa_status =
hsa_amd_ipc_memory_attach(&handle->ipc_handle, handle->psize, 1, agent, devPtr); hsa_amd_ipc_memory_attach((hsa_amd_ipc_memory_t*)&(iHandle->ipc_handle), iHandle->psize, 1, agent, devPtr);
if(hsa_status != HSA_STATUS_SUCCESS) if(hsa_status != HSA_STATUS_SUCCESS)
hipStatus = hipErrorMapBufferObjectFailed; hipStatus = hipErrorMapBufferObjectFailed;
#else #else
hipStatus = hipErrorRuntimeOther; hipStatus = hipErrorRuntimeOther;
#endif #endif
return hipStatus; return ihipLogStatus(hipStatus);
} }
hipError_t hipIpcCloseMemHandle(void *devPtr){ hipError_t hipIpcCloseMemHandle(void *devPtr){
@@ -1213,7 +1214,7 @@ hipError_t hipIpcCloseMemHandle(void *devPtr){
#else #else
hipStatus = hipErrorRuntimeOther; hipStatus = hipErrorRuntimeOther;
#endif #endif
return hipStatus; return ihipLogStatus(hipStatus);
} }
// hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle){ // hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle){