Skip to content

Commit

Permalink
#984 print excluded phases for mod entries
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Aug 14, 2020
1 parent ecabfb4 commit 1e923de
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 45 deletions.
46 changes: 1 addition & 45 deletions src/vt/runtime/runtime_banner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,50 +63,6 @@

#include <mpi.h>

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()) {
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()));
}

if (not Spec::getModEntries().empty()) {
fmt::print("{}\tMod (%) specification lines:\n", vt::debug::vtPre());
}
for (auto const& mod_entry : Spec::getModEntries()) {
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;
}

namespace vt { namespace runtime {

void Runtime::printStartupBanner() {
Expand Down Expand Up @@ -334,7 +290,7 @@ void Runtime::printStartupBanner() {
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);
fmt::print(vrt::collection::balance::ReadLBSpec::toString());
}
} else {
auto a3 = fmt::format("Load balancer name: \"{}\"", getAppConfig()->vt_lb_name);
Expand Down
67 changes: 67 additions & 0 deletions src/vt/vrt/collection/balance/read_lb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "vt/vrt/collection/balance/lb_type.h"
#include "vt/configs/arguments/app_config.h"

#include <sstream>
#include <string>
#include <fstream>
#include <cassert>
Expand Down Expand Up @@ -294,4 +295,70 @@ ReadLBSpec::parseParams(std::vector<std::string> params) {
return SpecEntry{0, "", param_map};
}

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);
};

auto excluded_str = [](SpecIndex idx) -> std::string {
std::stringstream ss;
auto exact_entries = ReadLBSpec::getExactEntries();
auto max_idx = exact_entries.empty() ? 0 : exact_entries.rbegin()->first;

for (auto k = 1; k*idx <= max_idx; k++) {
auto next_entry = ReadLBSpec::entry(k*idx);
if (next_entry != nullptr and next_entry->getIdx() != idx) {
ss << fmt::format("{}, ", debug::emph(std::to_string(k*idx)));
}
}
std::string s = ss.str();
return s.empty() ? s : s.substr(0, s.size() - 2);
};

/*static*/ std::string ReadLBSpec::toString() {
std::stringstream ss;

ReadLBSpec::openFile(theConfig()->vt_lb_file_name);
ReadLBSpec::readFile();

if (not ReadLBSpec::getExactEntries().empty()) {
ss << fmt::format("{}\tExact specification lines:\n", vt::debug::vtPre());
}
for (auto const& exact_entry : ReadLBSpec::getExactEntries()) {
ss << fmt::format("{}\tRun `{}` on phase {} with arguments `{}`\n",
vt::debug::vtPre(),
vt::debug::emph(exact_entry.second.getName()),
vt::debug::emph(std::to_string(exact_entry.first)),
param_str(exact_entry.second.getParams()));
}

if (not ReadLBSpec::getModEntries().empty()) {
ss << fmt::format(
"{}\tMod (%) specification lines:\n", vt::debug::vtPre()
);
}
for (auto const& mod_entry : ReadLBSpec::getModEntries()) {
ss << fmt::format("{}\tRun `{}` every {} phases with arguments `{}`",
vt::debug::vtPre(),
vt::debug::emph(mod_entry.second.getName()),
vt::debug::emph(std::to_string(mod_entry.first)),
param_str(mod_entry.second.getParams()));

auto excluded_phases = excluded_str(mod_entry.first);
if (not excluded_phases.empty()) {
ss << " excluding phases " << excluded_phases;
}
ss << '\n';
}
return ss.str();
}

}}}} /* end namespace vt::vrt::collection::balance */
1 change: 1 addition & 0 deletions src/vt/vrt/collection/balance/read_lb.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ struct ReadLBSpec {
static ParamMapType parseParams(std::vector<std::string> params);
static SpecEntry makeSpecFromParams(std::string params);
static void clear();
static std::string toString();

private:
static bool read_complete_;
Expand Down

0 comments on commit 1e923de

Please sign in to comment.