12 #ifndef SST_CORE_CONFIG_H 13 #define SST_CORE_CONFIG_H 15 #include "sst/core/configShared.h" 16 #include "sst/core/serialization/serializable.h" 17 #include "sst/core/sst_types.h" 22 #include <patchlevel.h> 26 extern int main(
int argc,
char** argv);
32 class SSTModelDescription;
35 namespace StandardConfigParsers {
37 int check_unitalgebra_store_string(std::string valid_units, std::string& var, std::string arg);
56 friend int ::main(
int argc,
char** argv);
69 void initialize(uint32_t num_ranks,
bool first_rank);
78 bool checkConfigFile();
83 bool setOptionFromModel(
const std::string& entryName,
const std::string& value);
124 SST_CONFIG_DECLARE_OPTION_NOVAR(usage, std::bind(&
Config::parseUsage,
this, std::placeholders::_1));
135 SST_CONFIG_DECLARE_OPTION_NOVAR(help, std::bind(&
Config::parseHelp,
this, std::placeholders::_1));
142 printf(
"SST-Core Version (" PACKAGE_VERSION);
143 if ( strcmp(SSTCORE_GIT_HEADSHA, PACKAGE_VERSION) ) {
144 printf(
", git branch : " SSTCORE_GIT_BRANCH);
145 printf(
", SHA: " SSTCORE_GIT_HEADSHA);
152 SST_CONFIG_DECLARE_OPTION_NOVAR(version, std::bind(&
Config::parseVersion, std::placeholders::_1));
159 uint32_t num_ranks_ = 1;
162 uint32_t num_ranks()
const {
return num_ranks_; }
171 SST_CONFIG_DECLARE_OPTION(uint32_t, num_threads, 1, &StandardConfigParsers::from_string<uint32_t>);
176 SST_CONFIG_DECLARE_OPTION(std::string, configFile,
"NONE", &StandardConfigParsers::from_string<std::string>);
181 SST_CONFIG_DECLARE_OPTION(std::string, model_options,
"",
182 std::bind(&StandardConfigParsers::append_string,
" \"",
"\"", std::placeholders::_1, std::placeholders::_2));
187 SST_CONFIG_DECLARE_OPTION(
int, print_timing, 0,
188 std::bind(&StandardConfigParsers::from_string_default<int>, std::placeholders::_1, std::placeholders::_2, 2));
193 SST_CONFIG_DECLARE_OPTION(std::string, timing_json,
"", &StandardConfigParsers::from_string<std::string>);
198 SST_CONFIG_DECLARE_OPTION(std::string, stop_at,
"0ns", &StandardConfigParsers::from_string<std::string>);
203 SST_CONFIG_DECLARE_OPTION(uint32_t, exit_after, 0, &StandardConfigParsers::wall_time_to_seconds);
208 SST_CONFIG_DECLARE_OPTION(std::string, partitioner,
"sst.linear", &StandardConfigParsers::element_name);
213 SST_CONFIG_DECLARE_OPTION(uint32_t, heartbeat_wall_period, 0, &StandardConfigParsers::wall_time_to_seconds);
218 SST_CONFIG_DECLARE_OPTION(std::string, heartbeat_sim_period,
"",
219 std::bind(&StandardConfigParsers::check_unitalgebra_store_string,
"s, Hz", std::placeholders::_1,
220 std::placeholders::_2));
225 SST_CONFIG_DECLARE_OPTION(std::string, output_directory,
"", &StandardConfigParsers::from_string<std::string>);
230 SST_CONFIG_DECLARE_OPTION(
231 std::string, output_core_prefix,
"@x SST Core: ", &StandardConfigParsers::from_string<std::string>);
240 SST_CONFIG_DECLARE_OPTION(std::string, output_config_graph,
"", &StandardConfigParsers::from_string<std::string>);
246 SST_CONFIG_DECLARE_OPTION(std::string, output_json,
"", &StandardConfigParsers::from_string<std::string>);
252 int parse_parallel_output(
bool& var, std::string arg)
254 if ( num_ranks_ == 1 )
return 0;
256 int ret_code = StandardConfigParsers::flag_default_true(var, arg);
257 if ( ret_code != 0 )
return ret_code;
261 if ( var ) output_partition_.value1 =
true;
265 SST_CONFIG_DECLARE_OPTION(
bool, parallel_output,
false,
266 std::bind(&Config::parse_parallel_output,
this, std::placeholders::_1, std::placeholders::_2));
276 SST_CONFIG_DECLARE_OPTION(std::string, output_dot,
"", &StandardConfigParsers::from_string<std::string>);
281 SST_CONFIG_DECLARE_OPTION(uint32_t, dot_verbosity, 0, &StandardConfigParsers::from_string<uint32_t>);
286 int parse_output_partition(
bool& output_part_flag, std::string& file_name, std::string arg)
289 output_part_flag =
true;
297 SST_CONFIG_DECLARE_OPTION_PAIR(
bool, output_partition,
false, std::string, component_partition_file,
"",
298 std::bind(&Config::parse_output_partition,
this, std::placeholders::_1, std::placeholders::_2,
299 std::placeholders::_3));
312 static std::string ext_help_timebase();
314 SST_CONFIG_DECLARE_OPTION(std::string, timeBase,
"1ps",
315 std::bind(&StandardConfigParsers::check_unitalgebra_store_string,
"s, Hz", std::placeholders::_1,
316 std::placeholders::_2),
317 &Config::ext_help_timebase);
338 int parse_parallel_load(
bool& parallel_load,
bool& parallel_load_mode_multi, std::string arg)
341 if ( num_ranks_ == 1 )
return 0;
344 parallel_load =
true;
348 std::string arg_lower(arg);
350 for (
auto& ch : arg_lower )
351 ch = std::tolower(ch, loc);
353 if ( arg_lower ==
"none" ) {
354 parallel_load =
false;
358 parallel_load =
true;
360 if ( arg_lower ==
"single" )
361 parallel_load_mode_multi =
false;
362 else if ( arg_lower ==
"multi" )
363 parallel_load_mode_multi =
true;
366 "Invalid option '%s' passed to --parallel-load. Valid options are NONE, SINGLE and MULTI.\n",
374 std::string parallel_load_str()
const 376 if ( !parallel_load_.value1 )
return "NONE";
377 if ( parallel_load_.value2 )
return "MULTI";
383 SST_CONFIG_DECLARE_OPTION_PAIR(
bool, parallel_load,
false,
bool, parallel_load_mode_multi,
true,
385 &Config::parse_parallel_load,
this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
390 SST_CONFIG_DECLARE_OPTION(
391 std::string, timeVortex,
"sst.timevortex.priority_queue", &StandardConfigParsers::from_string<std::string>);
396 SST_CONFIG_DECLARE_OPTION(
bool, interthread_links,
false, &StandardConfigParsers::flag_default_true);
404 SST_CONFIG_DECLARE_OPTION(
bool, cache_align_mempools,
false, &StandardConfigParsers::flag_default_true);
409 SST_CONFIG_DECLARE_OPTION(std::string, debugFile,
"/dev/null", &StandardConfigParsers::from_string<std::string>);
428 #if PY_MINOR_VERSION >= 9 432 static std::string ext_help_enable_python_coverage();
434 SST_CONFIG_DECLARE_OPTION(
bool, enable_python_coverage,
false, &StandardConfigParsers::flag_set_true,
435 &Config::ext_help_enable_python_coverage);
444 static std::string ext_help_enable_profiling();
446 SST_CONFIG_DECLARE_OPTION(std::string, enabled_profiling,
"",
447 std::bind(&StandardConfigParsers::append_string,
";",
"", std::placeholders::_1, std::placeholders::_2),
448 &Config::ext_help_enable_profiling);
453 SST_CONFIG_DECLARE_OPTION(
454 std::string, profiling_output,
"stdout", &StandardConfigParsers::from_string<std::string>);
464 static int parseRunMode(SimulationRunMode& val, std::string arg)
466 if ( !arg.compare(
"init") )
467 val = SimulationRunMode::INIT;
468 else if ( !arg.compare(
"run") )
469 val = SimulationRunMode::RUN;
470 else if ( !arg.compare(
"both") )
471 val = SimulationRunMode::BOTH;
473 fprintf(stderr,
"Unknown option for --run-mode: %s\n", arg.c_str());
474 val = SimulationRunMode::UNKNOWN;
477 return val != SimulationRunMode::UNKNOWN ? 0 : -1;
480 SST_CONFIG_DECLARE_OPTION(SimulationRunMode, runMode, SimulationRunMode::BOTH, &Config::parseRunMode);
488 switch ( runMode_ ) {
489 case SimulationRunMode::INIT:
491 case SimulationRunMode::RUN:
493 case SimulationRunMode::BOTH:
495 case SimulationRunMode::UNKNOWN:
506 SST_CONFIG_DECLARE_OPTION(std::string, interactive_console,
"", &StandardConfigParsers::from_string<std::string>);
511 SST_CONFIG_DECLARE_OPTION(std::string, interactive_start_time,
"",
512 std::bind(&StandardConfigParsers::from_string_default<std::string>, std::placeholders::_1,
513 std::placeholders::_2,
"0"));
518 SST_CONFIG_DECLARE_OPTION(std::string, replay_file,
"", &StandardConfigParsers::from_string<std::string>);
528 SST_CONFIG_DECLARE_OPTION(std::string, event_dump_file,
"", &StandardConfigParsers::from_string<std::string>);
535 SST_CONFIG_DECLARE_OPTION(
bool, rank_seq_startup,
false, &StandardConfigParsers::flag_set_true);
558 SST_CONFIG_DECLARE_OPTION(
bool, enable_sig_handling,
true, &StandardConfigParsers::flag_set_false);
563 static std::string ext_help_signals();
565 SST_CONFIG_DECLARE_OPTION(std::string, sigusr1,
"sst.rt.status.core",
566 &StandardConfigParsers::from_string<std::string>, Config::ext_help_signals);
571 SST_CONFIG_DECLARE_OPTION(std::string, sigusr2,
"sst.rt.status.all",
572 &StandardConfigParsers::from_string<std::string>, Config::ext_help_signals);
577 SST_CONFIG_DECLARE_OPTION(std::string, sigalrm,
"",
578 std::bind(&StandardConfigParsers::append_string,
";",
"", std::placeholders::_1, std::placeholders::_2),
579 Config::ext_help_signals);
587 SST_CONFIG_DECLARE_OPTION(
bool, checkpoint_enable, 0, &StandardConfigParsers::flag_set_true);
592 SST_CONFIG_DECLARE_OPTION(uint32_t, checkpoint_wall_period, 0, &StandardConfigParsers::wall_time_to_seconds);
597 SST_CONFIG_DECLARE_OPTION(std::string, checkpoint_sim_period,
"",
598 std::bind(&StandardConfigParsers::check_unitalgebra_store_string,
"s, Hz", std::placeholders::_1,
599 std::placeholders::_2));
604 SST_CONFIG_DECLARE_OPTION(
bool, load_from_checkpoint,
false, &StandardConfigParsers::flag_set_true);
609 static std::string ext_help_checkpoint_prefix();
611 SST_CONFIG_DECLARE_OPTION(std::string, checkpoint_prefix,
"checkpoint", &StandardConfigParsers::nonempty_string,
612 &Config::ext_help_checkpoint_prefix);
617 static int parse_checkpoint_name_format(std::string& var, std::string arg);
619 static std::string ext_help_checkpoint_format();
621 SST_CONFIG_DECLARE_OPTION(std::string, checkpoint_name_format,
"%p_%n_%t/%p_%n_%t",
622 std::bind(&Config::parse_checkpoint_name_format, std::placeholders::_1, std::placeholders::_2),
623 &Config::ext_help_checkpoint_format);
633 void merge_checkpoint_options(
Config& other);
642 int positionalCallback(
int num,
const std::string& arg);
647 std::string run_name;
648 bool first_rank_ =
false;
652 void insertOptions();
654 bool isFileNameOnly(
const std::string& name)
656 bool nameOnly =
true;
658 for (
size_t i = 0; i < name.size(); ++i ) {
659 if (
'/' == name[i] ) {
671 #endif // SST_CORE_CONFIG_H This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:42
Class to contain SST Simulation Configuration variables.
Definition: config.h:51
bool canInitiateCheckpoint()
Get whether or not any of the checkpoint options were turned on.
Definition: config.cc:658
Class to contain SST Simulation Configuration variables.
Definition: configShared.h:36
Definition: serializable.h:23
int checkArgsAfterParsing() override
Function that will be called at the end of parsing so that error checking can be done.
Definition: config.cc:632
int printUsage()
Called to print the help/usage message.
Definition: configBase.cc:275
int printExtHelp(const std::string &option)
Called to print the extended help for an option.
Definition: configBase.cc:388
std::string runMode_str() const
Get string version of runmode.
Definition: config.h:486
Main control class for a SST Simulation.
Definition: simulation_impl.h:122
void print()
Print to stdout the current configuration.
Definition: config.cc:287
Config()
Default constructor.
Definition: config.cc:336
int parseHelp(std::string arg)
Print extended help.
Definition: config.h:129
int parseUsage(std::string UNUSED(arg))
Level of verbosity to use in the core prints using Output.verbose or Output.debug.
Definition: config.h:122
Base class for Model Generation.
Definition: sstmodel.h:29
std::string getUsagePrelude() override
Called to get the prelude for the help/usage message.
Definition: config.cc:603
static int parseVersion(std::string UNUSED(arg))
Print version info.
Definition: config.h:140