71 #include <include/hpctoolkit-config.h> 80 #define ARG_ERROR(streamArgs) \ 81 { std::ostringstream WeIrDnAmE; \ 82 WeIrDnAmE << streamArgs ; \ 83 printError(std::cerr, WeIrDnAmE.str()); \ 91 "[profiling-options] -- <command> [command-arguments]";
97 hpcrun-flat profiles the execution of an arbitrary command <command> using\n\ 98 statistical sampling (rather than instrumentation). It collects per-thread\n\ 99 flat profiles, or IP (instruction pointer) histograms. Sample points may\n\ 100 be generated from multiple simultaneous sampling sources. hpcrun-flat\n\ 101 profiles complex applications that use forks, execs, and threads (but not\n\ 102 dynamic linking/unlinking); it may be used in conjuction with parallel\n\ 103 process launchers such as MPICH's mpiexec and SLURM's srun.\n\ 105 To configure hpcrun's sampling sources, specify events and periods using\n\ 106 the -e/--event option. For an event 'e' and period 'p', after every 'p'\n\ 107 instances of 'e', a sample is generated that causes hpcrun to inspect the\n\ 108 and record information about the monitored <command>.\n\ 110 When <command> terminates, per-thread profiles are written to files with\n\ 111 the names of the form:\n\ 112 <command>.hpcrun-flat.<hostname>.<pid>.<tid>\n\ 114 hpcrun-flat enables a user to abort a process and write the partial profiling\n\ 115 data to disk by sending the Interrupt signal (INT or Ctrl-C). This can be\n\ 116 extremely useful on long-running or misbehaving applications.\n\ 118 The special option '--' can be used to stop hpcrun option parsing; this is\n\ 119 especially useful when <command> takes arguments of its own.\n\ 121 Options: Informational\n\ 122 -l, --list-events-short\n\ 123 List available events. (N.B.: some may not be\n\ 125 -L, --list-events-long\n\ 126 Similar to above but with more information.\n\ 127 --paths Print paths for external PAPI and MONITOR.\n\ 128 -V, --version Print version information.\n\ 129 -h, --help Print help.\n\ 130 --debug [<n>] Debug: use debug level <n>. {1}\n\ 132 Options: Profiling (Defaults shown in curly brackets {})\n\ 133 -r [<yes|no>], --recursive [<yes|no>]\n\ 134 Profile processes spawned by <command>. {no} (Each\n\ 135 process will receive its own output file.)\n\ 136 -t <mode>, --threads <mode>\n\ 137 Select thread profiling mode. {each}\n\ 138 each: Separate profiles for each thread.\n\ 139 all: Combined profiles of all threads.\n\ 140 Only POSIX threads are supported; the WALLCLOCK event\n\ 141 cannot be used in a multithreaded process.\n\ 142 -e <event>[:<period>], --event <event>[:<period>]\n\ 143 An event to profile and its corresponding sample\n\ 144 period. <event> may be either a PAPI or native\n\ 145 processor event. May pass multiple times.\n\ 146 {PAPI_TOT_CYC:999999}.\n\ 147 o Recommended: always specify sampling period.\n\ 148 o Special event: WALLCLOCK (use once, without period)\n\ 149 o Hardware and drivers limit possibilities.\n\ 150 -o <outpath>, --output <outpath>\n\ 151 Directory for output data {.}\n\ 152 --papi-flag <flag>\n\ 153 Profile style flag {PAPI_POSIX_PROFIL}\n\ 156 * hpcrun-flat uses preloaded shared libraries to initiate profiling. For\n\ 157 this reason, it cannot be used to profile setuid programs.\n\ 158 * For the same reason, it cannot profile statically linked applications.\n\ 159 * Bug: hpcrun-flat cannot currently profile programs that themselves use\n\ 164 #define CLP CmdLineParser 169 {
'l',
"list-events-short", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL, NULL },
170 {
'L',
"list-events-long", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL, NULL },
171 { 0 ,
"paths", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL, NULL },
174 {
'r',
"recursive", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL, NULL },
175 {
't',
"threads", CLP::ARG_REQ, CLP::DUPOPT_CLOB,
NULL, NULL },
176 {
'e',
"event", CLP::ARG_REQ, CLP::DUPOPT_CAT,
";" , NULL },
177 {
'o',
"output", CLP::ARG_REQ , CLP::DUPOPT_CLOB,
NULL, NULL },
178 {
'f',
"papi-flag", CLP::ARG_REQ , CLP::DUPOPT_CLOB,
NULL, NULL },
180 {
'V',
"version", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL, NULL },
181 {
'h',
"help", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL, NULL },
182 { 0 ,
"debug", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL, NULL },
199 Args::Args(
int argc,
const char*
const argv[])
239 os <<
getCmd() <<
": " << msg << endl
240 <<
"Try '" <<
getCmd() <<
" --help' for more information." << endl;
261 bool requireCmd =
true;
308 if (arg ==
"no" || arg ==
"yes") {
312 ARG_ERROR(
"Unexpected option argument '" << arg <<
"'");
321 if (arg ==
"each" || arg ==
"all") {
325 ARG_ERROR(
"Unexpected option argument '" << arg <<
"'");
340 if (requireCmd && numArgs < 1) {
341 ARG_ERROR(
"Incorrect number of arguments: Missing <command> to profile.");
345 for (
uint i = 0; i < numArgs; ++i) {
362 os <<
"Args.cmd= " <<
getCmd() << endl;
bool isOpt(const char swShort) const
void printUsage(std::ostream &os) const
const std::string & getOptArg(const char swShort) const
const std::string & getCmd() const
virtual const std::string & what() const
bool isOptArg(const char swShort) const
void parse(const OptArgDesc *optArgDescs, int argc, const char *const argv[])
unsigned int getNumArgs() const
void printVersion(std::ostream &os) const
void parse(int argc, const char *const argv[])
virtual std::string message() const
std::vector< std::string > profArgV
std::string profRecursive
#define CmdLineParser_OptArgDesc_NULL_MACRO
void printError(std::ostream &os, const char *msg) const
void Diagnostics_SetDiagnosticFilterLevel(int lvl)
static CmdLineParser::OptArgDesc optArgs[]
const std::string & getArg(unsigned int i) const
const std::string & getCmd() const
void dump(std::ostream &os=std::cerr) const
static long toLong(const std::string &str)