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