Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
3dd70411b54bae9ba3ad962b5fbce3a29a3b5746
[simgrid.git] / src / simgrid / sg_config.cpp
1 /* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 /* sg_config: configuration infrastructure for the simulation world         */
7
8 #include "simgrid/sg_config.hpp"
9 #include "instr/instr_interface.hpp"
10 #include "mc/mc.h"
11 #include "simgrid/instr.h"
12 #include "src/internal_config.h"
13 #include "src/kernel/lmm/maxmin.hpp"
14 #include "src/mc/mc_replay.hpp"
15 #include "src/surf/surf_interface.hpp"
16 #include "surf/surf.hpp"
17 #include "xbt/config.h"
18 #include "xbt/config.hpp"
19
20 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf, "About the configuration of SimGrid");
21
22
23 /* 0: beginning of time (config cannot be changed yet);
24  * 1: initialized: cfg_set created (config can now be changed);
25  * 2: configured: command line parsed and config part of platform file was
26  *    integrated also, platform construction ongoing or done.
27  *    (Config cannot be changed anymore!)
28  */
29 int _sg_cfg_init_status = 0;
30
31 /* instruct the upper layer (simix or simdag) to exit as soon as possible */
32 int _sg_cfg_exit_asap = 0;
33
34 #define sg_cfg_exit_early() do { _sg_cfg_exit_asap = 1; return; } while (0)
35
36 /* Parse the command line, looking for options */
37 static void sg_config_cmd_line(int *argc, char **argv)
38 {
39   int shall_exit = 0;
40   int i;
41   int j;
42
43   for (j = i = 1; i < *argc; i++) {
44     if (not strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
45       char *opt = strchr(argv[i], '=');
46       opt++;
47
48       xbt_cfg_set_parse(opt);
49       XBT_DEBUG("Did apply '%s' as config setting", opt);
50     } else if (not strcmp(argv[i], "--version")) {
51       printf("%s\n", SIMGRID_VERSION_STRING);
52       shall_exit = 1;
53     } else if (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help")) {
54       printf("Description of the configuration accepted by this simulator:\n");
55       xbt_cfg_help();
56       printf(
57           "\n"
58           "Each of these configurations can be used by adding\n"
59           "    --cfg=<option name>:<option value>\n"
60           "to the command line.\n"
61           "\n"
62           "For more information, please refer to:\n"
63           "   --help-aliases for the list of all option aliases.\n"
64           "   --help-logs and --help-log-categories for the details of logging output.\n"
65           "   --help-models for a list of all models known by this simulator.\n"
66           "   --help-tracing for the details of all tracing options known by this simulator.\n"
67           "   --version to get SimGrid version information.\n"
68           "\n"
69         );
70       shall_exit = 1;
71     } else if (not strcmp(argv[i], "--help-aliases")) {
72       printf("Here is a list of all deprecated option names, with their replacement.\n");
73       xbt_cfg_aliases();
74       printf("Please consider using the recent names\n");
75       shall_exit = 1;
76     } else if (not strcmp(argv[i], "--help-models")) {
77       model_help("host", surf_host_model_description);
78       printf("\n");
79       model_help("CPU", surf_cpu_model_description);
80       printf("\n");
81       model_help("network", surf_network_model_description);
82       printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
83       for (int k = 0; surf_optimization_mode_description[k].name; k++)
84         printf("  %s: %s\n",
85                surf_optimization_mode_description[k].name,
86                surf_optimization_mode_description[k].description);
87       printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
88       shall_exit = 1;
89     } else if (not strcmp(argv[i], "--help-tracing")) {
90       TRACE_help (1);
91       shall_exit = 1;
92     } else {
93       argv[j++] = argv[i];
94     }
95   }
96   if (j < *argc) {
97     argv[j] = nullptr;
98     *argc = j;
99   }
100   if (shall_exit)
101     sg_cfg_exit_early();
102 }
103
104 /* callback of the plugin variable */
105 static void _sg_cfg_cb__plugin(const std::string& value)
106 {
107   xbt_assert(_sg_cfg_init_status < 2, "Cannot load a plugin after the initialization");
108
109   if (value.empty())
110     return;
111
112   if (value == "help") {
113     model_help("plugin", surf_plugin_description);
114     sg_cfg_exit_early();
115   }
116
117   int plugin_id = find_model_description(surf_plugin_description, value);
118   surf_plugin_description[plugin_id].model_init_preparse();
119 }
120
121 /* callback of the host/model variable */
122 static void _sg_cfg_cb__host_model(const std::string& value)
123 {
124   xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
125
126   if (value == "help") {
127     model_help("host", surf_host_model_description);
128     sg_cfg_exit_early();
129   }
130
131   /* Make sure that the model exists */
132   find_model_description(surf_host_model_description, value);
133 }
134
135 /* callback of the cpu/model variable */
136 static void _sg_cfg_cb__cpu_model(const std::string& value)
137 {
138   xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
139
140   if (value == "help") {
141     model_help("CPU", surf_cpu_model_description);
142     sg_cfg_exit_early();
143   }
144
145   /* New Module missing */
146   find_model_description(surf_cpu_model_description, value);
147 }
148
149 /* callback of the cpu/model variable */
150 static void _sg_cfg_cb__optimization_mode(const std::string& value)
151 {
152   xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
153
154   if (value == "help") {
155     model_help("optimization", surf_optimization_mode_description);
156     sg_cfg_exit_early();
157   }
158
159   /* New Module missing */
160   find_model_description(surf_optimization_mode_description, value);
161 }
162
163 /* callback of the cpu/model variable */
164 static void _sg_cfg_cb__storage_mode(const std::string& value)
165 {
166   xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
167
168   if (value == "help") {
169     model_help("storage", surf_storage_model_description);
170     sg_cfg_exit_early();
171   }
172
173   find_model_description(surf_storage_model_description, value);
174 }
175
176 /* callback of the network_model variable */
177 static void _sg_cfg_cb__network_model(const std::string& value)
178 {
179   xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
180
181   if (value == "help") {
182     model_help("network", surf_network_model_description);
183     sg_cfg_exit_early();
184   }
185
186   /* New Module missing */
187   find_model_description(surf_network_model_description, value);
188 }
189
190 #if SIMGRID_HAVE_MC
191 extern int _sg_do_model_check_record;
192 static void _sg_cfg_cb_model_check_record(const char *name) {
193   _sg_do_model_check_record = xbt_cfg_get_boolean(name);
194 }
195 #endif
196
197 static void _sg_cfg_cb_contexts_parallel_mode(const std::string& mode_name)
198 {
199   if (mode_name == "posix") {
200     SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
201   } else if (mode_name == "futex") {
202     SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
203   } else if (mode_name == "busy_wait") {
204     SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
205   } else {
206     xbt_die("Command line setting of the parallel synchronization mode should "
207             "be one of \"posix\", \"futex\" or \"busy_wait\"");
208   }
209 }
210
211 /* build description line with possible values */
212 static void describe_model(char *result,int resultsize,
213                            const s_surf_model_description_t model_description[],
214                            const char *name,
215                            const char *description)
216 {
217   result[0] = '\0';
218   char *p = result;
219   p += snprintf(result,resultsize-1, "%s. Possible values: %s", description,
220             model_description[0].name ? model_description[0].name : "n/a");
221   for (int i = 1; model_description[i].name; i++)
222     p += snprintf(p,resultsize-(p-result)-1, ", %s", model_description[i].name);
223   p += snprintf(p,resultsize-(p-result)-1, ".\n       (use 'help' as a value to see the long description of each %s)", name);
224
225   xbt_assert(p<result+resultsize-1,"Buffer too small to display the model description of %s",name);
226 }
227
228 /* create the config set, register what should be and parse the command line*/
229 void sg_config_init(int *argc, char **argv)
230 {
231   const int descsize = 1024;
232   char description[descsize];
233
234   /* Create the configuration support */
235   if (_sg_cfg_init_status != 0) { /* Only create stuff if not already inited */
236     XBT_WARN("Call to sg_config_init() after initialization ignored");
237     return;
238   }
239
240   /* Plugins configuration */
241   describe_model(description, descsize, surf_plugin_description, "plugin", "The plugins");
242   simgrid::config::declareFlag<std::string>("plugin", description, "", &_sg_cfg_cb__plugin);
243
244   describe_model(description, descsize, surf_cpu_model_description, "model", "The model to use for the CPU");
245   simgrid::config::declareFlag<std::string>("cpu/model", description, "Cas01", &_sg_cfg_cb__cpu_model);
246
247   describe_model(description, descsize, surf_storage_model_description, "model", "The model to use for the storage");
248   simgrid::config::declareFlag<std::string>("storage/model", description, "default", &_sg_cfg_cb__storage_mode);
249
250   describe_model(description, descsize, surf_network_model_description, "model", "The model to use for the network");
251   simgrid::config::declareFlag<std::string>("network/model", description, "LV08", &_sg_cfg_cb__network_model);
252
253   describe_model(description, descsize, surf_optimization_mode_description, "optimization mode",
254                  "The optimization modes to use for the network");
255   simgrid::config::declareFlag<std::string>("network/optim", description, "Lazy", &_sg_cfg_cb__optimization_mode);
256
257   describe_model(description, descsize, surf_host_model_description, "model", "The model to use for the host");
258   simgrid::config::declareFlag<std::string>("host/model", description, "default", &_sg_cfg_cb__host_model);
259
260   simgrid::config::bindFlag(sg_surf_precision, "surf/precision",
261                             "Numerical precision used when updating simulation times (in seconds)");
262
263   simgrid::config::bindFlag(sg_maxmin_precision, "maxmin/precision",
264                             "Numerical precision used when computing resource sharing (in flops/sec or bytes/sec)");
265
266   simgrid::config::bindFlag(sg_concurrency_limit, "maxmin/concurrency-limit", {"maxmin/concurrency_limit"},
267                             "Maximum number of concurrent variables in the maxmim system. Also limits the number of "
268                             "processes on each host, at higher level. (default: -1 means no such limitation)");
269
270   /* The parameters of network models */
271
272   sg_latency_factor = 13.01; // comes from the default LV08 network model
273   simgrid::config::bindFlag(sg_latency_factor, "network/latency-factor", {"network/latency_factor"},
274                             "Correction factor to apply to the provided latency (default value set by network model)");
275
276   sg_bandwidth_factor = 0.97; // comes from the default LV08 network model
277   simgrid::config::bindFlag(
278       sg_bandwidth_factor, "network/bandwidth-factor", {"network/bandwidth_factor"},
279       "Correction factor to apply to the provided bandwidth (default value set by network model)");
280
281   sg_weight_S_parameter = 20537; // comes from the default LV08 network model
282   simgrid::config::bindFlag(
283       sg_weight_S_parameter, "network/weight-S", {"network/weight_S"},
284       "Correction factor to apply to the weight of competing streams (default value set by network model)");
285
286   /* Inclusion path */
287   simgrid::config::declareFlag<std::string>("path", "Lookup path for inclusions in platform and deployment XML files",
288                                             "", [](std::string const& path) {
289                                               if (not path.empty())
290                                                 surf_path.push_back(path);
291                                             });
292
293   simgrid::config::declareFlag<bool>("cpu/maxmin-selective-update", "Update the constraint set propagating recursively "
294                                                                     "to others constraints (off by default unless "
295                                                                     "optim is set to lazy)",
296                                      "no");
297   simgrid::config::alias("cpu/maxmin-selective-update", {"cpu/maxmin_selective_update"});
298   simgrid::config::declareFlag<bool>("network/maxmin-selective-update", "Update the constraint set propagating "
299                                                                         "recursively to others constraints (off by "
300                                                                         "default unless optim is set to lazy)",
301                                      "no");
302   simgrid::config::alias("network/maxmin-selective-update", {"network/maxmin_selective_update"});
303   /* Replay (this part is enabled even if MC it disabled) */
304   simgrid::config::bindFlag(MC_record_path, "model-check/replay",
305                             "Model-check path to replay (as reported by SimGrid when a violation is reported)");
306
307 #if SIMGRID_HAVE_MC
308   /* do model-checking-record */
309   xbt_cfg_register_boolean("model-check/record", "no", _sg_cfg_cb_model_check_record,
310                            "Record the model-checking paths");
311
312   xbt_cfg_register_int("model-check/checkpoint", 0, _mc_cfg_cb_checkpoint,
313                        "Specify the amount of steps between checkpoints during stateful model-checking (default: 0 => "
314                        "stateless verification). "
315                        "If value=1, one checkpoint is saved for each step => faster verification, but huge memory "
316                        "consumption; higher values are good compromises between speed and memory consumption.");
317
318   xbt_cfg_register_boolean("model-check/sparse-checkpoint", "no", _mc_cfg_cb_sparse_checkpoint,
319                            "Use sparse per-page snapshots.");
320   xbt_cfg_register_boolean("model-check/ksm", "no", _mc_cfg_cb_ksm, "Kernel same-page merging");
321
322   xbt_cfg_register_string("model-check/property", "", _mc_cfg_cb_property,
323                           "Name of the file containing the property, as formatted by the ltl2ba program.");
324   xbt_cfg_register_boolean("model-check/communications-determinism", "no", _mc_cfg_cb_comms_determinism,
325                            "Whether to enable the detection of communication determinism");
326   simgrid::config::alias("model-check/communications-determinism", {"model-check/communications_determinism"});
327
328   xbt_cfg_register_boolean("model-check/send-determinism", "no", _mc_cfg_cb_send_determinism,
329                            "Enable/disable the detection of send-determinism in the communications schemes");
330   simgrid::config::alias("model-check/send-determinism", {"model-check/send_determinism"});
331
332   /* Specify the kind of model-checking reduction */
333   xbt_cfg_register_string("model-check/reduction", "dpor", _mc_cfg_cb_reduce,
334                           "Specify the kind of exploration reduction (either none or DPOR)");
335   xbt_cfg_register_boolean("model-check/timeout", "no", _mc_cfg_cb_timeout,
336                            "Whether to enable timeouts for wait requests");
337
338   xbt_cfg_register_boolean("model-check/hash", "no", _mc_cfg_cb_hash,
339                            "Whether to enable state hash for state comparison (experimental)");
340   xbt_cfg_register_boolean("model-check/snapshot-fds", "no", _mc_cfg_cb_snapshot_fds,
341                            "Whether file descriptors must be snapshoted (currently unusable)");
342   simgrid::config::alias("model-check/snapshot-fds", {"model-check/snapshot_fds"});
343   xbt_cfg_register_int("model-check/max-depth", 1000, _mc_cfg_cb_max_depth,
344                        "Maximal exploration depth (default: 1000)");
345   simgrid::config::alias("model-check/max-depth", {"model-check/max_depth"});
346   xbt_cfg_register_int("model-check/visited", 0, _mc_cfg_cb_visited,
347                        "Specify the number of visited state stored for state comparison reduction. If value=5, the "
348                        "last 5 visited states are stored. If value=0 (the default), all states are stored.");
349
350   xbt_cfg_register_string("model-check/dot-output", "", _mc_cfg_cb_dot_output,
351                           "Name of dot output file corresponding to graph state");
352   simgrid::config::alias("model-check/dot-output", {"model-check/dot_output"});
353   xbt_cfg_register_boolean("model-check/termination", "no", _mc_cfg_cb_termination,
354                            "Whether to enable non progressive cycle detection");
355 #endif
356
357   extern bool _sg_do_verbose_exit;
358   simgrid::config::bindFlag(_sg_do_verbose_exit, "verbose-exit", "Activate the \"do nothing\" mode in Ctrl-C");
359
360   simgrid::config::declareFlag<int>("contexts/stack-size", "Stack size of contexts in KiB", 8 * 1024, [](int value) {
361     smx_context_stack_size_was_set = 1;
362     smx_context_stack_size         = value * 1024;
363   });
364   /* (FIXME: this is unpleasant) Reset this static variable that was altered when setting the default value. */
365   smx_context_stack_size_was_set = 0;
366   simgrid::config::alias("contexts/stack-size", {"contexts/stack_size"});
367
368   /* guard size for contexts stacks in memory pages */
369 #if defined(_WIN32) || (PTH_STACKGROWTH != -1)
370   int default_guard_size = 0;
371 #else
372   int default_guard_size = 1;
373 #endif
374   simgrid::config::declareFlag<int>("contexts/guard-size", "Guard size for contexts stacks in memory pages",
375                                     default_guard_size, [](int value) {
376                                       smx_context_guard_size_was_set = 1;
377                                       smx_context_guard_size         = value * xbt_pagesize;
378                                     });
379   /* No, it was not set yet (the above setdefault() changed this to 1). */
380   smx_context_guard_size_was_set = 0;
381   simgrid::config::alias("contexts/guard-size", {"contexts/guard_size"});
382   simgrid::config::declareFlag<int>("contexts/nthreads", "Number of parallel threads used to execute user contexts", 1,
383                                     &SIMIX_context_set_nthreads);
384
385   simgrid::config::declareFlag<int>("contexts/parallel-threshold",
386                                     "Minimal number of user contexts to be run in parallel (raw contexts only)", 2,
387                                     &SIMIX_context_set_parallel_threshold);
388   simgrid::config::alias("contexts/parallel-threshold", {"contexts/parallel_threshold"});
389
390   /* synchronization mode for parallel user contexts */
391 #if HAVE_FUTEX_H
392   std::string default_synchro_mode = "futex";
393 #else //No futex on mac and posix is unimplememted yet
394   std::string default_synchro_mode = "busy_wait";
395 #endif
396   simgrid::config::declareFlag<std::string>("contexts/synchro", "Synchronization mode to use when running contexts in "
397                                                                 "parallel (either futex, posix or busy_wait)",
398                                             default_synchro_mode, &_sg_cfg_cb_contexts_parallel_mode);
399
400   // For smpi/bw-factor and smpi/lat-factor
401   // SMPI model can be used without enable_smpi, so keep this out of the ifdef.
402   simgrid::config::declareFlag<std::string>("smpi/bw-factor",
403                                             "Bandwidth factors for smpi. Format: "
404                                             "'threshold0:value0;threshold1:value1;...;thresholdN:valueN', "
405                                             "meaning if(size >=thresholdN ) return valueN.",
406                                             "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;"
407                                             "1426:0.608902;732:0.341987;257:0.338112;0:0.812084");
408   simgrid::config::alias("smpi/bw-factor", {"smpi/bw_factor"});
409
410   simgrid::config::declareFlag<std::string>("smpi/lat-factor", "Latency factors for smpi.",
411                                             "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;"
412                                             "1426:1.61075;732:1.9503;257:1.95341;0:2.01467");
413   simgrid::config::alias("smpi/lat-factor", {"smpi/lat_factor"});
414   simgrid::config::declareFlag<std::string>("smpi/IB-penalty-factors",
415                                             "Correction factor to communications using Infiniband model with "
416                                             "contention (default value based on Stampede cluster profiling)",
417                                             "0.965;0.925;1.35");
418   simgrid::config::alias("smpi/IB-penalty-factors", {"smpi/IB_penalty_factors"});
419
420 #if HAVE_SMPI
421   simgrid::config::declareFlag<double>("smpi/host-speed", "Speed of the host running the simulation (in flop/s). "
422                                                           "Used to bench the operations.",
423                                        20000.0);
424   simgrid::config::alias("smpi/host-speed", {"smpi/running_power", "smpi/running-power"});
425
426   simgrid::config::declareFlag<bool>("smpi/keep-temps", "Whether we should keep the generated temporary files.", false);
427
428   simgrid::config::declareFlag<bool>("smpi/display-timing", "Whether we should display the timing after simulation.",
429                                      false);
430   simgrid::config::alias("smpi/display-timing", {"smpi/display_timing"});
431
432   simgrid::config::declareFlag<bool>("smpi/simulate-computation",
433                                      "Whether the computational part of the simulated application should be simulated.",
434                                      true);
435   simgrid::config::alias("smpi/simulate-computation", {"smpi/simulate_computation"});
436
437   simgrid::config::declareFlag<std::string>(
438       "smpi/shared-malloc", "Whether SMPI_SHARED_MALLOC is enabled. Disable it for debugging purposes.", "global");
439   simgrid::config::alias("smpi/shared-malloc", {"smpi/use_shared_malloc", "smpi/use-shared-malloc"});
440   simgrid::config::declareFlag<double>("smpi/shared-malloc-blocksize",
441                                        "Size of the bogus file which will be created for global shared allocations",
442                                        1UL << 20);
443   simgrid::config::declareFlag<std::string>("smpi/shared-malloc-hugepage",
444                                             "Path to a mounted hugetlbfs, to use huge pages with shared malloc.", "");
445
446   simgrid::config::declareFlag<double>(
447       "smpi/cpu-threshold", "Minimal computation time (in seconds) not discarded, or -1 for infinity.", 1e-6);
448   simgrid::config::alias("smpi/cpu-threshold", {"smpi/cpu_threshold"});
449
450   simgrid::config::declareFlag<int>(
451       "smpi/async-small-thresh",
452       "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver", 0);
453   simgrid::config::alias("smpi/async-small-thresh", {"smpi/async_small_thres", "smpi/async_small_thresh"});
454
455   simgrid::config::declareFlag<bool>("smpi/trace-call-location",
456                                      "Should filename and linenumber of MPI calls be traced?", false);
457
458   simgrid::config::declareFlag<int>(
459       "smpi/send-is-detached-thresh",
460       "Threshold of message size where MPI_Send stops behaving like MPI_Isend and becomes MPI_Ssend", 65536);
461   simgrid::config::alias("smpi/send-is-detached-thresh",
462                          {"smpi/send_is_detached_thres", "smpi/send_is_detached_thresh"});
463
464   const char* default_privatization = std::getenv("SMPI_PRIVATIZATION");
465   if (default_privatization == nullptr)
466     default_privatization = "no";
467
468   simgrid::config::declareFlag<std::string>(
469       "smpi/privatization", "How we should privatize global variable at runtime (no, yes, mmap, dlopen).",
470       default_privatization);
471   simgrid::config::alias("smpi/privatization", {"smpi/privatize_global_variables", "smpi/privatize-global-variables"});
472
473   simgrid::config::declareFlag<bool>("smpi/grow-injected-times",
474                                      "Whether we want to make the injected time in MPI_Iprobe and MPI_Test grow, to "
475                                      "allow faster simulation. This can make simulation less precise, though.",
476                                      true);
477
478 #if HAVE_PAPI
479   simgrid::config::declareFlag<std::string>("smpi/papi-events",
480                                             "This switch enables tracking the specified counters with PAPI", "");
481 #endif
482   simgrid::config::declareFlag<std::string>("smpi/comp-adjustment-file",
483                                             "A file containing speedups or slowdowns for some parts of the code.", "");
484   simgrid::config::declareFlag<std::string>(
485       "smpi/os", "Small messages timings (MPI_Send minimum time for small messages)", "0:0:0:0:0");
486   simgrid::config::declareFlag<std::string>(
487       "smpi/ois", "Small messages timings (MPI_Isend minimum time for small messages)", "0:0:0:0:0");
488   simgrid::config::declareFlag<std::string>(
489       "smpi/or", "Small messages timings (MPI_Recv minimum time for small messages)", "0:0:0:0:0");
490
491   simgrid::config::declareFlag<double>("smpi/iprobe-cpu-usage",
492                                        "Maximum usage of CPUs by MPI_Iprobe() calls. We've observed that MPI_Iprobes "
493                                        "consume significantly less power than the maximum of a specific application. "
494                                        "This value is then (Iprobe_Usage/Max_Application_Usage).",
495                                        1.0);
496
497   simgrid::config::declareFlag<std::string>("smpi/coll-selector", "Which collective selector to use", "default");
498   simgrid::config::alias("smpi/coll-selector", {"smpi/coll_selector"});
499   simgrid::config::declareFlag<std::string>("smpi/gather", "Which collective to use for gather", "");
500   simgrid::config::declareFlag<std::string>("smpi/allgather", "Which collective to use for allgather", "");
501   simgrid::config::declareFlag<std::string>("smpi/barrier", "Which collective to use for barrier", "");
502   simgrid::config::declareFlag<std::string>("smpi/reduce_scatter", "Which collective to use for reduce_scatter", "");
503   simgrid::config::alias("smpi/reduce_scatter", {"smpi/reduce-scatter"});
504   simgrid::config::declareFlag<std::string>("smpi/scatter", "Which collective to use for scatter", "");
505   simgrid::config::declareFlag<std::string>("smpi/allgatherv", "Which collective to use for allgatherv", "");
506   simgrid::config::declareFlag<std::string>("smpi/allreduce", "Which collective to use for allreduce", "");
507   simgrid::config::declareFlag<std::string>("smpi/alltoall", "Which collective to use for alltoall", "");
508   simgrid::config::declareFlag<std::string>("smpi/alltoallv", "Which collective to use for alltoallv", "");
509   simgrid::config::declareFlag<std::string>("smpi/bcast", "Which collective to use for bcast", "");
510   simgrid::config::declareFlag<std::string>("smpi/reduce", "Which collective to use for reduce", "");
511 #endif // HAVE_SMPI
512
513   /* Storage */
514
515   sg_storage_max_file_descriptors = 1024;
516   simgrid::config::bindFlag(sg_storage_max_file_descriptors, "storage/max_file_descriptors",
517                             "Maximum number of concurrently opened files per host. Default is 1024");
518
519   /* Others */
520
521   simgrid::config::declareFlag<bool>(
522       "exception/cutpath", "Whether to cut all path information from call traces, used e.g. in exceptions.", false);
523
524   extern bool _sg_do_clean_atexit;
525   simgrid::config::bindFlag(_sg_do_clean_atexit, "clean-atexit", {"clean_atexit"},
526                             "Whether to cleanup SimGrid at exit. Disable it if your code segfaults after its end.");
527
528   if (surf_path.empty())
529     xbt_cfg_setdefault_string("path", "./");
530
531   _sg_cfg_init_status = 1;
532
533   sg_config_cmd_line(argc, argv);
534
535   xbt_mallocator_initialization_is_done(SIMIX_context_is_parallel());
536 }
537
538 void sg_config_finalize()
539 {
540   if (not _sg_cfg_init_status)
541     return;                     /* Not initialized yet. Nothing to do */
542
543   xbt_cfg_free(&simgrid_config);
544   _sg_cfg_init_status = 0;
545 }