Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CR 1217061 : xrt-smi advanced --help prints Alveo help #8545

Merged
merged 6 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions src/runtime_src/core/tools/xbutil2/OO_Reports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ print_preemption_telemetry(const xrt_core::device* device)
// ----- C L A S S M E T H O D S -------------------------------------------

OO_Reports::OO_Reports( const std::string &_longName, bool _isHidden )
: OptionOptions(_longName, _isHidden, "Hidden reports")
: OptionOptions(_longName, _isHidden, "Reports to generate: clocks, preemption")
, m_device("")
, m_action("")
, m_help(false)
{
m_optionsDescription.add_options()
("device,d", boost::program_options::value<decltype(m_device)>(&m_device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest")
("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command")
("mode", boost::program_options::value<decltype(m_action)>(&m_action)->required(), "Action to perform: clocks, preemption")
;

m_optionsHidden.add_options()
("mode", boost::program_options::value<decltype(m_action)>(&m_action)->implicit_value(""), "Reports to generate: clocks, preemption");

m_positionalOptions.
add("mode", 1 /* max_count */)
;
Expand All @@ -100,25 +102,17 @@ OO_Reports::execute(const SubCmdOptions& _options) const

// Parse sub-command ...
po::variables_map vm;
process_arguments(vm, _options);

try {
po::options_description all_options("All Options");
all_options.add(m_optionsDescription);
po::command_line_parser parser(_options);
XBUtilities::process_arguments(vm, parser, all_options, m_positionalOptions, true);
} catch(boost::program_options::error&) {
if(m_help) {
printHelp();
throw xrt_core::error(std::errc::operation_canceled);
}
// Exit if neither action or device specified
if(m_action.empty()) {
std::cerr << boost::format("ERROR: the required argument for option '--report' is missing\n");
printHelp();
throw xrt_core::error(std::errc::operation_canceled);
}
if (m_help) {
printHelp();
return;
}
if(m_action.empty()) {
std::cerr << boost::format("ERROR: the required argument for option '--report' is missing\n");
printHelp();
throw xrt_core::error(std::errc::operation_canceled);
}

// Find device of interest
std::shared_ptr<xrt_core::device> device;

Expand Down
14 changes: 6 additions & 8 deletions src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ namespace po = boost::program_options;

SubCmdAdvanced::SubCmdAdvanced(bool _isHidden, bool _isDepricated, bool _isPreliminary, const boost::property_tree::ptree& configurations)
: SubCmd("advanced",
"Low level command operations")
"Low level command operations"),
m_device("")
{
const std::string longDescription = "Low level command operations.";
setLongDescription(longDescription);
Expand All @@ -45,6 +46,7 @@ SubCmdAdvanced::SubCmdAdvanced(bool _isHidden, bool _isDepricated, bool _isPreli
setIsPreliminary(_isPreliminary);

m_commonOptions.add_options()
("device,d", boost::program_options::value<decltype(m_device)>(&m_device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this device. "xrt-smi advanced --device <>" Is not a valid command. We have devices inside the suboptions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can print device specific help only when m_device is populated.
SubCmdProgram class also has a m_device which works on the OptionOption mechanism, similar to advanced.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, please make sure that all possible option combos work after this change!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only clocks and preemption are used as valida reports right now. Generating preemption exits silently and clocks works fine :

Z:\Repos\XRT-MCDM-FORK\XRT-MCDM\build\WRelease\xilinx\xrt>xrt-smi advanced --report preemption

Z:\Repos\XRT-MCDM-FORK\XRT-MCDM\build\WRelease\xilinx\xrt>xrt-smi advanced --report clocks

Clocks
  H Clock                : 800 MHz
  MP-NPU Clock           : 400 MHz

("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command")
;

Expand Down Expand Up @@ -77,17 +79,13 @@ SubCmdAdvanced::execute(const SubCmdOptions& _options) const
auto optionOption = checkForSubOption(vm);

// No suboption print help
if (!optionOption) {
printHelp();
if (!optionOption || m_help) {
printHelp(false, "", XBU::get_device_class(m_device, true));
return;
}

// 2) Process the top level options
if (m_help)
topOptions.push_back("--help");

optionOption->setGlobalOptions(getGlobalOptions());

// Execute the option
optionOption->execute(topOptions);
optionOption->execute(_options);
}
1 change: 1 addition & 0 deletions src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SubCmdAdvanced : public SubCmd {

private:
bool m_help;
std::string m_device;
};

#endif
Expand Down
Loading