Skip to content

Commit

Permalink
VITIS-10910 Separate Ryzen and Alveo devices in ReportHost List (Xili…
Browse files Browse the repository at this point in the history
…nx#7856)

* VITIS-10910 Separate ryzen and alveo device lists within ReportHost

Signed-off-by: Daniel Benusovich <[email protected]>

* VITIS-10910 Separate json generation for ryzen cards for host report

Signed-off-by: Daniel Benusovich <[email protected]>

* VITIS-10910 Fix indentation

Signed-off-by: Daniel Benusovich <[email protected]>

---------

Signed-off-by: Daniel Benusovich <[email protected]>
  • Loading branch information
dbenusov authored Dec 19, 2023
1 parent 9f739b4 commit eaf8282
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 44 deletions.
30 changes: 21 additions & 9 deletions src/runtime_src/core/tools/common/XBUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ XBUtilities::get_available_devices(bool inUserDomain)
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));

//user pf doesn't have mfg node. Also if user pf is loaded, it means that the card is not is mfg mode
const auto is_mfg = xrt_core::device_query_default<xrt_core::query::is_mfg>(device, false);

Expand All @@ -104,7 +107,15 @@ XBUtilities::get_available_devices(bool inUserDomain)
pt_dev.put("instance","n/a");
}
else {
pt_dev.put("vbnv", xrt_core::device_query<xrt_core::query::rom_vbnv>(device));
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;
}

try { //1RP
pt_dev.put("id", xrt_core::query::rom_time_since_epoch::to_string(xrt_core::device_query<xrt_core::query::rom_time_since_epoch>(device)));
}
Expand All @@ -121,17 +132,18 @@ XBUtilities::get_available_devices(bool inUserDomain)
// The id wasn't added
}

try {
auto instance = xrt_core::device_query<xrt_core::query::instance>(device);
std::string pf = device->is_userpf() ? "user" : "mgmt";
pt_dev.put("instance",boost::str(boost::format("%s(inst=%d)") % pf % instance));
}
catch(const xrt_core::query::exception&) {
// The instance wasn't added
}
try {
auto instance = xrt_core::device_query<xrt_core::query::instance>(device);
std::string pf = device->is_userpf() ? "user" : "mgmt";
pt_dev.put("instance",boost::str(boost::format("%s(inst=%d)") % pf % instance));
}
catch(const xrt_core::query::exception&) {
// The instance wasn't added
}

}
pt_dev.put("is_ready", xrt_core::device_query_default<xrt_core::query::is_ready>(device, true));

pt.push_back(std::make_pair("", pt_dev));
}
return pt;
Expand Down
97 changes: 62 additions & 35 deletions src/runtime_src/core/tools/common/reports/ReportHost.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
/**
* Copyright (C) 2020-2022 Xilinx, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may
* not use this file except in compliance with the License. A copy of the
* License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

// ------ I N C L U D E F I L E S -------------------------------------------
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020-2022 Xilinx, Inc
// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.

// Local - Include Files
#include "ReportHost.h"
#include "tools/common/XBUtilitiesCore.h"
Expand Down Expand Up @@ -62,11 +49,66 @@ ReportHost::getPropertyTree20202( const xrt_core::device * /*_pDevice*/,
_pt.add_child("host", pt);
}

static void
printAlveoDevices(const boost::property_tree::ptree& available_devices, std::ostream& _output)
{
const Table2D::HeaderData bdf = {"BDF", Table2D::Justification::left};
const Table2D::HeaderData colon = {":", Table2D::Justification::left};
const Table2D::HeaderData vbnv = {"Shell", Table2D::Justification::left};
const Table2D::HeaderData id = {"Logic UUID", Table2D::Justification::left};
const Table2D::HeaderData instance = {"Device ID", Table2D::Justification::left};
const Table2D::HeaderData ready = {"Device Ready*", Table2D::Justification::left};
const std::vector<Table2D::HeaderData> table_headers = {bdf, colon, vbnv, id, instance, ready};
Table2D device_table(table_headers);

for (const auto& kd : available_devices) {
const boost::property_tree::ptree& dev = kd.second;

if (dev.get<std::string>("device_class") != xrt_core::query::device_class::enum_to_str(xrt_core::query::device_class::type::alveo))
continue;

const std::string bdf_string = "[" + dev.get<std::string>("bdf") + "]";
const std::string ready_string = dev.get<bool>("is_ready", false) ? "Yes" : "No";
const std::vector<std::string> entry_data = {bdf_string, ":", dev.get<std::string>("vbnv", "n/a"), dev.get<std::string>("id", "n/a"), dev.get<std::string>("instance", "n/a"), ready_string};
device_table.addEntry(entry_data);
}

if (!device_table.empty())
_output << boost::str(boost::format("%s\n") % device_table);
}

static void
printRyzenDevices(const boost::property_tree::ptree& available_devices, std::ostream& _output)
{
const Table2D::HeaderData bdf = {"BDF", Table2D::Justification::left};
const Table2D::HeaderData colon = {":", Table2D::Justification::left};
const Table2D::HeaderData name = {"Name", Table2D::Justification::left};
const Table2D::HeaderData instance = {"Device ID", Table2D::Justification::left};
const Table2D::HeaderData ready = {"Device Ready*", Table2D::Justification::left};
const std::vector<Table2D::HeaderData> table_headers = {bdf, colon, name, instance, ready};
Table2D device_table(table_headers);

for (const auto& kd : available_devices) {
const boost::property_tree::ptree& dev = kd.second;

if (dev.get<std::string>("device_class") != xrt_core::query::device_class::enum_to_str(xrt_core::query::device_class::type::ryzen))
continue;

const std::string bdf_string = "[" + dev.get<std::string>("bdf") + "]";
const std::string ready_string = dev.get<bool>("is_ready", false) ? "Yes" : "No";
const std::vector<std::string> entry_data = {bdf_string, ":", dev.get<std::string>("name", "n/a"), dev.get<std::string>("instance", "n/a"), ready_string};
device_table.addEntry(entry_data);
}

if (!device_table.empty())
_output << boost::str(boost::format("%s\n") % device_table);
}

void
ReportHost::writeReport(const xrt_core::device* /*_pDevice*/,
const boost::property_tree::ptree& _pt,
const std::vector<std::string>& /*_elementsFilter*/,
std::ostream & _output) const
std::ostream& _output) const
{
boost::property_tree::ptree empty_ptree;

Expand Down Expand Up @@ -119,23 +161,8 @@ ReportHost::writeReport(const xrt_core::device* /*_pDevice*/,
if (available_devices.empty())
_output << " 0 devices found" << std::endl;

const Table2D::HeaderData bdf = {"BDF", Table2D::Justification::left};
const Table2D::HeaderData colon = {":", Table2D::Justification::left};
const Table2D::HeaderData vbnv = {"Shell", Table2D::Justification::left};
const Table2D::HeaderData id = {"Logic UUID", Table2D::Justification::left};
const Table2D::HeaderData instance = {"Device ID", Table2D::Justification::left};
const Table2D::HeaderData ready = {"Device Ready*", Table2D::Justification::left};
const std::vector<Table2D::HeaderData> table_headers = {bdf, colon, vbnv, id, instance, ready};
Table2D device_table(table_headers);

for (const auto& kd : available_devices) {
const boost::property_tree::ptree& dev = kd.second;
const std::string bdf_string = "[" + dev.get<std::string>("bdf") + "]";
const std::string ready_string = dev.get<bool>("is_ready", false) ? "Yes" : "No";
const std::vector<std::string> entry_data = {bdf_string, ":", dev.get<std::string>("vbnv", "n/a"), dev.get<std::string>("id", "n/a"), dev.get<std::string>("instance", "n/a"), ready_string};
device_table.addEntry(entry_data);
}
printAlveoDevices(available_devices, _output);
printRyzenDevices(available_devices, _output);

_output << boost::str(boost::format("%s\n") % device_table);
_output << "* Devices that are not ready will have reduced functionality when using XRT tools\n";
}

0 comments on commit eaf8282

Please sign in to comment.