36 #include <sys/types.h> 57 #include <lib/topology.h> 58 #include <lib/abm_layer.h> 70 OPT_SCHEDULER =
OPT_FIRST + PARAM_SCHEDULER,
71 OPT_CKTRM_MODE =
OPT_FIRST + PARAM_CKTRM_MODE,
72 OPT_LPS_DISTRIBUTION =
OPT_FIRST + PARAM_LPS_DISTRIBUTION,
75 OPT_STATE_SAVING =
OPT_FIRST + PARAM_STATE_SAVING,
76 OPT_SNAPSHOT =
OPT_FIRST + PARAM_SNAPSHOT,
88 OPT_DETERMINISTIC_SEED,
138 const char *argp_program_version = PACKAGE_STRING
"\nCopyright (C) 2008-2019 HPDCS Group";
139 const char *argp_program_bug_address = PACKAGE_BUGREPORT;
146 static char doc[] =
"ROOT-Sim - a fast distributed multithreaded Parallel Discrete Event Simulator \v For more information check the official wiki at https://github.com/HPDCS/ROOT-Sim/wiki";
149 static char args_doc[] =
"";
151 static const struct argp_option argp_options[] = {
152 {
"wt", OPT_NP,
"VALUE", 0,
"Number of total cores being used by the simulation", 0},
153 {
"lp", OPT_NPRC,
"VALUE", 0,
"Total number of Logical Processes being launched at simulation startup", 0},
154 {
"output-dir", OPT_OUTPUT_DIR,
"PATH", 0,
"Path to a folder where execution statistics are stored. If not present, it is created", 0},
155 {
"scheduler", OPT_SCHEDULER,
"TYPE", 0,
"LP Scheduling algorithm. Supported values are: stf", 0},
156 {
"npwd", OPT_NPWD, 0, 0,
"Non Piece-Wise-Deterministic simulation model. See manpage for accurate description", 0},
157 {
"p", OPT_P,
"VALUE", 0,
"Checkpointing interval", 0},
158 {
"full", OPT_FULL, 0, 0,
"Take only full logs", 0},
159 {
"inc", OPT_INC, 0, 0,
"Take only incremental logs (still to be released)", 0},
160 {
"A", OPT_A, 0, 0,
"Autonomic subsystem: set checkpointing interval and log mode automatically at runtime (still to be released)", 0},
161 {
"gvt", OPT_GVT,
"VALUE", 0,
"Time between two GVT reductions (in milliseconds)", 0},
162 {
"cktrm-mode", OPT_CKTRM_MODE,
"TYPE", 0,
"Termination Detection mode. Supported values: normal, incremental, accurate", 0},
163 {
"simulation-time", OPT_SIMULATION_TIME,
"VALUE", 0,
"Halt the simulation when all LPs reach this logical time. 0 means infinite", 0},
164 {
"lps-distribution", OPT_LPS_DISTRIBUTION,
"TYPE", 0,
"LPs distributions over simulation kernels policies. Supported values: block, circular", 0},
165 {
"deterministic-seed", OPT_DETERMINISTIC_SEED, 0, 0,
"Do not change the initial random seed for LPs. Enforces different deterministic simulation runs", 0},
166 {
"verbose", OPT_VERBOSE,
"TYPE", 0,
"Verbose execution", 0},
167 {
"stats", OPT_STATS,
"TYPE", 0,
"Level of detail in the output statistics", 0},
168 {
"seed", OPT_SEED,
"VALUE", 0,
"Manually specify the initial random seed", 0},
169 {
"serial", OPT_SERIAL, 0, 0,
"Run a serial simulation (using Calendar Queues)", 0},
170 {
"sequential", OPT_SERIAL, 0, OPTION_ALIAS, NULL, 0},
171 {
"no-core-binding", OPT_NO_CORE_BINDING, 0, 0,
"Disable the binding of threads to specific physical processing cores", 0},
172 {
"silent-output", OPT_SILENT, 0, 0,
"Disable any output generated by printf() calls (also from models)", 0},
173 {
"no-preemption", OPT_PREEMPTION, 0, 0,
"Disable Preemptive Time Warp", 0},
177 #define malformed_option_failure() argp_error(state, "invalid value \"%s\" in %s option.\nAborting!", arg, state->argv[state->next -1 -(arg != NULL)]) 179 #define conflicting_option_failure(msg) argp_error(state, "the requested option %s with value \"%s\" is conflicting: " msg "\nAborting!", state->argv[state->next -1 -(arg != NULL)], arg) 183 #define handle_string_option(label, var) \ 188 if(strcmp(arg, param_to_text[key - OPT_FIRST][__i]) == 0) { \ 192 if(!param_to_text[key - OPT_FIRST][++__i]) \ 193 malformed_option_failure(); \ 200 #define parse_ullong_limits(low, high) \ 202 unsigned long long int __value; \ 204 __value = strtoull(arg, &__endptr, 10); \ 205 if(!(*arg != '\0' && *__endptr == '\0' && (__value > low || __value == low) && __value <= high)) { \ 206 malformed_option_failure(); \ 211 static error_t parse_opt (
int key,
char *arg,
struct argp_state *state)
218 conflicting_option_failure(
"this option has already been specified");
225 if(strcmp(arg,
"auto") == 0) {
228 n_cores = parse_ullong_limits(1, UINT_MAX);
233 n_prc_tot = parse_ullong_limits(1, UINT_MAX);
249 conflicting_option_failure(
"I'm requested to run non piece-wise deterministically, but a checkpointing interval is set already.");
257 conflicting_option_failure(
"Copy State Saving is selected, but I'm requested to set a checkpointing interval.");
268 argp_failure(state, EXIT_FAILURE, ENOSYS,
"incremental state saving is not supported in stable version yet...\nAborting");
272 argp_failure(state, EXIT_FAILURE, ENOSYS,
"autonomic state saving is not supported in stable version yet...\nAborting");
279 case OPT_SIMULATION_TIME:
283 case OPT_DETERMINISTIC_SEED:
295 case OPT_NO_CORE_BINDING:
310 memset(scanned, 0,
sizeof(scanned));
331 case ARGP_KEY_SUCCESS:
335 rootsim_error(
true,
"Number of cores was not provided \"--wt\"\n");
338 rootsim_error(
true,
"Number of LPs was not provided \"--lp\"\n");
341 rootsim_error(
true,
"Demanding %u cores, which are more than available (%d)\n",
n_cores,
get_cores());
347 rootsim_error(
true,
"Too many LPs, maximum supported number is %u\n",
MAX_LPs);
350 rootsim_error(
true,
"Requested a simulation run with %u LPs and %u worker threads: the mapping is not possible\n",
n_prc_tot,
n_cores);
365 return ARGP_ERR_UNKNOWN;
370 #undef parse_ullong_limits 371 #undef handle_string_option 372 #undef conflicting_option_failure 373 #undef malformed_option_failure 375 static struct argp_child argp_child[2] = {
376 {0, 0,
"Model specific options", 0},
380 static struct argp argp = { argp_options, parse_opt, args_doc, doc, argp_child, 0, 0 };
398 rootsim_error(
true,
"Too many kernels, maximum supported number is %u\n",
MAX_KERNELS);
405 #ifdef HAVE_CROSS_STATE 410 argp_child[0].argp = &model_argp;
412 argp_parse (&argp, argc, argv, 0, NULL, NULL);
434 remote_memory_init();
474 case CAP_DETERMINISTIC_SEED:
478 case CAP_CORE_BINDING:
484 case CAP_LINUX_MODULES:
486 case CAP_LP_REBINDING:
487 #ifdef HAVE_LP_REBINDING 508 case CAP_SCHEDULER ... CAP_VERBOSE:
510 case CAP_SIMULATION_TIME:
513 rootsim_error(
false,
"Requesting information for an unknown capability\n");
519 info->capability = which;
528 case CAP_LPS_DISTRIBUTION:
534 case CAP_STATE_SAVING:
558 case CAP_SIMULATION_TIME:
562 rootsim_error(
false,
"Requesting information for an unknown capability\n");
uint64_t seed
The master seed to be used in this run.
void abm_layer_init(void)
#define bitmap_set(bitmap, bit_index)
This sets the bit with index bit_index of the bitmap bitmap.
int lps
Number of active logical processes.
seed_type set_seed
The master seed to be used in this run.
int check_termination_mode
Check termination strategy: standard or incremental.
char * output_dir
Destination Directory of output files.
int verbose
Kernel verbose.
Core ROOT-Sim functionalities.
void statistics_init(void)
ROOT-Sim header for model development.
unsigned int n_cores
Total number of cores required for simulation.
#define bitmap_required_size(requested_bits)
Computes the required size of a bitmap with requested_bits entries.
int verbose
Kernel verbose.
int ckpt_period
Number of events to execute before taking a snapshot in PSS (ignored otherwise)
void initialization_complete(void)
int checkpointing
Type of checkpointing scheme (e.g., PSS, CSS, ...)
#define MAX_THREADS_PER_KERNEL
void ParallelScheduleNewEvent(unsigned int gid_receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size)
Schedule a new message to some LP.
bool deterministic_seed
Does not change the seed value config file that will be read during the next runs.
int ckpt_period
Number of events to execute before taking a snapshot in PSS (ignored otherwise)
#define DEFAULT_OUTPUT_DIR
This macro specified the default output directory, if nothing is passed as an option.
_opt_codes
This is the list of mnemonics for arguments.
int scheduler
Which scheduler to be used.
The ROOT-Sim scheduler main module header.
int simulation_time
Wall-clock-time based termination predicate.
Generic thread management facilities.
Consistent and Committed Global State.
int stats
Produce performance statistic file (default STATS_ALL)
int gvt_time_period
Wall-Clock time to wait before executiong GVT operations.
int lps_distribution
Policy for the LP to Kernel mapping.
int scheduler
Which scheduler to be used.
simulation_configuration rootsim_config
This global variable holds the configuration for the current simulation.
void SystemInit(int argc, char **argv)
Memory Manager main header.
int ckpt_mode
Type of checkpointing mode (Synchronous, Semi-Asyncronous, ...)
capability_t
Capability enumeration.
bool silent_output
Disable any output generated by printf() calls.
int simulation_time
Wall-clock-time based termination predicate.
bool CapabilityAvailable(enum capability_t which, struct capability_info_t *info)
Query runtime capabilities while executing the model.
void mpi_init(int *argc, char ***argv)
Initialize MPI subsystem.
void(* ScheduleNewEvent)(unsigned int gid_receiver, simtime_t timestamp, unsigned int event_type, void *event_content, unsigned int event_size)
This is the function pointer to correctly set ScheduleNewEvent API version, depending if we're runnin...
#define get_cores()
Macro to get the core count on the hosting machine.
#define bitmap_check(bitmap, bit_index)
This checks if the bit with index bit_index of the bitmap bitmap is set or unset. ...
const char *const param_to_text[][5]
#define MAX_LPs
Maximum number of LPs the simulator will handle.
enum stats_levels stats
Produce performance statistic file (default STATS_ALL)
int lps_distribution
Policy for the LP to Kernel mapping.
const char * output_dir
Destination Directory of output files.
int snapshot
Type of snapshot (e.g., full, incremental, autonomic, ...)
void communication_init(void)
Initialize the communication subsystem.
int state_saving
Type of checkpointing mode (Synchronous, Semi-Asyncronous, ...)
bool core_binding
Bind threads to specific core (reduce context switches and cache misses)
Event & Cross State Synchornization.
int termination_mode
Check termination strategy: standard or incremental.
unsigned int n_prc_tot
Total number of logical processes running in the simulation.
int gvt_time_period
Wall-Clock time to wait before executiong GVT operations.
bool serial
If the simulation must be run serially.
unsigned char rootsim_bitmap
This defines a generic bitmap.
bool disable_preemption
If compiled for preemptive Time Warp, it can be disabled at runtime.
unsigned int n_ker
Total number of simulation kernel instances running.