Skip to content

Commit

Permalink
Fix for CR-1206995 : Inconsistency between the version printed by xrt…
Browse files Browse the repository at this point in the history
…-smi --version and xrt-smi examine (#8476)

* Fix for CR-1206995

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Created an API to avoid code duplication

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Adding missing indentation

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Fixed available devices logic

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

---------

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>
Co-authored-by: Akshay Tondak <Akshay.Tondak@amd.com>
  • Loading branch information
aktondak and Akshay Tondak authored Oct 2, 2024
1 parent e41a5bc commit 5d6c913
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 43 deletions.
41 changes: 32 additions & 9 deletions src/runtime_src/core/tools/common/XBUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,19 +731,42 @@ get_xrt_pretty_version()
std::stringstream ss;
boost::property_tree::ptree pt_xrt;
xrt_core::sysinfo::get_xrt_info(pt_xrt);
boost::property_tree::ptree empty_ptree;
const boost::property_tree::ptree available_devices = XBUtilities::get_available_devices(true);
XBUtilities::fill_xrt_versions(pt_xrt, ss, available_devices);
return ss.str();
}

ss << boost::format("%-20s : %s\n") % "Version" % pt_xrt.get<std::string>("version", "N/A");
ss << boost::format("%-20s : %s\n") % "Branch" % pt_xrt.get<std::string>("branch", "N/A");
ss << boost::format("%-20s : %s\n") % "Hash" % pt_xrt.get<std::string>("hash", "N/A");
ss << boost::format("%-20s : %s\n") % "Hash Date" % pt_xrt.get<std::string>("build_date", "N/A");
void
XBUtilities::
fill_xrt_versions(const boost::property_tree::ptree& pt_xrt,
std::stringstream& output,
const boost::property_tree::ptree& available_devices)
{
boost::property_tree::ptree empty_ptree;
output << boost::format(" %-20s : %s\n") % "Version" % pt_xrt.get<std::string>("version", "N/A");
output << boost::format(" %-20s : %s\n") % "Branch" % pt_xrt.get<std::string>("branch", "N/A");
output << boost::format(" %-20s : %s\n") % "Hash" % pt_xrt.get<std::string>("hash", "N/A");
output << boost::format(" %-20s : %s\n") % "Hash Date" % pt_xrt.get<std::string>("build_date", "N/A");
const boost::property_tree::ptree& available_drivers = pt_xrt.get_child("drivers", empty_ptree);
for(auto& drv : available_drivers) {
const boost::property_tree::ptree& driver = drv.second;
std::string drv_name = driver.get<std::string>("name", "N/A");
boost::algorithm::to_upper(drv_name);
ss << boost::format("%-20s : %s, %s\n") % drv_name
% driver.get<std::string>("version", "N/A") % driver.get<std::string>("hash", "N/A");
std::string drv_hash = driver.get<std::string>("hash", "N/A");
if (!boost::iequals(drv_hash, "N/A")) {
output << boost::format(" %-20s : %s, %s\n") % drv_name
% driver.get<std::string>("version", "N/A") % driver.get<std::string>("hash", "N/A");
} else {
std::string drv_version = boost::iequals(drv_name, "N/A") ? drv_name : drv_name.append(" Version");
output << boost::format(" %-20s : %s\n") % drv_version % driver.get<std::string>("version", "N/A");
}
if (boost::iequals(drv_name, "xclmgmt") && boost::iequals(driver.get<std::string>("version", "N/A"), "unknown"))
output << "WARNING: xclmgmt version is unknown. Is xclmgmt driver loaded? Or is MSD/MPD running?" << std::endl;
}
if (!available_devices.empty()) {
const boost::property_tree::ptree& dev = available_devices.begin()->second;
if (dev.get<std::string>("device_class") == xrt_core::query::device_class::enum_to_str(xrt_core::query::device_class::type::ryzen))
output << boost::format(" %-20s : %s\n") % "NPU Firmware Version" % available_devices.begin()->second.get<std::string>("firmware_version");
else
output << boost::format(" %-20s : %s\n") % "Firmware Version" % available_devices.begin()->second.get<std::string>("firmware_version");
}
return ss.str();
}
5 changes: 5 additions & 0 deletions src/runtime_src/core/tools/common/XBUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ namespace XBUtilities {
std::string
get_xrt_pretty_version();

void
fill_xrt_versions(const boost::property_tree::ptree&,
std::stringstream&,
const boost::property_tree::ptree&);

/**
* OEM ID is a unique number called as the
* Private Enterprise Number (PEN) maintained by IANA
Expand Down
37 changes: 3 additions & 34 deletions src/runtime_src/core/tools/common/reports/ReportHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,45 +131,14 @@ ReportHost::writeReport(const xrt_core::device* /*_pDevice*/,
_output << boost::format(" %-20s : %s\n") % "BIOS Version" % _pt.get<std::string>("host.os.bios_version");
_output << std::endl;
_output << "XRT\n";
_output << boost::format(" %-20s : %s\n") % "Version" % _pt.get<std::string>("host.xrt.version", "N/A");
_output << boost::format(" %-20s : %s\n") % "Branch" % _pt.get<std::string>("host.xrt.branch", "N/A");
_output << boost::format(" %-20s : %s\n") % "Hash" % _pt.get<std::string>("host.xrt.hash", "N/A");
_output << boost::format(" %-20s : %s\n") % "Hash Date" % _pt.get<std::string>("host.xrt.build_date", "N/A");
const boost::property_tree::ptree& available_drivers = _pt.get_child("host.xrt.drivers", empty_ptree);
for(auto& drv : available_drivers) {
const boost::property_tree::ptree& driver = drv.second;
std::string drv_name = driver.get<std::string>("name", "N/A");
std::string drv_hash = driver.get<std::string>("hash", "N/A");
if (!boost::iequals(drv_hash, "N/A")) {
_output << boost::format(" %-20s : %s, %s\n") % drv_name
% driver.get<std::string>("version", "N/A") % driver.get<std::string>("hash", "N/A");
} else {
std::string drv_version = boost::iequals(drv_name, "N/A") ? drv_name : drv_name.append(" Version");
_output << boost::format(" %-20s : %s\n") % drv_version % driver.get<std::string>("version", "N/A");
}
if (boost::iequals(drv_name, "xclmgmt") && boost::iequals(driver.get<std::string>("version", "N/A"), "unknown"))
_output << "WARNING: xclmgmt version is unknown. Is xclmgmt driver loaded? Or is MSD/MPD running?" << std::endl;
}
std::stringstream xrt_version_ss;
XBUtilities::fill_xrt_versions(_pt.get_child("host.xrt", empty_ptree), xrt_version_ss, available_devices);
_output << xrt_version_ss.str();
}
catch (const boost::property_tree::ptree_error &ex) {
throw xrt_core::error(boost::str(boost::format("%s. Please contact your Xilinx representative to fix the issue")
% ex.what()));
}

try {
if (!available_devices.empty()) {
// This check depends on the assumption that if there is a RyzenAI device, it is on its own.
const boost::property_tree::ptree& dev = available_devices.begin()->second;
if (dev.get<std::string>("device_class") == xrt_core::query::device_class::enum_to_str(xrt_core::query::device_class::type::ryzen))
_output << boost::format(" %-20s : %s\n") % "NPU Firmware Version" % available_devices.begin()->second.get<std::string>("firmware_version");
else
_output << boost::format(" %-20s : %s\n") % "Firmware Version" % available_devices.begin()->second.get<std::string>("firmware_version");
}
}
catch (...) {
//no device available
}

_output << std::endl << "Device(s) Present\n";
if (available_devices.empty())
_output << " 0 devices found" << std::endl;
Expand Down

0 comments on commit 5d6c913

Please sign in to comment.