diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 83c60f3e35..3793cfdf8c 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -57,6 +57,30 @@ typedef struct ihipDevice_t *hipDevice_t; typedef struct ihipStream_t *hipStream_t; +//TODO: IPC implementation + +#define hipIpcMemLazyEnablePeerAccess 0 +struct ihipIpcMemHandle_t; +typedef struct ihipIpcMemHandle_t *hipIpcMemHandle_t; +struct ihipIpcEventHandle_t; +typedef struct ihipIpcEventHandle_t *hipIpcEventHandle_t; + +typedef std::nullptr_t nullptr_t ; + +__device__ double +__longlong_as_double(long long int x) +{ + return (double)x; +} +__device__ long long int +__double_as_longlong(double x) +{ + return (long long int)x; +} + + +//END TODO + typedef struct ihipModule_t *hipModule_t; typedef struct ihipFunction_t *hipFunction_t; @@ -1605,11 +1629,23 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device); * @brief Returns a PCI Bus Id string for the device. * @param [out] pciBusId * @param [in] len + * @param [hipDevice_t] device + * + * @returns #hipSuccess, #hipErrorInavlidDevice + */ +// hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device); + + +/** + * @brief Returns a PCI Bus Id string for the device, overloaded to take int device ID. + * @param [out] pciBusId + * @param [in] len * @param [in] device * * @returns #hipSuccess, #hipErrorInavlidDevice */ -hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device); +hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,int device); + /** * @brief Returns a handle to a compute device. @@ -1791,7 +1827,11 @@ hipError_t hipProfilerStop(); * @} */ - +//TODO: implement IPC apis +hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr); +hipError_t hipIpcCloseMemHandle(void *devPtr); +hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle); +hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags); #ifdef __cplusplus diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 868dd0b05d..38021ad525 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -337,13 +337,21 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) return ihipLogStatus(e); } -hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device) +// hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device) +// { +// HIP_INIT_API(pciBusId, len, device); +// hipError_t e = hipSuccess; +// int deviceId= device->_deviceId; +// e = ihipDeviceGetAttribute((int*)pciBusId, hipDeviceAttributePciBusId, deviceId); +// return ihipLogStatus(e); +// } + +hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,int device) { HIP_INIT_API(pciBusId, len, device); hipError_t e = hipSuccess; - int deviceId= device->_deviceId; int tempPciBusId = 0; - e = ihipDeviceGetAttribute( &tempPciBusId, hipDeviceAttributePciBusId, deviceId); + e = ihipDeviceGetAttribute( &tempPciBusId, hipDeviceAttributePciBusId, device); if( e == hipSuccess) { std::string tempPciStr = std::to_string(tempPciBusId); memcpy( pciBusId , tempPciStr.c_str() , tempPciStr.length() ); diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 4b91228032..b565c5a770 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1034,3 +1034,18 @@ hipError_t hipMemGetAddressRange ( hipDeviceptr_t* pbase, size_t* psize, hipDevi hipStatus = hipErrorInvalidDevicePointer; return hipStatus; } + + +//TODO: IPC implementaiton: +hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr){ + return hipSuccess; +} +hipError_t hipIpcCloseMemHandle(void *devPtr){ + return hipSuccess; +} +hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle){ + return hipSuccess; +} +hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags){ + return hipSuccess; +}