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,
382 "The model to use for the network. Possible values: ");
384 while (*(++p) != '\0');
385 for (i = 0; surf_network_model_description[i].name; i++)
386 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
387 surf_network_model_description[i].name);
389 ".\n (use 'help' as a value to see the long description of each model)");
390 default_value = xbt_strdup("LV08");
391 xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string,
392 &default_value, 1, 1, &_surf_cfg_cb__network_model,
396 "The optimization modes to use for the network. Possible values: ");
398 while (*(++p) != '\0');
399 for (i = 0; surf_optimization_mode_description[i].name; i++)
400 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
401 surf_optimization_mode_description[i].name);
403 ".\n (use 'help' as a value to see the long description of each optimization mode)");
404 default_value = xbt_strdup("Lazy");
405 xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string,
406 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
409 "The model to use for the workstation. Possible values: ");
411 while (*(++p) != '\0');
412 for (i = 0; surf_workstation_model_description[i].name; i++)
413 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
414 surf_workstation_model_description[i].name);
416 ".\n (use 'help' as a value to see the long description of each model)");
417 default_value = xbt_strdup("default");
418 xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string,
419 &default_value, 1, 1,
420 &_surf_cfg_cb__workstation_model, NULL);
422 xbt_free(description);
424 xbt_cfg_register(&_surf_cfg_set, "network/TCP_gamma",
425 "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)",
426 xbt_cfgelm_double, NULL, 1, 1,
427 _surf_cfg_cb__tcp_gamma, NULL);
428 xbt_cfg_setdefault_double(_surf_cfg_set, "network/TCP_gamma", 20000.0);
430 xbt_cfg_register(&_surf_cfg_set, "maxmin/precision",
431 "Numerical precision used when updating simulation models (epsilon in double comparisons)",
432 xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__maxmin_precision, NULL);
433 xbt_cfg_setdefault_double(_surf_cfg_set, "maxmin/precision", 0.00001); // FIXME use setdefault everywhere here!
435 /* The parameters of network models */
437 double_default_value = 0.0;
438 xbt_cfg_register(&_surf_cfg_set, "network/sender_gap",
439 "Minimum gap between two overlapping sends",
440 xbt_cfgelm_double, &double_default_value, 1, 1,
441 _surf_cfg_cb__sender_gap, NULL);
443 double_default_value = 1.0;
444 xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
445 "Correction factor to apply to the provided latency (default value set by network model)",
446 xbt_cfgelm_double, &double_default_value, 1, 1,
447 _surf_cfg_cb__latency_factor, NULL);
448 double_default_value = 1.0;
449 xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
450 "Correction factor to apply to the provided bandwidth (default value set by network model)",
451 xbt_cfgelm_double, &double_default_value, 1, 1,
452 _surf_cfg_cb__bandwidth_factor, NULL);
453 double_default_value = 0.0;
454 xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
455 "Correction factor to apply to the weight of competing streams(default value set by network model)",
456 xbt_cfgelm_double, &double_default_value, 1, 1,
457 _surf_cfg_cb__weight_S, NULL);
460 xbt_cfg_register(&_surf_cfg_set, "path",
461 "Lookup path for inclusions in platform and deployment XML files",
462 xbt_cfgelm_string, NULL, 0, 0,
463 _surf_cfg_cb__surf_path, NULL);
465 default_value_int = 0;
466 xbt_cfg_register(&_surf_cfg_set, "cpu/maxmin_selective_update",
467 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
468 xbt_cfgelm_int, &default_value_int, 0, 1,
470 default_value_int = 0;
471 xbt_cfg_register(&_surf_cfg_set, "network/maxmin_selective_update",
472 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
473 xbt_cfgelm_int, &default_value_int, 0, 1,
477 /* do model-checking */
478 default_value_int = 0;
479 xbt_cfg_register(&_surf_cfg_set, "model-check",
480 "Verify the system through model-checking instead of simulating it (EXPERIMENTAL)",
481 xbt_cfgelm_int, &default_value_int, 0, 1,
482 _surf_cfg_cb_model_check, NULL);
484 /* do stateful model-checking */
485 default_value_int = 0;
486 xbt_cfg_register(&_surf_cfg_set, "model-check/checkpoint",
487 "Specify the amount of steps between checkpoints during stateful model-checking (default: 0 => stateless verification). "
488 "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.",
489 xbt_cfgelm_int, &default_value_int, 0, 1,
490 _mc_cfg_cb_checkpoint, NULL);
492 /* do liveness model-checking */
493 default_value = xbt_strdup("");
494 xbt_cfg_register(&_surf_cfg_set, "model-check/property",
495 "Specify the name of the file containing the property. It must be the result of the ltl2ba program.",
496 xbt_cfgelm_string, &default_value, 0, 1,
497 _mc_cfg_cb_property, NULL);
499 /* Specify the kind of model-checking reduction */
500 default_value = xbt_strdup("unset");
501 xbt_cfg_register(&_surf_cfg_set, "model-check/reduction",
502 "Specify the kind of exploration reduction (either none or DPOR)",
503 xbt_cfgelm_string, &default_value, 0, 1,
504 _mc_cfg_cb_reduce, NULL);
507 /* do verbose-exit */
508 default_value_int = 1;
509 xbt_cfg_register(&_surf_cfg_set, "verbose-exit",
510 "Activate the \"do nothing\" mode in Ctrl-C",
511 xbt_cfgelm_int, &default_value_int, 0, 1,
512 _surf_cfg_cb_verbose_exit, NULL);
515 /* context factory */
516 default_value = xbt_strdup("ucontext");
517 xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
518 "Context factory to use in SIMIX (ucontext, thread or raw)",
519 xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);
521 /* stack size of contexts in Ko */
522 default_value_int = 128;
523 xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
524 "Stack size of contexts in Kib (ucontext or raw only)",
525 xbt_cfgelm_int, &default_value_int, 1, 1,
526 _surf_cfg_cb_context_stack_size, NULL);
528 /* number of parallel threads for user processes */
529 default_value_int = 1;
530 xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
531 "Number of parallel threads used to execute user contexts",
532 xbt_cfgelm_int, &default_value_int, 1, 1,
533 _surf_cfg_cb_contexts_nthreads, NULL);
535 /* minimal number of user contexts to be run in parallel */
536 default_value_int = 2;
537 xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
538 "Minimal number of user contexts to be run in parallel (raw contexts only)",
539 xbt_cfgelm_int, &default_value_int, 1, 1,
540 _surf_cfg_cb_contexts_parallel_threshold, NULL);
542 /* synchronization mode for parallel user contexts */
544 default_value = xbt_strdup("futex");
545 #else //No futex on mac and posix is unimplememted yet
546 default_value = xbt_strdup("busy_wait");
548 xbt_cfg_register(&_surf_cfg_set, "contexts/synchro",
549 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
550 xbt_cfgelm_string, &default_value, 1, 1,
551 _surf_cfg_cb_contexts_parallel_mode, NULL);
553 /* number of parallel threads for Surf */
554 default_value_int = surf_get_nthreads();
555 xbt_cfg_register(&_surf_cfg_set, "surf/nthreads",
556 "Number of parallel threads used to update Surf models",
557 xbt_cfgelm_int, &default_value_int, 1, 1,
558 _surf_cfg_cb_surf_nthreads, NULL);
560 default_value = xbt_strdup("no");
561 xbt_cfg_register(&_surf_cfg_set, "network/coordinates",
562 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
563 xbt_cfgelm_string, &default_value, 1, 1,
564 _surf_cfg_cb__surf_network_coordinates, NULL);
565 xbt_cfg_setdefault_string(_surf_cfg_set, "network/coordinates", default_value);
567 default_value_int = 0;
568 xbt_cfg_register(&_surf_cfg_set, "network/crosstraffic",
569 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
570 xbt_cfgelm_int, &default_value_int, 0, 1,
571 _surf_cfg_cb__surf_network_crosstraffic, NULL);
572 xbt_cfg_setdefault_int(_surf_cfg_set, "network/crosstraffic", default_value_int);
575 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter",
576 "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
577 xbt_cfgelm_double, NULL, 1, 1,
578 _surf_cfg_cb__gtnets_jitter, NULL);
579 xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets/jitter", 0.0);
581 default_value_int = 10;
582 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter_seed",
583 "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
584 xbt_cfgelm_int, &default_value_int, 0, 1,
585 _surf_cfg_cb__gtnets_jitter_seed, NULL);
588 xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
589 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
590 xbt_cfgelm_string, NULL, 1, 1,
592 xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
596 double default_reference_speed = 20000.0;
597 xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
598 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
599 xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
602 int default_display_timing = 0;
603 xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
604 "Boolean indicating whether we should display the timing after simulation.",
605 xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
608 double default_threshold = 1e-6;
609 xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
610 "Minimal computation time (in seconds) not discarded.",
611 xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
614 int default_small_messages_threshold = 0;
615 xbt_cfg_register(&_surf_cfg_set, "smpi/async_small_thres",
616 "Maximal size of messages that are to be sent asynchronously, without waiting for the receiver",
617 xbt_cfgelm_int, &default_small_messages_threshold, 1, 1, NULL,
620 //For smpi/bw_factor and smpi/lat_factor
621 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
622 //test is if( size >= thresholdN ) return valueN;
623 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
624 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
625 xbt_cfg_register(&_surf_cfg_set, "smpi/bw_factor",
626 "Bandwidth factors for smpi.",
627 xbt_cfgelm_string, NULL, 1, 1, NULL,
629 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");
631 xbt_cfg_register(&_surf_cfg_set, "smpi/lat_factor",
632 "Latency factors for smpi.",
633 xbt_cfgelm_string, NULL, 1, 1, NULL,
635 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");
640 /* retrieves the current directory of the current process */
641 const char *initial_path = __surf_get_initial_path();
642 xbt_assert((initial_path),
643 "__surf_get_initial_path() failed! Can't resolves current Windows directory");
645 surf_path = xbt_dynar_new(sizeof(char *), NULL);
646 xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
650 surf_config_cmd_line(argc, argv);
652 _surf_init_status = 1;
654 XBT_WARN("Call to surf_config_init() after initialization ignored");
658 void surf_config_finalize(void)
660 if (!_surf_init_status)
661 return; /* Not initialized yet. Nothing to do */
663 xbt_cfg_free(&_surf_cfg_set);
664 _surf_init_status = 0;
667 /* Pick the right models for CPU, net and workstation, and call their model_init_preparse */
668 void surf_config_models_setup()
670 char *workstation_model_name;
671 int workstation_id = -1;
672 char *network_model_name = NULL;
673 char *cpu_model_name = NULL;
675 char *storage_model_name = NULL;
677 workstation_model_name =
678 xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
679 network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
680 cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
681 storage_model_name = xbt_cfg_get_string(_surf_cfg_set, "storage/model");
683 /* Check whether we use a net/cpu model differing from the default ones, in which case
684 * we should switch to the "compound" workstation model to correctly dispatch stuff to
685 * the right net/cpu models.
688 if((!xbt_cfg_is_default_value(_surf_cfg_set, "network/model") ||
689 !xbt_cfg_is_default_value(_surf_cfg_set, "cpu/model")) &&
690 xbt_cfg_is_default_value(_surf_cfg_set, "workstation/model"))
692 const char *val = "compound";
694 ("Switching workstation model to compound since you changed the network and/or cpu model(s)");
695 xbt_cfg_set_string(_surf_cfg_set, "workstation/model", val);
696 workstation_model_name = (char *) "compound";
699 XBT_DEBUG("Workstation model: %s", workstation_model_name);
701 find_model_description(surf_workstation_model_description,
702 workstation_model_name);
703 if (!strcmp(workstation_model_name, "compound")) {
707 xbt_assert(cpu_model_name,
708 "Set a cpu model to use with the 'compound' workstation model");
710 xbt_assert(network_model_name,
711 "Set a network model to use with the 'compound' workstation model");
714 find_model_description(surf_network_model_description,
717 find_model_description(surf_cpu_model_description, cpu_model_name);
719 surf_cpu_model_description[cpu_id].model_init_preparse();
720 surf_network_model_description[network_id].model_init_preparse();
723 XBT_DEBUG("Call workstation_model_init");
724 surf_workstation_model_description[workstation_id].model_init_preparse();
726 XBT_DEBUG("Call storage_model_init");
727 storage_id = find_model_description(surf_storage_model_description, storage_model_name);
728 surf_storage_model_description[storage_id].model_init_preparse();