1 /* Copyright (c) 2009, 2010. 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 /* surf_config: configuration infrastructure for the simulation world */
10 #include "xbt/config.h"
13 #include "surf/surf_private.h"
14 #include "surf/surf_routing.h" /* COORD_HOST_LEVEL and COORD_ASR_LEVEL */
15 #include "simgrid/simix.h"
16 #include "mc/mc.h" /* configuration callbacks of model-checking */
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf,
19 "About the configuration of surf (and the rest of the simulation)");
21 xbt_cfg_t _surf_cfg_set = NULL;
23 int _surf_init_status = 0; /* 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 integrated also, platform construction ongoing or done.
26 (Config cannot be changed anymore!) */
29 /* Parse the command line, looking for options */
30 static void surf_config_cmd_line(int *argc, char **argv)
36 for (j = i = 1; i < *argc; i++) {
37 if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
38 opt = strchr(argv[i], '=');
41 xbt_cfg_set_parse(_surf_cfg_set, opt);
42 XBT_DEBUG("Did apply '%s' as config setting", opt);
43 } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) {
45 ("Description of the configuration accepted by this simulator:\n");
46 xbt_cfg_help(_surf_cfg_set);
49 "Each of these configurations can be used by adding\n"
50 " --cfg=<option name>:<option value>\n"
51 "to the command line.\n"
52 "You can also use --help-models to see the details of all models known by this simulator.\n"
55 "You can also use --help-tracing to see the details of all tracing options known by this simulator.\n"
58 "You can also use --help-logs and --help-log-categories to see the details of logging output.\n"
62 } else if (!strcmp(argv[i], "--help-models")) {
65 model_help("workstation", surf_workstation_model_description);
67 model_help("CPU", surf_cpu_model_description);
69 model_help("network", surf_network_model_description);
70 printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
71 for (k = 0; surf_optimization_mode_description[k].name; k++)
73 surf_optimization_mode_description[k].name,
74 surf_optimization_mode_description[k].description);
75 printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
78 } else if (!strcmp(argv[i], "--help-tracing")) {
91 _surf_init_status=1; // get everything cleanly cleaned on exit
97 /* callback of the workstation/model variable */
98 static void _surf_cfg_cb__workstation_model(const char *name, int pos)
102 xbt_assert(_surf_init_status == 1,
103 "Cannot change the model after the initialization");
105 val = xbt_cfg_get_string(_surf_cfg_set, name);
107 if (!strcmp(val, "help")) {
108 model_help("workstation", surf_workstation_model_description);
112 /* Make sure that the model exists */
113 find_model_description(surf_workstation_model_description, val);
116 /* callback of the cpu/model variable */
117 static void _surf_cfg_cb__cpu_model(const char *name, int pos)
121 xbt_assert(_surf_init_status == 1,
122 "Cannot change the model after the initialization");
124 val = xbt_cfg_get_string(_surf_cfg_set, name);
126 if (!strcmp(val, "help")) {
127 model_help("CPU", surf_cpu_model_description);
131 /* New Module missing */
132 find_model_description(surf_cpu_model_description, val);
135 /* callback of the cpu/model variable */
136 static void _surf_cfg_cb__optimization_mode(const char *name, int pos)
140 xbt_assert(_surf_init_status == 1,
141 "Cannot change the model after the initialization");
143 val = xbt_cfg_get_string(_surf_cfg_set, name);
145 if (!strcmp(val, "help")) {
146 model_help("optimization", surf_optimization_mode_description);
150 /* New Module missing */
151 find_model_description(surf_optimization_mode_description, val);
154 /* callback of the cpu/model variable */
155 static void _surf_cfg_cb__storage_mode(const char *name, int pos)
159 xbt_assert(_surf_init_status == 1,
160 "Cannot change the model after the initialization");
162 val = xbt_cfg_get_string(_surf_cfg_set, name);
164 if (!strcmp(val, "help")) {
165 model_help("storage", surf_storage_model_description);
169 /* New Module missing */
170 find_model_description(surf_storage_model_description, val);
173 /* callback of the workstation_model variable */
174 static void _surf_cfg_cb__network_model(const char *name, int pos)
178 xbt_assert(_surf_init_status == 1,
179 "Cannot change the model after the initialization");
181 val = xbt_cfg_get_string(_surf_cfg_set, name);
183 if (!strcmp(val, "help")) {
184 model_help("network", surf_network_model_description);
188 /* New Module missing */
189 find_model_description(surf_network_model_description, val);
193 /* callbacks of the network models values */
194 static void _surf_cfg_cb__tcp_gamma(const char *name, int pos)
196 sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
199 static void _surf_cfg_cb__maxmin_precision(const char* name, int pos)
201 sg_maxmin_precision = xbt_cfg_get_double(_surf_cfg_set, name);
204 static void _surf_cfg_cb__sender_gap(const char* name, int pos)
206 sg_sender_gap = xbt_cfg_get_double(_surf_cfg_set, name);
209 static void _surf_cfg_cb__latency_factor(const char *name, int pos)
211 sg_latency_factor = xbt_cfg_get_double(_surf_cfg_set, name);
214 static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos)
216 sg_bandwidth_factor = xbt_cfg_get_double(_surf_cfg_set, name);
219 static void _surf_cfg_cb__weight_S(const char *name, int pos)
221 sg_weight_S_parameter = xbt_cfg_get_double(_surf_cfg_set, name);
224 /* callback of the inclusion path */
225 static void _surf_cfg_cb__surf_path(const char *name, int pos)
227 char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
228 xbt_dynar_push(surf_path, &path);
231 /* callback to decide if we want to use the model-checking */
232 #include "xbt_modinter.h"
233 extern int _surf_do_model_check; /* this variable lives in xbt_main until I find a right location for it */
235 static void _surf_cfg_cb_model_check(const char *name, int pos)
237 _surf_do_model_check = xbt_cfg_get_int(_surf_cfg_set, name);
240 if (_surf_do_model_check) {
241 xbt_die("You tried to activate the model-checking from the command line, but it was not compiled in. Change your settings in cmake, recompile and try again");
246 extern int _surf_do_verbose_exit;
248 static void _surf_cfg_cb_verbose_exit(const char *name, int pos)
250 _surf_do_verbose_exit = xbt_cfg_get_int(_surf_cfg_set, name);
254 static void _surf_cfg_cb_context_factory(const char *name, int pos) {
255 smx_context_factory_name = xbt_cfg_get_string(_surf_cfg_set, name);
258 static void _surf_cfg_cb_context_stack_size(const char *name, int pos)
260 smx_context_stack_size_was_set = 1;
261 smx_context_stack_size = xbt_cfg_get_int(_surf_cfg_set, name) * 1024;
264 static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
266 SIMIX_context_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
269 static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
271 SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_surf_cfg_set, name));
274 static void _surf_cfg_cb_contexts_parallel_mode(const char *name, int pos)
276 const char* mode_name = xbt_cfg_get_string(_surf_cfg_set, name);
277 if (!strcmp(mode_name, "posix")) {
278 SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
280 else if (!strcmp(mode_name, "futex")) {
281 SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
283 else if (!strcmp(mode_name, "busy_wait")) {
284 SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
287 xbt_die("Command line setting of the parallel synchronization mode should "
288 "be one of \"posix\", \"futex\" or \"busy_wait\"");
292 static void _surf_cfg_cb_surf_nthreads(const char *name, int pos)
294 surf_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
297 static void _surf_cfg_cb__surf_network_coordinates(const char *name,
300 char *val = xbt_cfg_get_string(_surf_cfg_set, name);
301 if (!strcmp(val, "yes")) {
302 if (!COORD_HOST_LEVEL) {
303 COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
304 COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
306 } else if (!strcmp(val, "no")) {
307 if (COORD_HOST_LEVEL)
308 xbt_die("Setting of whether to use coordinate cannot be disabled once set.");
310 xbt_die("Command line setting of whether to use coordinates must be either \"yes\" or \"no\"");
314 static void _surf_cfg_cb__surf_network_crosstraffic(const char *name,
317 sg_network_crosstraffic = xbt_cfg_get_int(_surf_cfg_set, name);
321 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos)
323 sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
326 static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
328 sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
332 /* create the config set, register what should be and parse the command line*/
333 void surf_config_init(int *argc, char **argv)
335 char *description = xbt_malloc(1024), *p = description;
337 double double_default_value;
338 int default_value_int;
341 /* Create the configuration support */
342 if (_surf_init_status == 0) { /* Only create stuff if not already inited */
344 "The model to use for the CPU. Possible values: ");
346 while (*(++p) != '\0');
347 for (i = 0; surf_cpu_model_description[i].name; i++)
348 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
349 surf_cpu_model_description[i].name);
351 ".\n (use 'help' as a value to see the long description of each model)");
352 default_value = xbt_strdup("Cas01");
353 xbt_cfg_register(&_surf_cfg_set, "cpu/model", description, xbt_cfgelm_string,
354 &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL);
357 "The optimization modes to use for the CPU. Possible values: ");
359 while (*(++p) != '\0');
360 for (i = 0; surf_optimization_mode_description[i].name; i++)
361 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
362 surf_optimization_mode_description[i].name);
364 ".\n (use 'help' as a value to see the long description of each optimization mode)");
365 default_value = xbt_strdup("Lazy");
366 xbt_cfg_register(&_surf_cfg_set, "cpu/optim", description, xbt_cfgelm_string,
367 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
370 "The model to use for the storage. Possible values: ");
372 while (*(++p) != '\0');
373 for (i = 0; surf_storage_model_description[i].name; i++)
374 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
375 surf_storage_model_description[i].name);
377 ".\n (use 'help' as a value to see the long description of each model)");
378 default_value = xbt_strdup("default");
379 xbt_cfg_register(&_surf_cfg_set, "storage/model", description, xbt_cfgelm_string,
380 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
383 /* ********************************************************************* */
384 /* TUTORIAL: New model */
386 "The model to use for the New model. Possible values: ");
388 while (*(++p) != '\0');
389 for (i = 0; surf_new_model_description[i].name; i++)
390 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
391 surf_new_model_description[i].name);
393 ".\n (use 'help' as a value to see the long description of each model)");
394 default_value = xbt_strdup("default");
395 xbt_cfg_register(&_surf_cfg_set, "new_model/model", description, xbt_cfgelm_string,
396 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
398 /* ********************************************************************* */
401 "The model to use for the network. Possible values: ");
403 while (*(++p) != '\0');
404 for (i = 0; surf_network_model_description[i].name; i++)
405 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
406 surf_network_model_description[i].name);
408 ".\n (use 'help' as a value to see the long description of each model)");
409 default_value = xbt_strdup("LV08");
410 xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string,
411 &default_value, 1, 1, &_surf_cfg_cb__network_model,
415 "The optimization modes to use for the network. Possible values: ");
417 while (*(++p) != '\0');
418 for (i = 0; surf_optimization_mode_description[i].name; i++)
419 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
420 surf_optimization_mode_description[i].name);
422 ".\n (use 'help' as a value to see the long description of each optimization mode)");
423 default_value = xbt_strdup("Lazy");
424 xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string,
425 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
428 "The model to use for the workstation. Possible values: ");
430 while (*(++p) != '\0');
431 for (i = 0; surf_workstation_model_description[i].name; i++)
432 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
433 surf_workstation_model_description[i].name);
435 ".\n (use 'help' as a value to see the long description of each model)");
436 default_value = xbt_strdup("default");
437 xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string,
438 &default_value, 1, 1,
439 &_surf_cfg_cb__workstation_model, NULL);
441 xbt_free(description);
443 xbt_cfg_register(&_surf_cfg_set, "network/TCP_gamma",
444 "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)",
445 xbt_cfgelm_double, NULL, 1, 1,
446 _surf_cfg_cb__tcp_gamma, NULL);
447 xbt_cfg_setdefault_double(_surf_cfg_set, "network/TCP_gamma", 4194304.0);
449 xbt_cfg_register(&_surf_cfg_set, "maxmin/precision",
450 "Numerical precision used when updating simulation models (epsilon in double comparisons)",
451 xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__maxmin_precision, NULL);
452 xbt_cfg_setdefault_double(_surf_cfg_set, "maxmin/precision", 0.00001); // FIXME use setdefault everywhere here!
454 /* The parameters of network models */
456 double_default_value = 0.0;
457 xbt_cfg_register(&_surf_cfg_set, "network/sender_gap",
458 "Minimum gap between two overlapping sends",
459 xbt_cfgelm_double, &double_default_value, 1, 1,
460 _surf_cfg_cb__sender_gap, NULL);
462 double_default_value = 1.0;
463 xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
464 "Correction factor to apply to the provided latency (default value set by network model)",
465 xbt_cfgelm_double, &double_default_value, 1, 1,
466 _surf_cfg_cb__latency_factor, NULL);
467 double_default_value = 1.0;
468 xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
469 "Correction factor to apply to the provided bandwidth (default value set by network model)",
470 xbt_cfgelm_double, &double_default_value, 1, 1,
471 _surf_cfg_cb__bandwidth_factor, NULL);
472 double_default_value = 0.0;
473 xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
474 "Correction factor to apply to the weight of competing streams(default value set by network model)",
475 xbt_cfgelm_double, &double_default_value, 1, 1,
476 _surf_cfg_cb__weight_S, NULL);
479 xbt_cfg_register(&_surf_cfg_set, "path",
480 "Lookup path for inclusions in platform and deployment XML files",
481 xbt_cfgelm_string, NULL, 0, 0,
482 _surf_cfg_cb__surf_path, NULL);
484 default_value_int = 0;
485 xbt_cfg_register(&_surf_cfg_set, "cpu/maxmin_selective_update",
486 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
487 xbt_cfgelm_int, &default_value_int, 0, 1,
489 default_value_int = 0;
490 xbt_cfg_register(&_surf_cfg_set, "network/maxmin_selective_update",
491 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
492 xbt_cfgelm_int, &default_value_int, 0, 1,
496 /* do model-checking */
497 xbt_cfg_register(&_surf_cfg_set, "model-check",
498 "Verify the system through model-checking instead of simulating it (EXPERIMENTAL)",
499 xbt_cfgelm_int, NULL, 0, 1,
500 _surf_cfg_cb_model_check, NULL);
501 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check", 0);
503 /* do stateful model-checking */
504 xbt_cfg_register(&_surf_cfg_set, "model-check/checkpoint",
505 "Specify the amount of steps between checkpoints during stateful model-checking (default: 0 => stateless verification). "
506 "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.",
507 xbt_cfgelm_int, NULL, 0, 1,
508 _mc_cfg_cb_checkpoint, NULL);
509 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/checkpoint", 0);
511 /* do liveness model-checking */
512 xbt_cfg_register(&_surf_cfg_set, "model-check/property",
513 "Specify the name of the file containing the property. It must be the result of the ltl2ba program.",
514 xbt_cfgelm_string, NULL, 0, 1,
515 _mc_cfg_cb_property, NULL);
516 xbt_cfg_setdefault_string(_surf_cfg_set, "model-check/property", "");
518 /* Specify the kind of model-checking reduction */
519 xbt_cfg_register(&_surf_cfg_set, "model-check/reduction",
520 "Specify the kind of exploration reduction (either none or DPOR)",
521 xbt_cfgelm_string, NULL, 0, 1,
522 _mc_cfg_cb_reduce, NULL);
523 xbt_cfg_setdefault_string(_surf_cfg_set, "model-check/reduction", "dpor");
525 /* Enable/disable timeout for wait requests with model-checking */
526 xbt_cfg_register(&_surf_cfg_set, "model-check/timeout",
527 "Enable/Disable timeout for wait requests",
528 xbt_cfgelm_int, NULL, 0, 1,
529 _mc_cfg_cb_timeout, NULL);
530 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/timeout", 0);
532 /* Set max depth exploration */
533 xbt_cfg_register(&_surf_cfg_set, "model-check/max_depth",
534 "Specify the max depth of exploration (default : 1000)",
535 xbt_cfgelm_int, NULL, 0, 1,
536 _mc_cfg_cb_max_depth, NULL);
537 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/max_depth", 1000);
539 /* Set number of visited state stored for state comparison reduction*/
540 xbt_cfg_register(&_surf_cfg_set, "model-check/visited",
541 "Specify the number of visited state stored for state comparison reduction. If value=5, the last 5 visited states are stored",
542 xbt_cfgelm_int, NULL, 0, 1,
543 _mc_cfg_cb_visited, NULL);
544 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/visited", 0);
547 /* do verbose-exit */
548 default_value_int = 1;
549 xbt_cfg_register(&_surf_cfg_set, "verbose-exit",
550 "Activate the \"do nothing\" mode in Ctrl-C",
551 xbt_cfgelm_int, &default_value_int, 0, 1,
552 _surf_cfg_cb_verbose_exit, NULL);
555 /* context factory */
556 default_value = xbt_strdup("ucontext");
557 xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
558 "Context factory to use in SIMIX (ucontext, thread or raw)",
559 xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);
561 /* stack size of contexts in Ko */
562 default_value_int = 128;
563 xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
564 "Stack size of contexts in Kib (ucontext or raw only)",
565 xbt_cfgelm_int, &default_value_int, 1, 1,
566 _surf_cfg_cb_context_stack_size, NULL);
568 /* number of parallel threads for user processes */
569 default_value_int = 1;
570 xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
571 "Number of parallel threads used to execute user contexts",
572 xbt_cfgelm_int, &default_value_int, 1, 1,
573 _surf_cfg_cb_contexts_nthreads, NULL);
575 /* minimal number of user contexts to be run in parallel */
576 default_value_int = 2;
577 xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
578 "Minimal number of user contexts to be run in parallel (raw contexts only)",
579 xbt_cfgelm_int, &default_value_int, 1, 1,
580 _surf_cfg_cb_contexts_parallel_threshold, NULL);
582 /* synchronization mode for parallel user contexts */
584 default_value = xbt_strdup("futex");
585 #else //No futex on mac and posix is unimplememted yet
586 default_value = xbt_strdup("busy_wait");
588 xbt_cfg_register(&_surf_cfg_set, "contexts/synchro",
589 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
590 xbt_cfgelm_string, &default_value, 1, 1,
591 _surf_cfg_cb_contexts_parallel_mode, NULL);
593 /* number of parallel threads for Surf */
594 default_value_int = surf_get_nthreads();
595 xbt_cfg_register(&_surf_cfg_set, "surf/nthreads",
596 "Number of parallel threads used to update Surf models",
597 xbt_cfgelm_int, &default_value_int, 1, 1,
598 _surf_cfg_cb_surf_nthreads, NULL);
600 default_value = xbt_strdup("no");
601 xbt_cfg_register(&_surf_cfg_set, "network/coordinates",
602 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
603 xbt_cfgelm_string, &default_value, 1, 1,
604 _surf_cfg_cb__surf_network_coordinates, NULL);
605 xbt_cfg_setdefault_string(_surf_cfg_set, "network/coordinates", default_value);
607 default_value_int = 0;
608 xbt_cfg_register(&_surf_cfg_set, "network/crosstraffic",
609 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
610 xbt_cfgelm_int, &default_value_int, 0, 1,
611 _surf_cfg_cb__surf_network_crosstraffic, NULL);
612 xbt_cfg_setdefault_int(_surf_cfg_set, "network/crosstraffic", default_value_int);
615 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter",
616 "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
617 xbt_cfgelm_double, NULL, 1, 1,
618 _surf_cfg_cb__gtnets_jitter, NULL);
619 xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets/jitter", 0.0);
621 default_value_int = 10;
622 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter_seed",
623 "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
624 xbt_cfgelm_int, &default_value_int, 0, 1,
625 _surf_cfg_cb__gtnets_jitter_seed, NULL);
628 xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
629 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
630 xbt_cfgelm_string, NULL, 1, 1,
632 xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
636 double default_reference_speed = 20000.0;
637 xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
638 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
639 xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
642 int default_display_timing = 0;
643 xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
644 "Boolean indicating whether we should display the timing after simulation.",
645 xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
648 double default_threshold = 1e-6;
649 xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
650 "Minimal computation time (in seconds) not discarded.",
651 xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
654 int default_small_messages_threshold = 0;
655 xbt_cfg_register(&_surf_cfg_set, "smpi/async_small_thres",
656 "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver",
657 xbt_cfgelm_int, &default_small_messages_threshold, 1, 1, NULL,
660 //For smpi/bw_factor and smpi/lat_factor
661 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
662 //test is if( size >= thresholdN ) return valueN;
663 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
664 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
665 xbt_cfg_register(&_surf_cfg_set, "smpi/bw_factor",
666 "Bandwidth factors for smpi.",
667 xbt_cfgelm_string, NULL, 1, 1, NULL,
669 xbt_cfg_setdefault_string(_surf_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");
671 xbt_cfg_register(&_surf_cfg_set, "smpi/lat_factor",
672 "Latency factors for smpi.",
673 xbt_cfgelm_string, NULL, 1, 1, NULL,
675 xbt_cfg_setdefault_string(_surf_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");
680 /* retrieves the current directory of the current process */
681 const char *initial_path = __surf_get_initial_path();
682 xbt_assert((initial_path),
683 "__surf_get_initial_path() failed! Can't resolves current Windows directory");
685 surf_path = xbt_dynar_new(sizeof(char *), NULL);
686 xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
689 _surf_init_status = 1;
691 surf_config_cmd_line(argc, argv);
694 XBT_WARN("Call to surf_config_init() after initialization ignored");
698 void surf_config_finalize(void)
700 if (!_surf_init_status)
701 return; /* Not initialized yet. Nothing to do */
703 xbt_cfg_free(&_surf_cfg_set);
704 _surf_init_status = 0;
707 /* Pick the right models for CPU, net and workstation, and call their model_init_preparse */
708 void surf_config_models_setup()
710 char *workstation_model_name;
711 int workstation_id = -1;
712 char *network_model_name = NULL;
713 char *cpu_model_name = NULL;
715 char *storage_model_name = NULL;
717 workstation_model_name =
718 xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
719 network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
720 cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
721 storage_model_name = xbt_cfg_get_string(_surf_cfg_set, "storage/model");
723 /* Check whether we use a net/cpu model differing from the default ones, in which case
724 * we should switch to the "compound" workstation model to correctly dispatch stuff to
725 * the right net/cpu models.
728 if((!xbt_cfg_is_default_value(_surf_cfg_set, "network/model") ||
729 !xbt_cfg_is_default_value(_surf_cfg_set, "cpu/model")) &&
730 xbt_cfg_is_default_value(_surf_cfg_set, "workstation/model"))
732 const char *val = "compound";
734 ("Switching workstation model to compound since you changed the network and/or cpu model(s)");
735 xbt_cfg_set_string(_surf_cfg_set, "workstation/model", val);
736 workstation_model_name = (char *) "compound";
739 XBT_DEBUG("Workstation model: %s", workstation_model_name);
741 find_model_description(surf_workstation_model_description,
742 workstation_model_name);
743 if (!strcmp(workstation_model_name, "compound")) {
747 xbt_assert(cpu_model_name,
748 "Set a cpu model to use with the 'compound' workstation model");
750 xbt_assert(network_model_name,
751 "Set a network model to use with the 'compound' workstation model");
754 find_model_description(surf_network_model_description,
757 find_model_description(surf_cpu_model_description, cpu_model_name);
759 surf_cpu_model_description[cpu_id].model_init_preparse();
760 surf_network_model_description[network_id].model_init_preparse();
763 XBT_DEBUG("Call workstation_model_init");
764 surf_workstation_model_description[workstation_id].model_init_preparse();
766 XBT_DEBUG("Call storage_model_init");
767 storage_id = find_model_description(surf_storage_model_description, storage_model_name);
768 surf_storage_model_description[storage_id].model_init_preparse();
770 /* ********************************************************************* */
771 /* TUTORIAL: New model */
772 int new_model_id = -1;
773 char *new_model_name = NULL;
774 new_model_name = xbt_cfg_get_string(_surf_cfg_set, "new_model/model");
775 XBT_DEBUG("Call new model_init");
776 new_model_id = find_model_description(surf_new_model_description, new_model_name);
777 surf_new_model_description[new_model_id].model_init_preparse();
778 /* ********************************************************************* */