From f1ca1c9186bed805327d561cda9b22ff5121a85d Mon Sep 17 00:00:00 2001 From: Nicole Lemaster Slattengren Date: Fri, 17 Sep 2021 15:14:48 -0700 Subject: [PATCH] #1359: LB: add function for printing lb-specific args --- .../balance/lb_invoke/lb_manager.cc | 34 +++++++++++++++++++ .../collection/balance/lb_invoke/lb_manager.h | 8 +++++ 2 files changed, 42 insertions(+) diff --git a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc index f466c31b7a..620f51925e 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc @@ -262,6 +262,40 @@ void LBManager::startLB(PhaseType phase, LBType lb) { runLB(base_proxy, phase); } +void LBManager::printLBArgsHelp(LBType lb) { + if (theContext()->getNode() == 0) { + fmt::print("\nLB arguments for {}:\n\n", lb_names_[lb]); + + std::unordered_map help; + + switch (lb) { + case LBType::HierarchicalLB: + help = std::move(lb::HierarchicalLB::getInputKeysWithHelp()); + break; + case LBType::GreedyLB: + help = std::move(lb::GreedyLB::getInputKeysWithHelp()); + break; + case LBType::RotateLB: + help = std::move(lb::RotateLB::getInputKeysWithHelp()); + break; + case LBType::TemperedLB: + help = std::move(lb::TemperedLB::getInputKeysWithHelp()); + break; + case LBType::RandomLB: + help = std::move(lb::RandomLB::getInputKeysWithHelp()); + break; + default: + fmt::print("Documentation has not been provided for this LB.\n\n"); + break; + } + + for (auto &arg_help : help) { + fmt::print("Argument: {}\n", arg_help.first); + fmt::print("{}\n", arg_help.second); + } + } +} + void LBManager::startup() { thePhase()->registerHookCollective(phase::PhaseHook::EndPostMigration, []{ auto const phase = thePhase()->getCurrentPhase(); diff --git a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h index 8964fb0e77..c8294a905a 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h @@ -133,6 +133,14 @@ struct LBManager : runtime::component::Component { */ void startLB(PhaseType phase, LBType lb); + /** + * \internal + * \brief Print documentation for LB args for the chosen LB + * + * \param[in] lb the load balancer to query + */ + static void printLBArgsHelp(LBType lb); + protected: /** * \internal