Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/runtime_src/core/common/smi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ std::string
smi::
build_json() const
{
std::lock_guard<std::mutex> lock(m_mutex);

ptree config;
ptree subcommands;

Expand All @@ -111,6 +113,8 @@ tuple_vector
smi::
get_list(const std::string& subcommand, const std::string& suboption) const
{
std::lock_guard<std::mutex> lock(m_mutex);

const auto it = m_subcommands.find(subcommand);
if (it == m_subcommands.end()) {
throw std::runtime_error("Subcommand not found: " + subcommand);
Expand All @@ -131,6 +135,8 @@ tuple_vector
smi::
get_option_options(const std::string& subcommand) const
{
std::lock_guard<std::mutex> lock(m_mutex);

const auto it = m_subcommands.find(subcommand);
if (it == m_subcommands.end()) {
throw std::runtime_error("Subcommand not found: " + subcommand);
Expand Down
10 changes: 7 additions & 3 deletions src/runtime_src/core/common/smi.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
// 3rd Party Library - Include Files
#include <boost/property_tree/ptree.hpp>

#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <tuple>
#include <vector>
#include <memory>
#include <map>

namespace xq = xrt_core::query;

Expand Down Expand Up @@ -129,11 +130,14 @@ class subcommand {
// Each shim (including smi_default) should create objects of smi class and populate
// them with their custom fields. Currently, shims create singleton instanced of it.
class smi {
mutable std::mutex m_mutex;
std::map<std::string, subcommand> m_subcommands;

public:
void
add_subcommand(std::string name, subcommand subcmd) {
add_subcommand(std::string name, subcommand subcmd)
{
std::lock_guard<std::mutex> lock(m_mutex);
m_subcommands.emplace(std::move(name), std::move(subcmd));
}

Expand Down
9 changes: 2 additions & 7 deletions src/runtime_src/core/tools/common/SubCmdExamineInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,8 @@ SubCmdExamineInternal::execute(const SubCmdOptions& _options) const
// Determine report level
std::vector<std::string> reportsToRun(m_reportNames);
if (reportsToRun.empty()) {
if (!XBU::getAdvance()) {
reportsToRun.push_back("host");
}
else {
print_help_internal();
return;
}
// Default report with or without --advanced (advanced only unlocks hidden options/reports).
reportsToRun.push_back("host");
Comment thread
aktondak marked this conversation as resolved.
Outdated
}

if ((std::find(reportsToRun.begin(), reportsToRun.end(), "all") != reportsToRun.end()) && (reportsToRun.size() > 1)) {
Expand Down
9 changes: 2 additions & 7 deletions src/runtime_src/core/tools/xbutil2/SubCmdExamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,8 @@ SubCmdExamine::execute(const SubCmdOptions& _options) const
// Determine report level
std::vector<std::string> reportsToRun(options.m_reportNames);
if (reportsToRun.empty()) {
if (!XBU::getAdvance()) {
reportsToRun.emplace_back("host");
}
else {
printHelp();
return;
}
// Default report with or without --advanced (advanced only unlocks hidden options/reports).
reportsToRun.emplace_back("host");
}

if ((std::find(reportsToRun.begin(), reportsToRun.end(), "all") != reportsToRun.end()) && (reportsToRun.size() > 1)) {
Expand Down
Loading