Skip to content

Commit

Permalink
Vitis 13804 : XRT-SMI re-architecture Patch 1 (#8656)
Browse files Browse the repository at this point in the history
* Json config work chk1

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Config based xrt-smi chk2

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Review comment updates and XRT standalone build failure fix

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Removed extended keys options API

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Build fail try 1

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Build failure fix

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Change to device query

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Build correction

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Changing device query to string type

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Build failure fix

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Remove TODO tasks since we moved to query requests

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Possible pipeline test failure fix

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Disabling device query for non xrt-smi cases

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Adding device query to alveo device

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Moving query to pcie queries

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Build failure fix

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Build fix try 2

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Build fix

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

* Review comments handled

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>

---------

Signed-off-by: Akshay Tondak <Akshay.Tondak@amd.com>
Co-authored-by: Akshay Tondak <Akshay.Tondak@amd.com>
  • Loading branch information
aktondak and Akshay Tondak authored Jan 15, 2025
1 parent 91cc354 commit 4e8c32a
Show file tree
Hide file tree
Showing 17 changed files with 913 additions and 118 deletions.
1 change: 1 addition & 0 deletions src/runtime_src/core/pcie/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_library(core_pcielinux_objects OBJECT
pcidrv.cpp
shim.cpp
system_linux.cpp
smi.cpp
)

target_compile_definitions(core_pcielinux_objects
Expand Down
26 changes: 26 additions & 0 deletions src/runtime_src/core/pcie/linux/device_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "core/include/xdp/spc.h"
#include "core/pcie/driver/linux/include/mgmt-ioctl.h"

#include "smi.h"
#include "pcidev.h"
#include "xrt.h"

Expand Down Expand Up @@ -906,6 +907,30 @@ struct am_counter

};

struct xrt_smi_config
{
using result_type = std::any;

static result_type
get(const xrt_core::device* device, key_type key, const std::any& reqType)
{
if (key != key_type::xrt_smi_config)
throw xrt_core::query::no_such_key(key, "Not implemented");
std::string xrt_smi_config;
const auto xrt_smi_config_type = std::any_cast<xrt_core::query::xrt_smi_config::type>(reqType);
switch (xrt_smi_config_type) {
case xrt_core::query::xrt_smi_config::type::options_config:
xrt_smi_config = xrt_core::smi::get_smi_config();
break;
default:
throw xrt_core::query::no_such_key(key, "Not implemented");
}

return xrt_smi_config;
}
};



/* ASM counter values
* In PCIe Linux, access the sysfs file for ASM to retrieve the ASM counter values
Expand Down Expand Up @@ -1457,6 +1482,7 @@ initialize_query_table()
emplace_func4_request<query::aim_counter, aim_counter>();
emplace_func4_request<query::am_counter, am_counter>();
emplace_func4_request<query::asm_counter, asm_counter>();
emplace_func4_request<query::xrt_smi_config, xrt_smi_config>();
emplace_func4_request<query::lapc_status, lapc_status>();
emplace_func4_request<query::spc_status, spc_status>();
emplace_func4_request<query::accel_deadlock_status, accel_deadlock_status>();
Expand Down
211 changes: 211 additions & 0 deletions src/runtime_src/core/pcie/linux/smi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
#include "smi.h"

namespace xrt_core::smi {

static constexpr std::string_view xrt_smi_config =
R"(
{
"subcommands":
[{
"name" : "validate",
"description" : "Validates the given device by executing the platform's validate executable.",
"tag" : "basic",
"options" :
[
{
"name": "device",
"alias": "d",
"description": "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest",
"tag": "basic",
"default_value": "",
"option_type": "common",
"value_type" : "string"
},
{
"name": "format",
"alias": "f",
"description": "Report output format",
"tag": "basic",
"default_value": "JSON",
"option_type": "common",
"value_type" : "string"
},
{
"name": "output",
"alias": "o",
"description" : "Direct the output to the given file",
"tag": "basic",
"default_value": "",
"option_type": "common",
"value_type" : "string"
},
{
"name": "help",
"alias": "h",
"description" : "Help to use this sub-command",
"tag": "basic",
"default_value": "",
"option_type": "common",
"value_type" : "none"
},
{
"name" : "run",
"alias" : "r",
"description" : "Run a subset of the test suite",
"tag" : "basic",
"option_type": "common",
"value_type" : "array",
"options" : [
{
"name" : "latency",
"tag" : "basic",
"description" : "Run end-to-end latency test"
},
{
"name" : "throughput",
"tag" : "basic",
"description" : "Run end-to-end throughput test"
},
{
"name" : "cmd-chain-latency",
"tag" : "basic",
"description" : "Run command chain latency test"
},
{
"name" : "cmd-chain-throughput",
"tag" : "basic",
"description" : "Run end-to-end throughput test using command chaining"
},
{
"name" : "df-bw",
"tag" : "basic",
"description" : "Run dataflow bandwidth test"
},
{
"name" : "tct-one-col",
"tag" : "basic",
"description" : "Run TCT test with one column"
},
{
"name" : "tct-all-col",
"tag" : "basic",
"description" : "Run TCT test with all columns"
},
{
"name" : "gemm",
"tag" : "basic",
"description" : "Run GEMM test"
},
{
"name" : "aie-reconfig-overhead",
"tag" : "advanced",
"description" : "Run AIE reconfiguration overhead test"
},
{
"name" : "spatial-sharing-overhead",
"tag" : "advanced",
"description" : "Run spatial sharing overhead test"
},
{
"name" : "temporal-sharing-overhead",
"tag" : "advanced",
"description" : "Run temporal sharing overhead test"
}
]
},
{
"name" : "path",
"alias" : "p",
"description" : "Path to the directory containing validate xclbins",
"tag" : "basic",
"default_value": "",
"option_type": "hidden",
"value_type" : "string"
},
{
"name" : "param",
"description" : "Extended parameter for a given test. Format: <test-name>:<key>:<value>",
"tag" : "basic",
"option_type": "hidden",
"default_value": "",
"value_type" : "string"
},
{
"name" : "pmode",
"description" : "Specify which power mode to run the benchmarks in. Note: Some tests might be unavailable for some modes",
"tag" : "basic",
"option_type": "hidden",
"default_value": "",
"value_type" : "string"
}
]
},
{
"name" : "examine",
"tag" : "basic",
"description": "This command will 'examine' the state of the system/device and will generate a report of interest in a text or JSON format.",
"options":
[
{
"name": "device",
"description": "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest",
"tag": "devl",
"value_type": "string"
},
{
"name": "format",
"description": "Report output format",
"tag": "devl",
"value_type": "string"
},
{
"name": "report",
"description": "The type of report to be produced. Reports currently available are:",
"tag": "basic",
"options": [
{
"name": "aie-partitions",
"tag": "basic",
"description": "AIE partition information"
},
{
"name": "telemetry",
"tag": "devl",
"description": "Telemetry data for the device"
}
]
}
]
},
{
"name" : "configure",
"tag" : "devl",
"description" : "Device and host configuration.",
"options" :
[
{
"name": "device",
"description": "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest",
"tag": "devl",
"value_type" : "string"
},
{
"name": "pmode",
"description": "Modes: default, powersaver, balanced, performance, turbo",
"tag": "basic",
"value_type": "string"
}
]
}]
}
)";


std::string
get_smi_config()
{
return std::string(xrt_smi_config);
}
} // namespace xrt_core::smi
11 changes: 11 additions & 0 deletions src/runtime_src/core/pcie/linux/smi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.

#include <string>

namespace xrt_core::smi {

std::string
get_smi_config();

} // namespace xrt_core::smi
12 changes: 12 additions & 0 deletions src/runtime_src/core/tools/common/SubCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,15 @@ SubCmd::checkForSubOption(const boost::program_options::variables_map& vm, const
return option;
}

void
SubCmd::setOptionConfig(const boost::property_tree::ptree &config)
{
m_jsonConfig = SubCmdJsonObjects::JsonConfig(config.get_child("subcommands"), getName());
try{
m_jsonConfig.addProgramOptions(m_commonOptions, "common", getName());
m_jsonConfig.addProgramOptions(m_hiddenOptions, "hidden", getName());
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
}
3 changes: 3 additions & 0 deletions src/runtime_src/core/tools/common/SubCmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <boost/program_options.hpp>

#include "JSONConfigurable.h"
#include "SubCmdJsonObjects.h"
#include "OptionOptions.h"

class SubCmd : public JSONConfigurable {
Expand All @@ -38,6 +39,7 @@ class SubCmd : public JSONConfigurable {
const std::string & getExecutableName() const {return m_executableName; };

void setGlobalOptions(const boost::program_options::options_description &globalOptions) { m_globalOptions.add(globalOptions); };
void setOptionConfig(const boost::property_tree::ptree &config);

protected:
const boost::program_options::options_description & getGlobalOptions() const { return m_globalOptions; };
Expand Down Expand Up @@ -85,6 +87,7 @@ class SubCmd : public JSONConfigurable {
boost::program_options::options_description m_hiddenOptions;
boost::program_options::positional_options_description m_positionals;
boost::property_tree::ptree m_commandConfig;
SubCmdJsonObjects::JsonConfig m_jsonConfig;

template<class T>
std::vector<std::shared_ptr<T>>
Expand Down
Loading

0 comments on commit 4e8c32a

Please sign in to comment.