SST 12.1.0
Structural Simulation Toolkit
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 */
20extern int main(int argc, char** argv);
21
22namespace SST {
23
24class ConfigHelper;
25class SSTModelDescription;
26/**
27 * Class to contain SST Simulation Configuration variables
28 */
30{
31private:
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
76public:
77 /** Create a new Config object.
78 * @param world_size - number of parallel ranks in the simulation
79 */
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 */
221
222 /**
223 Retruns the string equivalent for parallel-load: NONE (if
224 parallel load is off), SINGLE or MULTI.
225 */
226 std::string parallel_load_str() const
227 {
228 if ( !parallel_load_ ) return "NONE";
229 if ( parallel_load_mode_multi_ ) return "MULTI";
230 return "SINGLE";
231 }
232
233 /**
234 TimeVortex implementation to use
235 */
236 const std::string& timeVortex() const { return timeVortex_; }
237
238 /**
239 Use links that connect directly to ActivityQueue in receiving thread
240 */
241 bool interthread_links() const { return interthread_links_; }
242
243 /**
244 File to which core debug information should be written
245 */
246 const std::string& debugFile() const { return debugFile_; }
247
248 /**
249 Library path to use for finding element libraries (will replace
250 the libpath in the sstsimulator.conf file)
251 */
252 const std::string& libpath() const { return libpath_; }
253
254 /**
255 Paths to add to library search (adds to libpath found in
256 sstsimulator.conf file)
257 */
258 const std::string& addLibPath() const { return addLibPath_; }
259
260 // Advanced options - Profiling
261
262 /**
263 Profiling points to turn on
264 */
265 const std::string& enabledProfiling() const { return enabled_profiling_; }
266
267 /**
268 Profiling points to turn on
269 */
270 const std::string& profilingOutput() const { return profiling_output_; }
271
272 // Advanced options - Debug
273
274 /**
275 Run mode to use (Init, Both, Run-only). Note that Run-only is
276 not currently supported because there is not component level
277 checkpointing.
278 */
280
281 /**
282 Get string version of runmode.
283 */
284 std::string runMode_str() const
285 {
286 switch ( runMode_ ) {
287 case Simulation::INIT:
288 return "INIT";
289 case Simulation::RUN:
290 return "RUN";
291 case Simulation::BOTH:
292 return "BOTH";
294 return "UNKNOWN";
295 }
296 return "UNKNOWN";
297 }
298
299
300#ifdef USE_MEMPOOL
301 /**
302 File to output list of events that remain undeleted at the end
303 of the simulation.
304 */
305 const std::string& event_dump_file() const { return event_dump_file_; }
306#endif
307
308 /**
309 Run simulation initialization stages one rank at a time for
310 debug purposes
311 */
312 bool rank_seq_startup() const { return rank_seq_startup_; }
313
314 // Advanced options - envrionment
315
316 /**
317 Controls whether the environment variables that SST sees are
318 printed out
319 */
320 bool print_env() const { return print_env_; }
321
322 /**
323 Controls whether signal handlers are enable or not. NOTE: the
324 sense of this variable is opposite of the command line option
325 (--disable-signal-handlers)
326 */
328
329 // This option is used by the SST wrapper found in
330 // bootshare.{h,cc} and is never actually accessed once sst.x
331 // executes.
332 bool no_env_config() const { return no_env_config_; }
333
334
335 /** Print to stdout the current configuration */
336 void print();
337
338 void serialize_order(SST::Core::Serialization::serializer& ser) override
339 {
340 ser& verbose_;
341 ser& world_size_;
342 ser& configFile_;
343 ser& model_options_;
344 ser& print_timing_;
345 ser& stop_at_;
346 ser& exit_after_;
347 ser& partitioner_;
348 ser& heartbeatPeriod_;
351
353 ser& output_json_;
354 ser& parallel_output_;
355
356 ser& output_dot_;
357 ser& dot_verbosity_;
360
361 ser& timeBase_;
362 ser& parallel_load_;
364 ser& timeVortex_;
366 ser& debugFile_;
367 ser& libpath_;
368 ser& addLibPath_;
371 ser& runMode_;
372
373 ser& print_env_;
375 ser& no_env_config_;
376 }
377 ImplementSerializable(SST::Config)
378
379
380private:
381 //// Items private to Config
382
383 std::string run_name;
384
385 bool isFileNameOnly(const std::string& name)
386 {
387 bool nameOnly = true;
388
389 for ( size_t i = 0; i < name.size(); ++i ) {
390 if ( '/' == name[i] ) {
391 nameOnly = false;
392 break;
393 }
394 }
395
396 return nameOnly;
397 }
398
399 // Variables to hold the options. Declared in order they show up
400 // in the options array
401
402 // Information options
403 // No variable associated with help
404 // No variable associated with version
405
406 // Basic options
407 uint32_t verbose_; /*!< Verbosity */
408 // Num threads held in RankInfo.thread
409 RankInfo world_size_; /*!< Number of ranks, threads which should be invoked per rank */
410 std::string configFile_; /*!< Graph generation file */
411 std::string model_options_; /*!< Options to pass to Python Model generator */
412 bool print_timing_; /*!< Print SST timing information */
413 std::string stop_at_; /*!< When to stop the simulation */
414 uint32_t exit_after_; /*!< When (wall-time) to stop the simulation */
415 std::string partitioner_; /*!< Partitioner to use */
416 std::string heartbeatPeriod_; /*!< Sets the heartbeat period for the simulation */
417 std::string output_directory_; /*!< Output directory to dump all files to */
418 std::string output_core_prefix_; /*!< Set the SST::Output prefix for the core */
419
420 // Configuration output
421 std::string output_config_graph_; /*!< File to dump configuration graph */
422 std::string output_json_; /*!< File to dump JSON output */
423 bool parallel_output_; /*!< Output simulation graph in parallel */
424
425 // Graph output
426 std::string output_dot_; /*!< File to dump dot output */
427 uint32_t dot_verbosity_; /*!< Amount of detail to include in the dot graph output */
428 std::string component_partition_file_; /*!< File to dump component graph */
429 bool output_partition_; /*!< Output paritition info when writing config output */
430
431 // Advanced options
432 std::string timeBase_; /*!< Timebase of simulation */
433 bool parallel_load_; /*!< Load simulation graph in parallel */
434 bool parallel_load_mode_multi_; /*!< If true, load using multiple files */
435 std::string timeVortex_; /*!< TimeVortex implementation to use */
436 bool interthread_links_; /*!< Use interthread links */
437 std::string debugFile_; /*!< File to which debug information should be written */
438 std::string libpath_;
439 std::string addLibPath_;
440
441 // Advanced options - profiling
442 std::string enabled_profiling_; /*!< Enabled default profiling points */
443 std::string profiling_output_; /*!< Location to write profiling data */
444
445 // Advanced options - debug
446 Simulation::Mode_t runMode_; /*!< Run Mode (Init, Both, Run-only) */
447#ifdef USE_MEMPOOL
448 std::string event_dump_file_; /*!< File to dump undeleted events to */
449#endif
450 bool rank_seq_startup_; /*!< Run simulation initialization phases one rank at a time */
451
452 // Advanced options - envrionment
453 bool print_env_; /*!< Print SST environment */
454 bool enable_sig_handling_; /*!< Enable signal handling */
455 bool no_env_config_; /*!< Bypass compile-time environmental configuration */
456};
457
458} // namespace SST
459
460#endif // SST_CORE_CONFIG_H
Definition: config.cc:53
Class to contain SST Simulation Configuration variables.
Definition: config.h:30
const std::string & output_json() const
File to output json formatted config graph to (empty string means no output)
Definition: config.h:165
const std::string & output_directory() const
The directory to be used for writting output files.
Definition: config.h:146
const std::string & timeVortex() const
TimeVortex implementation to use.
Definition: config.h:236
const std::string & heartbeatPeriod() const
Simulation period at which to print out a "heartbeat" message.
Definition: config.h:141
const std::string & configFile() const
Name of the SDL file to use to genearte the simulation.
Definition: config.h:111
std::string enabled_profiling_
Definition: config.h:442
uint32_t dot_verbosity() const
Level of verbosity to use for the dot output.
Definition: config.h:186
uint32_t verbose_
Definition: config.h:407
bool rank_seq_startup() const
Run simulation initialization stages one rank at a time for debug purposes.
Definition: config.h:312
bool print_timing() const
Print SST timing information after the run.
Definition: config.h:121
bool interthread_links() const
Use links that connect directly to ActivityQueue in receiving thread.
Definition: config.h:241
bool output_partition() const
Controls whether partition info is output as part of configuration output.
Definition: config.h:196
uint32_t exit_after() const
Wall clock time (approximiate) in seconds to stop the simulation at.
Definition: config.h:131
bool print_env_
Definition: config.h:453
std::string output_directory_
Definition: config.h:417
uint32_t exit_after_
Definition: config.h:414
std::string timeVortex_
Definition: config.h:435
Simulation::Mode_t runMode() const
Run mode to use (Init, Both, Run-only).
Definition: config.h:279
~Config()
Create a new Config object.
Definition: config.h:80
const std::string & component_partition_file() const
File to output component partition info to (empty string means no output)
Definition: config.h:191
uint32_t num_threads() const
Number of threads requested.
Definition: config.h:101
std::string output_dot_
Definition: config.h:426
bool rank_seq_startup_
Definition: config.h:450
bool print_env() const
Controls whether the environment variables that SST sees are printed out.
Definition: config.h:320
std::string heartbeatPeriod_
Definition: config.h:416
const std::string & timeBase() const
Core timebase to use as the atomic time unit for the simulation.
Definition: config.h:205
std::string output_json_
Definition: config.h:422
uint32_t dot_verbosity_
Definition: config.h:427
std::string model_options_
Definition: config.h:411
bool enable_sig_handling_
Definition: config.h:454
std::string configFile_
Definition: config.h:410
const std::string & enabledProfiling() const
Profiling points to turn on.
Definition: config.h:265
RankInfo world_size_
Definition: config.h:409
uint32_t verbose() const
Level of verbosity to use in the core prints using Output.verbose or Output.debug.
Definition: config.h:95
const std::string & partitioner() const
Partitioner to use for parallel simualations.
Definition: config.h:136
bool interthread_links_
Definition: config.h:436
bool enable_sig_handling() const
Controls whether signal handlers are enable or not.
Definition: config.h:327
uint32_t num_ranks() const
Number of ranks in the simulation.
Definition: config.h:106
std::string stop_at_
Definition: config.h:413
std::string partitioner_
Definition: config.h:415
const std::string & addLibPath() const
Paths to add to library search (adds to libpath found in sstsimulator.conf file)
Definition: config.h:258
std::string parallel_load_str() const
Retruns the string equivalent for parallel-load: NONE (if parallel load is off), SINGLE or MULTI.
Definition: config.h:226
std::string output_core_prefix_
Definition: config.h:418
bool output_partition_
Definition: config.h:429
bool parallel_output() const
If true, and a config graph output option is specified, write each ranks graph separately.
Definition: config.h:171
bool parallel_load_mode_multi_
Definition: config.h:434
std::string runMode_str() const
Get string version of runmode.
Definition: config.h:284
const std::string & profilingOutput() const
Profiling points to turn on.
Definition: config.h:270
const std::string & model_options() const
Model options to pass to the SDL file.
Definition: config.h:116
const std::string & output_config_graph() const
File to output python formatted config graph to (empty string means no output)
Definition: config.h:159
const std::string & stop_at() const
Simulated cycle to stop the simulation at.
Definition: config.h:126
std::string profiling_output_
Definition: config.h:443
bool parallel_load_
Definition: config.h:433
void print()
Print to stdout the current configuration.
Definition: config.cc:545
bool parallel_load() const
Controls whether graph constuction will be done in parallel.
Definition: config.h:213
const std::string & output_dot() const
File to output dot formatted config graph to (empty string means no output).
Definition: config.h:181
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
std::string timeBase_
Definition: config.h:432
const std::string & libpath() const
Library path to use for finding element libraries (will replace the libpath in the sstsimulator....
Definition: config.h:252
std::string component_partition_file_
Definition: config.h:428
std::string debugFile_
Definition: config.h:437
std::string output_config_graph_
Definition: config.h:421
Simulation::Mode_t runMode_
Definition: config.h:446
const std::string output_core_prefix() const
Prefix to use for the default SST::Output object in core.
Definition: config.h:151
bool print_timing_
Definition: config.h:412
const std::string & debugFile() const
File to which core debug information should be written.
Definition: config.h:246
bool parallel_output_
Definition: config.h:423
bool no_env_config_
Definition: config.h:455
Definition: serializable.h:119
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Definition: rankInfo.h:22
Base class for Model Generation.
Definition: sstmodel.h:26
Mode_t
Type of Run Modes.
Definition: simulation.h:38
@ INIT
Definition: simulation.h:40
@ RUN
Definition: simulation.h:41
@ BOTH
Definition: simulation.h:42
@ UNKNOWN
Definition: simulation.h:39