Query agent family id from roct

Add agent info query HSA_AMD_AGENT_INFO_ASIC_FAMILY_ID.
Then we can remove the codes to parse family id.

Signed-off-by: Lang Yu <Lang.Yu@amd.com>
Change-Id: I3ac4746d3015e89b32322ebc0f8a3084f98677a4


[ROCm/ROCR-Runtime commit: d0e7c617df]
This commit is contained in:
Lang Yu
2022-08-17 11:40:37 +08:00
والد 2ce78f0612
کامیت 6283510a9f
6فایلهای تغییر یافته به همراه16 افزوده شده و 148 حذف شده
@@ -367,6 +367,9 @@ hsa_status_t CpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
return core::Runtime::runtime_singleton_->GetSystemInfo(HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY,
value);
break;
case HSA_AMD_AGENT_INFO_ASIC_FAMILY_ID:
*((uint32_t*)value) = static_cast<uint32_t>(properties_.FamilyID);
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
@@ -1102,6 +1102,9 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY:
*((uint64_t*)value) = wallclock_frequency_;
break;
case HSA_AMD_AGENT_INFO_ASIC_FAMILY_ID:
*((uint32_t*)value) = static_cast<uint32_t>(properties_.FamilyID);
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
@@ -79,150 +79,5 @@ hsa_status_t GetGPUAsicID(hsa_agent_t agent, uint32_t *chip_id) {
return HSA_STATUS_SUCCESS;
}
uint32_t DevIDToAddrLibFamily(uint32_t dev_id) {
uint32_t major_ver = MajorVerFromDevID(dev_id);
uint32_t minor_ver = MinorVerFromDevID(dev_id);
uint32_t step = StepFromDevID(dev_id);
// FAMILY_UNKNOWN 0xFF
// FAMILY_SI - Southern Islands: Tahiti (P), Pitcairn (PM), Cape Verde (M), Bali (V)
// FAMILY_TN - Fusion Trinity: Devastator - DVST (M), Scrapper (V)
// FAMILY_CI - Sea Islands: Hawaii (P), Maui (P), Bonaire (M)
// FAMILY_KV - Fusion Kaveri: Spectre, Spooky; Fusion Kabini: Kalindi
// FAMILY_VI - Volcanic Islands: Iceland (V), Tonga (M)
// FAMILY_CZ - Carrizo, Nolan, Amur
// FAMILY_PI - Pirate Islands
// FAMILY_AI - Arctic Islands
// FAMILY_RV - Raven
// FAMILY_NV - Navi
switch (major_ver) {
case 6:
switch (minor_ver) {
case 0:
switch (step) {
case 0:
case 1:
return FAMILY_SI;
default:
return FAMILY_UNKNOWN;
}
default:
return FAMILY_UNKNOWN;
}
case 7:
switch (minor_ver) {
case 0:
switch (step) {
case 0:
case 1:
case 2:
return FAMILY_CI;
case 3:
return FAMILY_KV;
default:
return FAMILY_UNKNOWN;
}
default:
return FAMILY_UNKNOWN;
}
case 8:
switch (minor_ver) {
case 0:
switch (step) {
case 0:
case 2:
case 3:
case 4:
return FAMILY_VI;
case 1:
return FAMILY_CZ;
default:
return FAMILY_UNKNOWN;
}
default:
return FAMILY_UNKNOWN;
}
case 9:
switch (minor_ver) {
case 0:
switch (step) {
case 0:
case 1:
case 4: // Vega12
case 6: // Vega20
case 8: // Arcturus
case 10: // Aldebaran
return FAMILY_AI;
case 2:
case 3:
case 12:
return FAMILY_RV;
default:
return FAMILY_UNKNOWN;
}
default:
return FAMILY_UNKNOWN;
}
case 10:
switch (minor_ver) {
case 0:
case 1: // Navi
case 3:
switch (step) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return FAMILY_NV;
default:
return FAMILY_UNKNOWN;
}
default:
return FAMILY_UNKNOWN;
}
case 11:
switch (minor_ver) {
case 0:
switch (step) {
case 0:
case 1:
case 2:
return FAMILY_GFX1100;
case 3:
return FAMILY_GFX1103;
default:
return FAMILY_UNKNOWN;
}
default:
return FAMILY_UNKNOWN;
}
default:
return FAMILY_UNKNOWN;
}
assert(0); // We should have already returned
}
} // namespace image
} // namespace rocr
@@ -52,7 +52,6 @@ namespace image {
uint32_t MajorVerFromDevID(uint32_t dev_id);
uint32_t MinorVerFromDevID(uint32_t dev_id);
uint32_t StepFromDevID(uint32_t dev_id);
uint32_t DevIDToAddrLibFamily(uint32_t dev_id);
hsa_status_t GetGPUAsicID(hsa_agent_t agent, uint32_t *chip_id);
} // namespace image
@@ -74,7 +74,9 @@ hsa_status_t ImageManagerKv::Initialize(hsa_agent_t agent_handle) {
uint32_t major_ver = MajorVerFromDevID(chip_id_);
assert(status == HSA_STATUS_SUCCESS);
family_type_ = DevIDToAddrLibFamily(chip_id_);
status = HSA::hsa_agent_get_info(
agent_, static_cast<hsa_agent_info_t>(HSA_AMD_AGENT_INFO_ASIC_FAMILY_ID), &family_type_);
assert(status == HSA_STATUS_SUCCESS);
HsaGpuTileConfig tileConfig = {0};
unsigned int tc[40];
@@ -330,7 +330,13 @@ typedef enum hsa_amd_agent_info_s {
* in the range 1-400MHz.
* The type of this attribute is uint64_t.
*/
HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY = 0xA016
HSA_AMD_AGENT_INFO_TIMESTAMP_FREQUENCY = 0xA016,
/**
* Queries for the ASIC family ID of an agent.
* The type of this attribute is uint32_t.
*/
HSA_AMD_AGENT_INFO_ASIC_FAMILY_ID = 0xA107
} hsa_amd_agent_info_t;
typedef struct hsa_amd_hdp_flush_s {