Skip to content

Commit

Permalink
[Xbutil] Add support to in xbutil for the newly added device utilizat…
Browse files Browse the repository at this point in the history
…ion queries (#8461)

* [Xbutil] Add support to in xbutil for the newly added device utilization queries

[Why]
Add support to in xbutil for the newly added device utilization queries

[How]
Add Tops section in platform report

Jira Id: EDGEML-8265

Signed-off-by: michuan <[email protected]>

* [Xbutil] Add support to in xbutil for the newly added device utilization queries

[Why]
Add support to in xbutil for the newly added device utilization queries

[How]
Add Tops section in platform report

Jira Id: EDGEML-8265

Signed-off-by: michuan <[email protected]>

* [Xbutil] Add support to in xbutil for the newly added device utilization queries

[Why]
Add support to in xbutil for the newly added device utilization queries

[How]
Add Tops section in platform report

Jira Id: EDGEML-8265

Signed-off-by: michuan <[email protected]>

* [Xbutil] Add support to in xbutil for the newly added device utilization queries

[Why]
Add support to in xbutil for the newly added device utilization queries

[How]
Add Tops section in platform report

Jira Id: EDGEML-8265

Signed-off-by: michuan <[email protected]>

* [Xbutil] Add support to in xbutil for the newly added device utilization queries

[Why]
Add support to in xbutil for the newly added device utilization queries

[How]
Add Tops section in platform report

Jira Id: EDGEML-8265

Signed-off-by: michuan <[email protected]>

* [Xbutil] Add support to in xbutil for the newly added device utilization queries

[Why]
Add support to in xbutil for the newly added device utilization queries

[How]
Add Tops section in platform report

Jira Id: EDGEML-8265

Signed-off-by: michuan <[email protected]>

* [Xbutil] Add support to in xbutil for the newly added device utilization queries

[Why]
Add support to in xbutil for the newly added device utilization queries

[How]
Add Tops section in platform report

Jira Id: EDGEML-8265

Signed-off-by: michuan <[email protected]>

---------

Signed-off-by: michuan <[email protected]>
  • Loading branch information
MichaelHuang-Amd authored Oct 7, 2024
1 parent aa7b534 commit d516d81
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/runtime_src/core/common/info_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,35 @@ add_clock_info(const xrt_core::device* device, ptree_type& pt)
}
}

void
add_tops_info(const xrt_core::device* device, ptree_type& pt)
{
ptree_type pt_tops_array;

try
{
auto res_info = xrt_core::device_query<xq::xrt_resource_raw>(device);
if (res_info.empty())
return;

for (auto &res : res_info)
{
if (res.type != xrt_core::query::xrt_resource_raw::resource_type::ipu_tops_max)
continue;

ptree_type pt_tops;
pt_tops.add("id", xq::xrt_resource_raw::get_name(res.type));
pt_tops.add("value", res.data_double);
pt_tops_array.push_back(std::make_pair("", pt_tops));
}
pt.put_child("tops", pt_tops_array);
}
catch (const xq::no_such_key &)
{
// ignoring if not available: Edge Case
}
}

void
add_electrical_info(const xrt_core::device* device, ptree_type& pt)
{
Expand Down Expand Up @@ -421,6 +450,7 @@ add_platform_info(const xrt_core::device* device, ptree_type& pt_platform_array)
ptree_type pt_platforms;

add_static_region_info(device, pt_platform);
add_tops_info(device, pt_platform);
add_status_info(device, pt_platform);

const auto device_class = xrt_core::device_query_default<xrt_core::query::device_class>(device, xrt_core::query::device_class::type::alveo);
Expand Down
58 changes: 58 additions & 0 deletions src/runtime_src/core/common/query_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum class key_type
ip_layout_raw,
debug_ip_layout_raw,
clock_freq_topology_raw,
xrt_resource_raw,
dma_stream,
device_status,
kds_cu_info,
Expand Down Expand Up @@ -1185,6 +1186,63 @@ struct clock_freq_topology_raw : request
get(const device*) const = 0;
};

/**
* Return some of the resouces within a NPU device
*/
struct xrt_resource_raw : request
{
/**
* enum class resource_type - represents the different types of resources
*/
enum class resource_type
{
ipu_clk_max, // Max H-Clocks, query returns uint64 value
ipu_tops_max, // Max TOPs, query returns double value
ipu_task_max, // Max Tasks, query returns uint64 value
ipu_tops_curr, // Current TOPs, query returns double value
ipu_task_curr // Current Tasks, query returns uint64 value
};

/**
* The buffer that holds the resource query data
*/
struct xrt_resource_query
{
resource_type type;
union
{
uint64_t data_uint64; // holds the value represented as uint64
double data_double; // holds the value represented as double
};
};

using result_type = std::vector<xrt_resource_query>; // get value type
static const key_type key = key_type::xrt_resource_raw;

static std::string
get_name(xrt_core::query::xrt_resource_raw::resource_type type)
{
switch (type)
{
case resource_type::ipu_clk_max:
return "Max Supported H-Clocks";
case resource_type::ipu_tops_max:
return "Max Supported TOPs";
case resource_type::ipu_task_max:
return "Max Supported Tasks";
case resource_type::ipu_tops_curr:
return "Current TOPs";
case resource_type::ipu_task_curr:
return "Current Tasks";
default:
throw xrt_core::internal_error("enum value does not exists");
}
}

virtual std::any
get(const device *) const = 0;
};

struct xmc_version : request
{
using result_type = std::string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ ReportRyzenPlatform::writeReport(const xrt_core::device* /*_pDevice*/,
}
}

const boost::property_tree::ptree& tops = pt_platform.get_child("tops", empty_ptree);
if (!tops.empty()) {
_output << "\nTOPs\n";
for (const auto& kt : tops) {
const boost::property_tree::ptree& pt_tops = kt.second;
std::string tops_name_type = pt_tops.get<std::string>("id");
_output << boost::format(" %-23s: %s Terabyte ops/second\n") % tops_name_type % pt_tops.get<std::string>("value");
}
}

auto watts = pt_platform.get<std::string>("electrical.power_consumption_watts", "N/A");
if (watts != "N/A")
_output << std::endl << boost::format("%-23s : %s Watts\n") % "Power" % watts;
Expand Down

0 comments on commit d516d81

Please sign in to comment.