SST  11.1.0
StructuralSimulationToolkit
config.h
1 // Copyright 2009-2021 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2021, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_CONFIG_H
13 #define SST_CORE_CONFIG_H
14 
15 #include "sst/core/env/envconfig.h"
16 #include "sst/core/env/envquery.h"
17 #include "sst/core/rankInfo.h"
18 #include "sst/core/serialization/serializable.h"
19 #include "sst/core/simulation.h"
20 #include "sst/core/sst_types.h"
21 
22 #include <string>
23 
24 namespace SST {
25 
26 /**
27  * Class to contain SST Simulation Configuration variables
28  */
30 {
31 public:
32  /** Create a new Config object.
33  * @param my_rank - parallel rank of this instance
34  * @param world_size - number of parallel ranks in the simulation
35  */
37  Config() {} // For serialization
38  ~Config();
39 
40  /**
41  Parse command-line arguments to update configuration values.
42 
43  @return Returns 0 if execution should continue. Returns -1
44  if there was an error. Returns 1 if run command line only
45  asked for information to be print (e.g. --help or -V).
46  */
47  int parseCmdLine(int argc, char* argv[]);
48  /** Set a configuration string to update configuration values */
49  bool setConfigEntryFromModel(const std::string& entryName, const std::string& value);
50  /** Return the current Verbosity level */
51  uint32_t getVerboseLevel();
52 
53  /** Print the SST core timing information */
54  bool printTimingInfo();
55 
56  /** Print the current configuration to stdout */
57  void Print();
58 
59  std::string debugFile; /*!< File to which debug information should be written */
60  Simulation::Mode_t runMode; /*!< Run Mode (Init, Both, Run-only) */
61  std::string configFile; /*!< Graph generation file */
62  std::string stopAtCycle; /*!< When to stop the simulation */
63  uint32_t stopAfterSec; /*!< When (wall-time) to stop the simulation */
64  std::string heartbeatPeriod; /*!< Sets the heartbeat period for the simulation */
65  std::string timeBase; /*!< Timebase of simulation */
66  std::string partitioner; /*!< Partitioner to use */
67  std::string timeVortex; /*!< TimeVortex implementation to use */
68  bool inter_thread_links; /*!< Use interthread links */
69  std::string output_config_graph; /*!< File to dump configuration graph */
70  std::string output_dot; /*!< File to dump dot output */
71  uint32_t dot_verbosity; /*!< Amount of detail to include in the dot graph output */
72  std::string output_xml; /*!< File to dump XML output */
73  std::string output_json; /*!< File to dump JSON output */
74  std::string output_directory; /*!< Output directory to dump all files to */
75  std::string model_options; /*!< Options to pass to Python Model generator */
76  std::string dump_component_graph_file; /*!< File to dump component graph */
77  std::string output_core_prefix; /*!< Set the SST::Output prefix for the core */
78 
79  RankInfo world_size; /*!< Number of ranks, threads which should be invoked per rank */
80  uint32_t verbose; /*!< Verbosity */
81  bool no_env_config; /*!< Bypass compile-time environmental configuration */
82  bool enable_sig_handling; /*!< Enable signal handling */
83  bool print_timing; /*!< Print SST timing information */
84  bool print_env; /*!< Print SST environment */
85 
86 #ifdef USE_MEMPOOL
87  std::string event_dump_file; /*!< File to dump undeleted events to */
88 #endif
89 
90  typedef bool (Config::*flagFunction)(void);
91  typedef bool (Config::*argFunction)(const std::string& arg);
92 
93  bool usage();
94  bool printVersion();
95  bool incrVerbose()
96  {
97  verbose++;
98  return true;
99  }
100  bool setVerbosity(const std::string& arg);
101  bool disableSigHandlers()
102  {
103  enable_sig_handling = false;
104  return true;
105  }
106  bool disableEnvConfig()
107  {
108  no_env_config = true;
109  return true;
110  }
111  bool enablePrintTiming()
112  {
113  print_timing = true;
114  return true;
115  }
116  bool enablePrintEnv()
117  {
118  print_env = true;
119  return true;
120  }
121 
122  bool setConfigFile(const std::string& arg);
123  bool setDebugFile(const std::string& arg);
124  bool setLibPath(const std::string& arg);
125  bool addLibPath(const std::string& arg);
126  bool setRunMode(const std::string& arg);
127  bool setStopAt(const std::string& arg);
128  bool setStopAfter(const std::string& arg);
129  bool setHeartbeat(const std::string& arg);
130  bool setTimebase(const std::string& arg);
131  bool setPartitioner(const std::string& arg);
132  bool setTimeVortex(const std::string& arg);
133  bool setInterThreadLinks(const std::string& arg);
134  bool setOutputDir(const std::string& arg);
135  bool setWriteConfig(const std::string& arg);
136  bool setWriteDot(const std::string& arg);
137  bool setDotVerbosity(const std::string& arg);
138  bool setWriteXML(const std::string& arg);
139  bool setWriteJSON(const std::string& arg);
140  bool setWritePartition(const std::string& arg);
141  bool setOutputPrefix(const std::string& arg);
142 #ifdef USE_MEMPOOL
143  bool setWriteUndeleted(const std::string& arg);
144 #endif
145  bool setModelOptions(const std::string& arg);
146  bool setNumThreads(const std::string& arg);
147 
148  Simulation::Mode_t getRunMode() { return runMode; }
149 
150  /** Print to stdout the current configuration */
151  void print()
152  {
153  std::cout << "debugFile = " << debugFile << std::endl;
154  std::cout << "runMode = " << runMode << std::endl;
155  std::cout << "libpath = " << getLibPath() << std::endl;
156  std::cout << "configFile = " << configFile << std::endl;
157  std::cout << "stopAtCycle = " << stopAtCycle << std::endl;
158  std::cout << "stopAfterSec = " << stopAfterSec << std::endl;
159  std::cout << "timeBase = " << timeBase << std::endl;
160  std::cout << "partitioner = " << partitioner << std::endl;
161  std::cout << "output_config_graph = " << output_config_graph << std::endl;
162  std::cout << "output_dot = " << output_dot << std::endl;
163  std::cout << "dot_verbosity = " << dot_verbosity << std::endl;
164  std::cout << "output_xml = " << output_xml << std::endl;
165  std::cout << "no_env_config = " << no_env_config << std::endl;
166  std::cout << "output_directory = " << output_directory << std::endl;
167  std::cout << "output_json = " << output_json << std::endl;
168  std::cout << "model_options = " << model_options << std::endl;
169  std::cout << "num_threads = " << world_size.thread << std::endl;
170  std::cout << "enable_sig_handling = " << enable_sig_handling << std::endl;
171  std::cout << "output_core_prefix = " << output_core_prefix << std::endl;
172  std::cout << "print_timing=" << print_timing << std::endl;
173  std::cout << "print_env" << print_env << std::endl;
174  }
175 
176  /** Return the library search path */
177  std::string getLibPath(void) const;
178 
179  uint32_t getNumRanks() { return world_size.rank; }
180  uint32_t getNumThreads() { return world_size.thread; }
181  uint32_t setNumThreads(uint32_t nthr)
182  {
183  uint32_t old = world_size.thread;
184  world_size.thread = nthr;
185  return old;
186  }
187 
188  void serialize_order(SST::Core::Serialization::serializer& ser) override
189  {
190  ser& debugFile;
191  ser& runMode;
192  ser& libpath;
193  ser& addlLibPath;
194  ser& configFile;
195  ser& stopAtCycle;
196  ser& stopAfterSec;
197  ser& timeBase;
198  ser& partitioner;
200  ser& output_config_graph;
201  ser& output_dot;
202  ser& dot_verbosity;
203  ser& output_xml;
204  ser& output_json;
205  ser& no_env_config;
206  ser& model_options;
207  ser& world_size;
208  ser& enable_sig_handling;
209  ser& output_core_prefix;
210  ser& print_timing;
211  }
212 
213 private:
214  std::string run_name;
215  std::string libpath;
216  std::string addlLibPath;
217 
218  int rank;
219  int numRanks;
220 
221  bool isFileNameOnly(const std::string& name)
222  {
223  bool nameOnly = true;
224 
225  for ( size_t i = 0; i < name.size(); ++i ) {
226  if ( '/' == name[i] ) {
227  nameOnly = false;
228  break;
229  }
230  }
231 
232  return nameOnly;
233  }
234 
235  ImplementSerializable(SST::Config)
236 };
237 
238 } // namespace SST
239 
240 #endif // SST_CORE_CONFIG_H
RankInfo world_size
Definition: config.h:79
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:34
uint32_t stopAfterSec
Definition: config.h:63
std::string partitioner
Definition: config.h:66
bool print_env
Definition: config.h:84
std::string timeVortex
Definition: config.h:67
Class to contain SST Simulation Configuration variables.
Definition: config.h:29
std::string heartbeatPeriod
Definition: config.h:64
bool inter_thread_links
Definition: config.h:68
std::string output_core_prefix
Definition: config.h:77
int parseCmdLine(int argc, char *argv[])
Parse command-line arguments to update configuration values.
Definition: config.cc:245
bool setConfigEntryFromModel(const std::string &entryName, const std::string &value)
Set a configuration string to update configuration values.
Definition: config.cc:346
Simulation::Mode_t runMode
Definition: config.h:60
uint32_t dot_verbosity
Definition: config.h:71
std::string output_config_graph
Definition: config.h:69
uint32_t getVerboseLevel()
Return the current Verbosity level.
Definition: config.cc:637
std::string output_dot
Definition: config.h:70
Definition: serializable.h:118
uint32_t verbose
Definition: config.h:80
std::string timeBase
Definition: config.h:65
bool no_env_config
Definition: config.h:81
std::string model_options
Definition: config.h:75
std::string output_xml
Definition: config.h:72
std::string output_directory
Definition: config.h:74
Definition: rankInfo.h:21
std::string output_json
Definition: config.h:73
void print()
Print to stdout the current configuration.
Definition: config.h:151
bool printTimingInfo()
Print the SST core timing information.
Definition: config.cc:631
std::string debugFile
Definition: config.h:59
std::string getLibPath(void) const
Return the library search path.
Definition: config.cc:643
std::string dump_component_graph_file
Definition: config.h:76
std::string configFile
Definition: config.h:61
std::string stopAtCycle
Definition: config.h:62
bool enable_sig_handling
Definition: config.h:82
Mode_t
Type of Run Modes.
Definition: simulation.h:39
void Print()
Print the current configuration to stdout.
bool print_timing
Definition: config.h:83