00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef SST_CORE_CONFIG_H
00013 #define SST_CORE_CONFIG_H
00014
00015 #include <sst/core/sst_types.h>
00016 #include <sst/core/serialization.h>
00017
00018 #include <string>
00019
00020 namespace boost {
00021 namespace program_options {
00022
00023 class options_description;
00024 class positional_options_description;
00025 class variables_map;
00026 }
00027 }
00028
00029 namespace SST {
00030
00031
00032
00033
00034 class Config {
00035 public:
00036
00037 typedef enum {
00038 UNKNOWN,
00039 INIT,
00040 RUN,
00041 BOTH
00042 } Mode_t;
00043
00044
00045
00046
00047
00048 Config(int my_rank, int world_size);
00049 ~Config();
00050
00051
00052 int parseCmdLine( int argc, char* argv[] );
00053
00054 int parseConfigFile( std::string config_string );
00055
00056 uint32_t getVerboseLevel();
00057
00058
00059 void setStopAt(std::string stopAtStr);
00060
00061 void setTimeBase(std::string timeBase);
00062
00063 void Print();
00064
00065 std::string debugFile;
00066 Mode_t runMode;
00067 std::string sdlfile;
00068 std::string stopAtCycle;
00069 std::string heartbeatPeriod;
00070 std::string timeBase;
00071 std::string partitioner;
00072 std::string generator;
00073 std::string generator_options;
00074 std::string output_config_graph;
00075 std::string output_dot;
00076 std::string output_xml;
00077 std::string output_json;
00078 std::string output_directory;
00079 std::string model_options;
00080 std::string dump_component_graph_file;
00081 std::string output_core_prefix;
00082
00083 uint32_t verbose;
00084 bool no_env_config;
00085 bool enable_sig_handling;
00086
00087 #ifdef USE_MEMPOOL
00088 std::string event_dump_file;
00089 #endif
00090
00091
00092
00093
00094 inline Mode_t setRunMode( std::string mode )
00095 {
00096 if( ! mode.compare( "init" ) ) return INIT;
00097 if( ! mode.compare( "run" ) ) return RUN;
00098 if( ! mode.compare( "both" ) ) return BOTH;
00099 return UNKNOWN;
00100 }
00101
00102 Mode_t getRunMode() {
00103 return runMode;
00104 }
00105
00106
00107 void print() {
00108 std::cout << "debugFile = " << debugFile << std::endl;
00109 std::cout << "runMode = " << runMode << std::endl;
00110 std::cout << "libpath = " << getLibPath() << std::endl;
00111 std::cout << "sdlfile = " << sdlfile << std::endl;
00112 std::cout << "stopAtCycle = " << stopAtCycle << std::endl;
00113 std::cout << "timeBase = " << timeBase << std::endl;
00114 std::cout << "partitioner = " << partitioner << std::endl;
00115 std::cout << "generator = " << generator << std::endl;
00116 std::cout << "gen_options = " << generator_options << std::endl;
00117 std::cout << "output_config_graph = " << output_config_graph << std::endl;
00118 std::cout << "output_xml = " << output_xml << std::endl;
00119 std::cout << "no_env_config = " << no_env_config << std::endl;
00120 std::cout << "output_directory = " << output_directory << std::endl;
00121 std::cout << "output_json = " << output_json << std::endl;
00122 std::cout << "model_options = " << model_options << std::endl;
00123 std::cout << "enable_sig_handling = " << enable_sig_handling << std::endl;
00124 std::cout << "output_core_prefix = " << output_core_prefix << std::endl;
00125 }
00126
00127
00128 std::string getLibPath(void) const {
00129 char *envpath = getenv("SST_LIB_PATH");
00130 if ( !addlLibPath.empty() ) {
00131 return addlLibPath + ":" + libpath;
00132 } else if ( NULL != envpath ) {
00133 return envpath;
00134 }
00135 return libpath;
00136 }
00137
00138
00139 int getRank() const { return rank; }
00140
00141 int getNumRanks() const { return numRanks; }
00142
00143 private:
00144 boost::program_options::options_description* visNoConfigDesc;
00145 boost::program_options::options_description* hiddenNoConfigDesc;
00146 boost::program_options::options_description* legacyDesc;
00147 boost::program_options::options_description* mainDesc;
00148 boost::program_options::positional_options_description* posDesc;
00149 boost::program_options::variables_map* var_map;
00150 std::string run_name;
00151 std::string libpath;
00152 std::string addlLibPath;
00153
00154 friend class boost::serialization::access;
00155 template<class Archive>
00156 void
00157 serialize(Archive & ar, const unsigned int version )
00158 {
00159 ar & BOOST_SERIALIZATION_NVP(debugFile);
00160 ar & BOOST_SERIALIZATION_NVP(runMode);
00161 ar & BOOST_SERIALIZATION_NVP(libpath);
00162 ar & BOOST_SERIALIZATION_NVP(addlLibPath);
00163 ar & BOOST_SERIALIZATION_NVP(sdlfile);
00164 ar & BOOST_SERIALIZATION_NVP(stopAtCycle);
00165 ar & BOOST_SERIALIZATION_NVP(timeBase);
00166 ar & BOOST_SERIALIZATION_NVP(partitioner);
00167 ar & BOOST_SERIALIZATION_NVP(generator);
00168 ar & BOOST_SERIALIZATION_NVP(generator_options);
00169 ar & BOOST_SERIALIZATION_NVP(dump_component_graph_file);
00170 ar & BOOST_SERIALIZATION_NVP(output_config_graph);
00171 ar & BOOST_SERIALIZATION_NVP(output_xml);
00172 ar & BOOST_SERIALIZATION_NVP(output_json);
00173 ar & BOOST_SERIALIZATION_NVP(no_env_config);
00174 ar & BOOST_SERIALIZATION_NVP(model_options);
00175 ar & BOOST_SERIALIZATION_NVP(enable_sig_handling);
00176 ar & BOOST_SERIALIZATION_NVP(output_core_prefix);
00177 }
00178
00179 int rank;
00180 int numRanks;
00181
00182 };
00183
00184 }
00185
00186 #endif // SST_CORE_CONFIG_H