Skip to content

Commit

Permalink
#900 pmpi- unify argument handling of --vt_trace_mpi
Browse files Browse the repository at this point in the history
- Now uses an option instead of a flag. Specify the form of MPI to enable.
  In C++, the options should be separated with spaces:

      --vt_mpi_trace internal
      --vt_mpi_trace external
      --vt_mpi_trace internal externall

  'internal' is the few select internal calls, 'external' is PMPI overall.
  • Loading branch information
pnstickne authored and lifflander committed Aug 4, 2020
1 parent e951b42 commit 9619d8c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
29 changes: 23 additions & 6 deletions src/vt/configs/arguments/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ namespace vt { namespace arguments {

/*static*/ bool ArgParse::parsed_ = false;

// Temporary variables used only for parsing artifacts.
namespace {
std::vector<std::string> arg_trace_mpi;
}

void addColorArgs(CLI::App& app) {
auto quiet = "Quiet the output from vt (only errors, warnings)";
auto always = "Colorize output (default)";
Expand Down Expand Up @@ -277,9 +282,7 @@ void addTraceArgs(CLI::App& app) {
* Flags to control tracing output
*/
auto trace = "Enable tracing (must be compiled with trace_enabled)";
auto trace_mpi = "Enable tracing of select internal MPI calls"
" (must be compiled with trace_enabled)";
auto trace_pmpi = "Enable tracing of external PMPI calls"
auto trace_mpi = "Enable tracing of MPI calls"
" (must be compiled with trace_enabled)";
auto tfile = "Name of trace files";
auto tdir = "Name of directory for trace files";
Expand All @@ -296,8 +299,8 @@ void addTraceArgs(CLI::App& app) {
auto tpolled = "Trace AsyncEvent component polling (inc. MPI_Isend requests)";
auto tirecv = "Trace MPI_Irecv request polling";
auto n = app.add_flag("--vt_trace", ArgConfig::vt_trace, trace);
auto nm = app.add_flag("--vt_trace_mpi", ArgConfig::vt_trace_mpi, trace_mpi);
auto no = app.add_flag("--vt_trace_pmpi", ArgConfig::vt_trace_pmpi, trace_pmpi);
auto nm = app.add_option("--vt_trace_mpi", arg_trace_mpi, trace_mpi)
->check(CLI::IsMember({"internal", "external"}));
auto o = app.add_option("--vt_trace_file", ArgConfig::vt_trace_file, tfile, "");
auto p = app.add_option("--vt_trace_dir", ArgConfig::vt_trace_dir, tdir, "");
auto q = app.add_option("--vt_trace_mod", ArgConfig::vt_trace_mod, tmod, 1);
Expand All @@ -316,7 +319,6 @@ void addTraceArgs(CLI::App& app) {
auto traceGroup = "Tracing Configuration";
n->group(traceGroup);
nm->group(traceGroup);
no->group(traceGroup);
o->group(traceGroup);
p->group(traceGroup);
q->group(traceGroup);
Expand Down Expand Up @@ -657,6 +659,19 @@ std::tuple<int, std::string> parseArguments(CLI::App& app, int& argc, char**& ar
return result;
}

/**
* \internal
* Application specific cleanup and mapping to actual app args.
*/
void postParseTransform() {
auto contains = [](std::vector<std::string> &v, std::string str){
return std::find(v.begin(), v.end(), str) not_eq v.end();
};

ArgConfig::vt_trace_mpi = contains(arg_trace_mpi, "internal");
ArgConfig::vt_trace_pmpi = contains(arg_trace_mpi, "external");
}

std::tuple<int, std::string> parseArguments(CLI::App& app, int& argc, char**& argv) {

std::vector<char*> vt_args;
Expand Down Expand Up @@ -732,6 +747,8 @@ std::tuple<int, std::string> parseArguments(CLI::App& app, int& argc, char**& ar
ArgConfig::mpi_init_args = mpi_args;
ArgConfig::passthru_args = passthru_args;

postParseTransform();

// Rebuild passthru into ref-returned argc/argv
// (only pass-through, not MPI_Init-bound)

Expand Down
3 changes: 1 addition & 2 deletions src/vt/pmpi/pmpi_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ struct PMPIComponent : runtime::component::Component<PMPIComponent> {

using ArgType = vt::arguments::ArgConfig;

PMPIComponent() {
}
PMPIComponent() = default;

std::string name() override { return "PMPI"; }

Expand Down
12 changes: 9 additions & 3 deletions src/vt/runtime/runtime_banner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ void Runtime::printStartupBanner() {
green, reset, magenta, opt, reset, compile, reset
);
};
auto opt_on_value = [=](std::string opt, std::string val, std::string compile) -> std::string {
return fmt::format(
"{}Option:{} flag {}{}{} on with value \"{}\": {}{}\n",
green, reset, magenta, opt, reset, val, compile, reset
);
};
auto opt_off = [=](std::string opt, std::string compile) -> std::string {
return fmt::format(
"{}Option:{} flag {}{}{} not set: {}{}\n",
Expand Down Expand Up @@ -455,12 +461,12 @@ void Runtime::printStartupBanner() {
}
if (ArgType::vt_trace_mpi) {
auto f11 = fmt::format("Tracing MPI invocations (select internal calls)");
auto f12 = opt_on("--vt_trace_mpi", f11);
auto f12 = opt_on_value("--vt_trace_mpi", "internal", f11);
fmt::print("{}\t{}{}", vt_pre, f12, reset);
}
if (ArgType::vt_trace_pmpi) {
auto f11 = fmt::format("Tracing PMPI invocations (external calls)");
auto f12 = opt_on("--vt_trace_mpi", f11);
auto f11 = fmt::format("Tracing MPI invocations (external calls)");
auto f12 = opt_on_value("--vt_trace_mpi", "external", f11);
fmt::print("{}\t{}{}", vt_pre, f12, reset);
}
if (ArgType::vt_trace_event_polling) {
Expand Down

0 comments on commit 9619d8c

Please sign in to comment.