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 /* Parse the command line, looking for options */
24 static void surf_config_cmd_line(int *argc, char **argv)
30 for (j = i = 1; i < *argc; i++) {
31 if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
32 opt = strchr(argv[i], '=');
35 xbt_cfg_set_parse(_surf_cfg_set, opt);
36 XBT_DEBUG("Did apply '%s' as config setting", opt);
37 } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) {
39 ("Description of the configuration accepted by this simulator:\n");
40 xbt_cfg_help(_surf_cfg_set);
43 "Each of these configurations can be used by adding\n"
44 " --cfg=<option name>:<option value>\n"
45 "to the command line.\n"
46 "You can also use --help-models to see the details of all models known by this simulator.\n"
49 "You can also use --help-tracing to see the details of all tracing options known by this simulator.\n"
52 "You can also use --help-logs and --help-log-categories to see the details of logging output.\n"
56 } else if (!strcmp(argv[i], "--help-models")) {
59 model_help("workstation", surf_workstation_model_description);
61 model_help("CPU", surf_cpu_model_description);
63 model_help("network", surf_network_model_description);
64 printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
65 for (k = 0; surf_optimization_mode_description[k].name; k++)
67 surf_optimization_mode_description[k].name,
68 surf_optimization_mode_description[k].description);
69 printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
72 } else if (!strcmp(argv[i], "--help-tracing")) {
89 int _surf_init_status = 0; /* 0: beginning of time;
90 1: pre-inited (cfg_set created);
91 2: inited (running) */
93 /* callback of the workstation/model variable */
94 static void _surf_cfg_cb__workstation_model(const char *name, int pos)
98 xbt_assert(_surf_init_status < 2,
99 "Cannot change the model after the initialization");
101 val = xbt_cfg_get_string(_surf_cfg_set, name);
103 if (!strcmp(val, "help")) {
104 model_help("workstation", surf_workstation_model_description);
108 /* Make sure that the model exists */
109 find_model_description(surf_workstation_model_description, val);
112 /* callback of the cpu/model variable */
113 static void _surf_cfg_cb__cpu_model(const char *name, int pos)
117 xbt_assert(_surf_init_status < 2,
118 "Cannot change the model after the initialization");
120 val = xbt_cfg_get_string(_surf_cfg_set, name);
122 if (!strcmp(val, "help")) {
123 model_help("CPU", surf_cpu_model_description);
127 /* New Module missing */
128 find_model_description(surf_cpu_model_description, val);
131 /* callback of the cpu/model variable */
132 static void _surf_cfg_cb__optimization_mode(const char *name, int pos)
136 xbt_assert(_surf_init_status < 2,
137 "Cannot change the model after the initialization");
139 val = xbt_cfg_get_string(_surf_cfg_set, name);
141 if (!strcmp(val, "help")) {
142 model_help("optimization", surf_optimization_mode_description);
146 /* New Module missing */
147 find_model_description(surf_optimization_mode_description, val);
150 /* callback of the cpu/model variable */
151 static void _surf_cfg_cb__storage_mode(const char *name, int pos)
155 xbt_assert(_surf_init_status < 2,
156 "Cannot change the model after the initialization");
158 val = xbt_cfg_get_string(_surf_cfg_set, name);
160 if (!strcmp(val, "help")) {
161 model_help("storage", surf_storage_model_description);
165 /* New Module missing */
166 find_model_description(surf_storage_model_description, val);
169 /* callback of the workstation_model variable */
170 static void _surf_cfg_cb__network_model(const char *name, int pos)
174 xbt_assert(_surf_init_status < 2,
175 "Cannot change the model after the initialization");
177 val = xbt_cfg_get_string(_surf_cfg_set, name);
179 if (!strcmp(val, "help")) {
180 model_help("network", surf_network_model_description);
184 /* New Module missing */
185 find_model_description(surf_network_model_description, val);
189 /* callbacks of the network models values */
190 static void _surf_cfg_cb__tcp_gamma(const char *name, int pos)
192 sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
195 static void _surf_cfg_cb__maxmin_precision(const char* name, int pos)
197 sg_maxmin_precision = xbt_cfg_get_double(_surf_cfg_set, name);
200 static void _surf_cfg_cb__sender_gap(const char* name, int pos)
202 sg_sender_gap = xbt_cfg_get_double(_surf_cfg_set, name);
205 static void _surf_cfg_cb__latency_factor(const char *name, int pos)
207 sg_latency_factor = xbt_cfg_get_double(_surf_cfg_set, name);
210 static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos)
212 sg_bandwidth_factor = xbt_cfg_get_double(_surf_cfg_set, name);
215 static void _surf_cfg_cb__weight_S(const char *name, int pos)
217 sg_weight_S_parameter = xbt_cfg_get_double(_surf_cfg_set, name);
220 /* callback of the inclusion path */
221 static void _surf_cfg_cb__surf_path(const char *name, int pos)
223 char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
224 xbt_dynar_push(surf_path, &path);
227 /* callback to decide if we want to use the model-checking */
228 #include "xbt_modinter.h"
229 extern int _surf_do_model_check; /* this variable lives in xbt_main until I find a right location for it */
231 static void _surf_cfg_cb_model_check(const char *name, int pos)
233 _surf_do_model_check = xbt_cfg_get_int(_surf_cfg_set, name);
235 if (_surf_do_model_check) {
237 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");
239 /* Tell modules using mallocators that they shouldn't. MC don't like them */
245 extern int _surf_do_verbose_exit;
247 static void _surf_cfg_cb_verbose_exit(const char *name, int pos)
249 _surf_do_verbose_exit = xbt_cfg_get_int(_surf_cfg_set, name);
253 static void _surf_cfg_cb_context_factory(const char *name, int pos) {
254 smx_context_factory_name = xbt_cfg_get_string(_surf_cfg_set, name);
257 static void _surf_cfg_cb_context_stack_size(const char *name, int pos)
259 smx_context_stack_size = xbt_cfg_get_int(_surf_cfg_set, name) * 1024;
262 static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
264 SIMIX_context_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
267 static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
269 SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_surf_cfg_set, name));
272 static void _surf_cfg_cb_contexts_parallel_mode(const char *name, int pos)
274 const char* mode_name = xbt_cfg_get_string(_surf_cfg_set, name);
275 if (!strcmp(mode_name, "posix")) {
276 SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
278 else if (!strcmp(mode_name, "futex")) {
279 SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
281 else if (!strcmp(mode_name, "busy_wait")) {
282 SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
285 xbt_die("Command line setting of the parallel synchronization mode should "
286 "be one of \"posix\", \"futex\" or \"busy_wait\"");
290 static void _surf_cfg_cb_surf_nthreads(const char *name, int pos)
292 surf_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
295 static void _surf_cfg_cb__surf_network_coordinates(const char *name,
298 char *val = xbt_cfg_get_string(_surf_cfg_set, name);
299 if (!strcmp(val, "yes")) {
300 if (!COORD_HOST_LEVEL) {
301 COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
302 COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
304 } else if (!strcmp(val, "no")) {
305 if (COORD_HOST_LEVEL)
306 xbt_die("Setting of whether to use coordinate cannot be disabled once set.");
308 xbt_die("Command line setting of whether to use coordinates must be either \"yes\" or \"no\"");
312 static void _surf_cfg_cb__surf_network_crosstraffic(const char *name,
315 sg_network_crosstraffic = xbt_cfg_get_int(_surf_cfg_set, name);
319 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos)
321 sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
324 static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
326 sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
330 /* create the config set, register what should be and parse the command line*/
331 void surf_config_init(int *argc, char **argv)
333 char *description = xbt_malloc(1024), *p = description;
335 double double_default_value;
336 int default_value_int;
339 /* Create the configuration support */
340 if (_surf_init_status == 0) { /* Only create stuff if not already inited */
342 "The model to use for the CPU. Possible values: ");
344 while (*(++p) != '\0');
345 for (i = 0; surf_cpu_model_description[i].name; i++)
346 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
347 surf_cpu_model_description[i].name);
349 ".\n (use 'help' as a value to see the long description of each model)");
350 default_value = xbt_strdup("Cas01");
351 xbt_cfg_register(&_surf_cfg_set, "cpu/model", description, xbt_cfgelm_string,
352 &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL);
355 "The optimization modes to use for the CPU. Possible values: ");
357 while (*(++p) != '\0');
358 for (i = 0; surf_optimization_mode_description[i].name; i++)
359 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
360 surf_optimization_mode_description[i].name);
362 ".\n (use 'help' as a value to see the long description of each optimization mode)");
363 default_value = xbt_strdup("Lazy");
364 xbt_cfg_register(&_surf_cfg_set, "cpu/optim", description, xbt_cfgelm_string,
365 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
368 "The model to use for the storage. Possible values: ");
370 while (*(++p) != '\0');
371 for (i = 0; surf_storage_model_description[i].name; i++)
372 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
373 surf_storage_model_description[i].name);
375 ".\n (use 'help' as a value to see the long description of each model)");
376 default_value = xbt_strdup("default");
377 xbt_cfg_register(&_surf_cfg_set, "storage/model", description, xbt_cfgelm_string,
378 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
381 /* ********************************************************************* */
382 /* TUTORIAL: New model */
384 "The model to use for the New model. Possible values: ");
386 while (*(++p) != '\0');
387 for (i = 0; surf_new_model_description[i].name; i++)
388 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
389 surf_new_model_description[i].name);
391 ".\n (use 'help' as a value to see the long description of each model)");
392 default_value = xbt_strdup("default");
393 xbt_cfg_register(&_surf_cfg_set, "new_model/model", description, xbt_cfgelm_string,
394 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
396 /* ********************************************************************* */
399 "The model to use for the network. Possible values: ");
401 while (*(++p) != '\0');
402 for (i = 0; surf_network_model_description[i].name; i++)
403 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
404 surf_network_model_description[i].name);
406 ".\n (use 'help' as a value to see the long description of each model)");
407 default_value = xbt_strdup("LV08");
408 xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string,
409 &default_value, 1, 1, &_surf_cfg_cb__network_model,
413 "The optimization modes to use for the network. Possible values: ");
415 while (*(++p) != '\0');
416 for (i = 0; surf_optimization_mode_description[i].name; i++)
417 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
418 surf_optimization_mode_description[i].name);
420 ".\n (use 'help' as a value to see the long description of each optimization mode)");
421 default_value = xbt_strdup("Lazy");
422 xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string,
423 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
426 "The model to use for the workstation. Possible values: ");
428 while (*(++p) != '\0');
429 for (i = 0; surf_workstation_model_description[i].name; i++)
430 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
431 surf_workstation_model_description[i].name);
433 ".\n (use 'help' as a value to see the long description of each model)");
434 default_value = xbt_strdup("default");
435 xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string,
436 &default_value, 1, 1,
437 &_surf_cfg_cb__workstation_model, NULL);
439 xbt_free(description);
441 xbt_cfg_register(&_surf_cfg_set, "network/TCP_gamma",
442 "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)",
443 xbt_cfgelm_double, NULL, 1, 1,
444 _surf_cfg_cb__tcp_gamma, NULL);
445 xbt_cfg_setdefault_double(_surf_cfg_set, "network/TCP_gamma", 20000.0);
447 xbt_cfg_register(&_surf_cfg_set, "maxmin/precision",
448 "Numerical precision used when updating simulation models (epsilon in double comparisons)",
449 xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__maxmin_precision, NULL);
450 xbt_cfg_setdefault_double(_surf_cfg_set, "maxmin/precision", 0.00001); // FIXME use setdefault everywhere here!
452 /* The parameters of network models */
454 double_default_value = 0.0;
455 xbt_cfg_register(&_surf_cfg_set, "network/sender_gap",
456 "Minimum gap between two overlapping sends",
457 xbt_cfgelm_double, &double_default_value, 1, 1,
458 _surf_cfg_cb__sender_gap, NULL);
460 double_default_value = 1.0;
461 xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
462 "Correction factor to apply to the provided latency (default value set by network model)",
463 xbt_cfgelm_double, &double_default_value, 1, 1,
464 _surf_cfg_cb__latency_factor, NULL);
465 double_default_value = 1.0;
466 xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
467 "Correction factor to apply to the provided bandwidth (default value set by network model)",
468 xbt_cfgelm_double, &double_default_value, 1, 1,
469 _surf_cfg_cb__bandwidth_factor, NULL);
470 double_default_value = 0.0;
471 xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
472 "Correction factor to apply to the weight of competing streams(default value set by network model)",
473 xbt_cfgelm_double, &double_default_value, 1, 1,
474 _surf_cfg_cb__weight_S, NULL);
477 xbt_cfg_register(&_surf_cfg_set, "path",
478 "Lookup path for inclusions in platform and deployment XML files",
479 xbt_cfgelm_string, NULL, 0, 0,
480 _surf_cfg_cb__surf_path, NULL);
482 default_value_int = 0;
483 xbt_cfg_register(&_surf_cfg_set, "cpu/maxmin_selective_update",
484 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
485 xbt_cfgelm_int, &default_value_int, 0, 1,
487 default_value_int = 0;
488 xbt_cfg_register(&_surf_cfg_set, "network/maxmin_selective_update",
489 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
490 xbt_cfgelm_int, &default_value_int, 0, 1,
494 /* do model-checking */
495 default_value_int = 0;
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, &default_value_int, 0, 1,
499 _surf_cfg_cb_model_check, NULL);
501 /* do stateful model-checking */
502 default_value_int = 0;
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, &default_value_int, 0, 1,
507 _mc_cfg_cb_checkpoint, NULL);
509 /* do liveness model-checking */
510 default_value = xbt_strdup("");
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, &default_value, 0, 1,
514 _mc_cfg_cb_property, NULL);
516 /* Specify the kind of model-checking reduction */
517 default_value = xbt_strdup("unset");
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, &default_value, 0, 1,
521 _mc_cfg_cb_reduce, NULL);
524 /* do verbose-exit */
525 default_value_int = 1;
526 xbt_cfg_register(&_surf_cfg_set, "verbose-exit",
527 "Activate the \"do nothing\" mode in Ctrl-C",
528 xbt_cfgelm_int, &default_value_int, 0, 1,
529 _surf_cfg_cb_verbose_exit, NULL);
532 /* context factory */
533 default_value = xbt_strdup("ucontext");
534 xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
535 "Context factory to use in SIMIX (ucontext, thread or raw)",
536 xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);
538 /* stack size of contexts in Ko */
539 default_value_int = 128;
540 xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
541 "Stack size of contexts in Kib (ucontext or raw only)",
542 xbt_cfgelm_int, &default_value_int, 1, 1,
543 _surf_cfg_cb_context_stack_size, NULL);
545 /* number of parallel threads for user processes */
546 default_value_int = 1;
547 xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
548 "Number of parallel threads used to execute user contexts",
549 xbt_cfgelm_int, &default_value_int, 1, 1,
550 _surf_cfg_cb_contexts_nthreads, NULL);
552 /* minimal number of user contexts to be run in parallel */
553 default_value_int = 2;
554 xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
555 "Minimal number of user contexts to be run in parallel (raw contexts only)",
556 xbt_cfgelm_int, &default_value_int, 1, 1,
557 _surf_cfg_cb_contexts_parallel_threshold, NULL);
559 /* synchronization mode for parallel user contexts */
561 default_value = xbt_strdup("futex");
562 #else //No futex on mac and posix is unimplememted yet
563 default_value = xbt_strdup("busy_wait");
565 xbt_cfg_register(&_surf_cfg_set, "contexts/synchro",
566 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
567 xbt_cfgelm_string, &default_value, 1, 1,
568 _surf_cfg_cb_contexts_parallel_mode, NULL);
570 /* number of parallel threads for Surf */
571 default_value_int = surf_get_nthreads();
572 xbt_cfg_register(&_surf_cfg_set, "surf/nthreads",
573 "Number of parallel threads used to update Surf models",
574 xbt_cfgelm_int, &default_value_int, 1, 1,
575 _surf_cfg_cb_surf_nthreads, NULL);
577 default_value = xbt_strdup("no");
578 xbt_cfg_register(&_surf_cfg_set, "network/coordinates",
579 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
580 xbt_cfgelm_string, &default_value, 1, 1,
581 _surf_cfg_cb__surf_network_coordinates, NULL);
582 xbt_cfg_setdefault_string(_surf_cfg_set, "network/coordinates", default_value);
584 default_value_int = 0;
585 xbt_cfg_register(&_surf_cfg_set, "network/crosstraffic",
586 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
587 xbt_cfgelm_int, &default_value_int, 0, 1,
588 _surf_cfg_cb__surf_network_crosstraffic, NULL);
589 xbt_cfg_setdefault_int(_surf_cfg_set, "network/crosstraffic", default_value_int);
592 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter",
593 "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
594 xbt_cfgelm_double, NULL, 1, 1,
595 _surf_cfg_cb__gtnets_jitter, NULL);
596 xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets/jitter", 0.0);
598 default_value_int = 10;
599 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter_seed",
600 "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
601 xbt_cfgelm_int, &default_value_int, 0, 1,
602 _surf_cfg_cb__gtnets_jitter_seed, NULL);
605 xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
606 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
607 xbt_cfgelm_string, NULL, 1, 1,
609 xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
613 double default_reference_speed = 20000.0;
614 xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
615 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
616 xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
619 int default_display_timing = 0;
620 xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
621 "Boolean indicating whether we should display the timing after simulation.",
622 xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
625 double default_threshold = 1e-6;
626 xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
627 "Minimal computation time (in seconds) not discarded.",
628 xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
631 int default_small_messages_threshold = 0;
632 xbt_cfg_register(&_surf_cfg_set, "smpi/async_small_thres",
633 "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver",
634 xbt_cfgelm_int, &default_small_messages_threshold, 1, 1, NULL,
637 //For smpi/bw_factor and smpi/lat_factor
638 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
639 //test is if( size >= thresholdN ) return valueN;
640 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
641 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
642 xbt_cfg_register(&_surf_cfg_set, "smpi/bw_factor",
643 "Bandwidth factors for smpi.",
644 xbt_cfgelm_string, NULL, 1, 1, NULL,
646 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");
648 xbt_cfg_register(&_surf_cfg_set, "smpi/lat_factor",
649 "Latency factors for smpi.",
650 xbt_cfgelm_string, NULL, 1, 1, NULL,
652 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");
657 /* retrieves the current directory of the current process */
658 const char *initial_path = __surf_get_initial_path();
659 xbt_assert((initial_path),
660 "__surf_get_initial_path() failed! Can't resolves current Windows directory");
662 surf_path = xbt_dynar_new(sizeof(char *), NULL);
663 xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
667 surf_config_cmd_line(argc, argv);
669 _surf_init_status = 1;
671 XBT_WARN("Call to surf_config_init() after initialization ignored");
675 void surf_config_finalize(void)
677 if (!_surf_init_status)
678 return; /* Not initialized yet. Nothing to do */
680 xbt_cfg_free(&_surf_cfg_set);
681 _surf_init_status = 0;
684 /* Pick the right models for CPU, net and workstation, and call their model_init_preparse */
685 void surf_config_models_setup()
687 char *workstation_model_name;
688 int workstation_id = -1;
689 char *network_model_name = NULL;
690 char *cpu_model_name = NULL;
692 char *storage_model_name = NULL;
694 workstation_model_name =
695 xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
696 network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
697 cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
698 storage_model_name = xbt_cfg_get_string(_surf_cfg_set, "storage/model");
700 /* Check whether we use a net/cpu model differing from the default ones, in which case
701 * we should switch to the "compound" workstation model to correctly dispatch stuff to
702 * the right net/cpu models.
705 if((!xbt_cfg_is_default_value(_surf_cfg_set, "network/model") ||
706 !xbt_cfg_is_default_value(_surf_cfg_set, "cpu/model")) &&
707 xbt_cfg_is_default_value(_surf_cfg_set, "workstation/model"))
709 const char *val = "compound";
711 ("Switching workstation model to compound since you changed the network and/or cpu model(s)");
712 xbt_cfg_set_string(_surf_cfg_set, "workstation/model", val);
713 workstation_model_name = (char *) "compound";
716 XBT_DEBUG("Workstation model: %s", workstation_model_name);
718 find_model_description(surf_workstation_model_description,
719 workstation_model_name);
720 if (!strcmp(workstation_model_name, "compound")) {
724 xbt_assert(cpu_model_name,
725 "Set a cpu model to use with the 'compound' workstation model");
727 xbt_assert(network_model_name,
728 "Set a network model to use with the 'compound' workstation model");
731 find_model_description(surf_network_model_description,
734 find_model_description(surf_cpu_model_description, cpu_model_name);
736 surf_cpu_model_description[cpu_id].model_init_preparse();
737 surf_network_model_description[network_id].model_init_preparse();
740 XBT_DEBUG("Call workstation_model_init");
741 surf_workstation_model_description[workstation_id].model_init_preparse();
743 XBT_DEBUG("Call storage_model_init");
744 storage_id = find_model_description(surf_storage_model_description, storage_model_name);
745 surf_storage_model_description[storage_id].model_init_preparse();
747 /* ********************************************************************* */
748 /* TUTORIAL: New model */
749 int new_model_id = -1;
750 char *new_model_name = NULL;
751 new_model_name = xbt_cfg_get_string(_surf_cfg_set, "new_model/model");
752 XBT_DEBUG("Call new model_init");
753 new_model_id = find_model_description(surf_new_model_description, new_model_name);
754 surf_new_model_description[new_model_id].model_init_preparse();
755 /* ********************************************************************* */