Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ SubCmdExamineInternal::execute(const SubCmdOptions& _options) const
std::cout << boost::format(" - %s\n") % report;

// Print available devices
const auto dev_pt = XBU::get_available_devices(true);
const auto dev_pt = XBU::get_available_bdfs(true);
if(dev_pt.empty())
std::cout << "0 devices found" << std::endl;
else
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/tools/common/XBMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void main_(int argc, char** argv,
boost::property_tree::ptree configTreeMain;
std::string config;

boost::property_tree::ptree available_devices = XBU::get_available_devices(isUserDomain);
boost::property_tree::ptree available_devices = XBU::get_available_bdfs(isUserDomain);

if (available_devices.empty()) //no device
config = xrt_smi_default::get_default_smi_config();
Expand Down
43 changes: 40 additions & 3 deletions src/runtime_src/core/tools/common/XBUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,43 @@ XBUtilities::Timer::format_time(std::chrono::duration<double> duration)
}


boost::property_tree::ptree
XBUtilities::get_available_bdfs(bool inUserDomain)
{
// Minimal listing for BDF selection and str_available_devs.
xrt_core::device_collection deviceCollection;
collect_devices(std::set<std::string> {"_all_"}, inUserDomain, deviceCollection);
boost::property_tree::ptree pt;
for (const auto & device : deviceCollection) {
boost::property_tree::ptree pt_dev;
pt_dev.put("bdf", xrt_core::query::pcie_bdf::to_string(xrt_core::device_query<xrt_core::query::pcie_bdf>(device)));

const auto device_class = xrt_core::device_query_default<xrt_core::query::device_class>(device, xrt_core::query::device_class::type::alveo);
pt_dev.put("device_class", xrt_core::query::device_class::enum_to_str(device_class));

const auto is_mfg = xrt_core::device_query_default<xrt_core::query::is_mfg>(device, false);

if (is_mfg) {
auto mGoldenVer = xrt_core::device_query<xrt_core::query::mfg_ver>(device);
std::string vbnv = "xilinx_" + xrt_core::device_query<xrt_core::query::board_name>(device) + "_GOLDEN_"+ std::to_string(mGoldenVer);
pt_dev.put("vbnv", vbnv);
}
else {
switch (device_class) {
case xrt_core::query::device_class::type::alveo:
pt_dev.put("vbnv", xrt_core::device_query<xrt_core::query::rom_vbnv>(device));
break;
case xrt_core::query::device_class::type::ryzen:
pt_dev.put("name", xrt_core::device_query<xrt_core::query::rom_vbnv>(device));
break;
}
}

pt.push_back(std::make_pair("", pt_dev));
}
return pt;
}

boost::property_tree::ptree
XBUtilities::get_available_devices(bool inUserDomain)
{
Expand Down Expand Up @@ -122,7 +159,7 @@ XBUtilities::get_available_devices(bool inUserDomain)
pt_dev.put("name", xrt_core::device_query<xrt_core::query::rom_vbnv>(device));
break;
}

if (device_class == xrt_core::query::device_class::type::ryzen) {
try { // Ryzen/NPU: derive UUID from PCIe BDF
pt_dev.put("id", xrt_core::query::pcie_bdf::to_uuid(
Expand Down Expand Up @@ -241,7 +278,7 @@ XBUtilities::resolve_device(bool is_user_domain,
if (device_var.defaulted()) {
if (boost::iequals(device_bdf, "default")) {
device_bdf.clear();
boost::property_tree::ptree available_devices = get_available_devices(is_user_domain);
boost::property_tree::ptree available_devices = get_available_bdfs(is_user_domain);
if (available_devices.empty())
throw std::runtime_error("No devices found.");
if (available_devices.size() > 1) {
Expand Down Expand Up @@ -298,7 +335,7 @@ XBUtilities::str_available_devs(bool _inUserDomain)
//gather available devices for user to pick from
std::stringstream available_devs;
available_devs << "\n Available devices:\n";
boost::property_tree::ptree available_devices = XBUtilities::get_available_devices(_inUserDomain);
boost::property_tree::ptree available_devices = XBUtilities::get_available_bdfs(_inUserDomain);
for (auto& kd : available_devices) {
boost::property_tree::ptree& dev = kd.second;
if (boost::iequals(dev.get<std::string>("device_class"), xrt_core::query::device_class::enum_to_str(xrt_core::query::device_class::type::alveo)))
Expand Down
3 changes: 3 additions & 0 deletions src/runtime_src/core/tools/common/XBUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ namespace XBUtilities {

std::string get_device_class(const std::string& deviceBDF, bool in_user_domain);

boost::property_tree::ptree
get_available_bdfs(bool inUserDomain);

boost::property_tree::ptree
get_available_devices(bool inUserDomain);

Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/tools/xbutil2/SubCmdExamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ SubCmdExamine::execute(const SubCmdOptions& _options) const
std::cout << boost::format(" - %s\n") % report;

// Print available devices
const auto dev_pt = XBU::get_available_devices(true);
const auto dev_pt = XBU::get_available_bdfs(true);
if(dev_pt.empty())
std::cout << "0 devices found" << std::endl;
else
Expand Down
Loading