From 745ea466e17941f4b44f751b891b61a0a20f982f Mon Sep 17 00:00:00 2001 From: Akshay Tondak Date: Thu, 30 Apr 2026 11:08:54 -0700 Subject: [PATCH 1/3] xrt-smi code cleanup Signed-off-by: Akshay Tondak --- src/runtime_src/core/common/CMakeLists.txt | 4 +- .../core/common/smi/CMakeLists.txt | 13 ++ src/runtime_src/core/common/{ => smi}/smi.cpp | 2 +- src/runtime_src/core/common/{ => smi}/smi.h | 6 +- .../smi_pcie.cpp => common/smi/smi_alveo.cpp} | 33 ++-- src/runtime_src/core/common/smi/smi_alveo.h | 13 ++ src/runtime_src/core/common/smi/smi_ryzen.cpp | 159 ++++++++++++++++++ src/runtime_src/core/common/smi/smi_ryzen.h | 62 +++++++ src/runtime_src/core/edge/user/CMakeLists.txt | 2 + .../core/edge/user/device_linux.cpp | 5 +- src/runtime_src/core/edge/user/smi_edge.cpp | 108 ------------ src/runtime_src/core/edge/user/smi_edge.h | 12 -- .../core/pcie/linux/CMakeLists.txt | 3 +- .../core/pcie/linux/device_linux.cpp | 5 +- src/runtime_src/core/pcie/linux/smi_pcie.h | 12 -- .../core/tools/common/SmiDefault.cpp | 4 +- src/runtime_src/core/tools/common/XBMain.cpp | 2 +- .../core/tools/common/XBUtilities.cpp | 2 +- .../core/tools/common/XBUtilities.h | 2 +- .../core/tools/common/tests/TestGemm.cpp | 2 +- .../common/tests/TestPreeemptionOverhead.cpp | 2 +- .../ContextHealth/OO_ContextHealth.cpp | 2 +- .../core/tools/xbutil2/SubCmdConfigure.h | 2 +- .../core/tools/xbutil2/SubCmdExamine.h | 2 +- .../core/tools/xbutil2/SubCmdValidate.cpp | 7 +- .../core/tools/xbutil2/SubCmdValidate.h | 2 +- 26 files changed, 294 insertions(+), 174 deletions(-) create mode 100644 src/runtime_src/core/common/smi/CMakeLists.txt rename src/runtime_src/core/common/{ => smi}/smi.cpp (99%) rename src/runtime_src/core/common/{ => smi}/smi.h (98%) rename src/runtime_src/core/{pcie/linux/smi_pcie.cpp => common/smi/smi_alveo.cpp} (94%) create mode 100644 src/runtime_src/core/common/smi/smi_alveo.h create mode 100644 src/runtime_src/core/common/smi/smi_ryzen.cpp create mode 100644 src/runtime_src/core/common/smi/smi_ryzen.h delete mode 100644 src/runtime_src/core/edge/user/smi_edge.cpp delete mode 100644 src/runtime_src/core/edge/user/smi_edge.h delete mode 100644 src/runtime_src/core/pcie/linux/smi_pcie.h diff --git a/src/runtime_src/core/common/CMakeLists.txt b/src/runtime_src/core/common/CMakeLists.txt index d4258e17ca5..af0109ae1bc 100644 --- a/src/runtime_src/core/common/CMakeLists.txt +++ b/src/runtime_src/core/common/CMakeLists.txt @@ -8,6 +8,7 @@ endif() add_subdirectory(api) add_subdirectory(xdp) add_subdirectory(runner) +add_subdirectory(smi) if(CMAKE_VERSION VERSION_LESS "3.18.0") message(WARNING "CMake version is less than 3.18.0, build of submodule aiebu disabled") @@ -51,7 +52,6 @@ add_library(core_common_library_objects OBJECT sysinfo.cpp xclbin_parser.cpp xclbin_swemu.cpp - smi.cpp ) target_include_directories(core_common_library_objects @@ -84,6 +84,7 @@ add_library(xrt_coreutil SHARED $ $ $ + $ ) add_library(xrt_coreutil_static STATIC @@ -91,6 +92,7 @@ add_library(xrt_coreutil_static STATIC $ $ $ + $ ) set_target_properties(xrt_coreutil PROPERTIES diff --git a/src/runtime_src/core/common/smi/CMakeLists.txt b/src/runtime_src/core/common/smi/CMakeLists.txt new file mode 100644 index 00000000000..a0d06f22e0a --- /dev/null +++ b/src/runtime_src/core/common/smi/CMakeLists.txt @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# +# OBJECT libraries linked into xrt_coreutil, xrt_core (Alveo/edge), and xrt_driver_xdna / other shims. + +add_library(core_common_smi_objects OBJECT smi.cpp) +target_include_directories(core_common_smi_objects + PRIVATE + ${XRT_SOURCE_DIR}/runtime_src + ) + +add_library(core_smi_alveo_objects OBJECT smi_alveo.cpp) +add_library(core_smi_ryzen_objects OBJECT smi_ryzen.cpp) diff --git a/src/runtime_src/core/common/smi.cpp b/src/runtime_src/core/common/smi/smi.cpp similarity index 99% rename from src/runtime_src/core/common/smi.cpp rename to src/runtime_src/core/common/smi/smi.cpp index 41199b18082..8270c66ccea 100644 --- a/src/runtime_src/core/common/smi.cpp +++ b/src/runtime_src/core/common/smi/smi.cpp @@ -4,7 +4,7 @@ #define XRT_CORE_COMMON_SOURCE // Local - Include Files -#include "smi.h" +#include "core/common/smi/smi.h" // 3rd Party Library - Include Files #include diff --git a/src/runtime_src/core/common/smi.h b/src/runtime_src/core/common/smi/smi.h similarity index 98% rename from src/runtime_src/core/common/smi.h rename to src/runtime_src/core/common/smi/smi.h index 726d0db2b81..fdbb14eb843 100644 --- a/src/runtime_src/core/common/smi.h +++ b/src/runtime_src/core/common/smi/smi.h @@ -3,8 +3,8 @@ #pragma once // Local include files -#include "config.h" -#include "query_requests.h" +#include "core/common/config.h" +#include "core/common/query_requests.h" // 3rd Party Library - Include Files #include @@ -182,7 +182,7 @@ class config_generator { // This subcommand is used for device and host configuration. // Derived classes must implement this method to define hardware-specific configuration logic. virtual subcommand - create_configure_subcommand() = 0; + create_configure_subcommand() = 0; }; // class smi_hardware_config diff --git a/src/runtime_src/core/pcie/linux/smi_pcie.cpp b/src/runtime_src/core/common/smi/smi_alveo.cpp similarity index 94% rename from src/runtime_src/core/pcie/linux/smi_pcie.cpp rename to src/runtime_src/core/common/smi/smi_alveo.cpp index d322bb44315..66167bfef5b 100644 --- a/src/runtime_src/core/pcie/linux/smi_pcie.cpp +++ b/src/runtime_src/core/common/smi/smi_alveo.cpp @@ -1,10 +1,18 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. -#include "smi_pcie.h" -namespace shim_pcie::smi { +#include "core/common/smi/smi_alveo.h" -xrt_core::smi::subcommand +#include "core/common/smi/smi.h" + +#include +#include +#include +#include + +namespace xrt_smi_alveo { + +static xrt_core::smi::subcommand create_validate_subcommand() { std::vector validate_test_desc = { @@ -29,7 +37,7 @@ create_validate_subcommand() {"verify", "Run 'Hello World' kernel test", "common"} }; - std::map> validate_suboptions; + std::map> validate_suboptions; validate_suboptions.emplace("device", std::make_shared("device", "d", "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest", "common", "", "string")); validate_suboptions.emplace("format", std::make_shared("format", "f", "Report output format. Valid values are:\n" "\tJSON - Latest JSON schema\n" @@ -40,12 +48,12 @@ create_validate_subcommand() "common", "", "array", validate_test_desc)); validate_suboptions.emplace("path", std::make_shared("path", "p", "Path to the directory containing validate xclbins", "hidden", "", "string")); validate_suboptions.emplace("param", std::make_shared("param", "", "Extended parameter for a given test. Format: ::", "hidden", "", "string")); - validate_suboptions.emplace("pmode", std::make_shared("pmode", "", "Specify which power mode to run the benchmarks in. Note: Some tests might be unavailable for some modes", "hidden", "", "string")); + validate_suboptions.emplace("pmode", std::make_shared("pmode", "", "Specify which power mode to run the benchmarks in. Note: Some tests might be unavailable for some modes", "hidden", "", "string")); return {"validate", "Validates the given device by executing the platform's validate executable", "common", std::move(validate_suboptions)}; } -xrt_core::smi::subcommand +static xrt_core::smi::subcommand create_examine_subcommand() { std::vector examine_report_desc = { @@ -67,7 +75,7 @@ create_examine_subcommand() {"thermal", "Thermal sensors present on the device", "common"} }; - std::map> examine_suboptions; + std::map> examine_suboptions; examine_suboptions.emplace("device", std::make_shared("device", "d", "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest", "common", "", "string")); examine_suboptions.emplace("format", std::make_shared("format", "f", "Report output format. Valid values are:\n" "\tJSON - Latest JSON schema\n" @@ -78,9 +86,9 @@ create_examine_subcommand() examine_suboptions.emplace("element", std::make_shared("element", "e", "Filters individual elements(s) from the report. Format: '///...'", "hidden", "", "array")); return {"examine", "This command will 'examine' the state of the system/device and will generate a report of interest in a text or JSON format.", "common", std::move(examine_suboptions)}; -} // namespace shim_pcie::smi +} -xrt_core::smi::subcommand +static xrt_core::smi::subcommand create_configure_subcommand() { std::map> configure_suboptions; @@ -89,22 +97,17 @@ create_configure_subcommand() configure_suboptions.emplace("p2p", std::make_shared("p2p", "", "Controls P2P functionality\n", "common", "", "string", true)); configure_suboptions.emplace("host-mem", std::make_shared("host-mem", "", "Controls host-mem functionality\n", "common", "", "string", true)); - return {"configure", "Device and host configuration", "common", std::move(configure_suboptions)}; } std::string get_smi_config() { - // Get the singleton instance auto smi_instance = xrt_core::smi::instance(); - - // Add subcommands smi_instance->add_subcommand("validate", create_validate_subcommand()); smi_instance->add_subcommand("examine", create_examine_subcommand()); smi_instance->add_subcommand("configure", create_configure_subcommand()); - return smi_instance->build_json(); } -} // namespace shim_pcie::smi +} // namespace xrt_smi_alveo diff --git a/src/runtime_src/core/common/smi/smi_alveo.h b/src/runtime_src/core/common/smi/smi_alveo.h new file mode 100644 index 00000000000..21f979ccc58 --- /dev/null +++ b/src/runtime_src/core/common/smi/smi_alveo.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +#pragma once + +#include + +namespace xrt_smi_alveo { + +// xrt-smi JSON for Alveo-class shims (PCIe Linux and edge user device_linux). +std::string +get_smi_config(); + +} // namespace xrt_smi_alveo diff --git a/src/runtime_src/core/common/smi/smi_ryzen.cpp b/src/runtime_src/core/common/smi/smi_ryzen.cpp new file mode 100644 index 00000000000..d84c089fe65 --- /dev/null +++ b/src/runtime_src/core/common/smi/smi_ryzen.cpp @@ -0,0 +1,159 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. + +#include "core/common/smi/smi_ryzen.h" + +#include "core/common/query_requests.h" + +using namespace xrt_core::smi; + +namespace xrt_smi_ryzen { + +config_gen_ryzen:: +config_gen_ryzen() +{ + validate_test_desc = { + {"aie-reconfig-overhead", "Run end-to-end array reconfiguration overhead through shim DMA", "hidden"}, + {"all", "All applicable validate tests will be executed (default)", "common"}, + {"cmd-chain-latency", "Run end-to-end latency test using command chaining", "hidden"}, + {"cmd-chain-throughput", "Run end-to-end throughput test using command chaining", "hidden"}, + {"df-bw", "Run bandwidth test on data fabric", "hidden"}, + {"gemm", "Measure the TOPS value of GEMM INT8operations", "common"}, + {"latency", "Run end-to-end latency test", "common"}, + {"quick", "Run a subset of four tests: \n1. latency \n2. throughput \n3. cmd-chain-latency \n4. cmd-chain-throughput", "hidden"}, + {"tct-all-col", "Measure average TCT processing time for all columns", "hidden"}, + {"tct-one-col", "Measure average TCT processing time for one column", "hidden"}, + {"throughput", "Run end-to-end throughput test", "common"}, + {"temporal-sharing-overhead", "Run end-to-end temporal sharing overhead test", "hidden"}, + {"preemption-overhead", "Measure preemption overhead at noop and memtile levels", "hidden"} + }; +} + +config_gen_phoenix:: +config_gen_phoenix() +{ + validate_test_desc = { + {"all", "All applicable validate tests will be executed (default)", "common"}, + {"df-bw", "Run bandwidth test on data fabric", "hidden"}, + {"latency", "Run end-to-end latency test", "common"}, + {"tct-all-col", "Measure average TCT processing time for all columns", "hidden"}, + {"tct-one-col", "Measure average TCT processing time for one column", "hidden"}, + {"throughput", "Run end-to-end throughput test", "common"}, + }; +} + +subcommand +config_gen_ryzen::create_validate_subcommand() +{ + std::map> validate_suboptions; + validate_suboptions.emplace("device", std::make_shared