BDFID (BusID/DeviceID/FunctionID) support.
Except FunctionID (or DomainID in CUDA) support, because cudaDeviceProp::pciDomainID is not reported by CUDA.
[ROCm/hip commit: 33f60c300d]
This commit is contained in:
@@ -91,6 +91,8 @@ typedef struct hipDeviceProp_t {
|
|||||||
int clockInstructionRate; ///< Frequency in khz of the timer used by the device-side "clock*" instructions. New for HIP.
|
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.
|
hipDeviceArch_t arch; ///< Architectural feature flags. New for HIP.
|
||||||
int concurrentKernels; ///< Device can possibly execute multiple kernels concurrently.
|
int concurrentKernels; ///< Device can possibly execute multiple kernels concurrently.
|
||||||
|
int pciBusID; ///< PCI Bus ID.
|
||||||
|
int pciDeviceID; ///< PCI Device ID.
|
||||||
} hipDeviceProp_t;
|
} hipDeviceProp_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -146,6 +148,8 @@ typedef enum hipDeviceAttribute_t {
|
|||||||
hipDeviceAttributeMaxThreadsPerMultiProcessor, ///< Maximum resident threads per multiprocessor.
|
hipDeviceAttributeMaxThreadsPerMultiProcessor, ///< Maximum resident threads per multiprocessor.
|
||||||
hipDeviceAttributeComputeCapabilityMajor, ///< Major compute capability version number.
|
hipDeviceAttributeComputeCapabilityMajor, ///< Major compute capability version number.
|
||||||
hipDeviceAttributeComputeCapabilityMinor, ///< Minor compute capability version number.
|
hipDeviceAttributeComputeCapabilityMinor, ///< Minor compute capability version number.
|
||||||
|
hipDeviceAttributePciBusId, ///< PCI Bus ID.
|
||||||
|
hipDeviceAttributePciDeviceId, ///< PCI Device ID.
|
||||||
} hipDeviceAttribute_t;
|
} hipDeviceAttribute_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -252,8 +252,10 @@ inline static hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t att
|
|||||||
cdattr = cudaDevAttrMaxThreadsPerMultiProcessor; break;
|
cdattr = cudaDevAttrMaxThreadsPerMultiProcessor; break;
|
||||||
case hipDeviceAttributeComputeCapabilityMajor:
|
case hipDeviceAttributeComputeCapabilityMajor:
|
||||||
cdattr = cudaDevAttrComputeCapabilityMajor; break;
|
cdattr = cudaDevAttrComputeCapabilityMajor; break;
|
||||||
case hipDeviceAttributeComputeCapabilityMinor:
|
case hipDeviceAttributePciBusId:
|
||||||
cdattr = cudaDevAttrComputeCapabilityMinor; break;
|
cdattr = cudaDevAttrPciBusId; break;
|
||||||
|
case hipDeviceAttributePciDeviceId:
|
||||||
|
cdattr = cudaDevAttrPciDeviceId; break;
|
||||||
default:
|
default:
|
||||||
cerror = cudaErrorInvalidValue; break;
|
cerror = cudaErrorInvalidValue; break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,7 +310,16 @@ hipError_t ihipDevice_t::getProperties(hipDeviceProp_t* prop)
|
|||||||
//prop->clockInstructionRate = counterHz / 1000;
|
//prop->clockInstructionRate = counterHz / 1000;
|
||||||
prop->clockInstructionRate = 100*1000; /* TODO-RT - hard-code until HSART has function to properly report clock */
|
prop->clockInstructionRate = 100*1000; /* TODO-RT - hard-code until HSART has function to properly report clock */
|
||||||
|
|
||||||
|
// Get Agent BDFID (bus/device/function ID)
|
||||||
|
uint16_t bdf_id = 1;
|
||||||
|
err = hsa_agent_get_info(_hsa_agent, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_BDFID, &bdf_id);
|
||||||
|
DeviceErrorCheck(err);
|
||||||
|
|
||||||
|
// BDFID is 16bit uint: [8bit - BusID | 5bit - Device ID | 3bit - Function/DomainID]
|
||||||
|
// TODO/Clarify: cudaDeviceProp::pciDomainID how to report?
|
||||||
|
// prop->pciDomainID = bdf_id & 0x7;
|
||||||
|
prop->pciDeviceID = (bdf_id>>3) & 0x1F;
|
||||||
|
prop->pciBusID = (bdf_id>>8) & 0xFF;
|
||||||
|
|
||||||
// Masquerade as a 3.0-level device. This will change as more HW functions are properly supported.
|
// Masquerade as a 3.0-level device. This will change as more HW functions are properly supported.
|
||||||
// Application code should use the arch.has* to do detailed feature detection.
|
// Application code should use the arch.has* to do detailed feature detection.
|
||||||
@@ -839,6 +848,10 @@ hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device)
|
|||||||
*pi = prop->major; break;
|
*pi = prop->major; break;
|
||||||
case hipDeviceAttributeComputeCapabilityMinor:
|
case hipDeviceAttributeComputeCapabilityMinor:
|
||||||
*pi = prop->minor; break;
|
*pi = prop->minor; break;
|
||||||
|
case hipDeviceAttributePciBusId:
|
||||||
|
*pi = prop->pciBusID; break;
|
||||||
|
case hipDeviceAttributePciDeviceId:
|
||||||
|
*pi = prop->pciDeviceID; break;
|
||||||
default:
|
default:
|
||||||
e = hipErrorInvalidValue; break;
|
e = hipErrorInvalidValue; break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ int main(int argc, char *argv[])
|
|||||||
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerMultiProcessor, props.maxThreadsPerMultiProcessor));
|
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeMaxThreadsPerMultiProcessor, props.maxThreadsPerMultiProcessor));
|
||||||
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMajor, props.major));
|
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMajor, props.major));
|
||||||
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMinor, props.minor));
|
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributeComputeCapabilityMinor, props.minor));
|
||||||
|
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePciBusId, props.pciBusID));
|
||||||
|
CHECK(test_hipDeviceGetAttribute(deviceId, hipDeviceAttributePciDeviceId, props.pciDeviceID));
|
||||||
passed();
|
passed();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user