SST  12.0.1
StructuralSimulationToolkit
config.h
1 // Copyright 2009-2022 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-2022, 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/simulation.h"
16 
17 #include <string>
18 
19 /* Forward declare for Friendship */
20 extern int main(int argc, char** argv);
21 
22 namespace SST {
23 
24 class ConfigHelper;
25 class SSTModelDescription;
26 /**
27  * Class to contain SST Simulation Configuration variables
28  */
30 {
31 private:
32  // Main creates the config object
33  friend int ::main(int argc, char** argv);
34  friend class ConfigHelper;
35  friend class SSTModelDescription;
36 
37  /**
38  Config constructor. Meant to only be created by main function
39  */
40  Config(RankInfo rank_info);
41 
42  /**
43  Default constructor used for serialization
44  */
45  Config() {}
46 
47  //// Functions for use in main
48 
49  /**
50  Parse command-line arguments to update configuration values.
51 
52  @return Returns 0 if execution should continue. Returns -1
53  if there was an error. Returns 1 if run command line only
54  asked for information to be print (e.g. --help or -V).
55  */
56  int parseCmdLine(int argc, char* argv[]);
57 
58  /**
59  Checks for the existance of the config file. This needs to be
60  called after adding any rank numbers to the file in the case of
61  parallel loading.
62  */
63  bool checkConfigFile();
64 
65  /**
66  Get the final library path for loading element libraries
67  */
68  std::string getLibPath(void) const;
69 
70  // Functions to be called from ModelDescriptions
71 
72  /** Set a configuration string to update configuration values */
73  bool setOptionFromModel(const std::string& entryName, const std::string& value);
74 
75 
76 public:
77  /** Create a new Config object.
78  * @param world_size - number of parallel ranks in the simulation
79  */
80  ~Config() {}
81 
82  // Functions to access config options. Declared in order they show
83  // up in the options array
84 
85  // Information options
86  // No variable associated with help
87  // No variable associated with version
88 
89  // Basic options
90 
91  /**
92  Level of verbosity to use in the core prints using
93  Output.verbose or Output.debug.
94  */
95  uint32_t verbose() const { return verbose_; }
96 
97 
98  /**
99  Number of threads requested
100  */
101  uint32_t num_threads() const { return world_size_.thread; }
102 
103  /**
104  Number of ranks in the simulation
105  */
106  uint32_t num_ranks() const { return world_size_.rank; }
107 
108  /**
109  Name of the SDL file to use to genearte the simulation
110  */
111  const std::string& configFile() const { return configFile_; }
112 
113  /**
114  Model options to pass to the SDL file
115  */
116  const std::string& model_options() const { return model_options_; }
117 
118  /**
119  Print SST timing information after the run
120  */
121  bool print_timing() const { return print_timing_; }
122 
123  /**
124  Simulated cycle to stop the simulation at
125  */
126  const std::string& stop_at() const { return stop_at_; }
127 
128  /**
129  Wall clock time (approximiate) in seconds to stop the simulation at
130  */
131  uint32_t exit_after() const { return exit_after_; }
132 
133  /**
134  Partitioner to use for parallel simualations
135  */
136  const std::string& partitioner() const { return partitioner_; }
137 
138  /**
139  Simulation period at which to print out a "heartbeat" message
140  */
141  const std::string& heartbeatPeriod() const { return heartbeatPeriod_; }
142 
143  /**
144  The directory to be used for writting output files
145  */
146  const std::string& output_directory() const { return output_directory_; }
147 
148  /**
149  Prefix to use for the default SST::Output object in core
150  */
151  const std::string output_core_prefix() const { return output_core_prefix_; }
152 
153  // Configuration output
154 
155  /**
156  File to output python formatted config graph to (empty string means no
157  output)
158  */
159  const std::string& output_config_graph() const { return output_config_graph_; }
160 
161  /**
162  File to output json formatted config graph to (empty string means no
163  output)
164  */
165  const std::string& output_json() const { return output_json_; }
166 
167  /**
168  If true, and a config graph output option is specified, write
169  each ranks graph separately
170  */
171  bool parallel_output() const { return parallel_output_; }
172 
173 
174  // Graph output
175 
176  /**
177  File to output dot formatted config graph to (empty string means no
178  output). Note, this is not a format that can be used as input for simulation
179 
180  */
181  const std::string& output_dot() const { return output_dot_; }
182 
183  /**
184  Level of verbosity to use for the dot output.
185  */
186  uint32_t dot_verbosity() const { return dot_verbosity_; }
187 
188  /**
189  File to output component partition info to (empty string means no output)
190  */
191  const std::string& component_partition_file() const { return component_partition_file_; }
192 
193  /**
194  Controls whether partition info is output as part of configuration output
195  */
196  bool output_partition() const { return output_partition_; }
197 
198  // Advanced options
199 
200  /**
201  Core timebase to use as the atomic time unit for the
202  simulation. It is usually best to just leave this at the
203  default (1ps)
204  */
205  const std::string& timeBase() const { return timeBase_; }
206 
207  /**
208  Controls whether graph constuction will be done in parallel.
209  If it is, then the SDL file name is modified to add the rank
210  number to the file name right before the file extension, if
211  parallel_load_mode_multi is true.
212  */
213  bool parallel_load() const { return parallel_load_; }
214 
215  /**
216  If graph constuction will be done in parallel, will use a
217  file per rank if true, and the same file for each rank if
218  false.
219  */
220  bool parallel_load_mode_multi() const { return parallel_load_mode_multi_; }
221 
222  /**
223  TimeVortex implementation to use
224  */
225  const std::string& timeVortex() const { return timeVortex_; }
226 
227  /**
228  Use links that connect directly to ActivityQueue in receiving thread
229  */
230  bool interthread_links() const { return interthread_links_; }
231 
232  /**
233  File to which core debug information should be written
234  */
235  const std::string& debugFile() const { return debugFile_; }
236 
237  /**
238  Library path to use for finding element libraries (will replace
239  the libpath in the sstsimulator.conf file)
240  */
241  const std::string& libpath() const { return libpath_; }
242 
243  /**
244  Paths to add to library search (adds to libpath found in
245  sstsimulator.conf file)
246  */
247  const std::string& addLibPath() const { return addLibPath_; }
248 
249  // Advanced options - Debug
250 
251  /**
252  Run mode to use (Init, Both, Run-only). Note that Run-only is
253  not currently supported because there is not component level
254  checkpointing.
255  */
256  Simulation::Mode_t runMode() const { return runMode_; }
257 
258 
259 #ifdef USE_MEMPOOL
260  /**
261  File to output list of events that remain undeleted at the end
262  of the simulation.
263  */
264  const std::string& event_dump_file() const { return event_dump_file_; }
265 #endif
266 
267  /**
268  Run simulation initialization stages one rank at a time for
269  debug purposes
270  */
271  bool rank_seq_startup() const { return rank_seq_startup_; }
272 
273  // Advanced options - envrionment
274 
275  /**
276  Controls whether the environment variables that SST sees are
277  printed out
278  */
279  bool print_env() const { return print_env_; }
280 
281  /**
282  Controls whether signal handlers are enable or not. NOTE: the
283  sense of this variable is opposite of the command line option
284  (--disable-signal-handlers)
285  */
286  bool enable_sig_handling() const { return enable_sig_handling_; }
287 
288  // This option is used by the SST wrapper found in
289  // bootshare.{h,cc} and is never actually accessed once sst.x
290  // executes.
291  bool no_env_config() const { return no_env_config_; }
292 
293 
294  /** Print to stdout the current configuration */
295  void print();
296 
297  void serialize_order(SST::Core::Serialization::serializer& ser) override
298  {
299  ser& verbose_;
300  ser& world_size_;
301  ser& configFile_;
302  ser& model_options_;
303  ser& print_timing_;
304  ser& stop_at_;
305  ser& exit_after_;
306  ser& partitioner_;
307  ser& heartbeatPeriod_;
308  ser& output_directory_;
309  ser& output_core_prefix_;
310 
311  ser& output_config_graph_;
312  ser& output_json_;
313  ser& parallel_output_;
314 
315  ser& output_dot_;
316  ser& dot_verbosity_;
317  ser& component_partition_file_;
318  ser& output_partition_;
319 
320  ser& timeBase_;
321  ser& parallel_load_;
322  ser& parallel_load_mode_multi_;
323  ser& timeVortex_;
324  ser& interthread_links_;
325  ser& debugFile_;
326  ser& libpath_;
327  ser& addLibPath_;
328  ser& runMode_;
329 
330  ser& print_env_;
331  ser& enable_sig_handling_;
332  ser& no_env_config_;
333  }
334  ImplementSerializable(SST::Config)
335 
336 
337 private:
338  //// Items private to Config
339 
340  std::string run_name;
341 
342  bool isFileNameOnly(const std::string& name)
343  {
344  bool nameOnly = true;
345 
346  for ( size_t i = 0; i < name.size(); ++i ) {
347  if ( '/' == name[i] ) {
348  nameOnly = false;
349  break;
350  }
351  }
352 
353  return nameOnly;
354  }
355 
356  // Variables to hold the options. Declared in order they show up
357  // in the options array
358 
359  // Information options
360  // No variable associated with help
361  // No variable associated with version
362 
363  // Basic options
364  uint32_t verbose_; /*!< Verbosity */
365  // Num threads held in RankInfo.thread
366  RankInfo world_size_; /*!< Number of ranks, threads which should be invoked per rank */
367  std::string configFile_; /*!< Graph generation file */
368  std::string model_options_; /*!< Options to pass to Python Model generator */
369  bool print_timing_; /*!< Print SST timing information */
370  std::string stop_at_; /*!< When to stop the simulation */
371  uint32_t exit_after_; /*!< When (wall-time) to stop the simulation */
372  std::string partitioner_; /*!< Partitioner to use */
373  std::string heartbeatPeriod_; /*!< Sets the heartbeat period for the simulation */
374  std::string output_directory_; /*!< Output directory to dump all files to */
375  std::string output_core_prefix_; /*!< Set the SST::Output prefix for the core */
376 
377  // Configuration output
378  std::string output_config_graph_; /*!< File to dump configuration graph */
379  std::string output_json_; /*!< File to dump JSON output */
380  bool parallel_output_; /*!< Output simulation graph in parallel */
381 
382  // Graph output
383  std::string output_dot_; /*!< File to dump dot output */
384  uint32_t dot_verbosity_; /*!< Amount of detail to include in the dot graph output */
385  std::string component_partition_file_; /*!< File to dump component graph */
386  bool output_partition_; /*!< Output paritition info when writing config output */
387 
388  // Advanced options
389  std::string timeBase_; /*!< Timebase of simulation */
390  bool parallel_load_; /*!< Load simulation graph in parallel */
391  bool parallel_load_mode_multi_; /*!< If true, load using multiple files */
392  std::string timeVortex_; /*!< TimeVortex implementation to use */
393  bool interthread_links_; /*!< Use interthread links */
394  std::string debugFile_; /*!< File to which debug information should be written */
395  std::string libpath_;
396  std::string addLibPath_;
397 
398  // Advanced options - debug
399  Simulation::Mode_t runMode_; /*!< Run Mode (Init, Both, Run-only) */
400 #ifdef USE_MEMPOOL
401  std::string event_dump_file_; /*!< File to dump undeleted events to */
402 #endif
403  bool rank_seq_startup_; /*!< Run simulation initialization phases one rank at a time */
404 
405  // Advanced options - envrionment
406  bool print_env_; /*!< Print SST environment */
407  bool enable_sig_handling_; /*!< Enable signal handling */
408  bool no_env_config_; /*!< Bypass compile-time environmental configuration */
409 };
410 
411 } // namespace SST
412 
413 #endif // SST_CORE_CONFIG_H
bool interthread_links() const
Use links that connect directly to ActivityQueue in receiving thread.
Definition: config.h:230
const std::string & configFile() const
Name of the SDL file to use to genearte the simulation.
Definition: config.h:111
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:34
const std::string & output_directory() const
The directory to be used for writting output files.
Definition: config.h:146
const std::string & stop_at() const
Simulated cycle to stop the simulation at.
Definition: config.h:126
Class to contain SST Simulation Configuration variables.
Definition: config.h:29
const std::string & partitioner() const
Partitioner to use for parallel simualations.
Definition: config.h:136
bool parallel_output() const
If true, and a config graph output option is specified, write each ranks graph separately.
Definition: config.h:171
bool enable_sig_handling() const
Controls whether signal handlers are enable or not.
Definition: config.h:286
const std::string & heartbeatPeriod() const
Simulation period at which to print out a &quot;heartbeat&quot; message.
Definition: config.h:141
const std::string & output_json() const
File to output json formatted config graph to (empty string means no output)
Definition: config.h:165
Definition: serializable.h:118
const std::string & addLibPath() const
Paths to add to library search (adds to libpath found in sstsimulator.conf file)
Definition: config.h:247
const std::string & output_dot() const
File to output dot formatted config graph to (empty string means no output).
Definition: config.h:181
const std::string & libpath() const
Library path to use for finding element libraries (will replace the libpath in the sstsimulator...
Definition: config.h:241
const std::string & timeVortex() const
TimeVortex implementation to use.
Definition: config.h:225
Definition: config.cc:52
Definition: rankInfo.h:21
~Config()
Create a new Config object.
Definition: config.h:80
uint32_t verbose() const
Level of verbosity to use in the core prints using Output.verbose or Output.debug.
Definition: config.h:95
void print()
Print to stdout the current configuration.
Definition: config.cc:527
const std::string & debugFile() const
File to which core debug information should be written.
Definition: config.h:235
const std::string & component_partition_file() const
File to output component partition info to (empty string means no output)
Definition: config.h:191
Simulation::Mode_t runMode() const
Run mode to use (Init, Both, Run-only).
Definition: config.h:256
bool print_env() const
Controls whether the environment variables that SST sees are printed out.
Definition: config.h:279
bool output_partition() const
Controls whether partition info is output as part of configuration output.
Definition: config.h:196
bool print_timing() const
Print SST timing information after the run.
Definition: config.h:121
uint32_t exit_after() const
Wall clock time (approximiate) in seconds to stop the simulation at.
Definition: config.h:131
const std::string output_core_prefix() const
Prefix to use for the default SST::Output object in core.
Definition: config.h:151
Base class for Model Generation.
Definition: sstmodel.h:25
const std::string & model_options() const
Model options to pass to the SDL file.
Definition: config.h:116
uint32_t num_ranks() const
Number of ranks in the simulation.
Definition: config.h:106
uint32_t num_threads() const
Number of threads requested.
Definition: config.h:101
uint32_t dot_verbosity() const
Level of verbosity to use for the dot output.
Definition: config.h:186
bool parallel_load_mode_multi() const
If graph constuction will be done in parallel, will use a file per rank if true, and the same file fo...
Definition: config.h:220
Mode_t
Type of Run Modes.
Definition: simulation.h:38
const std::string & timeBase() const
Core timebase to use as the atomic time unit for the simulation.
Definition: config.h:205
bool rank_seq_startup() const
Run simulation initialization stages one rank at a time for debug purposes.
Definition: config.h:271
const std::string & output_config_graph() const
File to output python formatted config graph to (empty string means no output)
Definition: config.h:159
bool parallel_load() const
Controls whether graph constuction will be done in parallel.
Definition: config.h:213