Skip to content

Commit

Permalink
CR-1206962 (#8323)
Browse files Browse the repository at this point in the history
Signed-off-by: AShivangi <shivangiagarwal53@gmail.com>
  • Loading branch information
AShivangi authored Aug 1, 2024
1 parent 483c755 commit 7d9b1da
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 49 deletions.
2 changes: 0 additions & 2 deletions src/runtime_src/core/pcie/driver/linux/xocl/xocl_types.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/*
* Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
*
* Authors: daniel.benusovich@amd.com
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
Expand Down
97 changes: 50 additions & 47 deletions src/runtime_src/core/tools/xbutil2/SubCmdValidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,47 @@ run_tests_on_devices( std::shared_ptr<xrt_core::device> &device,
return has_failures;
}

/*
* Extended keys helper struct
*/
struct ExtendedKeysStruct {
std::string test_name;
std::string param_name;
std::string description;
};

static std::vector<ExtendedKeysStruct> extendedKeysCollection = {
{"dma", "block-size", "Memory transfer size (bytes)"}
};

std::string
extendedKeysOptions()
{
static unsigned int m_maxColumnWidth = 100;
std::stringstream fmt_output;
// Formatting color parameters
const std::string fgc_header = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor(EscapeCodes::FGC_HEADER).string();
const std::string fgc_optionName = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor(EscapeCodes::FGC_OPTION).string();
const std::string fgc_optionBody = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor(EscapeCodes::FGC_OPTION_BODY).string();
const std::string fgc_reset = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor::reset();

// Report option group name (if defined)
boost::format fmtHeader(fgc_header + "\n%s:\n" + fgc_reset);
fmt_output << fmtHeader % "EXTENDED KEYS";

// Report the options
boost::format fmtOption(fgc_optionName + " %-18s " + fgc_optionBody + "- %s\n" + fgc_reset);
unsigned int optionDescTab = 23;

for (auto& param : extendedKeysCollection) {
const auto key_desc = (boost::format("%s:<value> - %s") % param.param_name % param.description).str();
const auto& formattedString = XBU::wrap_paragraphs(key_desc, optionDescTab, m_maxColumnWidth - optionDescTab, false);
fmt_output << fmtOption % param.test_name % formattedString;
}

return fmt_output.str();
}

}
//end anonymous namespace

Expand Down Expand Up @@ -454,65 +495,27 @@ SubCmdValidate::SubCmdValidate(bool _isHidden, bool _isDepricated, bool _isPreli

common_options.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")
("format,f", boost::program_options::value<decltype(m_format)>(&m_format)->implicit_value(""), (std::string("Report output format. Valid values are:\n") + formatOptionValues).c_str() )
("output,o", boost::program_options::value<decltype(m_output)>(&m_output)->implicit_value(""), "Direct the output to the given file")
("param", boost::program_options::value<decltype(m_param)>(&m_param), "Extended parameter for a given test. Format: <test-name>:<key>:<value>")
("path,p", boost::program_options::value<decltype(m_xclbin_location)>(&m_xclbin_location)->implicit_value(""), "Path to the directory containing validate xclbins")
("format,f", boost::program_options::value<decltype(m_format)>(&m_format), (std::string("Report output format. Valid values are:\n") + formatOptionValues).c_str() )
("output,o", boost::program_options::value<decltype(m_output)>(&m_output), "Direct the output to the given file")
("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command")
;

m_hiddenOptions.add_options()
("path,p", boost::program_options::value<decltype(m_xclbin_location)>(&m_xclbin_location)->implicit_value(""), "Path to the directory containing validate xclbins")
("param", boost::program_options::value<decltype(m_param)>(&m_param), (std::string("Extended parameter for a given test. Format: <test-name>:<key>:<value>\n") + extendedKeysOptions()).c_str())
;

m_commonOptions.add(common_options);
m_commonOptions.add_options()
("run,r", boost::program_options::value<decltype(m_tests_to_run)>(&m_tests_to_run)->multitoken()->zero_tokens(), (std::string("Run a subset of the test suite. Valid options are:\n") + formatRunValues).c_str() )
;
}

/*
* Extended keys helper struct
*/
struct ExtendedKeysStruct {
std::string test_name;
std::string param_name;
std::string description;
};

static std::vector<ExtendedKeysStruct> extendedKeysCollection = {
{"dma", "block-size", "Memory transfer size (bytes)"}
};

std::string
extendedKeysOptions()
{
static unsigned int m_maxColumnWidth = 100;
std::stringstream fmt_output;
// Formatting color parameters
const std::string fgc_header = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor(EscapeCodes::FGC_HEADER).string();
const std::string fgc_optionName = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor(EscapeCodes::FGC_OPTION).string();
const std::string fgc_optionBody = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor(EscapeCodes::FGC_OPTION_BODY).string();
const std::string fgc_reset = XBU::is_escape_codes_disabled() ? "" : EscapeCodes::fgcolor::reset();

// Report option group name (if defined)
boost::format fmtHeader(fgc_header + "\n%s:\n" + fgc_reset);
fmt_output << fmtHeader % "EXTENDED KEYS";

// Report the options
boost::format fmtOption(fgc_optionName + " %-18s " + fgc_optionBody + "- %s\n" + fgc_reset);
unsigned int optionDescTab = 23;

for (auto& param : extendedKeysCollection) {
const auto key_desc = (boost::format("%s:<value> - %s") % param.param_name % param.description).str();
const auto& formattedString = XBU::wrap_paragraphs(key_desc, optionDescTab, m_maxColumnWidth - optionDescTab, false);
fmt_output << fmtOption % param.test_name % formattedString;
}

return fmt_output.str();
}

void
SubCmdValidate::print_help_internal() const
{
if (m_device.empty()) {
printHelp(false, extendedKeysOptions());
printHelp(false);
return;
}

Expand All @@ -528,7 +531,7 @@ SubCmdValidate::print_help_internal() const
common_options.add_options()
("run,r", boost::program_options::value<decltype(tempVec)>(&tempVec)->multitoken(), (std::string("Run a subset of the test suite. Valid options are:\n") + testOptionValues).c_str() )
;
printHelp(common_options, m_hiddenOptions, deviceClass, false, extendedKeysOptions());
printHelp(common_options, m_hiddenOptions, deviceClass, false);
}

void
Expand Down

0 comments on commit 7d9b1da

Please sign in to comment.