71 #include <include/hpctoolkit-config.h> 86 #define ARG_ERROR(streamArgs) \ 87 { std::ostringstream WeIrDnAmE; \ 88 WeIrDnAmE << streamArgs ; \ 89 printError(std::cerr, WeIrDnAmE.str()); \ 97 "[options] <measurement-group>...\n";
100 hpcprof and hpcprof-mpi analyze call path profile performance measurements,\n\ 101 attribute them to static source code structure, and generate an Experiment\n\ 102 database for use with hpcviewer. hpcprof-mpi is a scalable (parallel)\n\ 103 version of hpcprof.\n\ 105 Both hpcprof and hpcprof-mpi expect a list of measurement-groups, where a\n\ 106 group is a call path profile directory or an individual profile file.\n\ 108 N.B.: For best results (a) compile your application with debugging\n\ 109 information (e.g., -g); (b) pass recursive search paths with the -I option;\n\ 110 and (c) pass structure information with the -S option.\n\ 113 -v [<n>], --verbose [<n>]\n\ 114 Verbose: generate progress messages to stderr at\n\ 115 verbosity level <n>. {1}\n\ 116 -V, --version Print version information.\n\ 117 -h, --help Print this help.\n\ 118 --debug [<n>] Debug: use debug level <n>. {1}\n\ 120 Options: Source Code and Static Structure:\n\ 121 --name <name>, --title <name>\n\ 122 Set the database's name (title) to <name>.\n\ 123 -I <path>, --include <path>\n\ 124 Use <path> when searching for source files. For a\n\ 125 recursive search, append a + after the last slash,\n\ 126 e.g., /mypath/+ . May use multiple -I options.\n\ 127 -S <file>, --structure <file>\n\ 128 Use hpcstruct structure file <file> for correlation.\n\ 129 May pass multiple times (e.g., for shared libraries).\n\ 130 -R '<old-path>=<new-path>', --replace-path '<old-path>=<new-path>'\n\ 131 Substitute instances of <old-path> with <new-path>;\n\ 132 apply to all paths (profile's load map, source code)\n\ 133 for which <old-path> is a prefix. Use '\\' to escape\n\ 134 instances of '=' within a path. May pass multiple\n\ 138 -M <metric>, --metric <metric>\n\ 139 Specify metrics to compute, where <metric> is one of\n\ 141 sum: sum over threads/processes\n\ 142 stats: sum, mean, standard dev, coef of var, min, &\n\ 143 max over threads/processes\n\ 144 thread: per-thread metrics\n\ 145 Default: {sum}. May pass multiple times.\n\ 146 hpcprof-mpi does not compute 'thread'.\n\ 147 --force-metric Force hpcprof to show all thread-level metrics,\n\ 148 regardless of their number.\n\ 151 -o <db-path>, --db <db-path>, --output <db-path>\n\ 152 Specify Experiment database name <db-path>.\n\ 155 --metric-db <yes|no>\n\ 156 Control whether to generate a thread-level metric\n\ 157 value database for hpcviewer scatter plots. {yes}\n\ 158 --remove-redundancy \n\ 159 Eliminate procedure name redundancy in experiment.xml\n\ 160 --struct-id Add 'str=nnn' field to profile data with the hpcstruct\n\ 161 node id (for debug, default no).\n\ 166 #define CLP CmdLineParser 167 #define CLP_SEPARATOR "!!!" 171 { 0 ,
"agent-cilk", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
173 { 0 ,
"agent-mpi", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
175 { 0 ,
"agent-pthread", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
179 { 0 ,
"name", CLP::ARG_REQ, CLP::DUPOPT_CLOB,
NULL,
181 { 0 ,
"title", CLP::ARG_REQ, CLP::DUPOPT_CLOB,
NULL,
184 {
'I',
"include", CLP::ARG_REQ, CLP::DUPOPT_CAT,
CLP_SEPARATOR,
186 {
'S',
"structure", CLP::ARG_REQ, CLP::DUPOPT_CAT,
CLP_SEPARATOR,
188 {
'R',
"replace-path", CLP::ARG_REQ, CLP::DUPOPT_CAT,
CLP_SEPARATOR,
191 {
'N',
"normalize", CLP::ARG_REQ, CLP::DUPOPT_CLOB,
NULL,
195 {
'M',
"metric", CLP::ARG_REQ, CLP::DUPOPT_CAT,
CLP_SEPARATOR,
197 { 0 ,
"force-metric", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
201 {
'o',
"output", CLP::ARG_REQ , CLP::DUPOPT_CLOB,
NULL,
203 { 0 ,
"db", CLP::ARG_REQ , CLP::DUPOPT_CLOB,
NULL,
205 { 0 ,
"metric-db", CLP::ARG_REQ, CLP::DUPOPT_CLOB,
NULL,
207 { 0 ,
"struct-id", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
211 {
'v',
"verbose", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
212 CLP::isOptArg_long },
213 {
'V',
"version", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
215 {
'h',
"help", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
217 { 0,
"remove-redundancy", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
219 { 0 ,
"debug", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
220 CLP::isOptArg_long },
268 os <<
getCmd() <<
": " << msg << endl
269 <<
"Try '" <<
getCmd() <<
" --help' for more information." << endl;
325 if (!
agent.empty()) {
ARG_ERROR(
"Only one agent is supported!"); }
326 agent =
"agent-cilk";
329 if (!
agent.empty()) {
ARG_ERROR(
"Only one agent is supported!"); }
333 if (!
agent.empty()) {
ARG_ERROR(
"Only one agent is supported!"); }
334 agent =
"agent-pthread";
347 std::vector<std::string> searchPaths;
350 for (
uint i = 0; i < searchPaths.size(); ++i) {
367 std::vector<std::string> replacePaths;
370 for (
uint i = 0; i < replacePaths.size(); ++i) {
371 int occurancesOfEquals =
374 if (occurancesOfEquals > 1) {
375 ARG_ERROR(
"Too many occurances of \'=\'; make sure to escape any \'=\' in your paths");
377 else if(occurancesOfEquals == 0) {
378 ARG_ERROR(
"The \'=\' between the old path and new path is missing");
389 std::vector<std::string> metricVec;
392 for (
uint i = 0; i < metricVec.size(); ++i) {
399 bool isDbDirSet =
false;
418 if ( !(numArgs >= 1) ) {
419 ARG_ERROR(
"Incorrect number of arguments!");
423 for (
uint i = 0; i < numArgs; ++i) {
449 os <<
"ArgsHPCProf.cmd= " <<
getCmd() << endl;
459 if (value ==
"all") {
462 else if (value ==
"none") {
466 ARG_ERROR(errTag <<
": Unexpected value received: '" << value <<
"'");
475 if (value ==
"thread") {
480 else if (value ==
"sum") {
486 else if (value ==
"stats") {
493 ARG_ERROR(errTag <<
": Unexpected value received: '" << value <<
"'");
501 static const string hpctk =
"hpctoolkit-";
502 static const string meas =
"-measurements";
509 const string& fnm = profileArg;
510 size_t pos_hpctk = -1;
511 size_t pos_meas = string::npos;
518 pos1 = fnm.find(hpctk, pos_hpctk + 1);
519 if (pos1 == string::npos)
522 pos2 = fnm.find(meas, pos1 + hpctk.length() - 1);
523 if (pos2 == string::npos)
531 if (fnm.find_first_of(
"/", pos_hpctk + hpctk.length()) > pos_meas) {
535 size_t pfx_a = fnm.find_last_of(
'/', pos_hpctk);
536 size_t pfx_beg = (pfx_a == string::npos) ? 0 : pfx_a + 1;
537 size_t pfx_end = pos_hpctk;
538 string pfx = fnm.substr(pfx_beg, pfx_end - pfx_beg);
543 size_t nm_beg = pos_hpctk + hpctk.length();
544 size_t nm_end = (nm_beg > pos_meas) ? nm_beg : pos_meas;
545 string nm = fnm.substr(nm_beg, nm_end - nm_beg);
551 size_t sfx_beg = pos_meas + meas.length();
552 size_t sfx_end = fnm.find_first_of(
'/', sfx_beg);
553 if (sfx_end == string::npos) {
554 sfx_end = fnm.size();
556 if (sfx_beg < sfx_end) {
557 sfx = fnm.substr(sfx_beg, sfx_end - sfx_beg);
bool isOpt(const char swShort) const
#define Analysis_DB_DIR_nm
PathTupleVec searchPathTpls
const std::string & getOptArg(const char swShort) const
#define ARG_ERROR(streamArgs)
int parseReplacePath(const std::string &arg)
virtual void dump(std::ostream &os=std::cerr) const
bool parseArg_norm(const std::string &value, const char *errTag)
virtual const std::string & what() const
void printError(std::ostream &os, const char *msg) const
static const char * usage_summary
std::vector< std::string > structureFiles
bool isOptArg(const char swShort) const
static void MetricFlg_clear(uint &flags, MetricFlg x)
void parse(const OptArgDesc *optArgDescs, int argc, const char *const argv[])
static const char * version_info
unsigned int getNumArgs() const
void tokenize_str(const std::string &tokenstr, const char *delim, std::vector< std::string > &tokenvec)
virtual void dump(std::ostream &os=std::cerr) const
virtual std::string message() const
void parseArg_metric(const std::string &value, const char *errTag)
virtual void parse(int argc, const char *const argv[])
void printUsage(std::ostream &os) const
#define Analysis_OUT_DB_EXPERIMENT
const std::string DefaultPathTupleTarget
#define CmdLineParser_OptArgDesc_NULL_MACRO
std::vector< std::string > profileFiles
void Diagnostics_SetDiagnosticFilterLevel(int lvl)
const std::string & getArg(unsigned int i) const
static std::string makeDBDirName(const std::string &profileArg)
static const char * usage_details
static bool parseArg_bool(const std::string &value, const char *errTag)
static CmdLineParser::OptArgDesc optArgs[]
#define Analysis_DB_DIR_pfx
std::pair< std::string, std::string > PathTuple
static void MetricFlg_set(uint &flags, MetricFlg x)
virtual const std::string getCmd() const =0
static long toLong(const std::string &str)
void printVersion(std::ostream &os) const