72 #include <sys/types.h> 76 #include <include/hpctoolkit-config.h> 89 #define ARG_ERROR(streamArgs) \ 90 { std::ostringstream WeIrDnAmE; \ 91 WeIrDnAmE << streamArgs ; \ 92 printError(std::cerr, WeIrDnAmE.str()); \ 102 "[output-options] [correlation-options] <profile-file>...";
105 "[output-options] --config <config-file>\n";
108 hpcprof-flat correlates flat profiling metrics with static source code\n\ 109 structure and (by default) generates an Experiment database for use with\n\ 110 hpcviewer. hpcprof-flat is invoked in one of two ways. In the former,\n\ 111 correlation options are specified on the command line along with a list of\n\ 112 flat profile files. In the latter, these options along with derived metrics\n\ 113 are specified in the configuration file <config-file>. Note that the first\n\ 114 mode is generally sufficient since derived metrics may be computed in\n\ 115 hpcviewer. However, to facilitate the batch processing of the second mode,\n\ 116 when run in the first mode, a sample configuration file (config.xml) is\n\ 117 generated within the Experiment database.\n\ 119 For optimal results, structure information from hpcstruct should be provided.\n\ 120 Without structure information, hpcprof-flat will default to correlation using\n\ 121 line map information.\n\ 125 -v [<n>], --verbose [<n>]\n\ 126 Verbose: generate progress messages to stderr at\n\ 127 verbosity level <n>. {1} (Use n=3 to debug path\n\ 128 replacement if metric and program structure is not\n\ 129 properly matched.)\n\ 130 -V, --version Print version information.\n\ 131 -h, --help Print help.\n\ 132 --debug [<n>] Debug: use debug level <n>. {1}\n\ 134 Options: Source Structure Correlation:\n\ 135 --name <name>, --title <name>\n\ 136 Set the database's name (title) to <name>.\n\ 137 -I <path>, --include <path>\n\ 138 Use <path> when searching for source files. For a\n\ 139 recursive search, append a '*' after the last slash,\n\ 140 e.g., '/mypath/*' (quote or escape to protect from\n\ 141 the shell.) May pass multiple times.\n\ 142 -S <file>, --structure <file>\n\ 143 Use hpcstruct structure file <file> for correlation.\n\ 144 May pass multiple times (e.g., for shared libraries).\n\ 145 -R '<old-path>=<new-path>', --replace-path '<old-path>=<new-path>'\n\ 146 Substitute instances of <old-path> with <new-path>;\n\ 147 apply to all paths (profile's load map, source code)\n\ 148 for which <old-path> is a prefix. Use '\\' to escape\n\ 149 instances of '=' within a path. May pass multiple\n\ 153 -o <db-path>, --db <db-path>, --output <db-path>\n\ 154 Specify Experiment database name <db-path>.\n\ 156 --src [yes|no], --source [yes|no]\n\ 157 Whether to copy source code files into Experiment\n\ 158 database. {yes} By default, hpcprof-flat copies source\n\ 159 files with performance metrics and that can be\n\ 160 reached by PATH/REPLACE statements, resulting in a\n\ 161 self-contained dataset that does not rely on an\n\ 162 external source code repository. Note that if\n\ 163 copying is suppressed, the database is no longer\n\ 166 Output formats: Select different output formats and optionally specify the\n\ 167 output filename <file> (located within the Experiment database). The output\n\ 168 is sparse in the sense that it ignores program areas without profiling\n\ 169 information. (Set <file> to '-' to write to stdout.)\n\ 170 -x [<file>], --experiment [<file>]\n\ 172 NOTE: To disable, set <file> to 'no'.\n";
180 #define CLP CmdLineParser 181 #define CLP_SEPARATOR "!!!" 186 { 0 ,
"config", CLP::ARG_REQ, CLP::DUPOPT_CLOB,
NULL,
192 { 0 ,
"title", CLP::ARG_REQ, CLP::DUPOPT_CLOB,
CLP_SEPARATOR,
195 {
'I',
"include", CLP::ARG_REQ, CLP::DUPOPT_CAT,
CLP_SEPARATOR,
197 {
'S',
"structure", CLP::ARG_REQ, CLP::DUPOPT_CAT,
CLP_SEPARATOR,
199 {
'R',
"replace-path", CLP::ARG_REQ, CLP::DUPOPT_CAT,
CLP_SEPARATOR,
203 {
'o',
"output", CLP::ARG_REQ , CLP::DUPOPT_CLOB,
NULL,
205 { 0 ,
"db", CLP::ARG_REQ , CLP::DUPOPT_CLOB,
NULL,
208 { 0 ,
"src", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
210 { 0 ,
"source", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
214 {
'x',
"experiment", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
216 { 0 ,
"csv", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
220 {
'v',
"verbose", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
221 CLP::isOptArg_long },
222 {
'V',
"version", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
224 {
'h',
"help", CLP::ARG_NONE, CLP::DUPOPT_CLOB,
NULL,
226 { 0 ,
"debug", CLP::ARG_OPT, CLP::DUPOPT_CLOB,
NULL,
227 CLP::isOptArg_long },
244 Args::Args(
int argc,
const char*
const argv[])
289 os <<
getCmd() <<
": " << msg << endl
290 <<
"Try '" <<
getCmd() <<
" --help' for more information." << endl;
304 static string cmd =
"hpcprof-flat";
369 std::vector<std::string> searchPaths;
372 for (
uint i = 0; i < searchPaths.size(); ++i) {
385 std::vector<std::string> replacePaths;
388 for (
uint i = 0; i < replacePaths.size(); ++i) {
389 int occurancesOfEquals =
392 if (occurancesOfEquals > 1) {
393 ARG_ERROR(
"Too many occurances of \'=\'; make sure to escape any \'=\' in your paths");
395 else if(occurancesOfEquals == 0) {
396 ARG_ERROR(
"The \'=\' between the old path and new path is missing");
438 ARG_ERROR(
"Incorrect number of arguments!");
442 if ( !(numArgs >= 1) ) {
443 ARG_ERROR(
"Incorrect number of arguments!");
447 for (
uint i = 0; i < numArgs; ++i) {
466 os <<
"Args.cmd= " <<
getCmd() << endl;
467 os <<
"Args.hpcHome= " <<
hpcHome << endl;
468 os <<
"::trace " <<
::trace << endl;
480 cerr <<
"Error: Please set your " <<
HPCTOOLKIT <<
" environment variable." 486 int len = strlen(home);
487 if (home[len-1] ==
'/') home[--len] = 0;
489 DIR *fp = opendir(home);
491 cerr <<
"Error: " << home <<
" is not a directory" << endl;
bool isOpt(const char swShort) const
PathTupleVec searchPathTpls
void printUsage(std::ostream &os) const
const std::string & getOptArg(const char swShort) const
int parseReplacePath(const std::string &arg)
virtual const std::string & what() const
std::vector< std::string > structureFiles
bool isOptArg(const char swShort) const
bool profflat_computeFinalMetricValues
void parse(const OptArgDesc *optArgDescs, int argc, const char *const argv[])
bool configurationFileMode
unsigned int getNumArgs() const
void printVersion(std::ostream &os) const
#define Analysis_OUT_DB_CSV
void parse(int argc, const char *const argv[])
void tokenize_str(const std::string &tokenstr, const char *delim, std::vector< std::string > &tokenvec)
std::string out_db_experiment
virtual void dump(std::ostream &os=std::cerr) const
virtual std::string message() const
std::string configurationFile
std::string out_db_config
#define Analysis_OUT_DB_EXPERIMENT
const std::string DefaultPathTupleTarget
#define CmdLineParser_OptArgDesc_NULL_MACRO
std::vector< std::string > profileFiles
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
static const std::string HPCTOOLKIT
const std::string & getCmd() const
void dump(std::ostream &os=std::cerr) const
std::pair< std::string, std::string > PathTuple
static long toLong(const std::string &str)