SST 15.0
Structural Simulation Toolkit
config.h
1// Copyright 2009-2025 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-2025, 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/configShared.h"
16#include "sst/core/serialization/serializable.h"
17#include "sst/core/sst_types.h"
18
19// Pull in the patchlevel for Python so we can check Python version
20#include <patchlevel.h>
21#include <string>
22
23/* Forward declare for Friendship */
24extern int main(int argc, char** argv);
25
26namespace SST {
27class Config;
28
29class ConfigHelper;
31/**
32 * Class to contain SST Simulation Configuration variables.
33 *
34 * NOTE: This class needs to be serialized for the sst.x executable,
35 * but not for the sst (wrapper compiled from the boot*.{h,cc} files)
36 * executable. To avoid having to compile all the serialization code
37 * into the bootstrap executable, the Config class is the first level
38 * of class hierarchy to inherit from serializable.
39 */
41{
42
43private:
44 // Main creates the config object
45 friend int ::main(int argc, char** argv);
46 friend class ConfigHelper;
47 friend class SSTModelDescription;
48
49 /**
50 Config constructor. Meant to only be created by main function
51 */
52 Config(uint32_t num_ranks, bool first_rank);
53
54 /**
55 Default constructor used for serialization. At this point,
56 first_rank_ is no longer needed, so just initialize to false.
57 */
58 Config() :
59 ConfigShared(true, {}),
60 first_rank_(false)
61 {}
62
63 //// Functions for use in main
64
65 /**
66 Checks for the existance of the config file. This needs to be
67 called after adding any rank numbers to the file in the case of
68 parallel loading.
69 */
70 bool checkConfigFile();
71
72 // Function to be called from ModelDescriptions
73
74 /** Set a configuration string to update configuration values */
75 bool setOptionFromModel(const std::string& entryName, const std::string& value);
76
77
78public:
79 ~Config() {}
80
81 // Functions to access config options. Declared in order they show
82 // up in the options array
83
84 // Information options
85 // No variable associated with help
86 // No variable associated with version
87
88 // Basic options
89
90 /**
91 Level of verbosity to use in the core prints using
92 Output.verbose or Output.debug.
93
94 ** Included in ConfigShared
95 uint32_t verbose() const { return verbose_; }
96 */
97
98
99 /**
100 Number of threads requested
101 */
102 uint32_t num_threads() const { return num_threads_; }
103
104 /**
105 Number of ranks in the simulation
106 */
107 uint32_t num_ranks() const { return num_ranks_; }
108
109 /**
110 Name of the SDL file to use to genearte the simulation
111 */
112 const std::string& configFile() const { return configFile_; }
113
114 /**
115 Model options to pass to the SDL file
116 */
117 const std::string& model_options() const { return model_options_; }
118
119 /**
120 Print SST timing information after the run
121 */
122 bool print_timing() const { return print_timing_; }
123
124 /**
125 Simulated cycle to stop the simulation at
126 */
127 const std::string& stop_at() const { return stop_at_; }
128
129 /**
130 Wall clock time (approximiate) in seconds to stop the simulation at
131 */
132 uint32_t exit_after() const { return exit_after_; }
133
134 /**
135 Partitioner to use for parallel simulations
136 */
137 const std::string& partitioner() const { return partitioner_; }
138
139 /**
140 Simulation period at which to print out a "heartbeat" message
141 */
142 const std::string& heartbeat_sim_period() const { return heartbeat_sim_period_; }
143
144 /**
145 Wall-clock period at which to print out a "heartbeat" message
146 */
147 uint32_t heartbeat_wall_period() const { return heartbeat_wall_period_; }
148
149 /**
150 The directory to be used for writting output files
151 */
152 const std::string& output_directory() const { return output_directory_; }
153
154 /**
155 Prefix to use for the default SST::Output object in core
156 */
157 const std::string output_core_prefix() const { return output_core_prefix_; }
158
159 // Configuration output
160
161 /**
162 File to output python formatted config graph to (empty string means no
163 output)
164 */
165 const std::string& output_config_graph() const { return output_config_graph_; }
166
167 /**
168 File to output json formatted config graph to (empty string means no
169 output)
170 */
171 const std::string& output_json() const { return output_json_; }
172
173 /**
174 If true, and a config graph output option is specified, write
175 each ranks graph separately
176 */
177 bool parallel_output() const { return parallel_output_; }
178
179
180 // Graph output
181
182 /**
183 File to output dot formatted config graph to (empty string means no
184 output). Note, this is not a format that can be used as input for simulation
185
186 */
187 const std::string& output_dot() const { return output_dot_; }
188
189 /**
190 Level of verbosity to use for the dot output.
191 */
192 uint32_t dot_verbosity() const { return dot_verbosity_; }
193
194 /**
195 File to output component partition info to (empty string means no output)
196 */
197 const std::string& component_partition_file() const { return component_partition_file_; }
198
199 /**
200 Controls whether partition info is output as part of configuration output
201 */
202 bool output_partition() const { return output_partition_; }
203
204 // Advanced options
205
206 /**
207 Core timebase to use as the atomic time unit for the
208 simulation. It is usually best to just leave this at the
209 default (1ps)
210 */
211 const std::string& timeBase() const { return timeBase_; }
212
213 /**
214 Controls whether graph constuction will be done in parallel.
215 If it is, then the SDL file name is modified to add the rank
216 number to the file name right before the file extension, if
217 parallel_load_mode_multi is true.
218 */
219 bool parallel_load() const { return parallel_load_; }
220
221 /**
222 If graph constuction will be done in parallel, will use a
223 file per rank if true, and the same file for each rank if
224 false.
225 */
226 bool parallel_load_mode_multi() const { return parallel_load_mode_multi_; }
227
228 /**
229 Returns the string equivalent for parallel-load: NONE (if
230 parallel load is off), SINGLE or MULTI.
231 */
232 std::string parallel_load_str() const
233 {
234 if ( !parallel_load_ ) return "NONE";
235 if ( parallel_load_mode_multi_ ) return "MULTI";
236 return "SINGLE";
237 }
238
239 /**
240 * Interval at which to create a checkpoint in wall time
241 */
242 uint32_t checkpoint_wall_period() const { return checkpoint_wall_period_; }
243 /**
244 * Interval at which to create a checkpoint in simulated time
245 */
246 const std::string& checkpoint_sim_period() const { return checkpoint_sim_period_; }
247
248 /**
249 * Returns whether the simulation will begin from a checkpoint (true) or not (false).
250 */
251 bool load_from_checkpoint() const { return load_from_checkpoint_; }
252
253 /**
254 Prefix for checkpoint filenames and directory
255 */
256 const std::string& checkpoint_prefix() const { return checkpoint_prefix_; }
257
258 /**
259 Format for checkout filenames
260 */
261 const std::string& checkpoint_name_format() const { return checkpoint_name_format_; }
262
263 /**
264 TimeVortex implementation to use
265 */
266 const std::string& timeVortex() const { return timeVortex_; }
267
268 /**
269 Use links that connect directly to ActivityQueue in receiving thread
270 */
271 bool interthread_links() const { return interthread_links_; }
272
273#ifdef USE_MEMPOOL
274 /**
275 Controls whether mempool items are cache-aligned
276
277 */
278 bool cache_align_mempools() const { return cache_align_mempools_; }
279#endif
280 /**
281 File to which core debug information should be written
282 */
283 const std::string& debugFile() const { return debugFile_; }
284
285 /**
286 Library path to use for finding element libraries (will replace
287 the libpath in the sstsimulator.conf file)
288
289 ** Included in ConfigShared
290 const std::string& libpath() const { return libpath_; }
291 */
292
293 /**
294 Paths to add to library search (adds to libpath found in
295 sstsimulator.conf file)
296
297 ** Included in ConfigShared
298 const std::string& addLibPath() const { return addLibPath_; }
299 */
300
301
302#if PY_MINOR_VERSION >= 9
303 /**
304 Controls whether the Python coverage object will be loaded
305 */
306 bool enablePythonCoverage() const { return enable_python_coverage_; }
307#endif
308
309 // Advanced options - Profiling
310
311 /**
312 Profiling points to turn on
313 */
314 const std::string& enabledProfiling() const { return enabled_profiling_; }
315
316 /**
317 Profiling points to turn on
318 */
319 const std::string& profilingOutput() const { return profiling_output_; }
320
321 // Advanced options - Debug
322
323 /**
324 Run mode to use (Init, Both, Run-only). Note that Run-only is
325 not currently supported because there is not component level
326 checkpointing.
327 */
328 SimulationRunMode runMode() const { return runMode_; }
329
330 /**
331 Get string version of runmode.
332 */
333 std::string runMode_str() const
334 {
335 switch ( runMode_ ) {
336 case SimulationRunMode::INIT:
337 return "INIT";
338 case SimulationRunMode::RUN:
339 return "RUN";
340 case SimulationRunMode::BOTH:
341 return "BOTH";
342 case SimulationRunMode::UNKNOWN:
343 return "UNKNOWN";
344 }
345 return "UNKNOWN";
346 }
347
348 /**
349 Get the InteractiveAction to use for interactive mode
350 */
351 std::string interactive_console() const { return interactive_console_; }
352
353 /**
354 Get the time to start interactive mode
355 */
356 std::string interactive_start_time() const { return interactive_start_time_; }
357
358
359#ifdef USE_MEMPOOL
360 /**
361 File to output list of events that remain undeleted at the end
362 of the simulation.
363
364 If no mempools, just reutrn empty string. This avoids a check
365 for mempools in main.cc
366 */
367 const std::string& event_dump_file() const { return event_dump_file_; }
368#endif
369
370 /**
371 Run simulation initialization stages one rank at a time for
372 debug purposes
373 */
374 bool rank_seq_startup() const { return rank_seq_startup_; }
375
376 // Advanced options - envrionment
377
378 /**
379 Controls whether the environment variables that SST sees are
380 printed out
381
382 ** Included in ConfigShared
383 bool print_env() const { return print_env_; }
384 */
385
386 /**
387 ** Included in ConfigShared
388 bool no_env_config() const { return no_env_config_; }
389 */
390
391 /**
392 Controls whether signal handlers are enable or not. NOTE: the
393 sense of this variable is opposite of the command1 line option
394 (--disable-signal-handlers)
395 */
396 bool enable_sig_handling() const { return enable_sig_handling_; }
397
398 /**
399 * SIGUSR1 handler
400 */
401 const std::string& sigusr1() const { return sigusr1_; }
402
403 /**
404 * SIGUSR2 handler
405 */
406 const std::string& sigusr2() const { return sigusr2_; }
407
408 /**
409 * SIGALRM handler(s)
410 */
411 const std::string& sigalrm() const { return sigalrm_; }
412
413 // This option is used by the SST wrapper found in
414 // bootshare.{h,cc} and is never actually accessed once sst.x
415 // executes.
416
417
418 /** Get whether or not any of the checkpoint options were turned on */
420
421 /** Print to stdout the current configuration */
422 void print();
423
424 void serialize_order(SST::Core::Serialization::serializer& ser) override
425 {
426 SST_SER(verbose_);
427 SST_SER(configFile_);
428 SST_SER(model_options_);
429 SST_SER(print_timing_);
430 SST_SER(stop_at_);
431 SST_SER(exit_after_);
432 SST_SER(partitioner_);
433 SST_SER(heartbeat_wall_period_);
434 SST_SER(heartbeat_sim_period_);
435 SST_SER(output_directory_);
436 SST_SER(output_core_prefix_);
437
438 SST_SER(output_config_graph_);
439 SST_SER(output_json_);
440 SST_SER(parallel_output_);
441
442 SST_SER(output_dot_);
443 SST_SER(dot_verbosity_);
444 SST_SER(component_partition_file_);
445 SST_SER(output_partition_);
446
447 SST_SER(timeBase_);
448 SST_SER(parallel_load_);
449 SST_SER(parallel_load_mode_multi_);
450 SST_SER(timeVortex_);
451 SST_SER(interthread_links_);
452#ifdef USE_MEMPOOL
453 SST_SER(cache_align_mempools_);
454#endif
455 SST_SER(debugFile_);
456 SST_SER(libpath_);
457 SST_SER(addlibpath_);
458#if PY_MINOR_VERSION >= 9
459 SST_SER(enable_python_coverage_);
460#endif
461 SST_SER(enabled_profiling_);
462 SST_SER(profiling_output_);
463 SST_SER(runMode_);
464 SST_SER(interactive_console_);
465 SST_SER(interactive_start_time_);
466#ifdef USE_MEMPOOL
467 SST_SER(event_dump_file_);
468#endif
469 SST_SER(load_from_checkpoint_);
470 SST_SER(checkpoint_wall_period_);
471 SST_SER(checkpoint_sim_period_);
472 SST_SER(checkpoint_prefix_);
473 SST_SER(checkpoint_name_format_);
474
475 SST_SER(enable_sig_handling_);
476 SST_SER(sigusr1_);
477 SST_SER(sigusr2_);
478 SST_SER(sigalrm_);
479 SST_SER(print_env_);
480 SST_SER(no_env_config_);
481 }
482 ImplementSerializable(SST::Config);
483
484protected:
485 std::string getUsagePrelude() override;
486 int checkArgsAfterParsing() override;
487 int positionalCallback(int num, const std::string& arg);
488
489private:
490 //// Items private to Config
491
492 std::string run_name;
493 bool first_rank_;
494
495 // Inserts all the command line options into the underlying data
496 // structures
497 void insertOptions();
498
499 bool isFileNameOnly(const std::string& name)
500 {
501 bool nameOnly = true;
502
503 for ( size_t i = 0; i < name.size(); ++i ) {
504 if ( '/' == name[i] ) {
505 nameOnly = false;
506 break;
507 }
508 }
509
510 return nameOnly;
511 }
512
513 // Variables to hold the options. Declared in order they show up
514 // in the options array
515
516 // Information options
517 // No variable associated with help
518 // No variable associated with version
519
520 // Basic options
521 // uint32_t verbose_; ** in ConfigShared
522 // Num threads held in RankInfo.thread
523 uint32_t num_ranks_; /*!< Number of ranks in the simulation */
524 uint32_t num_threads_; /*!< Number of threads requested */
525 std::string configFile_; /*!< Graph generation file */
526 std::string model_options_; /*!< Options to pass to Python Model generator */
527 bool print_timing_; /*!< Print SST timing information */
528 std::string stop_at_; /*!< When to stop the simulation */
529 uint32_t exit_after_; /*!< When (wall-time) to stop the simulation */
530 std::string partitioner_; /*!< Partitioner to use */
531 std::string heartbeat_sim_period_; /*!< Sets the heartbeat (simulated time) period for the simulation */
532 uint32_t heartbeat_wall_period_; /*!< Sets the heartbeat (wall-clock time) period for the simulation */
533 std::string output_directory_; /*!< Output directory to dump all files to */
534 std::string output_core_prefix_; /*!< Set the SST::Output prefix for the core */
535
536 // Configuration output
537 std::string output_config_graph_; /*!< File to dump configuration graph */
538 std::string output_json_; /*!< File to dump JSON output */
539 bool parallel_output_; /*!< Output simulation graph in parallel */
540
541 // Graph output
542 std::string output_dot_; /*!< File to dump dot output */
543 uint32_t dot_verbosity_; /*!< Amount of detail to include in the dot graph output */
544 std::string component_partition_file_; /*!< File to dump component graph */
545 bool output_partition_; /*!< Output paritition info when writing config output */
546
547 // Advanced options
548 std::string timeBase_; /*!< Timebase of simulation */
549 bool parallel_load_; /*!< Load simulation graph in parallel */
550 bool parallel_load_mode_multi_; /*!< If true, load using multiple files */
551 std::string timeVortex_; /*!< TimeVortex implementation to use */
552 bool interthread_links_; /*!< Use interthread links */
553#ifdef USE_MEMPOOL
554 bool cache_align_mempools_; /*!< Cache align allocations from mempools */
555#endif
556 std::string debugFile_; /*!< File to which debug information should be written */
557 // std::string libpath_; ** in ConfigShared
558 // std::string addLibPath_; ** in ConfigShared
559#if PY_MINOR_VERSION >= 9
560 bool enable_python_coverage_; /*!< Enable the Python coverage module */
561#endif
562
563 // Advanced options - profiling
564 std::string enabled_profiling_; /*!< Enabled default profiling points */
565 std::string profiling_output_; /*!< Location to write profiling data */
566
567 // Advanced options - debug
568 SimulationRunMode runMode_; /*!< Run Mode (Init, Both, Run-only) */
569 std::string interactive_console_; /*!< Action to use for interactive mode */
570 std::string interactive_start_time_; /*!< Time to drop into interactive mode */
571#ifdef USE_MEMPOOL
572 std::string event_dump_file_; /*!< File to dump undeleted events to */
573#endif
574 bool rank_seq_startup_; /*!< Run simulation initialization phases one rank at a time */
575
576 // Advanced options - checkpoint
577 bool load_from_checkpoint_; /*!< If true, load from checkpoint instead of config file */
578 std::string checkpoint_sim_period_; /*!< Interval to generate checkpoints at in terms of the simulated clock */
579 uint32_t
580 checkpoint_wall_period_; /*!< Interval to generate checkpoints at in terms of wall-clock measured seconds */
581 std::string checkpoint_prefix_; /*!< Prefix for checkpoint filename and checkpoint directory */
582 std::string checkpoint_name_format_; /*!< Format for checkpoint filenames */
583
584 // Advanced options - environment
585 bool enable_sig_handling_; /*!< Enable signal handling */
586 std::string sigusr1_; /*!< RealTimeAction to call on a SIGUSR1 */
587 std::string sigusr2_; /*!< RealTimeAction to call on a SIGUSR2 */
588 std::string sigalrm_; /*!< RealTimeAction(s) to call on a SIGALRM */
589 // bool print_env_; ** in ConfigShared
590 // bool no_env_config_; ** in ConfigShared
591};
592
593} // namespace SST
594
595#endif // SST_CORE_CONFIG_H
Definition config.cc:33
ConfigShared(bool suppress_print, bool include_libpath, bool include_env, bool include_verbose)
ConfigShared constructor that it meant to be used when needing a stand alone ConfigShared (i....
Definition configShared.cc:23
ConfigShared()
Default constructor used for serialization.
Definition configShared.h:59
Class to contain SST Simulation Configuration variables.
Definition config.h:41
const std::string & output_json() const
File to output json formatted config graph to (empty string means no output)
Definition config.h:171
const std::string & output_directory() const
The directory to be used for writting output files.
Definition config.h:152
const std::string & timeVortex() const
TimeVortex implementation to use.
Definition config.h:266
const std::string & configFile() const
Name of the SDL file to use to genearte the simulation.
Definition config.h:112
uint32_t checkpoint_wall_period() const
Interval at which to create a checkpoint in wall time.
Definition config.h:242
uint32_t dot_verbosity() const
Level of verbosity to use for the dot output.
Definition config.h:192
bool rank_seq_startup() const
Run simulation initialization stages one rank at a time for debug purposes.
Definition config.h:374
bool print_timing() const
Print SST timing information after the run.
Definition config.h:122
bool interthread_links() const
Use links that connect directly to ActivityQueue in receiving thread.
Definition config.h:271
bool output_partition() const
Controls whether partition info is output as part of configuration output.
Definition config.h:202
uint32_t exit_after() const
Wall clock time (approximiate) in seconds to stop the simulation at.
Definition config.h:132
const std::string & component_partition_file() const
File to output component partition info to (empty string means no output)
Definition config.h:197
uint32_t num_threads() const
Level of verbosity to use in the core prints using Output.verbose or Output.debug.
Definition config.h:102
SimulationRunMode runMode() const
Run mode to use (Init, Both, Run-only).
Definition config.h:328
const std::string & checkpoint_prefix() const
Prefix for checkpoint filenames and directory.
Definition config.h:256
const std::string & timeBase() const
Core timebase to use as the atomic time unit for the simulation.
Definition config.h:211
const std::string & enabledProfiling() const
Library path to use for finding element libraries (will replace the libpath in the sstsimulator....
Definition config.h:314
const std::string & sigalrm() const
SIGALRM handler(s)
Definition config.h:411
const std::string & partitioner() const
Partitioner to use for parallel simulations.
Definition config.h:137
bool enable_sig_handling() const
Controls whether the environment variables that SST sees are printed out.
Definition config.h:396
uint32_t num_ranks() const
Number of ranks in the simulation.
Definition config.h:107
bool load_from_checkpoint() const
Returns whether the simulation will begin from a checkpoint (true) or not (false).
Definition config.h:251
const std::string & sigusr1() const
SIGUSR1 handler.
Definition config.h:401
bool canInitiateCheckpoint()
Get whether or not any of the checkpoint options were turned on.
Definition config.cc:1255
std::string parallel_load_str() const
Returns the string equivalent for parallel-load: NONE (if parallel load is off), SINGLE or MULTI.
Definition config.h:232
bool parallel_output() const
If true, and a config graph output option is specified, write each ranks graph separately.
Definition config.h:177
std::string runMode_str() const
Get string version of runmode.
Definition config.h:333
const std::string & heartbeat_sim_period() const
Simulation period at which to print out a "heartbeat" message.
Definition config.h:142
const std::string & profilingOutput() const
Profiling points to turn on.
Definition config.h:319
const std::string & model_options() const
Model options to pass to the SDL file.
Definition config.h:117
const std::string & output_config_graph() const
File to output python formatted config graph to (empty string means no output)
Definition config.h:165
const std::string & stop_at() const
Simulated cycle to stop the simulation at.
Definition config.h:127
const std::string & sigusr2() const
SIGUSR2 handler.
Definition config.h:406
std::string interactive_console() const
Get the InteractiveAction to use for interactive mode.
Definition config.h:351
void print()
Print to stdout the current configuration.
Definition config.cc:814
bool parallel_load() const
Controls whether graph constuction will be done in parallel.
Definition config.h:219
const std::string & output_dot() const
File to output dot formatted config graph to (empty string means no output).
Definition config.h:187
std::string getUsagePrelude() override
Called to get the prelude for the help/usage message.
Definition config.cc:1200
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:226
uint32_t heartbeat_wall_period() const
Wall-clock period at which to print out a "heartbeat" message.
Definition config.h:147
const std::string & checkpoint_name_format() const
Format for checkout filenames.
Definition config.h:261
std::string interactive_start_time() const
Get the time to start interactive mode.
Definition config.h:356
const std::string output_core_prefix() const
Prefix to use for the default SST::Output object in core.
Definition config.h:157
const std::string & debugFile() const
File to which core debug information should be written.
Definition config.h:283
const std::string & checkpoint_sim_period() const
Interval at which to create a checkpoint in simulated time.
Definition config.h:246
Definition serializable.h:24
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:45
Base class for Model Generation.
Definition sstmodel.h:30