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"
12 #include "xbt/mallocator.h"
14 #include "surf/surf_private.h"
15 #include "surf/surf_routing.h" /* COORD_HOST_LEVEL and COORD_ASR_LEVEL */
16 #include "simgrid/simix.h"
17 #include "mc/mc.h" /* configuration callbacks of model-checking */
19 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf,
20 "About the configuration of surf (and the rest of the simulation)");
22 xbt_cfg_t _surf_cfg_set = NULL;
24 int _surf_init_status = 0; /* 0: beginning of time (config cannot be changed yet);
25 1: initialized: cfg_set created (config can now be changed);
26 2: configured: command line parsed and config part of platform file was integrated also, platform construction ongoing or done.
27 (Config cannot be changed anymore!) */
30 /* Parse the command line, looking for options */
31 static void surf_config_cmd_line(int *argc, char **argv)
37 for (j = i = 1; i < *argc; i++) {
38 if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
39 opt = strchr(argv[i], '=');
42 xbt_cfg_set_parse(_surf_cfg_set, opt);
43 XBT_DEBUG("Did apply '%s' as config setting", opt);
44 } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) {
46 ("Description of the configuration accepted by this simulator:\n");
47 xbt_cfg_help(_surf_cfg_set);
50 "Each of these configurations can be used by adding\n"
51 " --cfg=<option name>:<option value>\n"
52 "to the command line.\n"
53 "You can also use --help-models to see the details of all models known by this simulator.\n"
56 "You can also use --help-tracing to see the details of all tracing options known by this simulator.\n"
59 "You can also use --help-logs and --help-log-categories to see the details of logging output.\n"
63 } else if (!strcmp(argv[i], "--help-models")) {
66 model_help("workstation", surf_workstation_model_description);
68 model_help("CPU", surf_cpu_model_description);
70 model_help("network", surf_network_model_description);
71 printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
72 for (k = 0; surf_optimization_mode_description[k].name; k++)
74 surf_optimization_mode_description[k].name,
75 surf_optimization_mode_description[k].description);
76 printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
79 } else if (!strcmp(argv[i], "--help-tracing")) {
92 _surf_init_status=1; // get everything cleanly cleaned on exit
98 /* callback of the workstation/model variable */
99 static void _surf_cfg_cb__workstation_model(const char *name, int pos)
103 xbt_assert(_surf_init_status == 1,
104 "Cannot change the model after the initialization");
106 val = xbt_cfg_get_string(_surf_cfg_set, name);
108 if (!strcmp(val, "help")) {
109 model_help("workstation", surf_workstation_model_description);
113 /* Make sure that the model exists */
114 find_model_description(surf_workstation_model_description, val);
117 /* callback of the cpu/model variable */
118 static void _surf_cfg_cb__cpu_model(const char *name, int pos)
122 xbt_assert(_surf_init_status == 1,
123 "Cannot change the model after the initialization");
125 val = xbt_cfg_get_string(_surf_cfg_set, name);
127 if (!strcmp(val, "help")) {
128 model_help("CPU", surf_cpu_model_description);
132 /* New Module missing */
133 find_model_description(surf_cpu_model_description, val);
136 /* callback of the cpu/model variable */
137 static void _surf_cfg_cb__optimization_mode(const char *name, int pos)
141 xbt_assert(_surf_init_status == 1,
142 "Cannot change the model after the initialization");
144 val = xbt_cfg_get_string(_surf_cfg_set, name);
146 if (!strcmp(val, "help")) {
147 model_help("optimization", surf_optimization_mode_description);
151 /* New Module missing */
152 find_model_description(surf_optimization_mode_description, val);
155 /* callback of the cpu/model variable */
156 static void _surf_cfg_cb__storage_mode(const char *name, int pos)
160 xbt_assert(_surf_init_status == 1,
161 "Cannot change the model after the initialization");
163 val = xbt_cfg_get_string(_surf_cfg_set, name);
165 if (!strcmp(val, "help")) {
166 model_help("storage", surf_storage_model_description);
170 /* New Module missing */
171 find_model_description(surf_storage_model_description, val);
174 /* callback of the workstation_model variable */
175 static void _surf_cfg_cb__network_model(const char *name, int pos)
179 xbt_assert(_surf_init_status == 1,
180 "Cannot change the model after the initialization");
182 val = xbt_cfg_get_string(_surf_cfg_set, name);
184 if (!strcmp(val, "help")) {
185 model_help("network", surf_network_model_description);
189 /* New Module missing */
190 find_model_description(surf_network_model_description, val);
194 /* callbacks of the network models values */
195 static void _surf_cfg_cb__tcp_gamma(const char *name, int pos)
197 sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
200 static void _surf_cfg_cb__maxmin_precision(const char* name, int pos)
202 sg_maxmin_precision = xbt_cfg_get_double(_surf_cfg_set, name);
205 static void _surf_cfg_cb__sender_gap(const char* name, int pos)
207 sg_sender_gap = xbt_cfg_get_double(_surf_cfg_set, name);
210 static void _surf_cfg_cb__latency_factor(const char *name, int pos)
212 sg_latency_factor = xbt_cfg_get_double(_surf_cfg_set, name);
215 static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos)
217 sg_bandwidth_factor = xbt_cfg_get_double(_surf_cfg_set, name);
220 static void _surf_cfg_cb__weight_S(const char *name, int pos)
222 sg_weight_S_parameter = xbt_cfg_get_double(_surf_cfg_set, name);
225 /* callback of the inclusion path */
226 static void _surf_cfg_cb__surf_path(const char *name, int pos)
228 char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
229 xbt_dynar_push(surf_path, &path);
232 /* callback to decide if we want to use the model-checking */
233 #include "xbt_modinter.h"
234 extern int _surf_do_model_check; /* this variable lives in xbt_main until I find a right location for it */
236 static void _surf_cfg_cb_model_check(const char *name, int pos)
238 _surf_do_model_check = xbt_cfg_get_int(_surf_cfg_set, name);
241 if (_surf_do_model_check) {
242 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");
247 extern int _surf_do_verbose_exit;
249 static void _surf_cfg_cb_verbose_exit(const char *name, int pos)
251 _surf_do_verbose_exit = xbt_cfg_get_int(_surf_cfg_set, name);
255 static void _surf_cfg_cb_context_factory(const char *name, int pos) {
256 smx_context_factory_name = xbt_cfg_get_string(_surf_cfg_set, name);
259 static void _surf_cfg_cb_context_stack_size(const char *name, int pos)
261 smx_context_stack_size_was_set = 1;
262 smx_context_stack_size = xbt_cfg_get_int(_surf_cfg_set, name) * 1024;
265 static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
267 SIMIX_context_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
270 static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
272 SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_surf_cfg_set, name));
275 static void _surf_cfg_cb_contexts_parallel_mode(const char *name, int pos)
277 const char* mode_name = xbt_cfg_get_string(_surf_cfg_set, name);
278 if (!strcmp(mode_name, "posix")) {
279 SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
281 else if (!strcmp(mode_name, "futex")) {
282 SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
284 else if (!strcmp(mode_name, "busy_wait")) {
285 SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
288 xbt_die("Command line setting of the parallel synchronization mode should "
289 "be one of \"posix\", \"futex\" or \"busy_wait\"");
293 static void _surf_cfg_cb_surf_nthreads(const char *name, int pos)
295 surf_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
298 static void _surf_cfg_cb__surf_network_coordinates(const char *name,
301 char *val = xbt_cfg_get_string(_surf_cfg_set, name);
302 if (!strcmp(val, "yes")) {
303 if (!COORD_HOST_LEVEL) {
304 COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
305 COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
307 } else if (!strcmp(val, "no")) {
308 if (COORD_HOST_LEVEL)
309 xbt_die("Setting of whether to use coordinate cannot be disabled once set.");
311 xbt_die("Command line setting of whether to use coordinates must be either \"yes\" or \"no\"");
315 static void _surf_cfg_cb__surf_network_crosstraffic(const char *name,
318 sg_network_crosstraffic = xbt_cfg_get_int(_surf_cfg_set, name);
322 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos)
324 sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
327 static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
329 sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
333 /* create the config set, register what should be and parse the command line*/
334 void surf_config_init(int *argc, char **argv)
336 char *description = xbt_malloc(1024), *p = description;
338 double double_default_value;
339 int default_value_int;
342 /* Create the configuration support */
343 if (_surf_init_status == 0) { /* Only create stuff if not already inited */
345 "The model to use for the CPU. Possible values: ");
347 while (*(++p) != '\0');
348 for (i = 0; surf_cpu_model_description[i].name; i++)
349 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
350 surf_cpu_model_description[i].name);
352 ".\n (use 'help' as a value to see the long description of each model)");
353 default_value = xbt_strdup("Cas01");
354 xbt_cfg_register(&_surf_cfg_set, "cpu/model", description, xbt_cfgelm_string,
355 &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL);
358 "The optimization modes to use for the CPU. Possible values: ");
360 while (*(++p) != '\0');
361 for (i = 0; surf_optimization_mode_description[i].name; i++)
362 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
363 surf_optimization_mode_description[i].name);
365 ".\n (use 'help' as a value to see the long description of each optimization mode)");
366 default_value = xbt_strdup("Lazy");
367 xbt_cfg_register(&_surf_cfg_set, "cpu/optim", description, xbt_cfgelm_string,
368 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
371 "The model to use for the storage. Possible values: ");
373 while (*(++p) != '\0');
374 for (i = 0; surf_storage_model_description[i].name; i++)
375 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
376 surf_storage_model_description[i].name);
378 ".\n (use 'help' as a value to see the long description of each model)");
379 default_value = xbt_strdup("default");
380 xbt_cfg_register(&_surf_cfg_set, "storage/model", description, xbt_cfgelm_string,
381 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
384 /* ********************************************************************* */
385 /* TUTORIAL: New model */
387 "The model to use for the New model. Possible values: ");
389 while (*(++p) != '\0');
390 for (i = 0; surf_new_model_description[i].name; i++)
391 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
392 surf_new_model_description[i].name);
394 ".\n (use 'help' as a value to see the long description of each model)");
395 default_value = xbt_strdup("default");
396 xbt_cfg_register(&_surf_cfg_set, "new_model/model", description, xbt_cfgelm_string,
397 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
399 /* ********************************************************************* */
402 "The model to use for the network. Possible values: ");
404 while (*(++p) != '\0');
405 for (i = 0; surf_network_model_description[i].name; i++)
406 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
407 surf_network_model_description[i].name);
409 ".\n (use 'help' as a value to see the long description of each model)");
410 default_value = xbt_strdup("LV08");
411 xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string,
412 &default_value, 1, 1, &_surf_cfg_cb__network_model,
416 "The optimization modes to use for the network. Possible values: ");
418 while (*(++p) != '\0');
419 for (i = 0; surf_optimization_mode_description[i].name; i++)
420 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
421 surf_optimization_mode_description[i].name);
423 ".\n (use 'help' as a value to see the long description of each optimization mode)");
424 default_value = xbt_strdup("Lazy");
425 xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string,
426 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
429 "The model to use for the workstation. Possible values: ");
431 while (*(++p) != '\0');
432 for (i = 0; surf_workstation_model_description[i].name; i++)
433 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
434 surf_workstation_model_description[i].name);
436 ".\n (use 'help' as a value to see the long description of each model)");
437 default_value = xbt_strdup("default");
438 xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string,
439 &default_value, 1, 1,
440 &_surf_cfg_cb__workstation_model, NULL);
442 xbt_free(description);
444 xbt_cfg_register(&_surf_cfg_set, "network/TCP_gamma",
445 "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)",
446 xbt_cfgelm_double, NULL, 1, 1,
447 _surf_cfg_cb__tcp_gamma, NULL);
448 xbt_cfg_setdefault_double(_surf_cfg_set, "network/TCP_gamma", 4194304.0);
450 xbt_cfg_register(&_surf_cfg_set, "maxmin/precision",
451 "Numerical precision used when updating simulation models (epsilon in double comparisons)",
452 xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__maxmin_precision, NULL);
453 xbt_cfg_setdefault_double(_surf_cfg_set, "maxmin/precision", 0.00001); // FIXME use setdefault everywhere here!
455 /* The parameters of network models */
457 double_default_value = 0.0;
458 xbt_cfg_register(&_surf_cfg_set, "network/sender_gap",
459 "Minimum gap between two overlapping sends",
460 xbt_cfgelm_double, &double_default_value, 1, 1,
461 _surf_cfg_cb__sender_gap, NULL);
463 double_default_value = 1.0;
464 xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
465 "Correction factor to apply to the provided latency (default value set by network model)",
466 xbt_cfgelm_double, &double_default_value, 1, 1,
467 _surf_cfg_cb__latency_factor, NULL);
468 double_default_value = 1.0;
469 xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
470 "Correction factor to apply to the provided bandwidth (default value set by network model)",
471 xbt_cfgelm_double, &double_default_value, 1, 1,
472 _surf_cfg_cb__bandwidth_factor, NULL);
473 double_default_value = 0.0;
474 xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
475 "Correction factor to apply to the weight of competing streams(default value set by network model)",
476 xbt_cfgelm_double, &double_default_value, 1, 1,
477 _surf_cfg_cb__weight_S, NULL);
480 xbt_cfg_register(&_surf_cfg_set, "path",
481 "Lookup path for inclusions in platform and deployment XML files",
482 xbt_cfgelm_string, NULL, 0, 0,
483 _surf_cfg_cb__surf_path, NULL);
485 default_value_int = 0;
486 xbt_cfg_register(&_surf_cfg_set, "cpu/maxmin_selective_update",
487 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
488 xbt_cfgelm_int, &default_value_int, 0, 1,
490 default_value_int = 0;
491 xbt_cfg_register(&_surf_cfg_set, "network/maxmin_selective_update",
492 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
493 xbt_cfgelm_int, &default_value_int, 0, 1,
497 /* do model-checking */
498 xbt_cfg_register(&_surf_cfg_set, "model-check",
499 "Verify the system through model-checking instead of simulating it (EXPERIMENTAL)",
500 xbt_cfgelm_int, NULL, 0, 1,
501 _surf_cfg_cb_model_check, NULL);
502 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check", 0);
504 /* do stateful model-checking */
505 xbt_cfg_register(&_surf_cfg_set, "model-check/checkpoint",
506 "Specify the amount of steps between checkpoints during stateful model-checking (default: 0 => stateless verification). "
507 "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.",
508 xbt_cfgelm_int, NULL, 0, 1,
509 _mc_cfg_cb_checkpoint, NULL);
510 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/checkpoint", 0);
512 /* do liveness model-checking */
513 xbt_cfg_register(&_surf_cfg_set, "model-check/property",
514 "Specify the name of the file containing the property. It must be the result of the ltl2ba program.",
515 xbt_cfgelm_string, NULL, 0, 1,
516 _mc_cfg_cb_property, NULL);
517 xbt_cfg_setdefault_string(_surf_cfg_set, "model-check/property", "");
519 /* Specify the kind of model-checking reduction */
520 xbt_cfg_register(&_surf_cfg_set, "model-check/reduction",
521 "Specify the kind of exploration reduction (either none or DPOR)",
522 xbt_cfgelm_string, NULL, 0, 1,
523 _mc_cfg_cb_reduce, NULL);
524 xbt_cfg_setdefault_string(_surf_cfg_set, "model-check/reduction", "dpor");
526 /* Enable/disable timeout for wait requests with model-checking */
527 xbt_cfg_register(&_surf_cfg_set, "model-check/timeout",
528 "Enable/Disable timeout for wait requests",
529 xbt_cfgelm_int, NULL, 0, 1,
530 _mc_cfg_cb_timeout, NULL);
531 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/timeout", 0);
533 /* Set max depth exploration */
534 xbt_cfg_register(&_surf_cfg_set, "model-check/max_depth",
535 "Specify the max depth of exploration (default : 1000)",
536 xbt_cfgelm_int, NULL, 0, 1,
537 _mc_cfg_cb_max_depth, NULL);
538 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/max_depth", 1000);
540 /* Set number of visited state stored for state comparison reduction*/
541 xbt_cfg_register(&_surf_cfg_set, "model-check/visited",
542 "Specify the number of visited state stored for state comparison reduction. If value=5, the last 5 visited states are stored",
543 xbt_cfgelm_int, NULL, 0, 1,
544 _mc_cfg_cb_visited, NULL);
545 xbt_cfg_setdefault_int(_surf_cfg_set, "model-check/visited", 0);
548 /* do verbose-exit */
549 default_value_int = 1;
550 xbt_cfg_register(&_surf_cfg_set, "verbose-exit",
551 "Activate the \"do nothing\" mode in Ctrl-C",
552 xbt_cfgelm_int, &default_value_int, 0, 1,
553 _surf_cfg_cb_verbose_exit, NULL);
556 /* context factory */
557 default_value = xbt_strdup("ucontext");
558 xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
559 "Context factory to use in SIMIX (ucontext, thread or raw)",
560 xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);
562 /* stack size of contexts in Ko */
563 default_value_int = 128;
564 xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
565 "Stack size of contexts in Kib (ucontext or raw only)",
566 xbt_cfgelm_int, &default_value_int, 1, 1,
567 _surf_cfg_cb_context_stack_size, NULL);
569 /* number of parallel threads for user processes */
570 default_value_int = 1;
571 xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
572 "Number of parallel threads used to execute user contexts",
573 xbt_cfgelm_int, &default_value_int, 1, 1,
574 _surf_cfg_cb_contexts_nthreads, NULL);
576 /* minimal number of user contexts to be run in parallel */
577 default_value_int = 2;
578 xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
579 "Minimal number of user contexts to be run in parallel (raw contexts only)",
580 xbt_cfgelm_int, &default_value_int, 1, 1,
581 _surf_cfg_cb_contexts_parallel_threshold, NULL);
583 /* synchronization mode for parallel user contexts */
585 default_value = xbt_strdup("futex");
586 #else //No futex on mac and posix is unimplememted yet
587 default_value = xbt_strdup("busy_wait");
589 xbt_cfg_register(&_surf_cfg_set, "contexts/synchro",
590 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
591 xbt_cfgelm_string, &default_value, 1, 1,
592 _surf_cfg_cb_contexts_parallel_mode, NULL);
594 /* number of parallel threads for Surf */
595 default_value_int = surf_get_nthreads();
596 xbt_cfg_register(&_surf_cfg_set, "surf/nthreads",
597 "Number of parallel threads used to update Surf models",
598 xbt_cfgelm_int, &default_value_int, 1, 1,
599 _surf_cfg_cb_surf_nthreads, NULL);
601 default_value = xbt_strdup("no");
602 xbt_cfg_register(&_surf_cfg_set, "network/coordinates",
603 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
604 xbt_cfgelm_string, &default_value, 1, 1,
605 _surf_cfg_cb__surf_network_coordinates, NULL);
606 xbt_cfg_setdefault_string(_surf_cfg_set, "network/coordinates", default_value);
608 default_value_int = 0;
609 xbt_cfg_register(&_surf_cfg_set, "network/crosstraffic",
610 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
611 xbt_cfgelm_int, &default_value_int, 0, 1,
612 _surf_cfg_cb__surf_network_crosstraffic, NULL);
613 xbt_cfg_setdefault_int(_surf_cfg_set, "network/crosstraffic", default_value_int);
616 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter",
617 "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
618 xbt_cfgelm_double, NULL, 1, 1,
619 _surf_cfg_cb__gtnets_jitter, NULL);
620 xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets/jitter", 0.0);
622 default_value_int = 10;
623 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter_seed",
624 "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
625 xbt_cfgelm_int, &default_value_int, 0, 1,
626 _surf_cfg_cb__gtnets_jitter_seed, NULL);
629 xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
630 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
631 xbt_cfgelm_string, NULL, 1, 1,
633 xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
637 double default_reference_speed = 20000.0;
638 xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
639 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
640 xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
643 int default_display_timing = 0;
644 xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
645 "Boolean indicating whether we should display the timing after simulation.",
646 xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
649 double default_threshold = 1e-6;
650 xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
651 "Minimal computation time (in seconds) not discarded.",
652 xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
655 int default_small_messages_threshold = 0;
656 xbt_cfg_register(&_surf_cfg_set, "smpi/async_small_thres",
657 "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver",
658 xbt_cfgelm_int, &default_small_messages_threshold, 1, 1, NULL,
661 //For smpi/bw_factor and smpi/lat_factor
662 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
663 //test is if( size >= thresholdN ) return valueN;
664 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
665 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
666 xbt_cfg_register(&_surf_cfg_set, "smpi/bw_factor",
667 "Bandwidth factors for smpi.",
668 xbt_cfgelm_string, NULL, 1, 1, NULL,
670 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");
672 xbt_cfg_register(&_surf_cfg_set, "smpi/lat_factor",
673 "Latency factors for smpi.",
674 xbt_cfgelm_string, NULL, 1, 1, NULL,
676 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");
681 /* retrieves the current directory of the current process */
682 const char *initial_path = __surf_get_initial_path();
683 xbt_assert((initial_path),
684 "__surf_get_initial_path() failed! Can't resolves current Windows directory");
686 surf_path = xbt_dynar_new(sizeof(char *), NULL);
687 xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
690 _surf_init_status = 1;
692 surf_config_cmd_line(argc, argv);
694 xbt_mallocator_initialization_is_done(SIMIX_context_is_parallel());
697 XBT_WARN("Call to surf_config_init() after initialization ignored");
701 void surf_config_finalize(void)
703 if (!_surf_init_status)
704 return; /* Not initialized yet. Nothing to do */
706 xbt_cfg_free(&_surf_cfg_set);
707 _surf_init_status = 0;
710 /* Pick the right models for CPU, net and workstation, and call their model_init_preparse */
711 void surf_config_models_setup()
713 char *workstation_model_name;
714 int workstation_id = -1;
715 char *network_model_name = NULL;
716 char *cpu_model_name = NULL;
718 char *storage_model_name = NULL;
720 workstation_model_name =
721 xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
722 network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
723 cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
724 storage_model_name = xbt_cfg_get_string(_surf_cfg_set, "storage/model");
726 /* Check whether we use a net/cpu model differing from the default ones, in which case
727 * we should switch to the "compound" workstation model to correctly dispatch stuff to
728 * the right net/cpu models.
731 if((!xbt_cfg_is_default_value(_surf_cfg_set, "network/model") ||
732 !xbt_cfg_is_default_value(_surf_cfg_set, "cpu/model")) &&
733 xbt_cfg_is_default_value(_surf_cfg_set, "workstation/model"))
735 const char *val = "compound";
737 ("Switching workstation model to compound since you changed the network and/or cpu model(s)");
738 xbt_cfg_set_string(_surf_cfg_set, "workstation/model", val);
739 workstation_model_name = (char *) "compound";
742 XBT_DEBUG("Workstation model: %s", workstation_model_name);
744 find_model_description(surf_workstation_model_description,
745 workstation_model_name);
746 if (!strcmp(workstation_model_name, "compound")) {
750 xbt_assert(cpu_model_name,
751 "Set a cpu model to use with the 'compound' workstation model");
753 xbt_assert(network_model_name,
754 "Set a network model to use with the 'compound' workstation model");
757 find_model_description(surf_network_model_description,
760 find_model_description(surf_cpu_model_description, cpu_model_name);
762 surf_cpu_model_description[cpu_id].model_init_preparse();
763 surf_network_model_description[network_id].model_init_preparse();
766 XBT_DEBUG("Call workstation_model_init");
767 surf_workstation_model_description[workstation_id].model_init_preparse();
769 XBT_DEBUG("Call storage_model_init");
770 storage_id = find_model_description(surf_storage_model_description, storage_model_name);
771 surf_storage_model_description[storage_id].model_init_preparse();
773 /* ********************************************************************* */
774 /* TUTORIAL: New model */
775 int new_model_id = -1;
776 char *new_model_name = NULL;
777 new_model_name = xbt_cfg_get_string(_surf_cfg_set, "new_model/model");
778 XBT_DEBUG("Call new model_init");
779 new_model_id = find_model_description(surf_new_model_description, new_model_name);
780 surf_new_model_description[new_model_id].model_init_preparse();
781 /* ********************************************************************* */