SST  6.1.0
StructuralSimulationToolkit
config.h
1 // Copyright 2009-2016 Sandia Corporation. Under the terms
2 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2016, Sandia Corporation
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  /** Parse command-line arguments to update configuration values */
43  int parseCmdLine( int argc, char* argv[] );
44  /** Set a configuration string to update configuration values */
45  bool setConfigEntryFromModel( const std::string &entryName, const std::string &value );
46  /** Return the current Verbosity level */
47  uint32_t getVerboseLevel();
48 
49  /** Print the SST core timing information */
50  bool printTimingInfo();
51 
52  /** Set the cycle at which to stop the simulation */
53  void setStopAt(std::string stopAtStr);
54  /** Sets the default timebase of the simulation */
55  void setTimeBase(std::string timeBase);
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  std::string heartbeatPeriod; /*!< Sets the heartbeat period for the simulation */
64  std::string timeBase; /*!< Timebase of simulation */
65  std::string partitioner; /*!< Partitioner to use */
66  std::string generator; /*!< Generator to use */
67  std::string generator_options; /*!< Options to pass to the generator */
68  std::string output_config_graph; /*!< File to dump configuration graph */
69  std::string output_dot; /*!< File to dump dot output */
70  std::string output_xml; /*!< File to dump XML output */
71  std::string output_json; /*!< File to dump JSON output */
72  std::string output_directory; /*!< Output directory to dump all files to */
73  std::string model_options; /*!< Options to pass to Python Model generator */
74  std::string dump_component_graph_file; /*!< File to dump component graph */
75  std::string output_core_prefix; /*!< Set the SST::Output prefix for the core */
76 
77  RankInfo world_size; /*!< Number of ranks, threads which should be invoked per rank */
78  uint32_t verbose; /*!< Verbosity */
79  bool no_env_config; /*!< Bypass compile-time environmental configuration */
80  bool enable_sig_handling; /*!< Enable signal handling */
81  bool print_timing; /*!< Print SST timing information */
82 
83 #ifdef USE_MEMPOOL
84  std::string event_dump_file; /*!< File to dump undeleted events to */
85 #endif
86 
87 
88  typedef bool (Config::*flagFunction)(void);
89  typedef bool (Config::*argFunction)(const std::string &arg);
90 
91  bool usage();
92  bool printVersion();
93  bool incrVerbose() { verbose++; return true;}
94  bool setVerbosity(const std::string &arg);
95  bool disableSigHandlers() { enable_sig_handling = false; return true;}
96  bool disableEnvConfig() { no_env_config = true; return true;}
97  bool enablePrintTiming() { print_timing = true; return true;}
98 
99  bool setConfigFile(const std::string &arg);
100  bool setDebugFile(const std::string &arg);
101  bool setLibPath(const std::string &arg);
102  bool addLibPath(const std::string &arg);
103  bool setRunMode(const std::string &arg);
104  bool setStopAt(const std::string &arg);
105  bool setHeartbeat(const std::string &arg);
106  bool setTimebase(const std::string &arg);
107  bool setPartitioner(const std::string &arg);
108  bool setGenerator(const std::string &arg);
109  bool setGeneratorOptions(const std::string &arg);
110  bool setOutputDir(const std::string &arg);
111  bool setWriteConfig(const std::string &arg);
112  bool setWriteDot(const std::string &arg);
113  bool setWriteXML(const std::string &arg);
114  bool setWriteJSON(const std::string &arg);
115  bool setWritePartition(const std::string &arg);
116  bool setOutputPrefix(const std::string &arg);
117 #ifdef USE_MEMPOOL
118  bool setWriteUndeleted(const std::string &arg);
119 #endif
120  bool setModelOptions(const std::string &arg);
121  bool setNumThreads(const std::string &arg);
122 
123 
124  Simulation::Mode_t getRunMode() { return runMode; }
125 
126  /** Print to stdout the current configuration */
127  void print() {
128  std::cout << "debugFile = " << debugFile << std::endl;
129  std::cout << "runMode = " << runMode << std::endl;
130  std::cout << "libpath = " << getLibPath() << std::endl;
131  std::cout << "configFile = " << configFile << std::endl;
132  std::cout << "stopAtCycle = " << stopAtCycle << std::endl;
133  std::cout << "timeBase = " << timeBase << std::endl;
134  std::cout << "partitioner = " << partitioner << std::endl;
135  std::cout << "generator = " << generator << std::endl;
136  std::cout << "gen_options = " << generator_options << std::endl;
137  std::cout << "output_config_graph = " << output_config_graph << std::endl;
138  std::cout << "output_xml = " << output_xml << std::endl;
139  std::cout << "no_env_config = " << no_env_config << std::endl;
140  std::cout << "output_directory = " << output_directory << std::endl;
141  std::cout << "output_json = " << output_json << std::endl;
142  std::cout << "model_options = " << model_options << std::endl;
143  std::cout << "num_threads = " << world_size.thread << std::endl;
144  std::cout << "enable_sig_handling = " << enable_sig_handling << std::endl;
145  std::cout << "output_core_prefix = " << output_core_prefix << std::endl;
146  std::cout << "print_timing=" << print_timing << std::endl;
147  }
148 
149 
150  /** Return the library search path */
151  std::string getLibPath(void) const;
152 
153  uint32_t getNumRanks() { return world_size.rank; }
154  uint32_t getNumThreads() { return world_size.thread; }
155  uint32_t setNumThreads(uint32_t nthr) {
156  uint32_t old = world_size.thread;
157  world_size.thread = nthr;
158  return old;
159  }
160 
161  void serialize_order(SST::Core::Serialization::serializer &ser)
162  {
163  ser & debugFile;
164  ser & runMode;
165  ser & libpath;
166  ser & addlLibPath;
167  ser & configFile;
168  ser & stopAtCycle;
169  ser & timeBase;
170  ser & partitioner;
171  ser & generator;
172  ser & generator_options;
174  ser & output_config_graph;
175  ser & output_xml;
176  ser & output_json;
177  ser & no_env_config;
178  ser & model_options;
179  ser & world_size;
180  ser & enable_sig_handling;
181  ser & output_core_prefix;
182  ser & print_timing;
183  }
184 
185 private:
186  std::string run_name;
187  std::string libpath;
188  std::string addlLibPath;
189 
190  int rank;
191  int numRanks;
192 
193  ImplementSerializable(SST::Config)
194 };
195 
196 } // namespace SST
197 
198 #endif // SST_CORE_CONFIG_H
RankInfo world_size
Definition: config.h:77
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
std::string generator_options
Definition: config.h:67
std::string partitioner
Definition: config.h:65
Class to contain SST Simulation Configuration variables.
Definition: config.h:31
std::string heartbeatPeriod
Definition: config.h:63
std::string output_core_prefix
Definition: config.h:75
int parseCmdLine(int argc, char *argv[])
Parse command-line arguments to update configuration values.
Definition: config.cc:206
bool setConfigEntryFromModel(const std::string &entryName, const std::string &value)
Set a configuration string to update configuration values.
Definition: config.cc:278
Simulation::Mode_t runMode
Definition: config.h:60
Definition: action.cc:17
std::string output_config_graph
Definition: config.h:68
uint32_t getVerboseLevel()
Return the current Verbosity level.
Definition: config.cc:421
std::string output_dot
Definition: config.h:69
Definition: serializable.h:108
void setTimeBase(std::string timeBase)
Sets the default timebase of the simulation.
uint32_t verbose
Definition: config.h:78
std::string timeBase
Definition: config.h:64
bool no_env_config
Definition: config.h:79
std::string model_options
Definition: config.h:73
std::string output_xml
Definition: config.h:70
std::string output_directory
Definition: config.h:72
Definition: rankInfo.h:21
std::string output_json
Definition: config.h:71
void print()
Print to stdout the current configuration.
Definition: config.h:127
bool printTimingInfo()
Print the SST core timing information.
Definition: config.cc:417
std::string debugFile
Definition: config.h:59
std::string generator
Definition: config.h:66
std::string getLibPath(void) const
Return the library search path.
Definition: config.cc:426
std::string dump_component_graph_file
Definition: config.h:74
std::string configFile
Definition: config.h:61
void setStopAt(std::string stopAtStr)
Set the cycle at which to stop the simulation.
std::string stopAtCycle
Definition: config.h:62
bool enable_sig_handling
Definition: config.h:80
Mode_t
Type of Run Modes.
Definition: simulation.h:78
void Print()
Print the current configuration to stdout.
bool print_timing
Definition: config.h:81