From 58b94ee42c9381a68589af6cb87256dc6510998c Mon Sep 17 00:00:00 2001 From: Chiming Date: Mon, 17 Aug 2026 16:08:29 -0700 Subject: [PATCH 1/3] add new function in xrt-smi to query the load on AIE array. Signed-off-by: Chiming --- src/runtime_src/core/common/info_platform.cpp | 21 +++++ src/runtime_src/core/common/query_requests.h | 27 +++++- src/runtime_src/core/common/smi/smi_ryzen.cpp | 44 ++-------- .../tools/common/reports/ReportAieLoad.cpp | 82 +++++++++++++++++++ .../core/tools/common/reports/ReportAieLoad.h | 28 +++++++ .../reports/platform/ReportRyzenPlatform.cpp | 6 ++ .../core/tools/xbutil2/SubCmdExamine.cpp | 65 +++++++++------ .../core/tools/xbutil2/SubCmdExamine.h | 5 +- 8 files changed, 212 insertions(+), 66 deletions(-) create mode 100644 src/runtime_src/core/tools/common/reports/ReportAieLoad.cpp create mode 100644 src/runtime_src/core/tools/common/reports/ReportAieLoad.h diff --git a/src/runtime_src/core/common/info_platform.cpp b/src/runtime_src/core/common/info_platform.cpp index 0c426249923..76541143405 100644 --- a/src/runtime_src/core/common/info_platform.cpp +++ b/src/runtime_src/core/common/info_platform.cpp @@ -9,6 +9,7 @@ #include "xrt/detail/xclbin.h" #include +#include // Too much typing using ptree_type = boost::property_tree::ptree; @@ -194,6 +195,25 @@ add_host_mem_info(const xrt_core::device* device, ptree_type& pt) pt.add("host_memory_status", get_host_mem_status(device)); } +void +add_aie_load_info(const xrt_core::device* device, ptree_type& pt) +{ + try { + const xq::aie_load::args args{}; // sample_duration_ms = 0 -> driver default + const auto data = xrt_core::device_query(device, args); + + ptree_type pt_aie_load; + if (data.load_percent == std::numeric_limits::max()) + pt_aie_load.put("load_percent", "N/A"); + else + pt_aie_load.put("load_percent", data.load_percent); + pt.put_child("aie_load", pt_aie_load); + } + catch (const xq::exception&) { + // Ignoring if not available: older driver/DLL or unsupported device + } +} + void add_status_info(const xrt_core::device* device, ptree_type& pt) { @@ -431,6 +451,7 @@ add_platform_info(const xrt_core::device* device, ptree_type& pt_platform_array) { add_electrical_info(device, pt_platform); add_thermal_info(device, pt_platform); + add_aie_load_info(device, pt_platform); break; } default: diff --git a/src/runtime_src/core/common/query_requests.h b/src/runtime_src/core/common/query_requests.h index 2f71d6e9e6e..5cd20bfa9aa 100644 --- a/src/runtime_src/core/common/query_requests.h +++ b/src/runtime_src/core/common/query_requests.h @@ -350,7 +350,8 @@ enum class key_type aie_read, aie_write, - aie_coredump + aie_coredump, + aie_load }; struct pcie_vendor : request @@ -4316,6 +4317,30 @@ struct aie_coredump : request std::any get(const device*, const std::any&) const override = 0; }; + +// AIE array hardware utilization, computed from two consecutive firmware +// activity-counter snapshots separated by sample_duration_ms milliseconds. +struct aie_load : request +{ + struct result_type { + uint32_t load_percent; // 0-100, or UINT32_MAX if unavailable + uint64_t timestamp_ms; // FW uptime when second snapshot was taken + uint64_t activity_counters[8]; // raw counter values from second snapshot + uint64_t operations_per_second; // total counter change across 8 counters per second + }; + + struct args { + uint32_t sample_duration_ms = 0; // 0 = driver default (XRT_AIE_LOAD_SAMPLE_INTERVAL_MS) + }; + + static const key_type key = key_type::aie_load; + + virtual std::any + get(const device*) const override = 0; + + virtual std::any + get(const device*, const std::any&) const override = 0; +}; } // query } // xrt_core diff --git a/src/runtime_src/core/common/smi/smi_ryzen.cpp b/src/runtime_src/core/common/smi/smi_ryzen.cpp index b8b61e1c3e0..20174656339 100644 --- a/src/runtime_src/core/common/smi/smi_ryzen.cpp +++ b/src/runtime_src/core/common/smi/smi_ryzen.cpp @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright (C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved. +// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. #define XRT_CORE_COMMON_SOURCE @@ -15,6 +15,7 @@ config_gen_ryzen:: config_gen_ryzen() { examine_report_desc = { + {"aie-load", "AIE array load utilization", "common"}, {"aie-partitions", "AIE partition information", "common"}, {"all", "All known reports are produced", "common"}, {"host", "Host information (default)", "common"}, @@ -63,7 +64,7 @@ config_gen_ryzen::create_validate_subcommand() validate_suboptions.emplace("device", std::make_shared