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 = xbt_cfg_get_int(_surf_cfg_set, name) * 1024;
263 static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
265 SIMIX_context_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
268 static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
270 SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_surf_cfg_set, name));
273 static void _surf_cfg_cb_contexts_parallel_mode(const char *name, int pos)
275 const char* mode_name = xbt_cfg_get_string(_surf_cfg_set, name);
276 if (!strcmp(mode_name, "posix")) {
277 SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
279 else if (!strcmp(mode_name, "futex")) {
280 SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
282 else if (!strcmp(mode_name, "busy_wait")) {
283 SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
286 xbt_die("Command line setting of the parallel synchronization mode should "
287 "be one of \"posix\", \"futex\" or \"busy_wait\"");
291 static void _surf_cfg_cb_surf_nthreads(const char *name, int pos)
293 surf_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
296 static void _surf_cfg_cb__surf_network_coordinates(const char *name,
299 char *val = xbt_cfg_get_string(_surf_cfg_set, name);
300 if (!strcmp(val, "yes")) {
301 if (!COORD_HOST_LEVEL) {
302 COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
303 COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
305 } else if (!strcmp(val, "no")) {
306 if (COORD_HOST_LEVEL)
307 xbt_die("Setting of whether to use coordinate cannot be disabled once set.");
309 xbt_die("Command line setting of whether to use coordinates must be either \"yes\" or \"no\"");
313 static void _surf_cfg_cb__surf_network_crosstraffic(const char *name,
316 sg_network_crosstraffic = xbt_cfg_get_int(_surf_cfg_set, name);
320 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos)
322 sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
325 static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
327 sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
331 /* create the config set, register what should be and parse the command line*/
332 void surf_config_init(int *argc, char **argv)
334 char *description = xbt_malloc(1024), *p = description;
336 double double_default_value;
337 int default_value_int;
340 /* Create the configuration support */
341 if (_surf_init_status == 0) { /* Only create stuff if not already inited */
343 "The model to use for the CPU. Possible values: ");
345 while (*(++p) != '\0');
346 for (i = 0; surf_cpu_model_description[i].name; i++)
347 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
348 surf_cpu_model_description[i].name);
350 ".\n (use 'help' as a value to see the long description of each model)");
351 default_value = xbt_strdup("Cas01");
352 xbt_cfg_register(&_surf_cfg_set, "cpu/model", description, xbt_cfgelm_string,
353 &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL);
356 "The optimization modes to use for the CPU. Possible values: ");
358 while (*(++p) != '\0');
359 for (i = 0; surf_optimization_mode_description[i].name; i++)
360 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
361 surf_optimization_mode_description[i].name);
363 ".\n (use 'help' as a value to see the long description of each optimization mode)");
364 default_value = xbt_strdup("Lazy");
365 xbt_cfg_register(&_surf_cfg_set, "cpu/optim", description, xbt_cfgelm_string,
366 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
369 "The model to use for the storage. Possible values: ");
371 while (*(++p) != '\0');
372 for (i = 0; surf_storage_model_description[i].name; i++)
373 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
374 surf_storage_model_description[i].name);
376 ".\n (use 'help' as a value to see the long description of each model)");
377 default_value = xbt_strdup("default");
378 xbt_cfg_register(&_surf_cfg_set, "storage/model", description, xbt_cfgelm_string,
379 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
382 /* ********************************************************************* */
383 /* TUTORIAL: New model */
385 "The model to use for the New model. Possible values: ");
387 while (*(++p) != '\0');
388 for (i = 0; surf_new_model_description[i].name; i++)
389 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
390 surf_new_model_description[i].name);
392 ".\n (use 'help' as a value to see the long description of each model)");
393 default_value = xbt_strdup("default");
394 xbt_cfg_register(&_surf_cfg_set, "new_model/model", description, xbt_cfgelm_string,
395 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
397 /* ********************************************************************* */
400 "The model to use for the network. Possible values: ");
402 while (*(++p) != '\0');
403 for (i = 0; surf_network_model_description[i].name; i++)
404 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
405 surf_network_model_description[i].name);
407 ".\n (use 'help' as a value to see the long description of each model)");
408 default_value = xbt_strdup("LV08");
409 xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string,
410 &default_value, 1, 1, &_surf_cfg_cb__network_model,
414 "The optimization modes to use for the network. Possible values: ");
416 while (*(++p) != '\0');
417 for (i = 0; surf_optimization_mode_description[i].name; i++)
418 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
419 surf_optimization_mode_description[i].name);
421 ".\n (use 'help' as a value to see the long description of each optimization mode)");
422 default_value = xbt_strdup("Lazy");
423 xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string,
424 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
427 "The model to use for the workstation. Possible values: ");
429 while (*(++p) != '\0');
430 for (i = 0; surf_workstation_model_description[i].name; i++)
431 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
432 surf_workstation_model_description[i].name);
434 ".\n (use 'help' as a value to see the long description of each model)");
435 default_value = xbt_strdup("default");
436 xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string,
437 &default_value, 1, 1,
438 &_surf_cfg_cb__workstation_model, NULL);
440 xbt_free(description);
442 xbt_cfg_register(&_surf_cfg_set, "network/TCP_gamma",
443 "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)",
444 xbt_cfgelm_double, NULL, 1, 1,
445 _surf_cfg_cb__tcp_gamma, NULL);
446 xbt_cfg_setdefault_double(_surf_cfg_set, "network/TCP_gamma", 20000.0);
448 xbt_cfg_register(&_surf_cfg_set, "maxmin/precision",
449 "Numerical precision used when updating simulation models (epsilon in double comparisons)",
450 xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__maxmin_precision, NULL);
451 xbt_cfg_setdefault_double(_surf_cfg_set, "maxmin/precision", 0.00001); // FIXME use setdefault everywhere here!
453 /* The parameters of network models */
455 double_default_value = 0.0;
456 xbt_cfg_register(&_surf_cfg_set, "network/sender_gap",
457 "Minimum gap between two overlapping sends",
458 xbt_cfgelm_double, &double_default_value, 1, 1,
459 _surf_cfg_cb__sender_gap, NULL);
461 double_default_value = 1.0;
462 xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
463 "Correction factor to apply to the provided latency (default value set by network model)",
464 xbt_cfgelm_double, &double_default_value, 1, 1,
465 _surf_cfg_cb__latency_factor, NULL);
466 double_default_value = 1.0;
467 xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
468 "Correction factor to apply to the provided bandwidth (default value set by network model)",
469 xbt_cfgelm_double, &double_default_value, 1, 1,
470 _surf_cfg_cb__bandwidth_factor, NULL);
471 double_default_value = 0.0;
472 xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
473 "Correction factor to apply to the weight of competing streams(default value set by network model)",
474 xbt_cfgelm_double, &double_default_value, 1, 1,
475 _surf_cfg_cb__weight_S, NULL);
478 xbt_cfg_register(&_surf_cfg_set, "path",
479 "Lookup path for inclusions in platform and deployment XML files",
480 xbt_cfgelm_string, NULL, 0, 0,
481 _surf_cfg_cb__surf_path, NULL);
483 default_value_int = 0;
484 xbt_cfg_register(&_surf_cfg_set, "cpu/maxmin_selective_update",
485 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
486 xbt_cfgelm_int, &default_value_int, 0, 1,
488 default_value_int = 0;
489 xbt_cfg_register(&_surf_cfg_set, "network/maxmin_selective_update",
490 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
491 xbt_cfgelm_int, &default_value_int, 0, 1,
495 /* do model-checking */
496 xbt_cfg_register(&_surf_cfg_set, "model-check",
497 "Verify the system through model-checking instead of simulating it (EXPERIMENTAL)",
498 xbt_cfgelm_int, NULL, 0, 1,
499 _surf_cfg_cb_model_check, NULL);
500 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check", 0);
502 /* do stateful model-checking */
503 xbt_cfg_register(&_surf_cfg_set, "model-check/checkpoint",
504 "Specify the amount of steps between checkpoints during stateful model-checking (default: 0 => stateless verification). "
505 "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.",
506 xbt_cfgelm_int, NULL, 0, 1,
507 _mc_cfg_cb_checkpoint, NULL);
508 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/checkpoint", 0);
510 /* do liveness model-checking */
511 xbt_cfg_register(&_surf_cfg_set, "model-check/property",
512 "Specify the name of the file containing the property. It must be the result of the ltl2ba program.",
513 xbt_cfgelm_string, NULL, 0, 1,
514 _mc_cfg_cb_property, NULL);
515 xbt_cfg_setdefault_string(_surf_cfg_set, "model-check/property", "");
517 /* Specify the kind of model-checking reduction */
518 xbt_cfg_register(&_surf_cfg_set, "model-check/reduction",
519 "Specify the kind of exploration reduction (either none or DPOR)",
520 xbt_cfgelm_string, NULL, 0, 1,
521 _mc_cfg_cb_reduce, NULL);
522 xbt_cfg_setdefault_string(_surf_cfg_set, "model-check/reduction", "dpor");
524 /* Enable/disable timeout for wait requests with model-checking */
525 xbt_cfg_register(&_surf_cfg_set, "model-check/timeout",
526 "Enable/Disable timeout for wait requests",
527 xbt_cfgelm_int, NULL, 0, 1,
528 _mc_cfg_cb_timeout, NULL);
529 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/timeout", 0);
531 /* Set max depth exploration */
532 xbt_cfg_register(&_surf_cfg_set, "model-check/max_depth",
533 "Specify the max depth of exploration (default : 1000)",
534 xbt_cfgelm_int, NULL, 0, 1,
535 _mc_cfg_cb_max_depth, NULL);
536 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/max_depth", 1000);
538 /* Set number of visited state stored for state comparison reduction*/
539 xbt_cfg_register(&_surf_cfg_set, "model-check/visited",
540 "Specify the number of visited state stored for state comparison reduction. If value=5, the last 5 visited states are stored",
541 xbt_cfgelm_int, NULL, 0, 1,
542 _mc_cfg_cb_visited, NULL);
543 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/visited", 0);
546 /* do verbose-exit */
547 default_value_int = 1;
548 xbt_cfg_register(&_surf_cfg_set, "verbose-exit",
549 "Activate the \"do nothing\" mode in Ctrl-C",
550 xbt_cfgelm_int, &default_value_int, 0, 1,
551 _surf_cfg_cb_verbose_exit, NULL);
554 /* context factory */
555 default_value = xbt_strdup("ucontext");
556 xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
557 "Context factory to use in SIMIX (ucontext, thread or raw)",
558 xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);
560 /* stack size of contexts in Ko */
561 default_value_int = 128;
562 xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
563 "Stack size of contexts in Kib (ucontext or raw only)",
564 xbt_cfgelm_int, &default_value_int, 1, 1,
565 _surf_cfg_cb_context_stack_size, NULL);
567 /* number of parallel threads for user processes */
568 default_value_int = 1;
569 xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
570 "Number of parallel threads used to execute user contexts",
571 xbt_cfgelm_int, &default_value_int, 1, 1,
572 _surf_cfg_cb_contexts_nthreads, NULL);
574 /* minimal number of user contexts to be run in parallel */
575 default_value_int = 2;
576 xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
577 "Minimal number of user contexts to be run in parallel (raw contexts only)",
578 xbt_cfgelm_int, &default_value_int, 1, 1,
579 _surf_cfg_cb_contexts_parallel_threshold, NULL);
581 /* synchronization mode for parallel user contexts */
583 default_value = xbt_strdup("futex");
584 #else //No futex on mac and posix is unimplememted yet
585 default_value = xbt_strdup("busy_wait");
587 xbt_cfg_register(&_surf_cfg_set, "contexts/synchro",
588 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
589 xbt_cfgelm_string, &default_value, 1, 1,
590 _surf_cfg_cb_contexts_parallel_mode, NULL);
592 /* number of parallel threads for Surf */
593 default_value_int = surf_get_nthreads();
594 xbt_cfg_register(&_surf_cfg_set, "surf/nthreads",
595 "Number of parallel threads used to update Surf models",
596 xbt_cfgelm_int, &default_value_int, 1, 1,
597 _surf_cfg_cb_surf_nthreads, NULL);
599 default_value = xbt_strdup("no");
600 xbt_cfg_register(&_surf_cfg_set, "network/coordinates",
601 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
602 xbt_cfgelm_string, &default_value, 1, 1,
603 _surf_cfg_cb__surf_network_coordinates, NULL);
604 xbt_cfg_setdefault_string(_surf_cfg_set, "network/coordinates", default_value);
606 default_value_int = 0;
607 xbt_cfg_register(&_surf_cfg_set, "network/crosstraffic",
608 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
609 xbt_cfgelm_int, &default_value_int, 0, 1,
610 _surf_cfg_cb__surf_network_crosstraffic, NULL);
611 xbt_cfg_setdefault_int(_surf_cfg_set, "network/crosstraffic", default_value_int);
614 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter",
615 "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
616 xbt_cfgelm_double, NULL, 1, 1,
617 _surf_cfg_cb__gtnets_jitter, NULL);
618 xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets/jitter", 0.0);
620 default_value_int = 10;
621 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter_seed",
622 "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
623 xbt_cfgelm_int, &default_value_int, 0, 1,
624 _surf_cfg_cb__gtnets_jitter_seed, NULL);
627 xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
628 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
629 xbt_cfgelm_string, NULL, 1, 1,
631 xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
635 double default_reference_speed = 20000.0;
636 xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
637 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
638 xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
641 int default_display_timing = 0;
642 xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
643 "Boolean indicating whether we should display the timing after simulation.",
644 xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
647 double default_threshold = 1e-6;
648 xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
649 "Minimal computation time (in seconds) not discarded.",
650 xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
653 int default_small_messages_threshold = 0;
654 xbt_cfg_register(&_surf_cfg_set, "smpi/async_small_thres",
655 "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver",
656 xbt_cfgelm_int, &default_small_messages_threshold, 1, 1, NULL,
659 //For smpi/bw_factor and smpi/lat_factor
660 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
661 //test is if( size >= thresholdN ) return valueN;
662 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
663 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
664 xbt_cfg_register(&_surf_cfg_set, "smpi/bw_factor",
665 "Bandwidth factors for smpi.",
666 xbt_cfgelm_string, NULL, 1, 1, NULL,
668 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");
670 xbt_cfg_register(&_surf_cfg_set, "smpi/lat_factor",
671 "Latency factors for smpi.",
672 xbt_cfgelm_string, NULL, 1, 1, NULL,
674 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");
679 /* retrieves the current directory of the current process */
680 const char *initial_path = __surf_get_initial_path();
681 xbt_assert((initial_path),
682 "__surf_get_initial_path() failed! Can't resolves current Windows directory");
684 surf_path = xbt_dynar_new(sizeof(char *), NULL);
685 xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
688 _surf_init_status = 1;
690 surf_config_cmd_line(argc, argv);
693 XBT_WARN("Call to surf_config_init() after initialization ignored");
697 void surf_config_finalize(void)
699 if (!_surf_init_status)
700 return; /* Not initialized yet. Nothing to do */
702 xbt_cfg_free(&_surf_cfg_set);
703 _surf_init_status = 0;
706 /* Pick the right models for CPU, net and workstation, and call their model_init_preparse */
707 void surf_config_models_setup()
709 char *workstation_model_name;
710 int workstation_id = -1;
711 char *network_model_name = NULL;
712 char *cpu_model_name = NULL;
714 char *storage_model_name = NULL;
716 workstation_model_name =
717 xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
718 network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
719 cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
720 storage_model_name = xbt_cfg_get_string(_surf_cfg_set, "storage/model");
722 /* Check whether we use a net/cpu model differing from the default ones, in which case
723 * we should switch to the "compound" workstation model to correctly dispatch stuff to
724 * the right net/cpu models.
727 if((!xbt_cfg_is_default_value(_surf_cfg_set, "network/model") ||
728 !xbt_cfg_is_default_value(_surf_cfg_set, "cpu/model")) &&
729 xbt_cfg_is_default_value(_surf_cfg_set, "workstation/model"))
731 const char *val = "compound";
733 ("Switching workstation model to compound since you changed the network and/or cpu model(s)");
734 xbt_cfg_set_string(_surf_cfg_set, "workstation/model", val);
735 workstation_model_name = (char *) "compound";
738 XBT_DEBUG("Workstation model: %s", workstation_model_name);
740 find_model_description(surf_workstation_model_description,
741 workstation_model_name);
742 if (!strcmp(workstation_model_name, "compound")) {
746 xbt_assert(cpu_model_name,
747 "Set a cpu model to use with the 'compound' workstation model");
749 xbt_assert(network_model_name,
750 "Set a network model to use with the 'compound' workstation model");
753 find_model_description(surf_network_model_description,
756 find_model_description(surf_cpu_model_description, cpu_model_name);
758 surf_cpu_model_description[cpu_id].model_init_preparse();
759 surf_network_model_description[network_id].model_init_preparse();
762 XBT_DEBUG("Call workstation_model_init");
763 surf_workstation_model_description[workstation_id].model_init_preparse();
765 XBT_DEBUG("Call storage_model_init");
766 storage_id = find_model_description(surf_storage_model_description, storage_model_name);
767 surf_storage_model_description[storage_id].model_init_preparse();
769 /* ********************************************************************* */
770 /* TUTORIAL: New model */
771 int new_model_id = -1;
772 char *new_model_name = NULL;
773 new_model_name = xbt_cfg_get_string(_surf_cfg_set, "new_model/model");
774 XBT_DEBUG("Call new model_init");
775 new_model_id = find_model_description(surf_new_model_description, new_model_name);
776 surf_new_model_description[new_model_id].model_init_preparse();
777 /* ********************************************************************* */