diff --git a/include/hip/hip_runtime_api.h b/include/hip/hip_runtime_api.h index dc163d5c25..0cdace0e99 100644 --- a/include/hip/hip_runtime_api.h +++ b/include/hip/hip_runtime_api.h @@ -102,6 +102,7 @@ typedef struct hipDeviceProp_t { int clockInstructionRate; ///< Frequency in khz of the timer used by the device-side "clock*" instructions. New for HIP. hipDeviceArch_t arch; ///< Architectural feature flags. New for HIP. int concurrentKernels; ///< Device can possibly execute multiple kernels concurrently. + int pciDomainID; ///< PCI Domain ID int pciBusID; ///< PCI Bus ID. int pciDeviceID; ///< PCI Device ID. size_t maxSharedMemoryPerMultiProcessor; ///< Maximum Shared Memory Per Multiprocessor. diff --git a/src/hip_device.cpp b/src/hip_device.cpp index 2bb9970d35..62518a1ba7 100644 --- a/src/hip_device.cpp +++ b/src/hip_device.cpp @@ -376,15 +376,10 @@ hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device) e = hipErrorInvalidDevice; } else { if((pciBusId != nullptr) && (len > 0)) { - int tempPciBusId = 0; - e = ihipDeviceGetAttribute( &tempPciBusId, hipDeviceAttributePciBusId, device); - if( e == hipSuccess) { - std::string tempPciStr = std::to_string(tempPciBusId); - if( len < tempPciStr.length()){ - e = hipErrorInvalidValue; - } else { - memcpy( pciBusId , tempPciStr.c_str() , tempPciStr.length() ); - } + auto deviceHandle = ihipGetDevice(device); + int retVal = snprintf(pciBusId,len, "%04x:%02x:%02x.0",deviceHandle->_props.pciDomainID,deviceHandle->_props.pciBusID,deviceHandle->_props.pciDeviceID); + if( retVal > 0 && retVal < len) { + e = hipSuccess; } } } diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index be591f2f04..f7f617615b 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -799,7 +799,7 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) DeviceErrorCheck(err); // BDFID is 16bit uint: [8bit - BusID | 5bit - Device ID | 3bit - Function/DomainID] - // prop->pciDomainID = bdf_id & 0x7; + prop->pciDomainID = bdf_id & 0x7; prop->pciDeviceID = (bdf_id>>3) & 0x1F; prop->pciBusID = (bdf_id>>8) & 0xFF;