|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. |
| 3 | + |
| 4 | +#include "core/common/smi/smi_ryzen.h" |
| 5 | + |
| 6 | +#include "core/common/query_requests.h" |
| 7 | + |
| 8 | +using namespace xrt_core::smi; |
| 9 | + |
| 10 | +namespace xrt_core::smi::ryzen { |
| 11 | + |
| 12 | +config_gen_ryzen:: |
| 13 | +config_gen_ryzen() |
| 14 | +{ |
| 15 | + validate_test_desc = { |
| 16 | + {"aie-reconfig-overhead", "Run end-to-end array reconfiguration overhead through shim DMA", "hidden"}, |
| 17 | + {"all", "All applicable validate tests will be executed (default)", "common"}, |
| 18 | + {"cmd-chain-latency", "Run end-to-end latency test using command chaining", "hidden"}, |
| 19 | + {"cmd-chain-throughput", "Run end-to-end throughput test using command chaining", "hidden"}, |
| 20 | + {"df-bw", "Run bandwidth test on data fabric", "hidden"}, |
| 21 | + {"gemm", "Measure the TOPS value of GEMM INT8operations", "common"}, |
| 22 | + {"latency", "Run end-to-end latency test", "common"}, |
| 23 | + {"quick", "Run a subset of four tests: \n1. latency \n2. throughput \n3. cmd-chain-latency \n4. cmd-chain-throughput", "hidden"}, |
| 24 | + {"tct-all-col", "Measure average TCT processing time for all columns", "hidden"}, |
| 25 | + {"tct-one-col", "Measure average TCT processing time for one column", "hidden"}, |
| 26 | + {"throughput", "Run end-to-end throughput test", "common"}, |
| 27 | + {"temporal-sharing-overhead", "Run end-to-end temporal sharing overhead test", "hidden"}, |
| 28 | + {"preemption-overhead", "Measure preemption overhead at noop and memtile levels", "hidden"} |
| 29 | + }; |
| 30 | +} |
| 31 | + |
| 32 | +config_gen_phoenix:: |
| 33 | +config_gen_phoenix() |
| 34 | +{ |
| 35 | + validate_test_desc = { |
| 36 | + {"all", "All applicable validate tests will be executed (default)", "common"}, |
| 37 | + {"df-bw", "Run bandwidth test on data fabric", "hidden"}, |
| 38 | + {"latency", "Run end-to-end latency test", "common"}, |
| 39 | + {"tct-all-col", "Measure average TCT processing time for all columns", "hidden"}, |
| 40 | + {"tct-one-col", "Measure average TCT processing time for one column", "hidden"}, |
| 41 | + {"throughput", "Run end-to-end throughput test", "common"}, |
| 42 | + }; |
| 43 | +} |
| 44 | + |
| 45 | +subcommand |
| 46 | +config_gen_ryzen::create_validate_subcommand() |
| 47 | +{ |
| 48 | + std::map<std::string, std::shared_ptr<option>> validate_suboptions; |
| 49 | + validate_suboptions.emplace("device", std::make_shared<option>("device", "d", "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest", "common", "", "string")); |
| 50 | + validate_suboptions.emplace("format", std::make_shared<option>("format", "f", "Report output format. Valid values are:\n" |
| 51 | + "\tJSON - Latest JSON schema\n" |
| 52 | + "\tJSON-2020.2 - JSON 2020.2 schema", "common", "JSON", "string")); |
| 53 | + validate_suboptions.emplace("output", std::make_shared<option>("output", "o", "Direct the output to the given file", "common", "", "string")); |
| 54 | + validate_suboptions.emplace("help", std::make_shared<option>("help", "h", "Help to use this sub-command", "common", "", "none")); |
| 55 | + validate_suboptions.emplace("run", std::make_shared<listable_description_option>("run", "r", "Run a subset of the test suite. Valid options are:\n", |
| 56 | + "common", "", "array", get_validate_test_desc())); |
| 57 | + validate_suboptions.emplace("param", std::make_shared<option>("param", "", "Extended parameter for a given test. Format: <test-name>:<key>:<value>", "param", "", "string")); |
| 58 | + validate_suboptions.emplace("pmode", std::make_shared<option>("pmode", "", "Specify which power mode to run the benchmarks in. Note: Some tests might be unavailable for some modes", "hidden", "", "string")); |
| 59 | + validate_suboptions.emplace("loop", std::make_shared<option>("loop", "", "Number of iterations to run the test", "hidden", "", "string")); |
| 60 | + |
| 61 | + return {"validate", "Validates the given device by executing the platform's validate executable", "common", std::move(validate_suboptions)}; |
| 62 | +} |
| 63 | + |
| 64 | +subcommand |
| 65 | +config_gen_ryzen::create_examine_subcommand() |
| 66 | +{ |
| 67 | + std::vector<basic_option> examine_report_desc = { |
| 68 | + {"aie-partitions", "AIE partition information", "common"}, |
| 69 | + {"all", "All known reports are produced", "common"}, |
| 70 | + {"host", "Host information (default)", "common"}, |
| 71 | + {"platform", "Platforms flashed on the device", "common"}, |
| 72 | + {"telemetry", "Telemetry data for the device", "hidden"}, |
| 73 | + {"preemption", "Preemption telemetry data for the device", "hidden"}, |
| 74 | + {"clocks", "Clock frequency information", "hidden"} |
| 75 | + }; |
| 76 | + |
| 77 | + std::map<std::string, std::shared_ptr<option>> examine_suboptions; |
| 78 | + examine_suboptions.emplace("device", std::make_shared<option>("device", "d", "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest", "common", "", "string")); |
| 79 | + examine_suboptions.emplace("format", std::make_shared<option>("format", "f", "Report output format. Valid values are:\n" |
| 80 | + "\tJSON - Latest JSON schema\n" |
| 81 | + "\tJSON-2020.2 - JSON 2020.2 schema", "common", "JSON", "string")); |
| 82 | + examine_suboptions.emplace("output", std::make_shared<option>("output", "o", "Direct the output to the given file", "common", "", "string")); |
| 83 | + examine_suboptions.emplace("help", std::make_shared<option>("help", "h", "Help to use this sub-command", "common", "", "none")); |
| 84 | + examine_suboptions.emplace("watch", std::make_shared<option>("watch", "", "Refresh interval in seconds between examine updates. Exit with Ctrl+C.", "hidden", "0", "string")); |
| 85 | + examine_suboptions.emplace("report", std::make_shared<listable_description_option>("report", "r", "The type of report to be produced. Reports currently available are:\n", "common", "", "array", examine_report_desc)); |
| 86 | + examine_suboptions.emplace("firmware-log", std::make_shared<option>("firmware-log", "", "Show status|watch firmware log data", "hidden", "", "string", true)); |
| 87 | + examine_suboptions.emplace("event-trace", std::make_shared<option>("event-trace", "", "Show status|watch event trace data", "hidden", "", "string", true)); |
| 88 | + examine_suboptions.emplace("context-health", std::make_shared<option>("context-health", "", "Show status|watch context health data", "hidden", "", "string", true)); |
| 89 | + |
| 90 | + 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)}; |
| 91 | +} |
| 92 | + |
| 93 | +subcommand |
| 94 | +config_gen_ryzen::create_configure_subcommand() |
| 95 | +{ |
| 96 | + std::map<std::string, std::shared_ptr<option>> configure_suboptions; |
| 97 | + configure_suboptions.emplace("device", std::make_shared<option>("device", "d", "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest", "common", "", "string")); |
| 98 | + configure_suboptions.emplace("help", std::make_shared<option>("help", "h", "Help to use this sub-command", "common", "", "none")); |
| 99 | + configure_suboptions.emplace("pmode", std::make_shared<option>("pmode", "", "Modes: default, powersaver, balanced, performance, turbo", "common", "", "string", true)); |
| 100 | + configure_suboptions.emplace("force-preemption", std::make_shared<option>("force-preemption", "", "Force enable|disable and see status of preemption", "hidden", "", "string", true)); |
| 101 | + configure_suboptions.emplace("event-trace", std::make_shared<option>("event-trace", "", "Enable|disable event tracing", "hidden", "", "string", true)); |
| 102 | + configure_suboptions.emplace("firmware-log", std::make_shared<option>("firmware-log", "", "Enable|disable firmware logging", "hidden", "", "string", true)); |
| 103 | + |
| 104 | + return {"configure", "Device and host configuration", "common", std::move(configure_suboptions)}; |
| 105 | +} |
| 106 | + |
| 107 | +void |
| 108 | +populate_smi_instance(xrt_core::smi::smi* smi_instance, const xrt_core::device* device) |
| 109 | +{ |
| 110 | + smi_hardware_config smi_hrdw; |
| 111 | + const auto pcie_id = xrt_core::device_query<xrt_core::query::pcie_id>(device); |
| 112 | + auto hardware_type = smi_hrdw.get_hardware_type(pcie_id); |
| 113 | + |
| 114 | + std::shared_ptr<config_generator> generator; |
| 115 | + |
| 116 | + switch (hardware_type) { |
| 117 | + case smi_hardware_config::hardware_type::phx: |
| 118 | + { |
| 119 | + generator = std::make_shared<config_gen_phoenix>(); |
| 120 | + break; |
| 121 | + } |
| 122 | + case smi_hardware_config::hardware_type::stxA0: |
| 123 | + case smi_hardware_config::hardware_type::stxB0: |
| 124 | + case smi_hardware_config::hardware_type::stxH: |
| 125 | + case smi_hardware_config::hardware_type::krk1: |
| 126 | + { |
| 127 | + generator = std::make_shared<config_gen_strix>(); |
| 128 | + break; |
| 129 | + } |
| 130 | + case smi_hardware_config::hardware_type::npu3_f1: |
| 131 | + case smi_hardware_config::hardware_type::npu3_f2: |
| 132 | + case smi_hardware_config::hardware_type::npu3_f3: |
| 133 | + { |
| 134 | + generator = std::make_shared<config_gen_npu3>(); |
| 135 | + break; |
| 136 | + } |
| 137 | + default: |
| 138 | + generator = std::make_shared<config_gen_strix>(); |
| 139 | + break; |
| 140 | + } |
| 141 | + |
| 142 | + if (generator) { |
| 143 | + smi_instance->add_subcommand("validate", generator->create_validate_subcommand()); |
| 144 | + smi_instance->add_subcommand("examine", generator->create_examine_subcommand()); |
| 145 | + smi_instance->add_subcommand("configure", generator->create_configure_subcommand()); |
| 146 | + } |
| 147 | +} |
| 148 | + |
| 149 | +std::string |
| 150 | +get_smi_config(const xrt_core::device* device) |
| 151 | +{ |
| 152 | + auto smi_instance = xrt_core::smi::instance(); |
| 153 | + |
| 154 | + populate_smi_instance(smi_instance, device); |
| 155 | + |
| 156 | + return smi_instance->build_json(); |
| 157 | +} |
| 158 | + |
| 159 | +} // namespace xrt_core::smi::ryzen |
0 commit comments