HPCToolkit
Args.hpp
Go to the documentation of this file.
1 // -*-Mode: C++;-*-
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 //***************************************************************************
48 //
49 // File:
50 // $HeadURL$
51 //
52 // Purpose:
53 // [The purpose of this file]
54 //
55 // Description:
56 // [The set of functions, macros, etc. defined in the file]
57 //
58 //***************************************************************************
59 
60 #ifndef Analysis_Args_hpp
61 #define Analysis_Args_hpp
62 
63 //************************* System Include Files ****************************
64 
65 #include <iostream>
66 #include <string>
67 #include <vector>
68 
69 //*************************** User Include Files ****************************
70 
71 #include <include/uint.h>
72 
73 //*************************** Forward Declarations **************************
74 
75 //***************************************************************************
76 
77 namespace Analysis {
78 
79 // PathTuple: a {path, viewname} pair.
80 // PathTuple.first = path; PathTuple.second = path target or viewname
81 // PathTupleVec: the vector of all 'PathTuple'
82 typedef std::pair<std::string, std::string> PathTuple;
83 typedef std::vector<PathTuple> PathTupleVec;
84 
85 const std::string DefaultPathTupleTarget = "src";
86 
87 } // namespace Analysis
88 
89 //***************************************************************************
90 
91 namespace Analysis {
92 
93 //---------------------------------------------------------------------------
94 // Arguments for source code correlation
95 //---------------------------------------------------------------------------
96 
97 class Args {
98 public:
99  Args();
100  virtual ~Args();
101 
102  // Dump
103  virtual std::string toString() const;
104 
105  virtual void dump(std::ostream& os = std::cerr) const;
106  void ddump() const;
107 
108 public:
109 
110  // -------------------------------------------------------
111  // Agent options
112  // -------------------------------------------------------
113 
114  std::string agent;
115 
116  // -------------------------------------------------------
117  // Attribution/Correlation arguments: general
118  // -------------------------------------------------------
119 
120  // Title
121  std::string title;
122 
123  // Search paths
124  //std::vector<std::string> searchPaths;
126 
127  // Structure files
128  std::vector<std::string> structureFiles;
129 
130  // Group files
131  std::vector<std::string> groupFiles;
132 
133  // Replace paths
134  std::vector<std::string> replaceInPath;
135  std::vector<std::string> replaceOutPath;
136 
137  // Profile files
138  std::vector<std::string> profileFiles;
139 
141 
142  // -------------------------------------------------------
143  // Attribution/Correlation arguments: special
144  // -------------------------------------------------------
145 
146  enum MetricFlg {
148  MetricFlg_Thread = (1 << 1),
149  MetricFlg_StatsSum = (1 << 2),
151  };
152 
153  static inline bool
155  { return (flags & x); }
156 
157  static inline void
159  { flags |= x; }
160 
161  static inline void
163  { flags &= ~x; }
164 
165  static inline bool
167  { return MetricFlg_isSet(flags, MetricFlg_Thread); }
168 
169  static inline bool
171  {
172  return (MetricFlg_isSet(flags, MetricFlg_StatsSum)
174  }
175 
177 
178  // TODO: Currently this is always true even though we only need to
179  // compute final metric values for (1) hpcproftt (flat) and (2)
180  // hpcprof-flat when it computes derived metrics. However, at the
181  // moment this is a sinking ship and not worth the time investment.
183 
184  // -------------------------------------------------------
185  // Output arguments: experiment database output
186  // -------------------------------------------------------
187 
188 #define Analysis_OUT_DB_EXPERIMENT "experiment.xml"
189 #define Analysis_OUT_DB_CSV "experiment.csv"
190 
191 #define Analysis_DB_DIR_pfx "hpctoolkit"
192 #define Analysis_DB_DIR_nm "database"
193 #define Analysis_DB_DIR "hpctoolkit-<app>-database"
194 
195 
196  std::string out_db_experiment; // disable: "", stdout: "-"
197  std::string out_db_csv; // disable: "", stdout: "-"
198 
199  std::string db_dir; // disable: ""
201 
202  std::string out_db_config; // disable: "", stdout: "-"
203 
206 
207  // -------------------------------------------------------
208  // Output arguments: textual output
209  // -------------------------------------------------------
210 
211 #define Analysis_OUT_TXT ""
212 
213  std::string out_txt; // disable: "", stdout: "-"
214 
215  enum TxtSum {
217 
218  // individual flags
219  TxtSum_fPgm = 0x00000001,
220  TxtSum_fLM = 0x00000010,
221  TxtSum_fFile = 0x00000100,
222  TxtSum_fProc = 0x00001000,
223  TxtSum_fLoop = 0x00010000,
224  TxtSum_fStmt = 0x00100000,
225 
226  // composite flags
229  };
230 
231  int/*TxtSum*/ txt_summary;
232 
234  std::vector<std::string> txt_srcFileGlobs;
235 
236  // flag to remove procedure name redundancy
237  // this feature is not fully reliable to remove procedure
238  // name redundancy, especially if compiled with g++ -O2
239  // since the compiler doesn't generate function parameters
240  // and cannot distinguish between foo(int) and foo(int, int)
242 
243 public:
244  // -------------------------------------------------------
245  //
246  // -------------------------------------------------------
247 
248  void
250 
251  // makes a unique database dir
252  void
253  makeDatabaseDir();
254 
255  std::string
256  searchPathStr() const;
257 
258 
259 private:
260  void Ctor();
261 };
262 
263 } // namespace Analysis
264 
265 //***************************************************************************
266 
267 #endif // Analysis_Args_hpp
void makeDatabaseDir()
Definition: Args.cpp:203
std::vector< std::string > groupFiles
Definition: Args.hpp:131
PathTupleVec searchPathTpls
Definition: Args.hpp:125
std::string db_dir
Definition: Args.hpp:199
uint prof_metrics
Definition: Args.hpp:176
bool remove_redundancy
Definition: Args.hpp:241
void Ctor()
Definition: Args.cpp:96
bool txt_srcAnnotation
Definition: Args.hpp:233
std::vector< std::string > structureFiles
Definition: Args.hpp:128
static bool MetricFlg_isSum(uint flags)
Definition: Args.hpp:170
static void MetricFlg_clear(uint &flags, MetricFlg x)
Definition: Args.hpp:162
bool profflat_computeFinalMetricValues
Definition: Args.hpp:182
virtual std::string toString() const
Definition: Args.cpp:135
bool db_addStructId
Definition: Args.hpp:205
static bool MetricFlg_isSet(uint flags, MetricFlg x)
Definition: Args.hpp:154
std::string out_db_experiment
Definition: Args.hpp:196
virtual void dump(std::ostream &os=std::cerr) const
Definition: Args.cpp:144
unsigned int uint
Definition: uint.h:124
std::vector< std::string > replaceInPath
Definition: Args.hpp:134
bool db_makeMetricDB
Definition: Args.hpp:204
std::string out_txt
Definition: Args.hpp:213
void ddump() const
Definition: Args.cpp:154
std::string searchPathStr() const
Definition: Args.cpp:214
std::string out_db_config
Definition: Args.hpp:202
const std::string DefaultPathTupleTarget
Definition: Args.hpp:85
std::vector< PathTuple > PathTupleVec
Definition: Args.hpp:83
std::vector< std::string > profileFiles
Definition: Args.hpp:138
std::string agent
Definition: Args.hpp:114
static bool MetricFlg_isThread(uint flags)
Definition: Args.hpp:166
std::string title
Definition: Args.hpp:121
std::vector< std::string > replaceOutPath
Definition: Args.hpp:135
void normalizeSearchPaths()
Definition: Args.cpp:169
bool db_copySrcFiles
Definition: Args.hpp:200
int txt_summary
Definition: Args.hpp:231
virtual ~Args()
Definition: Args.cpp:129
bool doNormalizeTy
Definition: Args.hpp:140
std::pair< std::string, std::string > PathTuple
Definition: Args.hpp:82
static void MetricFlg_set(uint &flags, MetricFlg x)
Definition: Args.hpp:158
std::vector< std::string > txt_srcFileGlobs
Definition: Args.hpp:234
std::string out_db_csv
Definition: Args.hpp:197