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,
87 OPT_GVT_SNAPSHOT_CYCLES,
89 OPT_DETERMINISTIC_SEED,
94 #ifdef HAVE_PREEMPTION 141 const char *argp_program_version = PACKAGE_STRING
"\nCopyright (C) 2008-2019 HPDCS Group";
142 const char *argp_program_bug_address = PACKAGE_BUGREPORT;
149 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";
152 static char args_doc[] =
"";
154 static const struct argp_option argp_options[] = {
155 {
"wt", OPT_NP,
"VALUE", 0,
"Number of total cores being used by the simulation", 0},
156 {
"lp", OPT_NPRC,
"VALUE", 0,
"Total number of Logical Processes being launched at simulation startup", 0},
157 {
"output-dir", OPT_OUTPUT_DIR,
"PATH", 0,
"Path to a folder where execution statistics are stored. If not present, it is created", 0},
158 {
"scheduler", OPT_SCHEDULER,
"TYPE", 0,
"LP Scheduling algorithm. Supported values are: stf", 0},
159 {
"npwd", OPT_NPWD, 0, 0,
"Non Piece-Wise-Deterministic simulation model. See manpage for accurate description", 0},
160 {
"p", OPT_P,
"VALUE", 0,
"Checkpointing interval", 0},
161 {
"full", OPT_FULL, 0, 0,
"Take only full logs", 0},
162 {
"inc", OPT_INC, 0, 0,
"Take only incremental logs (still to be released)", 0},
163 {
"A", OPT_A, 0, 0,
"Autonomic subsystem: set checkpointing interval and log mode automatically at runtime (still to be released)", 0},
164 {
"gvt", OPT_GVT,
"VALUE", 0,
"Time between two GVT reductions (in milliseconds)", 0},
165 {
"cktrm-mode", OPT_CKTRM_MODE,
"TYPE", 0,
"Termination Detection mode. Supported values: normal, incremental, accurate", 0},
166 {
"gvt-snapshot-cycles", OPT_GVT_SNAPSHOT_CYCLES,
"VALUE", 0,
"Termination detection is invoked after this number of GVT reductions", 0},
167 {
"simulation-time", OPT_SIMULATION_TIME,
"VALUE", 0,
"Halt the simulation when all LPs reach this logical time. 0 means infinite", 0},
168 {
"lps-distribution", OPT_LPS_DISTRIBUTION,
"TYPE", 0,
"LPs distributions over simulation kernels policies. Supported values: block, circular", 0},
169 {
"deterministic-seed", OPT_DETERMINISTIC_SEED, 0, 0,
"Do not change the initial random seed for LPs. Enforces different deterministic simulation runs", 0},
170 {
"verbose", OPT_VERBOSE,
"TYPE", 0,
"Verbose execution", 0},
171 {
"stats", OPT_STATS,
"TYPE", 0,
"Level of detail in the output statistics", 0},
172 {
"seed", OPT_SEED,
"VALUE", 0,
"Manually specify the initial random seed", 0},
173 {
"serial", OPT_SERIAL, 0, 0,
"Run a serial simulation (using Calendar Queues)", 0},
174 {
"sequential", OPT_SERIAL, 0, OPTION_ALIAS, NULL, 0},
175 {
"no-core-binding", OPT_NO_CORE_BINDING, 0, 0,
"Disable the binding of threads to specific physical processing cores", 0},
177 #ifdef HAVE_PREEMPTION 178 {
"no-preemption", OPT_PREEMPTION, 0, 0,
"Disable Preemptive Time Warp", 0},
183 #define malformed_option_failure() argp_error(state, "invalid value \"%s\" in %s option.\nAborting!", arg, state->argv[state->next -1 -(arg != NULL)]) 185 #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) 189 #define handle_string_option(label, var) \ 194 if(strcmp(arg, param_to_text[key - OPT_FIRST][__i]) == 0) { \ 198 if(!param_to_text[key - OPT_FIRST][++__i]) \ 199 malformed_option_failure(); \ 206 #define parse_ullong_limits(low, high) \ 208 unsigned long long int __value; \ 210 __value = strtoull(arg, &__endptr, 10); \ 211 if(!(*arg != '\0' && *__endptr == '\0' && (__value > low || __value == low) && __value <= high)) { \ 212 malformed_option_failure(); \ 217 static error_t parse_opt (
int key,
char *arg,
struct argp_state *state)
224 conflicting_option_failure(
"this option has already been specified");
231 if(strcmp(arg,
"auto") == 0){
234 n_cores = parse_ullong_limits(1, UINT_MAX);
239 n_prc_tot = parse_ullong_limits(1, UINT_MAX);
255 conflicting_option_failure(
"I'm requested to run non piece-wise deterministically, but a checkpointing interval is set already.");
263 conflicting_option_failure(
"Copy State Saving is selected, but I'm requested to set a checkpointing interval.");
274 argp_failure(state, EXIT_FAILURE, ENOSYS,
"incremental state saving is not supported in stable version yet...\nAborting");
278 argp_failure(state, EXIT_FAILURE, ENOSYS,
"autonomic state saving is not supported in stable version yet...\nAborting");
285 case OPT_GVT_SNAPSHOT_CYCLES:
289 case OPT_SIMULATION_TIME:
293 case OPT_DETERMINISTIC_SEED:
305 case OPT_NO_CORE_BINDING:
309 #ifdef HAVE_PREEMPTION 318 memset(scanned, 0,
sizeof(scanned));
337 #ifdef HAVE_PREEMPTION 342 case ARGP_KEY_SUCCESS:
346 rootsim_error(
true,
"Number of cores was not provided \"--wt\"\n");
349 rootsim_error(
true,
"Number of LPs was not provided \"--lp\"\n");
352 rootsim_error(
true,
"Demanding %u cores, which are more than available (%d)\n",
n_cores,
get_cores());
358 rootsim_error(
true,
"Too many LPs, maximum supported number is %u\n",
MAX_LPs);
361 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);
375 return ARGP_ERR_UNKNOWN;
380 #undef parse_ullong_limits 381 #undef handle_string_option 382 #undef conflicting_option_failure 383 #undef malformed_option_failure 385 static struct argp_child argp_child[2] = {
386 {0, 0,
"Model specific options", 0},
390 static struct argp argp = { argp_options, parse_opt, args_doc, doc, argp_child, 0, 0 };
407 rootsim_error(
true,
"Too many kernels, maximum supported number is %u\n",
MAX_KERNELS);
414 #ifdef HAVE_CROSS_STATE 419 argp_child[0].argp = &model_argp;
421 argp_parse (&argp, argc, argv, 0, NULL, NULL);
443 remote_memory_init();
void abm_layer_init(void)
#define bitmap_set(bitmap, bit_index)
This sets the bit with index bit_index of the bitmap bitmap.
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 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.
#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.
The ROOT-Sim scheduler main module header.
Generic thread management facilities.
Consistent and Committed Global State.
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 simulation_time
Wall-clock-time based termination predicate.
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.
int snapshot
Type of snapshot (e.g., full, incremental, autonomic, ...)
void communication_init(void)
Initialize the communication subsystem.
bool core_binding
Bind threads to specific core (reduce context switches and cache misses)
Event & Cross State Synchornization.
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.
int gvt_snapshot_cycles
GVT operations to be executed before rebuilding the state.