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

Move preemption and clocks to examine as advanced reports #8749

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
55 changes: 55 additions & 0 deletions src/runtime_src/core/tools/common/reports/ReportClocks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.

// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "ReportClocks.h"
#include "core/common/info_platform.h"
#include "tools/common/Table2D.h"

// 3rd Party Library - Include Files
#include <vector>

using bpt = boost::property_tree::ptree;

void
ReportClocks::getPropertyTreeInternal(const xrt_core::device* dev,
bpt& pt) const
{
// Defer to the 20202 format. If we ever need to update JSON data,
// Then update this method to do so.
getPropertyTree20202(dev, pt);
}

void
ReportClocks::getPropertyTree20202(const xrt_core::device* dev,
bpt& pt) const
{
// There can only be 1 root node
pt = xrt_core::platform::get_clock_info(dev);
}

void
ReportClocks::writeReport(const xrt_core::device* /*_pDevice*/,
const bpt& pt,
const std::vector<std::string>& /*_elementsFilter*/,
std::ostream& _output) const
{
_output << "Clocks\n";

const bpt empty_ptree;
const bpt& pt_clock_array = pt.get_child("clocks", empty_ptree);
if (pt_clock_array.empty()) {
_output << " No Clocks information available\n\n";
return;
}

//print clocks
std::stringstream ss;
for (const auto& kc : pt_clock_array) {
const bpt& pt_clock = kc.second;
ss << boost::format(" %-23s: %3s MHz\n") % pt_clock.get<std::string>("id")
% pt_clock.get<std::string>("freq_mhz");
}
std::cout << ss.str();
}
21 changes: 21 additions & 0 deletions src/runtime_src/core/tools/common/reports/ReportClocks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.

#ifndef __ReportClocks_h_
#define __ReportClocks_h_

// Please keep external include file dependencies to a minimum
#include "tools/common/Report.h"

class ReportClocks : public Report {
public:
ReportClocks() : Report("clocks", "Clocks data for the device", true /*deviceRequired*/) { /*empty*/ };

// Child methods that need to be implemented
public:
virtual void getPropertyTreeInternal(const xrt_core::device* dev, boost::property_tree::ptree& pt) const;
virtual void getPropertyTree20202(const xrt_core::device* deve, boost::property_tree::ptree& pt) const;
virtual void writeReport(const xrt_core::device* _pDevice, const boost::property_tree::ptree& _pt, const std::vector<std::string>& _elementsFilter, std::ostream& _output) const;
};

#endif
76 changes: 76 additions & 0 deletions src/runtime_src/core/tools/common/reports/ReportPreemption.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.

// ------ I N C L U D E F I L E S -------------------------------------------
// Local - Include Files
#include "ReportPreemption.h"
#include "core/common/info_telemetry.h"
#include "tools/common/Table2D.h"

// 3rd Party Library - Include Files
#include <vector>

using bpt = boost::property_tree::ptree;

void
ReportPreemption::getPropertyTreeInternal(const xrt_core::device* dev,
bpt& pt) const
{
// Defer to the 20202 format. If we ever need to update JSON data,
// Then update this method to do so.
getPropertyTree20202(dev, pt);
}

void
ReportPreemption::getPropertyTree20202(const xrt_core::device* dev,
bpt& pt) const
{
// There can only be 1 root node
pt = xrt_core::telemetry::preemption_telemetry_info(dev);
}

static std::string
generate_preemption_string(const bpt& pt)
{
std::stringstream ss;

std::vector<Table2D::HeaderData> preempt_headers = {
{"User Task", Table2D::Justification::left},
{"Ctx ID", Table2D::Justification::left},
{"Layer Boundary Events", Table2D::Justification::left},
{"Frame Boundary Events", Table2D::Justification::left},
};
Table2D preemption_table(preempt_headers);

for (const auto& [name, user_task] : pt) {
const std::vector<std::string> rtos_data = {
user_task.get<std::string>("user_task"),
user_task.get<std::string>("slot_index"),
user_task.get<std::string>("preemption_layer_boundary_events"),
user_task.get<std::string>("preemption_frame_boundary_events"),
};
preemption_table.addEntry(rtos_data);
}

ss << preemption_table.toString(" ") << "\n";

return ss.str();
}

void
ReportPreemption::writeReport(const xrt_core::device* ,
const bpt& pt,
const std::vector<std::string>&,
std::ostream& _output) const
{
const bpt empty_ptree;
bpt telemetry_array = pt.get_child("telemetry", empty_ptree);
_output << "Premption Telemetry Data\n";
if (telemetry_array.empty()) {
_output << " No hardware contexts running on device\n\n";
return;
}

_output << generate_preemption_string(telemetry_array);
_output << std::endl;
}
21 changes: 21 additions & 0 deletions src/runtime_src/core/tools/common/reports/ReportPreemption.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.

#ifndef __ReportPreemption_h_
#define __ReportPreemption_h_

// Please keep external include file dependencies to a minimum
#include "tools/common/Report.h"

class ReportPreemption : public Report {
public:
ReportPreemption() : Report("preemption", "Preemption data for the device", true /*deviceRequired*/) { /*empty*/ };

// Child methods that need to be implemented
public:
virtual void getPropertyTreeInternal(const xrt_core::device* dev, boost::property_tree::ptree& pt) const;
virtual void getPropertyTree20202(const xrt_core::device* deve, boost::property_tree::ptree& pt) const;
virtual void writeReport(const xrt_core::device* _pDevice, const boost::property_tree::ptree& _pt, const std::vector<std::string>& _elementsFilter, std::ostream& _output) const;
};

#endif
1 change: 0 additions & 1 deletion src/runtime_src/core/tools/xbutil2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ file(GLOB XBUTIL_V2_SUBCMD_FILES
"OO_HostMem.cpp"
"OO_Performance.cpp"
"OO_Preemption.cpp"
"OO_Reports.cpp"
)

# Merge the files into one collection
Expand Down
177 changes: 0 additions & 177 deletions src/runtime_src/core/tools/xbutil2/OO_Reports.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions src/runtime_src/core/tools/xbutil2/OO_Reports.h

This file was deleted.

Loading
Loading