diff --git a/src/vt/runtime/runtime_banner.cc b/src/vt/runtime/runtime_banner.cc index 7ad2a04c00..a76b32541b 100644 --- a/src/vt/runtime/runtime_banner.cc +++ b/src/vt/runtime/runtime_banner.cc @@ -63,50 +63,6 @@ #include -auto param_str = []( - std::unordered_map 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() { @@ -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); diff --git a/src/vt/vrt/collection/balance/read_lb.cc b/src/vt/vrt/collection/balance/read_lb.cc index cec3b9be3a..81dd78e7ed 100644 --- a/src/vt/vrt/collection/balance/read_lb.cc +++ b/src/vt/vrt/collection/balance/read_lb.cc @@ -48,6 +48,7 @@ #include "vt/vrt/collection/balance/lb_type.h" #include "vt/configs/arguments/app_config.h" +#include #include #include #include @@ -294,4 +295,70 @@ ReadLBSpec::parseParams(std::vector params) { return SpecEntry{0, "", param_map}; } +auto param_str = []( + std::unordered_map 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 */ diff --git a/src/vt/vrt/collection/balance/read_lb.h b/src/vt/vrt/collection/balance/read_lb.h index ec92823023..fc02b4ba93 100644 --- a/src/vt/vrt/collection/balance/read_lb.h +++ b/src/vt/vrt/collection/balance/read_lb.h @@ -194,6 +194,7 @@ struct ReadLBSpec { static ParamMapType parseParams(std::vector params); static SpecEntry makeSpecFromParams(std::string params); static void clear(); + static std::string toString(); private: static bool read_complete_;