[SWDEV-493274/SWDEV-514998] Add AMD SMI partition tests + Add Guest amd-smi static --partition (#127)

* [SWDEV-493274/SWDEV-514998] Add AMD SMI partition tests + Add Guest amd-smi static --partition

Changes:
    - Added amd-smi static --partition for guest systems
    - Added C++ tests for memory and compute (accelerator) partitions
    - Added Python tests for amdsmi_get_gpu_vram_info(),
       amdsmi_get_gpu_accelerator_partition_profile_config()
    - Updated Python tests for
      amdsmi_get_gpu_accelerator_partition_profile()
      Now includes more profile and resource detail
    - Added amdsmi_get_gpu_xcd_counter();
      Tests provided for both C++/Python APIs
    - Added AmdSmiVramType & AmdSmiVramVendor: they were missing
      python testing required adding.

Change-Id: Ib6549d8ccc5fb68726f38745b87c78f890186022
Signed-off-by: Charis Poag <Charis.Poag@amd.com>
This commit is contained in:
Poag, Charis
2025-03-11 16:38:46 -05:00
committad av GitHub
förälder d9fee767c3
incheckning 48cb5529d2
30 ändrade filer med 3505 tillägg och 399 borttagningar
+14 -2
Visa fil
@@ -6577,6 +6577,16 @@ rsmi_dev_partition_id_get(uint32_t dv_ind, uint32_t *partition_id) {
if (ret == RSMI_STATUS_SUCCESS) {
*partition_id = static_cast<uint32_t>((pci_id >> 28) & 0xf);
}
std::ostringstream bdf_sstream;
bdf_sstream << std::hex << std::setfill('0') << std::setw(4)
<< ((pci_id >> 32) & 0xFFFFFFFF) << ":";
bdf_sstream << std::hex << std::setfill('0') << std::setw(2) << ((pci_id >> 8) & 0xFF) << ":";
bdf_sstream << std::hex << std::setfill('0') << std::setw(2) << ((pci_id >> 3) & 0xF8) << ".";
bdf_sstream << std::hex << std::setfill('0') << +(pci_id & 0x7);
bdf_sstream << "\nPartition ID ((pci_id >> 28) & 0xf): " << std::dec
<< static_cast<int>((pci_id >> 28) & 0xf);
bdf_sstream << "\nPartition ID (pci_id & 0x7): " << std::dec << static_cast<int>(pci_id & 0x7);
// std::cout << __PRETTY_FUNCTION__ << " BDF: " << bdf_sstream.str() << std::endl;
/**
* Fall back is required due to driver changes within KFD.
@@ -6603,9 +6613,11 @@ rsmi_dev_partition_id_get(uint32_t dv_ind, uint32_t *partition_id) {
<< " | Success"
<< " | Device #: " << dv_ind
<< " | Type: partition_id"
<< " | Data: " << *partition_id
<< " | Data: " << static_cast<int>(*partition_id)
<< " | Returning = "
<< getRSMIStatusString(RSMI_STATUS_SUCCESS) << " |";
<< getRSMIStatusString(RSMI_STATUS_SUCCESS) << " |"
<< "\n BDF: " << bdf_sstream.str() << std::endl;
// std::cout << ss.str() << std::endl;
LOG_INFO(ss);
return ret;
CATCH
+34 -1
Visa fil
@@ -1020,7 +1020,7 @@ int Device::readDevInfoLine(DevInfoTypes type, std::string *line) {
<< get_type_string(type) << "), returning *line = "
<< *line;
LOG_INFO(ss);
fs.close();
return 0;
}
@@ -1103,6 +1103,7 @@ int Device::readDevInfoMultiLineStr(DevInfoTypes type,
while (std::getline(fs, line)) {
retVec->push_back(line);
}
fs.close();
if (retVec->empty()) {
ss << "Read devInfoMultiLineStr for DevInfoType ("
@@ -1771,6 +1772,38 @@ std::string Device::readBootPartitionState<rsmi_memory_partition_type_t>(
return boot_state;
}
rsmi_status_t Device::get_smi_device_identifiers(uint32_t device_id,
rsmi_device_identifiers_t *device_identifiers) {
bool found_device = false;
rsmi_status_t ret = RSMI_STATUS_NOT_SUPPORTED;
if (device_identifiers == nullptr) {
return RSMI_STATUS_INVALID_ARGS;
}
amd::smi::RocmSMI& smi = amd::smi::RocmSMI::getInstance();
auto devices = smi.devices();
for (uint32_t i = 0; i < devices.size(); i++) {
if (i != device_id) {
continue;
}
rsmi_device_identifiers_t smi_device;
smi_device.card_index = devices[i]->index();
smi_device.drm_render_minor = devices[i]->drm_render_minor();
smi_device.bdfid = devices[i]->bdfid();
smi_device.kfd_gpu_id = devices[i]->kfd_gpu_id();
smi_device.partition_id = devices[i]->m_partition_id;
smi_device.smi_device_id = i;
*device_identifiers = smi_device;
found_device = true;
break;
}
if (found_device) {
ret = RSMI_STATUS_SUCCESS;
}
return ret;
}
#undef RET_IF_NONZERO
} // namespace smi
+1 -1
Visa fil
@@ -3387,7 +3387,7 @@ AMGpuMetricsPublicLatestTupl_t GpuMetricsBase_v13_t::copy_internal_to_external_m
metrics_public_init.vcn_activity[0] = metrics_public_init.average_mm_activity;
}
// average_mm_activity needs to not be UIN16_MAX and
// metrics_public_init.xcp_stats->vcn_busy[0] should also be UIN16_MAX
// metrics_public_init.xcp_stats->vcn_busy[0] should also be UINT16_MAX
if (metrics_public_init.average_mm_activity != UINT16_MAX
&& metrics_public_init.xcp_stats->vcn_busy[0] == UINT16_MAX) {
metrics_public_init.xcp_stats->vcn_busy[0] = metrics_public_init.average_mm_activity;