From 8420edd5e44eaec81ea19b3022e90dfbd68b3787 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 7 Dec 2016 12:12:40 +0530 Subject: [PATCH] hipDeviceGetPCIBusId int version changes for CUDA runtime API Change-Id: I4d3b995f1d1ac83415ca84808a074e5c8cd72f3c [ROCm/hip commit: 266b27ac832d6a44c5ef9a12b96c65d759b09d04] --- .../hip/include/hip/hcc_detail/hip_runtime_api.h | 2 +- .../hip/include/hip/nvcc_detail/hip_runtime_api.h | 7 ++++++- projects/hip/src/hip_device.cpp | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) 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 1af8108441..3ab43ea64d 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1622,7 +1622,7 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device); * * @returns #hipSuccess, #hipErrorInavlidDevice */ -// hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device); +hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device); /** diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 1a24615475..5f5931cf1b 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -770,9 +770,14 @@ inline static hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) return hipCUResultTohipError(cuDeviceGetName(name,len,device)); } +inline static hipError_t hipDeviceGetPCIBusId(char* pciBusId,int len,int device) +{ + return hipCUDAErrorTohipError(cudaDeviceGetPCIBusId(pciBusId,len,device)); +} + inline static hipError_t hipDeviceGetPCIBusId(char* pciBusId,int len,hipDevice_t device) { - return hipCUResultTohipError(cuDeviceGetPCIBusId((char*)pciBusId,len,device)); + return hipCUResultTohipError(cuDeviceGetPCIBusId(pciBusId,len,device)); } inline static hipError_t hipDeviceGetByPCIBusId(int* device, const int *pciBusId) diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 093277b941..75266efd4a 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -337,6 +337,20 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) return ihipLogStatus(e); } +hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device) +{ + HIP_INIT_API(pciBusId, len, device); + hipError_t e = hipSuccess; + int deviceId= device->_deviceId; + int tempPciBusId = 0; + e = ihipDeviceGetAttribute( &tempPciBusId, hipDeviceAttributePciBusId, deviceId); + if( e == hipSuccess) { + std::string tempPciStr = std::to_string(tempPciBusId); + memcpy( pciBusId , tempPciStr.c_str() , tempPciStr.length() ); + } + return ihipLogStatus(e); +} + hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device) { HIP_INIT_API(pciBusId, len, device);