Skip to content

Commit

Permalink
#984 rename option to --vt_lb_show_spec and improve printing
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Aug 14, 2020
1 parent 782b24b commit a538972
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/md/lb-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following is an example LB specification:
120 GreedyLB c=0 k=2 f=3 i=3
\endcode

To print LB specification during startup, use `--vt_lb_print_file` command line flag.
To print LB specification during startup, use `--vt_lb_show_spec` command line flag.

\section load-balancers Load balancers

Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/arguments/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct AppConfig {
bool vt_trace_irecv_polling = false;

bool vt_lb = false;
bool vt_lb_print_file = false;
bool vt_lb_show_spec = false;
bool vt_lb_quiet = false;
std::string vt_lb_file_name = "";
std::string vt_lb_name = "NoLB";
Expand Down
4 changes: 2 additions & 2 deletions src/vt/configs/arguments/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void ArgConfig::addLbArgs(CLI::App& app) {
auto lb_args = "Arguments pass to LB: \"x=0 y=1 test=2\"";
auto lb_quiet = "Silence load balancing output";
auto lb_file_name = "LB specification file to read";
auto lb_print_file = "Print LB specification file during startup";
auto lb_show_spec = "Show LB specification during startup";
auto lb_name = "Name of the load balancer to use";
auto lb_interval = "Load balancing interval";
auto lb_stats = "Enable load balancing statistics";
Expand All @@ -345,7 +345,7 @@ void ArgConfig::addLbArgs(CLI::App& app) {
auto t1 = app.add_flag("--vt_lb_quiet", config_.vt_lb_quiet, lb_quiet);
auto u = app.add_option("--vt_lb_file_name", config_.vt_lb_file_name, lb_file_name, lbf)
->check(CLI::ExistingFile);
auto u1 = app.add_flag("--vt_lb_print_file", config_.vt_lb_print_file, lb_print_file);
auto u1 = app.add_flag("--vt_lb_show_spec", config_.vt_lb_show_spec, lb_show_spec);
auto v = app.add_option("--vt_lb_name", config_.vt_lb_name, lb_name, lbn);
auto v1 = app.add_option("--vt_lb_args", config_.vt_lb_args, lb_args, lba);
auto w = app.add_option("--vt_lb_interval", config_.vt_lb_interval, lb_interval, lbi);
Expand Down
51 changes: 34 additions & 17 deletions src/vt/runtime/runtime_banner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,44 @@

#include <mpi.h>

void printLBConfig(std::string const& filename) {
auto param_str = [](std::unordered_map<std::string,
std::string> const& params) -> std::string {
std::stringstream ss;
for (auto&& param : params) {
ss << fmt::format("{}={} ",
vt::debug::emph(param.first),
vt::debug::emph(param.second));
}
std::string s = ss.str();
return s.empty() ? s : s.substr(0, s.size() - 1);
};

void printLBSpec(std::string const& filename) {
using Spec = vt::vrt::collection::balance::ReadLBSpec;

Spec::openFile(filename);
Spec::readFile();

if (not Spec::getExactEntries().empty()) {
fmt::print("{}\tExact specification lines:\n", vt::debug::vtPre());
}
for (auto const& exact_entry : Spec::getExactEntries()) {
std::string formatted_params;
for (auto const& param : exact_entry.second.getParams()) {
formatted_params += fmt::format("{}={} ", param.first, param.second);
}
fmt::print("{}\tRun `{}` on phase {} with arguments `{}`\n",
vt::debug::vtPre(),
vt::debug::emph(exact_entry.second.getName()),
vt::debug::emph(std::to_string(exact_entry.second.getIdx())),
param_str(exact_entry.second.getParams()));
}

fmt::print("Run `{}` on phase {} with arguments `{}`\n", exact_entry.second.getName(), exact_entry.second.getIdx(), formatted_params);
if (not Spec::getModEntries().empty()) {
fmt::print("{}\tMod (%) specification lines:\n", vt::debug::vtPre());
}
for (auto const& mod_entry : Spec::getModEntries()) {
std::string formatted_params;
for (auto const& param : mod_entry.second.getParams()) {
formatted_params += fmt::format("{}={} ", param.first, param.second);
}

fmt::print("Run `{}` every {} phases with arguments `{}`\n", mod_entry.second.getName(), mod_entry.second.getIdx(), formatted_params);
fmt::print("{}\tRun `{}` every {} phases with arguments {}\n",
vt::debug::vtPre(),
vt::debug::emph(mod_entry.second.getName()),
vt::debug::emph(std::to_string(mod_entry.second.getIdx())),
param_str(mod_entry.second.getParams()));
}

return;
Expand Down Expand Up @@ -308,14 +325,14 @@ void Runtime::printStartupBanner() {
auto f9 = opt_on("--vt_lb", "Load balancing enabled");
fmt::print("{}\t{}{}", vt_pre, f9, reset);
if (getAppConfig()->vt_lb_file_name != "") {
auto f10 = opt_on("--vt_lb_file", "Reading LB config from file");
fmt::print("{}\t{}{}", vt_pre, f10, reset);
auto f12 = fmt::format("Reading file \"{}\"", getAppConfig()->vt_lb_file_name);
auto f12 = fmt::format("Reading LB specification from file \"{}\"", getAppConfig()->vt_lb_file_name);
auto f11 = opt_on("--vt_lb_file_name", f12);
fmt::print("{}\t{}{}", vt_pre, f11, reset);

if (getAppConfig()->vt_lb_print_file) {
printLBConfig(getAppConfig()->vt_lb_file_name);
if (getAppConfig()->vt_lb_show_spec) {
auto s = opt_on("--vt_lb_show_spec", "Showing LB specification");
fmt::print("{}\t{}", vt_pre, s);
printLBSpec(getAppConfig()->vt_lb_file_name);
}
} else {
auto a3 = fmt::format("Load balancer name: \"{}\"", getAppConfig()->vt_lb_name);
Expand Down

0 comments on commit a538972

Please sign in to comment.