Fixed hipDeviceGetByPCIBusId

Change-Id: Ia36bb9425671ef7659541c9aeedae4098456a31b
Dieser Commit ist enthalten in:
Rahul Garg
2017-06-30 10:11:41 +05:30
Ursprung 0fe0381608
Commit 467a2ba014
2 geänderte Dateien mit 20 neuen und 12 gelöschten Zeilen
+18 -10
Datei anzeigen
@@ -399,17 +399,25 @@ hipError_t hipDeviceGetByPCIBusId (int* device, const int* pciBusId )
{
HIP_INIT_API(device,pciBusId);
hipDeviceProp_t tempProp;
int deviceCount;
int deviceCount = 0 ;
hipError_t e = hipErrorInvalidValue;
ihipGetDeviceCount( &deviceCount );
*device = 0;
for (int i = 0; i< deviceCount; i++) {
ihipGetDeviceProperties( &tempProp, i );
if(tempProp.pciBusID == *pciBusId) {
*device =i;
e = hipSuccess;
break;
}
if((device != nullptr) && (pciBusId != nullptr)) {
int pciBusID = -1;
int pciDeviceID = -1;
int pciDomainID = -1;
int len = 0;
len = sscanf (pciBusId,"%04x:%02x:%02x",&pciDomainID,&pciBusID,&pciDeviceID);
if(len == 3) {
ihipGetDeviceCount( &deviceCount );
for (int i = 0; i< deviceCount; i++) {
ihipGetDeviceProperties( &tempProp, i );
if(tempProp.pciBusID == pciBusID) {
*device = i;
e = hipSuccess;
break;
}
}
}
}
return ihipLogStatus(e);
}