1 /* Copyright (c) 2009-2010, 2012-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 /* sg_config: configuration infrastructure for the simulation world */
10 #include "xbt/config.h"
12 #include "xbt/mallocator.h"
15 #include "xbt/sysdep.h"
16 #include "surf/surf.h"
17 #include "surf/maxmin.h"
18 #include "instr/instr_interface.h"
19 #include "simgrid/simix.h"
20 #include "simgrid/sg_config.h"
21 #include "simgrid_config.h" /* what was compiled in? */
23 #include "smpi/smpi_interface.h"
26 #include "src/mc/mc_record.h"
27 #include "simgrid/instr.h"
28 #include "src/mc/mc_replay.h"
30 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf,
31 "About the configuration of SimGrid");
33 xbt_cfg_t _sg_cfg_set = NULL;
35 /* 0: beginning of time (config cannot be changed yet);
36 * 1: initialized: cfg_set created (config can now be changed);
37 * 2: configured: command line parsed and config part of platform file was
38 * integrated also, platform construction ongoing or done.
39 * (Config cannot be changed anymore!)
41 int _sg_cfg_init_status = 0;
43 /* instruct the upper layer (simix or simdag) to exit as soon as possible */
44 int _sg_cfg_exit_asap = 0;
46 #define sg_cfg_exit_early() do { _sg_cfg_exit_asap = 1; return; } while (0)
48 /* Parse the command line, looking for options */
49 static void sg_config_cmd_line(int *argc, char **argv)
55 for (j = i = 1; i < *argc; i++) {
56 if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
57 opt = strchr(argv[i], '=');
60 xbt_cfg_set_parse(_sg_cfg_set, opt);
61 XBT_DEBUG("Did apply '%s' as config setting", opt);
62 } else if (!strcmp(argv[i], "--version")) {
63 printf("%s\n", SIMGRID_VERSION_STRING);
65 } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) {
66 printf("Description of the configuration accepted by this simulator:\n");
67 xbt_cfg_help(_sg_cfg_set);
70 "Each of these configurations can be used by adding\n"
71 " --cfg=<option name>:<option value>\n"
72 "to the command line.\n"
74 "For more information, please refer to:\n"
75 " --help-aliases for the list of all option aliases.\n"
76 " --help-logs and --help-log-categories for the details of logging output.\n"
77 " --help-models for a list of all models known by this simulator.\n"
78 " --help-tracing for the details of all tracing options known by this simulator.\n"
79 " --version to get SimGrid version information.\n"
83 } else if (!strcmp(argv[i], "--help-aliases")) {
84 printf("Here is a list of all deprecated option names, with their replacement.\n");
85 xbt_cfg_aliases(_sg_cfg_set);
86 printf("Please consider using the recent names\n");
88 } else if (!strcmp(argv[i], "--help-models")) {
91 model_help("host", surf_host_model_description);
93 model_help("CPU", surf_cpu_model_description);
95 model_help("network", surf_network_model_description);
96 printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
97 for (k = 0; surf_optimization_mode_description[k].name; k++)
99 surf_optimization_mode_description[k].name,
100 surf_optimization_mode_description[k].description);
101 printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
103 } else if (!strcmp(argv[i], "--help-tracing")) {
118 /* callback of the plugin variable */
119 static void _sg_cfg_cb__plugin(const char *name, int pos)
124 xbt_assert(_sg_cfg_init_status < 2,
125 "Cannot load a plugin after the initialization");
127 val = xbt_cfg_get_string(_sg_cfg_set, name);
129 if (!strcmp(val, "help")) {
130 model_help("plugin", surf_plugin_description);
134 /* New Module missing */
135 int plugin_id = find_model_description(surf_plugin_description, val);
136 surf_plugin_description[plugin_id].model_init_preparse();
139 /* callback of the host/model variable */
140 static void _sg_cfg_cb__host_model(const char *name, int pos)
144 xbt_assert(_sg_cfg_init_status < 2,
145 "Cannot change the model after the initialization");
147 val = xbt_cfg_get_string(_sg_cfg_set, name);
149 if (!strcmp(val, "help")) {
150 model_help("host", surf_host_model_description);
154 /* Make sure that the model exists */
155 find_model_description(surf_host_model_description, val);
158 /* callback of the vm/model variable */
159 static void _sg_cfg_cb__vm_model(const char *name, int pos)
163 xbt_assert(_sg_cfg_init_status < 2,
164 "Cannot change the model after the initialization");
166 val = xbt_cfg_get_string(_sg_cfg_set, name);
168 if (!strcmp(val, "help")) {
169 model_help("vm", surf_vm_model_description);
173 /* Make sure that the model exists */
174 find_model_description(surf_vm_model_description, val);
177 /* callback of the cpu/model variable */
178 static void _sg_cfg_cb__cpu_model(const char *name, int pos)
182 xbt_assert(_sg_cfg_init_status < 2,
183 "Cannot change the model after the initialization");
185 val = xbt_cfg_get_string(_sg_cfg_set, name);
187 if (!strcmp(val, "help")) {
188 model_help("CPU", surf_cpu_model_description);
192 /* New Module missing */
193 find_model_description(surf_cpu_model_description, val);
196 /* callback of the cpu/model variable */
197 static void _sg_cfg_cb__optimization_mode(const char *name, int pos)
201 xbt_assert(_sg_cfg_init_status < 2,
202 "Cannot change the model after the initialization");
204 val = xbt_cfg_get_string(_sg_cfg_set, name);
206 if (!strcmp(val, "help")) {
207 model_help("optimization", surf_optimization_mode_description);
211 /* New Module missing */
212 find_model_description(surf_optimization_mode_description, val);
215 /* callback of the cpu/model variable */
216 static void _sg_cfg_cb__storage_mode(const char *name, int pos)
220 xbt_assert(_sg_cfg_init_status < 2,
221 "Cannot change the model after the initialization");
223 val = xbt_cfg_get_string(_sg_cfg_set, name);
225 if (!strcmp(val, "help")) {
226 model_help("storage", surf_storage_model_description);
230 /* New Module missing */
231 find_model_description(surf_storage_model_description, val);
234 /* callback of the network_model variable */
235 static void _sg_cfg_cb__network_model(const char *name, int pos)
239 xbt_assert(_sg_cfg_init_status < 2,
240 "Cannot change the model after the initialization");
242 val = xbt_cfg_get_string(_sg_cfg_set, name);
244 if (!strcmp(val, "help")) {
245 model_help("network", surf_network_model_description);
249 /* New Module missing */
250 find_model_description(surf_network_model_description, val);
253 /* callbacks of the network models values */
254 static void _sg_cfg_cb__tcp_gamma(const char *name, int pos)
256 sg_tcp_gamma = xbt_cfg_get_double(_sg_cfg_set, name);
259 static void _sg_cfg_cb__maxmin_precision(const char* name, int pos)
261 sg_maxmin_precision = xbt_cfg_get_double(_sg_cfg_set, name);
264 static void _sg_cfg_cb__surf_precision(const char* name, int pos)
266 sg_surf_precision = xbt_cfg_get_double(_sg_cfg_set, name);
269 static void _sg_cfg_cb__sender_gap(const char* name, int pos)
271 sg_sender_gap = xbt_cfg_get_double(_sg_cfg_set, name);
274 static void _sg_cfg_cb__latency_factor(const char *name, int pos)
276 sg_latency_factor = xbt_cfg_get_double(_sg_cfg_set, name);
279 static void _sg_cfg_cb__bandwidth_factor(const char *name, int pos)
281 sg_bandwidth_factor = xbt_cfg_get_double(_sg_cfg_set, name);
284 static void _sg_cfg_cb__weight_S(const char *name, int pos)
286 sg_weight_S_parameter = xbt_cfg_get_double(_sg_cfg_set, name);
290 /* callback of the mpi collectives */
291 static void _sg_cfg_cb__coll(const char *category,
292 s_mpi_coll_description_t * table,
293 const char *name, int pos)
297 xbt_assert(_sg_cfg_init_status < 2,
298 "Cannot change the model after the initialization");
300 val = xbt_cfg_get_string(_sg_cfg_set, name);
302 if (!strcmp(val, "help")) {
303 coll_help(category, table);
307 /* New Module missing */
308 find_coll_description(table, val, category);
310 static void _sg_cfg_cb__coll_gather(const char *name, int pos){
311 _sg_cfg_cb__coll("gather", mpi_coll_gather_description, name, pos);
313 static void _sg_cfg_cb__coll_allgather(const char *name, int pos){
314 _sg_cfg_cb__coll("allgather", mpi_coll_allgather_description, name, pos);
316 static void _sg_cfg_cb__coll_allgatherv(const char *name, int pos){
317 _sg_cfg_cb__coll("allgatherv", mpi_coll_allgatherv_description, name, pos);
319 static void _sg_cfg_cb__coll_allreduce(const char *name, int pos)
321 _sg_cfg_cb__coll("allreduce", mpi_coll_allreduce_description, name, pos);
323 static void _sg_cfg_cb__coll_alltoall(const char *name, int pos)
325 _sg_cfg_cb__coll("alltoall", mpi_coll_alltoall_description, name, pos);
327 static void _sg_cfg_cb__coll_alltoallv(const char *name, int pos)
329 _sg_cfg_cb__coll("alltoallv", mpi_coll_alltoallv_description, name, pos);
331 static void _sg_cfg_cb__coll_bcast(const char *name, int pos)
333 _sg_cfg_cb__coll("bcast", mpi_coll_bcast_description, name, pos);
335 static void _sg_cfg_cb__coll_reduce(const char *name, int pos)
337 _sg_cfg_cb__coll("reduce", mpi_coll_reduce_description, name, pos);
339 static void _sg_cfg_cb__coll_reduce_scatter(const char *name, int pos){
340 _sg_cfg_cb__coll("reduce_scatter", mpi_coll_reduce_scatter_description, name, pos);
342 static void _sg_cfg_cb__coll_scatter(const char *name, int pos){
343 _sg_cfg_cb__coll("scatter", mpi_coll_scatter_description, name, pos);
345 static void _sg_cfg_cb__coll_barrier(const char *name, int pos){
346 _sg_cfg_cb__coll("barrier", mpi_coll_barrier_description, name, pos);
349 static void _sg_cfg_cb__wtime_sleep(const char *name, int pos){
350 smpi_wtime_sleep = xbt_cfg_get_double(_sg_cfg_set, name);
353 static void _sg_cfg_cb__iprobe_sleep(const char *name, int pos){
354 smpi_iprobe_sleep = xbt_cfg_get_double(_sg_cfg_set, name);
357 static void _sg_cfg_cb__test_sleep(const char *name, int pos){
358 smpi_test_sleep = xbt_cfg_get_double(_sg_cfg_set, name);
365 /* callback of the inclusion path */
366 static void _sg_cfg_cb__surf_path(const char *name, int pos)
368 char *path = xbt_strdup(xbt_cfg_get_string_at(_sg_cfg_set, name, pos));
369 xbt_dynar_push(surf_path, &path);
372 /* callback to decide if we want to use the model-checking */
373 #include "src/xbt_modinter.h"
376 extern int _sg_do_model_check; /* this variable lives in xbt_main until I find a right location for it */
377 extern int _sg_do_model_check_record;
380 static void _sg_cfg_cb_model_check_replay(const char *name, int pos) {
381 MC_record_path = xbt_cfg_get_string(_sg_cfg_set, name);
385 static void _sg_cfg_cb_model_check_record(const char *name, int pos) {
386 _sg_do_model_check_record = xbt_cfg_get_boolean(_sg_cfg_set, name);
390 extern int _sg_do_verbose_exit;
392 static void _sg_cfg_cb_verbose_exit(const char *name, int pos)
394 _sg_do_verbose_exit = xbt_cfg_get_boolean(_sg_cfg_set, name);
397 extern int _sg_do_clean_atexit;
399 static void _sg_cfg_cb_clean_atexit(const char *name, int pos)
401 _sg_do_clean_atexit = xbt_cfg_get_boolean(_sg_cfg_set, name);
404 static void _sg_cfg_cb_context_factory(const char *name, int pos)
406 smx_context_factory_name = xbt_cfg_get_string(_sg_cfg_set, name);
409 static void _sg_cfg_cb_context_stack_size(const char *name, int pos)
411 smx_context_stack_size_was_set = 1;
412 smx_context_stack_size = xbt_cfg_get_int(_sg_cfg_set, name) * 1024;
415 static void _sg_cfg_cb_context_guard_size(const char *name, int pos)
417 smx_context_guard_size_was_set = 1;
418 smx_context_guard_size = xbt_cfg_get_int(_sg_cfg_set, name) * xbt_pagesize;
421 static void _sg_cfg_cb_contexts_nthreads(const char *name, int pos)
423 SIMIX_context_set_nthreads(xbt_cfg_get_int(_sg_cfg_set, name));
426 static void _sg_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
428 SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_sg_cfg_set, name));
431 static void _sg_cfg_cb_contexts_parallel_mode(const char *name, int pos)
433 const char* mode_name = xbt_cfg_get_string(_sg_cfg_set, name);
434 if (!strcmp(mode_name, "posix")) {
435 SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
437 else if (!strcmp(mode_name, "futex")) {
438 SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
440 else if (!strcmp(mode_name, "busy_wait")) {
441 SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
444 xbt_die("Command line setting of the parallel synchronization mode should "
445 "be one of \"posix\", \"futex\" or \"busy_wait\"");
449 static void _sg_cfg_cb__surf_network_coordinates(const char *name,
452 static int already_set = 0;
453 int val = xbt_cfg_get_boolean(_sg_cfg_set, name);
456 COORD_HOST_LEVEL = sg_host_extension_create(xbt_dynar_free_voidp);
457 COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
462 xbt_die("Setting of whether to use coordinate cannot be disabled once set.");
465 static void _sg_cfg_cb__surf_network_crosstraffic(const char *name,
468 sg_network_crosstraffic = xbt_cfg_get_boolean(_sg_cfg_set, name);
471 /* build description line with possible values */
472 static void describe_model(char *result,
473 const s_surf_model_description_t model_description[],
475 const char *description)
478 sprintf(result, "%s. Possible values: %s", description,
479 model_description[0].name ? model_description[0].name : "n/a");
481 for (i = 1; model_description[i].name; i++)
482 p += sprintf(p, ", %s", model_description[i].name);
484 ".\n (use 'help' as a value to see the long description of each %s)",
488 /* create the config set, register what should be and parse the command line*/
489 void sg_config_init(int *argc, char **argv)
491 char description[1024];
493 /* Create the configuration support */
494 if (_sg_cfg_init_status == 0) { /* Only create stuff if not already inited */
496 /* Plugins configuration */
497 describe_model(description, surf_plugin_description,
498 "plugin", "The plugins");
499 xbt_cfg_register(&_sg_cfg_set, "plugin", description,
500 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__plugin);
502 describe_model(description, surf_cpu_model_description, "model", "The model to use for the CPU");
503 xbt_cfg_register(&_sg_cfg_set, "cpu/model", description, xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__cpu_model);
504 xbt_cfg_setdefault_string(_sg_cfg_set, "cpu/model", "Cas01");
506 describe_model(description, surf_optimization_mode_description, "optimization mode", "The optimization modes to use for the CPU");
507 xbt_cfg_register(&_sg_cfg_set, "cpu/optim", description, xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__optimization_mode);
508 xbt_cfg_setdefault_string(_sg_cfg_set, "cpu/optim", "Lazy");
510 describe_model(description, surf_storage_model_description, "model", "The model to use for the storage");
511 xbt_cfg_register(&_sg_cfg_set, "storage/model", description, xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__storage_mode);
512 xbt_cfg_setdefault_string(_sg_cfg_set, "storage/model", "default");
514 describe_model(description, surf_network_model_description, "model", "The model to use for the network");
515 xbt_cfg_register(&_sg_cfg_set, "network/model", description, xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__network_model);
516 xbt_cfg_setdefault_string(_sg_cfg_set, "network/model", "LV08");
518 describe_model(description, surf_optimization_mode_description, "optimization mode", "The optimization modes to use for the network");
519 xbt_cfg_register(&_sg_cfg_set, "network/optim", description, xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__optimization_mode);
520 xbt_cfg_setdefault_string(_sg_cfg_set, "network/optim", "Lazy");
522 describe_model(description, surf_host_model_description, "model", "The model to use for the host");
523 xbt_cfg_register(&_sg_cfg_set, "host/model", description, xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__host_model);
524 xbt_cfg_setdefault_string(_sg_cfg_set, "host/model", "default");
526 describe_model(description, surf_vm_model_description, "model", "The model to use for the vm");
527 xbt_cfg_register(&_sg_cfg_set, "vm/model", description, xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__vm_model);
528 xbt_cfg_setdefault_string(_sg_cfg_set, "vm/model", "default");
530 xbt_cfg_register(&_sg_cfg_set, "network/TCP_gamma",
531 "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; Use the last given value, which is the max window size)",
532 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__tcp_gamma);
533 xbt_cfg_setdefault_double(_sg_cfg_set, "network/TCP_gamma", 4194304.0);
535 xbt_cfg_register(&_sg_cfg_set, "surf/precision", "Numerical precision used when updating simulation times (in seconds)",
536 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__surf_precision);
537 xbt_cfg_setdefault_double(_sg_cfg_set, "surf/precision", 0.00001);
539 xbt_cfg_register(&_sg_cfg_set, "maxmin/precision",
540 "Numerical precision used when computing resource sharing (in ops/sec or bytes/sec)",
541 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__maxmin_precision);
542 xbt_cfg_setdefault_double(_sg_cfg_set, "maxmin/precision", 0.00001);
544 /* The parameters of network models */
546 xbt_cfg_register(&_sg_cfg_set, "network/sender_gap", "Minimum gap between two overlapping sends",
547 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__sender_gap);
548 /* real default for "network/sender_gap" is set in network_smpi.cpp */
549 xbt_cfg_setdefault_double(_sg_cfg_set, "network/sender_gap", NAN);
551 xbt_cfg_register(&_sg_cfg_set, "network/latency_factor",
552 "Correction factor to apply to the provided latency (default value set by network model)",
553 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__latency_factor);
554 xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0);
556 xbt_cfg_register(&_sg_cfg_set, "network/bandwidth_factor",
557 "Correction factor to apply to the provided bandwidth (default value set by network model)",
558 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__bandwidth_factor);
559 xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 1.0);
561 xbt_cfg_register(&_sg_cfg_set, "network/weight_S",
562 "Correction factor to apply to the weight of competing streams (default value set by network model)",
563 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__weight_S);
564 /* real default for "network/weight_S" is set in network_*.cpp */
565 xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", NAN);
568 xbt_cfg_register(&_sg_cfg_set, "path",
569 "Lookup path for inclusions in platform and deployment XML files",
570 xbt_cfgelm_string, 1, 0, _sg_cfg_cb__surf_path);
572 xbt_cfg_register(&_sg_cfg_set, "cpu/maxmin_selective_update",
573 "Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)",
574 xbt_cfgelm_boolean, 1, 1, NULL);
575 xbt_cfg_setdefault_boolean(_sg_cfg_set, "cpu/maxmin_selective_update", "no");
577 xbt_cfg_register(&_sg_cfg_set, "network/maxmin_selective_update",
578 "Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)",
579 xbt_cfgelm_boolean, 1, 1, NULL);
580 xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/maxmin_selective_update", "no");
582 /* Replay (this part is enabled even if MC it disabled) */
583 xbt_cfg_register(&_sg_cfg_set, "model-check/replay",
584 "Enable replay mode with the given path", xbt_cfgelm_string, 0, 1, _sg_cfg_cb_model_check_replay);
587 /* do model-checking-record */
588 xbt_cfg_register(&_sg_cfg_set, "model-check/record",
589 "Record the model-checking paths",
590 xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_model_check_record);
591 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/record", "no");
593 /* do stateful model-checking */
594 xbt_cfg_register(&_sg_cfg_set, "model-check/checkpoint",
595 "Specify the amount of steps between checkpoints during stateful model-checking (default: 0 => stateless verification). "
596 "If value=1, one checkpoint is saved for each step => faster verification, but huge memory consumption; higher values are good compromises between speed and memory consumption.",
597 xbt_cfgelm_int, 1, 1, _mc_cfg_cb_checkpoint);
598 xbt_cfg_setdefault_int(_sg_cfg_set, "model-check/checkpoint", 0);
600 /* do stateful model-checking */
601 xbt_cfg_register(&_sg_cfg_set, "model-check/sparse_checkpoint",
602 "Use sparse per-page snapshots.",
603 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_sparse_checkpoint);
604 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/sparse_checkpoint", "no");
606 /* do stateful model-checking */
607 xbt_cfg_register(&_sg_cfg_set, "model-check/soft-dirty",
608 "Use sparse per-page snapshots.",
609 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_soft_dirty);
610 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/soft-dirty", "no");
612 xbt_cfg_register(&_sg_cfg_set, "model-check/ksm",
613 "Kernel same-page merging",
614 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_ksm);
615 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/ksm", "no");
617 /* do liveness model-checking */
618 xbt_cfg_register(&_sg_cfg_set, "model-check/property",
619 "Specify the name of the file containing the property. It must be the result of the ltl2ba program.",
620 xbt_cfgelm_string, 1, 1, _mc_cfg_cb_property);
621 xbt_cfg_setdefault_string(_sg_cfg_set, "model-check/property", "");
623 /* do communications determinism model-checking */
624 xbt_cfg_register(&_sg_cfg_set, "model-check/communications_determinism",
625 "Enable/disable the detection of determinism in the communications schemes",
626 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_comms_determinism);
627 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/communications_determinism", "no");
629 /* do send determinism model-checking */
630 xbt_cfg_register(&_sg_cfg_set, "model-check/send_determinism",
631 "Enable/disable the detection of send-determinism in the communications schemes",
632 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_send_determinism);
633 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/send_determinism", "no");
635 /* Specify the kind of model-checking reduction */
636 xbt_cfg_register(&_sg_cfg_set, "model-check/reduction",
637 "Specify the kind of exploration reduction (either none or DPOR)",
638 xbt_cfgelm_string, 1, 1, _mc_cfg_cb_reduce);
639 xbt_cfg_setdefault_string(_sg_cfg_set, "model-check/reduction", "dpor");
641 /* Enable/disable timeout for wait requests with model-checking */
642 xbt_cfg_register(&_sg_cfg_set, "model-check/timeout",
643 "Enable/Disable timeout for wait requests",
644 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_timeout);
645 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/timeout", "no");
647 /* Enable/disable global hash computation with model-checking */
648 xbt_cfg_register(&_sg_cfg_set, "model-check/hash",
649 "Enable/Disable state hash for state comparison (experimental)",
650 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_hash);
651 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/hash", "no");
653 /* Set max depth exploration */
654 /* Currently, this option cannot be used. */
655 xbt_cfg_register(&_sg_cfg_set, "model-check/snapshot_fds",
656 "Whether file descriptors must be snapshoted",
657 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_snapshot_fds);
658 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/snapshot_fds", "no");
660 /* Set max depth exploration */
661 xbt_cfg_register(&_sg_cfg_set, "model-check/max_depth",
662 "Specify the max depth of exploration (default : 1000)",
663 xbt_cfgelm_int, 1, 1, _mc_cfg_cb_max_depth);
664 xbt_cfg_setdefault_int(_sg_cfg_set, "model-check/max_depth", 1000);
666 /* Set number of visited state stored for state comparison reduction*/
667 xbt_cfg_register(&_sg_cfg_set, "model-check/visited",
668 "Specify the number of visited state stored for state comparison reduction. If value=5, the last 5 visited states are stored",
669 xbt_cfgelm_int, 1, 1, _mc_cfg_cb_visited);
670 xbt_cfg_setdefault_int(_sg_cfg_set, "model-check/visited", 0);
672 /* Set file name for dot output of graph state */
673 xbt_cfg_register(&_sg_cfg_set, "model-check/dot_output",
674 "Specify the name of dot file corresponding to graph state",
675 xbt_cfgelm_string, 1, 1, _mc_cfg_cb_dot_output);
676 xbt_cfg_setdefault_string(_sg_cfg_set, "model-check/dot_output", "");
678 /* Enable/disable non progressive cycles detection with model-checking */
679 xbt_cfg_register(&_sg_cfg_set, "model-check/termination",
680 "Enable/Disable non progressive cycle detection",
681 xbt_cfgelm_boolean, 1, 1, _mc_cfg_cb_termination);
682 xbt_cfg_setdefault_boolean(_sg_cfg_set, "model-check/termination", "no");
685 /* do verbose-exit */
686 xbt_cfg_register(&_sg_cfg_set, "verbose-exit",
687 "Activate the \"do nothing\" mode in Ctrl-C",
688 xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_verbose_exit);
689 xbt_cfg_setdefault_boolean(_sg_cfg_set, "verbose-exit", "yes");
691 /* context factory */
692 const char *dflt_ctx_fact = "thread";
694 char *p = description +
696 "Context factory to use in SIMIX. Possible values: %s",
698 #if HAVE_UCONTEXT_CONTEXTS
699 dflt_ctx_fact = "ucontext";
700 p += sprintf(p, ", %s", dflt_ctx_fact);
702 #if HAVE_RAW_CONTEXTS
703 dflt_ctx_fact = "raw";
704 p += sprintf(p, ", %s", dflt_ctx_fact);
708 xbt_cfg_register(&_sg_cfg_set, "contexts/factory", description,
709 xbt_cfgelm_string, 1, 1, _sg_cfg_cb_context_factory);
710 xbt_cfg_setdefault_string(_sg_cfg_set, "contexts/factory", dflt_ctx_fact);
712 /* stack size of contexts in KiB */
713 xbt_cfg_register(&_sg_cfg_set, "contexts/stack_size",
714 "Stack size of contexts in KiB",
715 xbt_cfgelm_int, 1, 1, _sg_cfg_cb_context_stack_size);
716 xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/stack_size", 8*1024);
717 /* No, it was not set yet (the above setdefault() changed this to 1). */
718 smx_context_stack_size_was_set = 0;
720 /* guard size for contexts stacks in memory pages */
721 xbt_cfg_register(&_sg_cfg_set, "contexts/guard_size",
722 "Guard size for contexts stacks in memory pages",
723 xbt_cfgelm_int, 1, 1, _sg_cfg_cb_context_guard_size);
724 #if defined(_WIN32) || (PTH_STACKGROWTH != -1)
725 xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/guard_size", 0);
727 xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/guard_size", 1);
729 /* No, it was not set yet (the above setdefault() changed this to 1). */
730 smx_context_guard_size_was_set = 0;
732 /* number of parallel threads for user processes */
733 xbt_cfg_register(&_sg_cfg_set, "contexts/nthreads",
734 "Number of parallel threads used to execute user contexts",
735 xbt_cfgelm_int, 1, 1, _sg_cfg_cb_contexts_nthreads);
736 xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/nthreads", 1);
738 /* minimal number of user contexts to be run in parallel */
739 xbt_cfg_register(&_sg_cfg_set, "contexts/parallel_threshold",
740 "Minimal number of user contexts to be run in parallel (raw contexts only)",
741 xbt_cfgelm_int, 1, 1, _sg_cfg_cb_contexts_parallel_threshold);
742 xbt_cfg_setdefault_int(_sg_cfg_set, "contexts/parallel_threshold", 2);
744 /* synchronization mode for parallel user contexts */
745 xbt_cfg_register(&_sg_cfg_set, "contexts/synchro",
746 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
747 xbt_cfgelm_string, 1, 1, _sg_cfg_cb_contexts_parallel_mode);
749 xbt_cfg_setdefault_string(_sg_cfg_set, "contexts/synchro", "futex");
750 #else //No futex on mac and posix is unimplememted yet
751 xbt_cfg_setdefault_string(_sg_cfg_set, "contexts/synchro", "busy_wait");
754 xbt_cfg_register(&_sg_cfg_set, "network/coordinates",
755 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
756 xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb__surf_network_coordinates);
757 xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/coordinates", "no");
759 xbt_cfg_register(&_sg_cfg_set, "network/crosstraffic",
760 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
761 xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb__surf_network_crosstraffic);
762 xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", "no");
765 xbt_cfg_register(&_sg_cfg_set, "ns3/TcpModel",
766 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
767 xbt_cfgelm_string, 1, 1, NULL);
768 xbt_cfg_setdefault_string(_sg_cfg_set, "ns3/TcpModel", "default");
771 //For smpi/bw_factor and smpi/lat_factor
772 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
773 //test is if( size >= thresholdN ) return valueN;
774 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
775 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
776 // SMPI model can be used without enable_smpi, so keep this out of the ifdef.
777 xbt_cfg_register(&_sg_cfg_set, "smpi/bw_factor",
778 "Bandwidth factors for smpi.",
779 xbt_cfgelm_string, 1, 1, NULL);
780 xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/bw_factor", "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;1426:0.608902;732:0.341987;257:0.338112;0:0.812084");
782 xbt_cfg_register(&_sg_cfg_set, "smpi/lat_factor",
783 "Latency factors for smpi.",
784 xbt_cfgelm_string, 1, 1, NULL);
785 xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/lat_factor", "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;1426:1.61075;732:1.9503;257:1.95341;0:2.01467");
787 xbt_cfg_register(&_sg_cfg_set, "smpi/IB_penalty_factors",
788 "Correction factor to communications using Infiniband model with contention (default value based on Stampede cluster profiling)",
789 xbt_cfgelm_string, 1, 1, NULL);
790 xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/IB_penalty_factors", "0.965;0.925;1.35");
793 xbt_cfg_register(&_sg_cfg_set, "smpi/running_power",
794 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
795 xbt_cfgelm_double, 1, 1, NULL);
796 xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/running_power", 20000.0);
798 xbt_cfg_register(&_sg_cfg_set, "smpi/display_timing",
799 "Boolean indicating whether we should display the timing after simulation.",
800 xbt_cfgelm_boolean, 1, 1, NULL);
801 xbt_cfg_setdefault_boolean(_sg_cfg_set, "smpi/display_timing", "no");
803 xbt_cfg_register(&_sg_cfg_set, "smpi/simulate_computation",
804 "Boolean indicating whether the computational part of the simulated application should be simulated.",
805 xbt_cfgelm_boolean, 1, 1, NULL);
806 xbt_cfg_setdefault_boolean(_sg_cfg_set, "smpi/simulate_computation", "yes");
808 xbt_cfg_register(&_sg_cfg_set, "smpi/use_shared_malloc",
809 "Boolean indicating whether we should use shared memory when using SMPI_SHARED_MALLOC. Allows user to disable it for debug purposes.",
810 xbt_cfgelm_boolean, 1, 1, NULL);
811 xbt_cfg_setdefault_boolean(_sg_cfg_set, "smpi/use_shared_malloc", "yes");
813 xbt_cfg_register(&_sg_cfg_set, "smpi/cpu_threshold",
814 "Minimal computation time (in seconds) not discarded, or -1 for infinity.",
815 xbt_cfgelm_double, 1, 1, NULL);
816 xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/cpu_threshold", 1e-6);
818 xbt_cfg_register(&_sg_cfg_set, "smpi/async_small_thresh",
819 "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver",
820 xbt_cfgelm_int, 1, 1, NULL);
821 xbt_cfg_setdefault_int(_sg_cfg_set, "smpi/async_small_thresh", 0);
823 xbt_cfg_register(&_sg_cfg_set, "smpi/send_is_detached_thresh",
824 "Threshold of message size where MPI_Send stops behaving like MPI_Isend and becomes MPI_Ssend",
825 xbt_cfgelm_int, 1, 1, NULL);
826 xbt_cfg_setdefault_int(_sg_cfg_set, "smpi/send_is_detached_thresh", 65536);
828 xbt_cfg_register(&_sg_cfg_set, "smpi/privatize_global_variables",
829 "Boolean indicating whether we should privatize global variable at runtime.",
830 xbt_cfgelm_boolean, 1, 1, NULL);
831 xbt_cfg_setdefault_boolean(_sg_cfg_set, "smpi/privatize_global_variables", "no");
833 xbt_cfg_register(&_sg_cfg_set, "smpi/os",
834 "Small messages timings (MPI_Send minimum time for small messages)",
835 xbt_cfgelm_string, 1, 1, NULL);
836 xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/os", "1:0:0:0:0");
838 xbt_cfg_register(&_sg_cfg_set, "smpi/ois",
839 "Small messages timings (MPI_Isend minimum time for small messages)",
840 xbt_cfgelm_string, 1, 1, NULL);
841 xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/ois", "1:0:0:0:0");
843 xbt_cfg_register(&_sg_cfg_set, "smpi/or",
844 "Small messages timings (MPI_Recv minimum time for small messages)",
845 xbt_cfgelm_string, 1, 1, NULL);
846 xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/or", "1:0:0:0:0");
848 xbt_cfg_register(&_sg_cfg_set, "smpi/iprobe",
849 "Minimum time to inject inside a call to MPI_Iprobe",
850 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__iprobe_sleep);
851 xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/iprobe", 1e-4);
853 xbt_cfg_register(&_sg_cfg_set, "smpi/test",
854 "Minimum time to inject inside a call to MPI_Test",
855 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__test_sleep);
856 xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/test", 1e-4);
858 xbt_cfg_register(&_sg_cfg_set, "smpi/wtime",
859 "Minimum time to inject inside a call to MPI_Wtime",
860 xbt_cfgelm_double, 1, 1, _sg_cfg_cb__wtime_sleep);
861 xbt_cfg_setdefault_double(_sg_cfg_set, "smpi/wtime", 0.0);
863 xbt_cfg_register(&_sg_cfg_set, "smpi/coll_selector",
864 "Which collective selector to use",
865 xbt_cfgelm_string, 1, 1, NULL);
866 xbt_cfg_setdefault_string(_sg_cfg_set, "smpi/coll_selector", "default");
868 xbt_cfg_register(&_sg_cfg_set, "smpi/gather",
869 "Which collective to use for gather",
870 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_gather);
872 xbt_cfg_register(&_sg_cfg_set, "smpi/allgather",
873 "Which collective to use for allgather",
874 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allgather);
876 xbt_cfg_register(&_sg_cfg_set, "smpi/barrier",
877 "Which collective to use for barrier",
878 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_barrier);
880 xbt_cfg_register(&_sg_cfg_set, "smpi/reduce_scatter",
881 "Which collective to use for reduce_scatter",
882 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_reduce_scatter);
884 xbt_cfg_register(&_sg_cfg_set, "smpi/scatter",
885 "Which collective to use for scatter",
886 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_scatter);
888 xbt_cfg_register(&_sg_cfg_set, "smpi/allgatherv",
889 "Which collective to use for allgatherv",
890 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allgatherv);
892 xbt_cfg_register(&_sg_cfg_set, "smpi/allreduce",
893 "Which collective to use for allreduce",
894 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_allreduce);
896 xbt_cfg_register(&_sg_cfg_set, "smpi/alltoall",
897 "Which collective to use for alltoall",
898 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_alltoall);
900 xbt_cfg_register(&_sg_cfg_set, "smpi/alltoallv",
901 "Which collective to use for alltoallv",
902 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_alltoallv);
904 xbt_cfg_register(&_sg_cfg_set, "smpi/bcast",
905 "Which collective to use for bcast",
906 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_bcast);
908 xbt_cfg_register(&_sg_cfg_set, "smpi/reduce",
909 "Which collective to use for reduce",
910 xbt_cfgelm_string, 0, 1, &_sg_cfg_cb__coll_reduce);
913 xbt_cfg_register(&_sg_cfg_set, "exception/cutpath",
914 "\"yes\" or \"no\". \"yes\" will cut all path information from call traces, used e.g. in exceptions.",
915 xbt_cfgelm_boolean, 1, 1, NULL);
916 xbt_cfg_setdefault_boolean(_sg_cfg_set, "exception/cutpath", "no");
918 xbt_cfg_register(&_sg_cfg_set, "clean_atexit",
919 "\"yes\" or \"no\". \"yes\" enables all the cleanups of SimGrid (XBT,SIMIX,MSG) to be registered with atexit. \"no\" may be useful if your code segfaults when calling the exit function.",
920 xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_clean_atexit);
921 xbt_cfg_setdefault_boolean(_sg_cfg_set, "clean_atexit", "yes");
924 /* retrieves the current directory of the current process */
925 const char *initial_path = __surf_get_initial_path();
926 xbt_assert((initial_path), "__surf_get_initial_path() failed! Can't resolve current Windows directory");
928 surf_path = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
929 xbt_cfg_setdefault_string(_sg_cfg_set, "path", initial_path);
932 xbt_cfg_check(_sg_cfg_set);
933 _sg_cfg_init_status = 1;
935 sg_config_cmd_line(argc, argv);
937 xbt_mallocator_initialization_is_done(SIMIX_context_is_parallel());
939 XBT_WARN("Call to sg_config_init() after initialization ignored");
943 void sg_config_finalize(void)
945 if (!_sg_cfg_init_status)
946 return; /* Not initialized yet. Nothing to do */
948 xbt_cfg_free(&_sg_cfg_set);
949 _sg_cfg_init_status = 0;
952 int sg_cfg_is_default_value(const char *name)
954 return xbt_cfg_is_default_value(_sg_cfg_set, name);
957 int sg_cfg_get_int(const char* name)
959 return xbt_cfg_get_int(_sg_cfg_set, name);
962 double sg_cfg_get_double(const char* name)
964 return xbt_cfg_get_double(_sg_cfg_set, name);
967 char* sg_cfg_get_string(const char* name)
969 return xbt_cfg_get_string(_sg_cfg_set, name);
972 int sg_cfg_get_boolean(const char* name)
974 return xbt_cfg_get_boolean(_sg_cfg_set, name);
977 xbt_dynar_t sg_cfg_get_dynar(const char* name)
979 return xbt_cfg_get_dynar(_sg_cfg_set, name);