diff --git a/hipamd/include/hip/hcc_detail/hip_runtime_api.h b/hipamd/include/hip/hcc_detail/hip_runtime_api.h index b62d0c4957..8eecd1650f 100644 --- a/hipamd/include/hip/hcc_detail/hip_runtime_api.h +++ b/hipamd/include/hip/hcc_detail/hip_runtime_api.h @@ -1591,6 +1591,16 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device); */ hipError_t hipDeviceGetPCIBusId (int *pciBusId,int len,hipDevice_t device); +/** + * @brief Returns a handle to a compute device. + * @param [out] device handle + * @param [in] PCI Bus ID + * + * @returns #hipSuccess, #hipErrorInavlidDevice, #hipErrorInvalidValue + */ +hipError_t hipDeviceGetByPCIBusId ( int* device,const int* pciBusId ); + + /** * @brief Returns the total amount of memory on the device. * @param [out] bytes diff --git a/hipamd/src/hip_device.cpp b/hipamd/src/hip_device.cpp index 9d577f5313..29ab0805b8 100644 --- a/hipamd/src/hip_device.cpp +++ b/hipamd/src/hip_device.cpp @@ -340,8 +340,28 @@ hipError_t hipDeviceTotalMem (size_t *bytes,hipDevice_t device) return ihipLogStatus(e); } +hipError_t hipDeviceGetByPCIBusId (int* device, const int* pciBusId ) +{ + HIP_INIT_API(device,pciBusId); + hipDeviceProp_t tempProp; + int deviceCount; + hipError_t e = hipErrorInvalidValue; + hipGetDeviceCount( &deviceCount ); + *device = 0; + for (int i=0; i< deviceCount; i++) { + hipGetDeviceProperties( &tempProp, i ); + if(tempProp.pciBusID == *pciBusId) { + *device =i; + e = hipSuccess; + break; + } + } + return ihipLogStatus(e); +} + hipError_t hipChooseDevice( int* device, const hipDeviceProp_t* prop ) { + HIP_INIT_API(device,prop); hipDeviceProp_t tempProp; int deviceCount; int inPropCount=0;