Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json option for advance reports #8558

Merged
merged 5 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -87,8 +87,8 @@ calculate_col_utilization(const xrt_core::device* device, boost::property_tree::
// If this check is true, at least two contexts were active on the same column at once.
if (total_active_cols > total_device_cols)
total_active_cols = total_device_cols;
double total_col_utilization = ((static_cast<double>(total_active_cols) / total_device_cols) * 100);
return boost::str(boost::format("%.0f%%") % total_col_utilization);
double total_col_occupancy = ((static_cast<double>(total_active_cols) / total_device_cols) * 100);
return boost::str(boost::format("%.0f%%") % total_col_occupancy);
}

void
Expand All @@ -109,7 +109,7 @@ getPropertyTree20202(const xrt_core::device* _pDevice,
boost::property_tree::ptree pt;
pt.put("description", "AIE Partition Information");
pt.add_child("partitions", populate_aie_partition(_pDevice));
pt.put("total_col_utilization", calculate_col_utilization(_pDevice, pt));
pt.put("total_col_occupancy", calculate_col_utilization(_pDevice, pt));
_pt.add_child("aie_partitions", pt);
}

Expand All @@ -128,7 +128,7 @@ writeReport(const xrt_core::device* /*_pDevice*/,
return;
}

_output << boost::str(boost::format("Total Column Utilization: %s\n") % _pt.get<std::string>("aie_partitions.total_col_utilization"));
AShivangi marked this conversation as resolved.
Show resolved Hide resolved
_output << boost::str(boost::format("Total Column Occupancy: %s\n") % _pt.get<std::string>("aie_partitions.total_col_occupancy"));

for (const auto& pt_partition : pt_partitions) {
const auto& partition = pt_partition.second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -67,8 +65,6 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBUtilities::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -90,8 +86,6 @@ TestAIEReconfigOverhead::run(std::shared_ptr<xrt_core::device> dev)
if (!std::filesystem::exists(dpu_instr))
return ptree;

logger(ptree, "DPU-Sequence", dpu_instr);

size_t instr_size = 0;
try {
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ TestCmdChainLatency::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -65,8 +63,6 @@ TestCmdChainLatency::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ TestCmdChainThroughput::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -65,8 +63,6 @@ TestCmdChainThroughput::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ TestDF_bandwidth::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -71,8 +69,6 @@ TestDF_bandwidth::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -94,8 +90,6 @@ TestDF_bandwidth::run(std::shared_ptr<xrt_core::device> dev)
if (!std::filesystem::exists(dpu_instr))
return ptree;

logger(ptree, "DPU-Sequence", dpu_instr);

size_t instr_size = 0;
try {
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
Expand Down
6 changes: 0 additions & 6 deletions src/runtime_src/core/tools/common/tests/TestGemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ TestGemm::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -74,7 +72,6 @@ TestGemm::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -97,9 +94,6 @@ TestGemm::run(std::shared_ptr<xrt_core::device> dev)
if (!std::filesystem::exists(dpu_instr))
return ptree;

if(XBU::getVerbose())
logger(ptree, "DPU-Sequence", dpu_instr);

size_t instr_size = 0;
try {
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ TestNPULatency::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -65,8 +63,6 @@ TestNPULatency::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -80,7 +76,7 @@ TestNPULatency::run(std::shared_ptr<xrt_core::device> dev)
catch (const std::exception& )
{
logger (ptree, "Error", "Not enough columns available. Please make sure no other workload is running on the device.");
ptree.put("status", test_token_failed);ptree.put("status", test_token_failed);
ptree.put("status", test_token_failed);
return ptree;
}
xrt::xclbin::ip cu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ TestNPUThroughput::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -65,8 +63,6 @@ TestNPUThroughput::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ boost::property_tree::ptree TestSpatialSharingOvd::run(std::shared_ptr<xrt_core:
if (!std::filesystem::exists(xclbin_path))
return ptree;

// Log the xclbin path
logger(ptree, "Xclbin", xclbin_path);

// Create an xclbin object
xrt::xclbin xclbin;
try {
Expand Down Expand Up @@ -74,10 +71,6 @@ boost::property_tree::ptree TestSpatialSharingOvd::run(std::shared_ptr<xrt_core:
// Get the name of the found kernel
auto kernelName = xkernel.get_name();

// If verbose mode is enabled, log the kernel name
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

// Create a working device from the provided device
auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -98,7 +91,6 @@ boost::property_tree::ptree TestSpatialSharingOvd::run(std::shared_ptr<xrt_core:
if (!std::filesystem::exists(dpu_instr))
return ptree;

logger(ptree, "DPU-Sequence", dpu_instr);
/* Run 1 */
std::vector<std::thread> threads;
std::vector<TestCase> testcases;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ TestTCTAllColumn::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
Expand Down Expand Up @@ -67,8 +66,6 @@ TestTCTAllColumn::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -91,8 +88,6 @@ TestTCTAllColumn::run(std::shared_ptr<xrt_core::device> dev)
if (!std::filesystem::exists(dpu_instr))
return ptree;

logger(ptree, "DPU-Sequence", dpu_instr);

size_t instr_size = 0;
try {
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ TestTCTOneColumn::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try {
xclbin = xrt::xclbin(xclbin_path);
Expand Down Expand Up @@ -67,8 +65,6 @@ TestTCTOneColumn::run(std::shared_ptr<xrt_core::device> dev)
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -90,8 +86,6 @@ TestTCTOneColumn::run(std::shared_ptr<xrt_core::device> dev)
if (!std::filesystem::exists(dpu_instr))
return ptree;

logger(ptree, "DPU-Sequence", dpu_instr);

size_t instr_size = 0;
try {
instr_size = XBValidateUtils::get_instr_size(dpu_instr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ TestTemporalSharingOvd::run(std::shared_ptr<xrt_core::device> dev) {
if (!std::filesystem::exists(xclbin_path))
return ptree;

logger(ptree, "Xclbin", xclbin_path);

xrt::xclbin xclbin;
try{
xclbin = xrt::xclbin(xclbin_path);
Expand All @@ -55,8 +53,6 @@ TestTemporalSharingOvd::run(std::shared_ptr<xrt_core::device> dev) {
return ptree;
}
auto kernelName = xkernel.get_name();
if(XBU::getVerbose())
logger(ptree, "Details", boost::str(boost::format("Kernel name is '%s'") % kernelName));

auto working_dev = xrt::device(dev);
working_dev.register_xclbin(xclbin);
Expand All @@ -66,8 +62,6 @@ TestTemporalSharingOvd::run(std::shared_ptr<xrt_core::device> dev) {
if (!std::filesystem::exists(dpu_instr))
return ptree;

logger(ptree, "DPU-Sequence", dpu_instr);

// Run 1
std::vector<std::thread> threads;
std::vector<TestCase> testcases;
Expand Down
55 changes: 39 additions & 16 deletions src/runtime_src/core/tools/xbutil2/OO_Reports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,55 @@
// 3rd Party Library - Include Files
#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/property_tree/json_parser.hpp>
namespace po = boost::program_options;
using bpt = boost::property_tree::ptree;

namespace {

static void
print_preemption_telemetry(const xrt_core::device* device)
print_clock_info(const xrt_core::device* device, bool is_json)
{
boost::property_tree::ptree empty_ptree;
bpt empty_tree;
auto clocks = xrt_core::platform::get_clock_info(device);
const bpt& pt_clock_array = clocks.get_child("clocks", empty_tree);
if (pt_clock_array.empty()) {
std::cout << " No clock information available\n\n";
return;
}

// if json format is requested, print it to console and exit
if(is_json) {
boost::property_tree::write_json(std::cout, pt_clock_array, true);
return;
}
std::cout << std::endl << "Clocks" << std::endl;
for (const auto& kc : pt_clock_array) {
const bpt& pt_clock = kc.second;
std::string clock_name_type = pt_clock.get<std::string>("id");
std::cout << boost::format(" %-23s: %3s MHz\n") % clock_name_type % pt_clock.get<std::string>("freq_mhz");
}
}

static void
print_preemption_telemetry(const xrt_core::device* device, bool is_json)
{
bpt empty_ptree;
std::stringstream ss;
boost::property_tree::ptree telemetry_pt = xrt_core::telemetry::preemption_telemetry_info(device).get_child("telemetry", empty_ptree);
bpt telemetry_pt = xrt_core::telemetry::preemption_telemetry_info(device).get_child("telemetry", empty_ptree);
ss << "Premption Telemetry Data\n";
if (telemetry_pt.empty()) {
ss << " No hardware contexts running on device\n\n";
std::cout << ss.str();
return;
}

// if json format is requested, print it to console and exit
if(is_json) {
boost::property_tree::write_json(std::cout, telemetry_pt, true);
return;
}

std::vector<Table2D::HeaderData> preempt_headers = {
{"User Task", Table2D::Justification::left},
{"Ctx ID", Table2D::Justification::left},
Expand Down Expand Up @@ -67,10 +99,12 @@ OO_Reports::OO_Reports( const std::string &_longName, bool _isHidden )
, m_device("")
, m_action("")
, m_help(false)
, m_json(false)
{
m_optionsDescription.add_options()
("device,d", boost::program_options::value<decltype(m_device)>(&m_device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest")
("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command")
("json", boost::program_options::bool_switch(&m_json), "Output the report in json format to the console")
;

m_optionsHidden.add_options()
Expand Down Expand Up @@ -122,21 +156,10 @@ OO_Reports::execute(const SubCmdOptions& _options) const

try {
if (boost::iequals(m_action, "clocks")) {
bpt empty_tree;
auto clocks = xrt_core::platform::get_clock_info(device.get());
const bpt& pt_clock_array = clocks.get_child("clocks", empty_tree);
if(pt_clock_array.empty())
return;

std::cout << std::endl << "Clocks" << std::endl;
for (const auto& kc : pt_clock_array) {
const bpt& pt_clock = kc.second;
std::string clock_name_type = pt_clock.get<std::string>("id");
std::cout << boost::format(" %-23s: %3s MHz\n") % clock_name_type % pt_clock.get<std::string>("freq_mhz");
}
print_clock_info(device.get(), m_json);
}
else if (boost::iequals(m_action, "preemption")) {
print_preemption_telemetry(device.get());
print_preemption_telemetry(device.get(), m_json);
}
else {
throw xrt_core::error(boost::str(boost::format("Invalid report value: '%s'\n") % m_action));
Expand Down
Loading
Loading