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 */
9 #include "xbt/config.h"
11 #include "surf/surf_private.h"
12 #include "surf/surf_routing.h" /* COORD_HOST_LEVEL and COORD_ASR_LEVEL */
13 #include "simix/context.h"
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf,
16 "About the configuration of surf (and the rest of the simulation)");
18 xbt_cfg_t _surf_cfg_set = NULL;
20 static void LOG_help(void)
23 "Description of the logging output:\n"
25 " Threshold configuration: --log=CATEGORY_NAME.thres:PRIORITY_LEVEL\n"
26 " CATEGORY_NAME: defined in code with function 'XBT_LOG_NEW_CATEGORY'\n"
27 " PRIORITY_LEVEL: the level to print (trace,debug,verbose,info,warning,error,critical)\n"
28 " -> trace: enter and return of some functions\n"
29 " -> debug: crufty output\n"
30 " -> verbose: verbose output for the user wanting more\n"
31 " -> info: output about the regular functionning\n"
32 " -> warning: minor issue encountered\n"
33 " -> error: issue encountered\n"
34 " -> critical: major issue encountered\n"
36 " Format configuration: --log=CATEGORY_NAME.fmt:OPTIONS\n"
38 " -> %%%%: the %% char\n"
39 " -> %%n: platform-dependent line separator (LOG4J compatible)\n"
40 " -> %%e: plain old space (SimGrid extension)\n"
42 " -> %%m: user-provided message\n"
44 " -> %%c: Category name (LOG4J compatible)\n"
45 " -> %%p: Priority name (LOG4J compatible)\n"
47 " -> %%h: Hostname (SimGrid extension)\n"
48 " -> %%P: Process name (SimGrid extension)\n"
49 " -> %%t: Thread \"name\" (LOG4J compatible -- actually the address of the thread in memory)\n"
50 " -> %%i: Process PID (SimGrid extension -- this is a 'i' as in 'i'dea)\n"
52 " -> %%F: file name where the log event was raised (LOG4J compatible)\n"
53 " -> %%l: location where the log event was raised (LOG4J compatible, like '%%F:%%L' -- this is a l as in 'l'etter)\n"
54 " -> %%L: line number where the log event was raised (LOG4J compatible)\n"
55 " -> %%M: function name (LOG4J compatible -- called method name here of course).\n"
56 " Defined only when using gcc because there is no __FUNCTION__ elsewhere.\n"
58 " -> %%b: full backtrace (Called %%throwable in LOG4J). Defined only under windows or when using the GNU libc because\n"
59 " backtrace() is not defined elsewhere, and we only have a fallback for windows boxes, not mac ones for example.\n"
60 " -> %%B: short backtrace (only the first line of the %%b). Called %%throwable{short} in LOG4J; defined where %%b is.\n"
62 " -> %%d: date (UNIX-like epoch)\n"
63 " -> %%r: application age (time elapsed since the beginning of the application)\n"
67 /* Parse the command line, looking for options */
68 static void surf_config_cmd_line(int *argc, char **argv)
73 for (i = 1; i < *argc; i++) {
75 if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
76 opt = strchr(argv[i], '=');
79 xbt_cfg_set_parse(_surf_cfg_set, opt);
80 XBT_DEBUG("Did apply '%s' as config setting", opt);
82 } else if (!strncmp(argv[i], "--cfg-help", strlen("--cfg-help") + 1) ||
83 !strncmp(argv[i], "--help", strlen("--help") + 1)) {
85 ("Description of the configuration accepted by this simulator:\n");
86 xbt_cfg_help(_surf_cfg_set);
89 "You can also use --help-models to see the details of all models known by this simulator.\n"
92 "You can also use --help-tracing to see the details of all tracing options known by this simulator.\n"
95 "You can also use --help-logs to see the details of logging output.\n"
99 } else if (!strncmp(argv[i], "--help-models", strlen("--help-models") + 1)) {
100 model_help("workstation", surf_workstation_model_description);
102 model_help("CPU", surf_cpu_model_description);
104 model_help("network", surf_network_model_description);
105 printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
106 for (i = 0; surf_optimization_mode_description[i].name; i++)
107 printf(" %s: %s\n", surf_optimization_mode_description[i].name, surf_optimization_mode_description[i].description);
108 printf("Both network and CPU models have 'Lazy' as default optimization level\n");
110 } else if (!strncmp(argv[i], "--help-logs", strlen("--help-logs") + 1)) {
114 } else if (!strncmp(argv[i], "--help-tracing", strlen("--help-tracing") + 1)) {
119 if (remove_it) { /*remove this from argv */
120 for (j = i + 1; j < *argc; j++) {
121 argv[j - 1] = argv[j];
126 i--; /* compensate effect of next loop incrementation */
132 int _surf_init_status = 0; /* 0: beginning of time;
133 1: pre-inited (cfg_set created);
134 2: inited (running) */
136 /* callback of the workstation/model variable */
137 static void _surf_cfg_cb__workstation_model(const char *name, int pos)
141 xbt_assert(_surf_init_status < 2,
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("workstation", surf_workstation_model_description);
151 /* Make sure that the model exists */
152 find_model_description(surf_workstation_model_description, val);
155 /* callback of the cpu/model variable */
156 static void _surf_cfg_cb__cpu_model(const char *name, int pos)
160 xbt_assert(_surf_init_status < 2,
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("CPU", surf_cpu_model_description);
170 /* New Module missing */
171 find_model_description(surf_cpu_model_description, val);
174 /* callback of the cpu/model variable */
175 static void _surf_cfg_cb__optimization_mode(const char *name, int pos)
179 xbt_assert(_surf_init_status < 2,
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("optimization", surf_optimization_mode_description);
189 /* New Module missing */
190 find_model_description(surf_optimization_mode_description, val);
193 /* callback of the cpu/model variable */
194 static void _surf_cfg_cb__storage_mode(const char *name, int pos)
198 xbt_assert(_surf_init_status < 2,
199 "Cannot change the model after the initialization");
201 val = xbt_cfg_get_string(_surf_cfg_set, name);
203 if (!strcmp(val, "help")) {
204 model_help("storage", surf_storage_model_description);
208 /* New Module missing */
209 find_model_description(surf_storage_model_description, val);
212 /* callback of the workstation_model variable */
213 static void _surf_cfg_cb__network_model(const char *name, int pos)
217 xbt_assert(_surf_init_status < 2,
218 "Cannot change the model after the initialization");
220 val = xbt_cfg_get_string(_surf_cfg_set, name);
222 if (!strcmp(val, "help")) {
223 model_help("network", surf_network_model_description);
227 /* New Module missing */
228 find_model_description(surf_network_model_description, val);
232 /* callbacks of the network models values */
233 static void _surf_cfg_cb__tcp_gamma(const char *name, int pos)
235 sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
238 static void _surf_cfg_cb__maxmin_precision(const char* name, int pos)
240 sg_maxmin_precision = xbt_cfg_get_double(_surf_cfg_set, name);
243 static void _surf_cfg_cb__sender_gap(const char* name, int pos)
245 sg_sender_gap = xbt_cfg_get_double(_surf_cfg_set, name);
248 static void _surf_cfg_cb__latency_factor(const char *name, int pos)
250 sg_latency_factor = xbt_cfg_get_double(_surf_cfg_set, name);
253 static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos)
255 sg_bandwidth_factor = xbt_cfg_get_double(_surf_cfg_set, name);
258 static void _surf_cfg_cb__weight_S(const char *name, int pos)
260 sg_weight_S_parameter = xbt_cfg_get_double(_surf_cfg_set, name);
263 /* callback of the inclusion path */
264 static void _surf_cfg_cb__surf_path(const char *name, int pos)
266 char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
267 xbt_dynar_push(surf_path, &path);
270 /* callback to decide if we want to use the model-checking */
271 #include "xbt_modinter.h"
272 extern int _surf_do_model_check; /* this variable lives in xbt_main until I find a right location for it */
274 static void _surf_cfg_cb_model_check(const char *name, int pos)
276 _surf_do_model_check = xbt_cfg_get_int(_surf_cfg_set, name);
278 if (_surf_do_model_check) {
279 /* Tell modules using mallocators that they shouldn't. MC don't like them */
285 extern int _surf_do_verbose_exit;
287 static void _surf_cfg_cb_verbose_exit(const char *name, int pos)
289 _surf_do_verbose_exit = xbt_cfg_get_int(_surf_cfg_set, name);
293 static void _surf_cfg_cb_context_factory(const char *name, int pos)
295 smx_context_factory_name = xbt_cfg_get_string(_surf_cfg_set, name);
298 static void _surf_cfg_cb_context_stack_size(const char *name, int pos)
300 smx_context_stack_size = xbt_cfg_get_int(_surf_cfg_set, name) * 1024;
303 static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
305 SIMIX_context_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
308 static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
310 SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_surf_cfg_set, name));
313 static void _surf_cfg_cb_contexts_parallel_mode(const char *name, int pos)
315 const char* mode_name = xbt_cfg_get_string(_surf_cfg_set, name);
316 if (!strcmp(mode_name, "posix")) {
317 SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
319 else if (!strcmp(mode_name, "futex")) {
320 SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
322 else if (!strcmp(mode_name, "busy_wait")) {
323 SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
326 xbt_die("Command line setting of the parallel synchronization mode should "
327 "be one of \"posix\", \"futex\" or \"busy_wait\"");
331 static void _surf_cfg_cb_surf_nthreads(const char *name, int pos)
333 surf_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
336 static void _surf_cfg_cb__surf_network_coordinates(const char *name,
339 char *val = xbt_cfg_get_string(_surf_cfg_set, name);
340 if (!strcmp(val, "yes")) {
341 if (!COORD_HOST_LEVEL) {
342 COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
343 COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
345 } else if (!strcmp(val, "no")) {
346 if (COORD_HOST_LEVEL)
347 xbt_die("Setting of whether to use coordinate cannot be disabled once set.");
349 xbt_die("Command line setting of whether to use coordinates must be either \"yes\" or \"no\"");
353 static void _surf_cfg_cb__surf_network_crosstraffic(const char *name,
356 sg_network_crosstraffic = xbt_cfg_get_int(_surf_cfg_set, name);
360 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos)
362 sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
365 static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
367 sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
371 /* create the config set, register what should be and parse the command line*/
372 void surf_config_init(int *argc, char **argv)
374 char *description = xbt_malloc(1024), *p = description;
376 double double_default_value;
377 int default_value_int;
380 /* Create the configuration support */
381 if (_surf_init_status == 0) { /* Only create stuff if not already inited */
382 _surf_init_status = 1;
385 "The model to use for the CPU. Possible values: ");
387 while (*(++p) != '\0');
388 for (i = 0; surf_cpu_model_description[i].name; i++)
389 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
390 surf_cpu_model_description[i].name);
392 ".\n (use 'help' as a value to see the long description of each model)");
393 default_value = xbt_strdup("Cas01");
394 xbt_cfg_register(&_surf_cfg_set, "cpu/model", description, xbt_cfgelm_string,
395 &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL);
398 "The optimization modes to use for the CPU. Possible values: ");
400 while (*(++p) != '\0');
401 for (i = 0; surf_optimization_mode_description[i].name; i++)
402 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
403 surf_optimization_mode_description[i].name);
405 ".\n (use 'help' as a value to see the long description of each optimization mode)");
406 default_value = xbt_strdup("Lazy");
407 xbt_cfg_register(&_surf_cfg_set, "cpu/optim", description, xbt_cfgelm_string,
408 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
411 "The model to use for the storage. Possible values: ");
413 while (*(++p) != '\0');
414 for (i = 0; surf_storage_model_description[i].name; i++)
415 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
416 surf_storage_model_description[i].name);
418 ".\n (use 'help' as a value to see the long description of each model)");
419 default_value = xbt_strdup("default");
420 xbt_cfg_register(&_surf_cfg_set, "storage/model", description, xbt_cfgelm_string,
421 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
425 "The model to use for the network. Possible values: ");
427 while (*(++p) != '\0');
428 for (i = 0; surf_network_model_description[i].name; i++)
429 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
430 surf_network_model_description[i].name);
432 ".\n (use 'help' as a value to see the long description of each model)");
433 default_value = xbt_strdup("LV08");
434 xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string,
435 &default_value, 1, 1, &_surf_cfg_cb__network_model,
439 "The optimization modes to use for the network. Possible values: ");
441 while (*(++p) != '\0');
442 for (i = 0; surf_optimization_mode_description[i].name; i++)
443 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
444 surf_optimization_mode_description[i].name);
446 ".\n (use 'help' as a value to see the long description of each optimization mode)");
447 default_value = xbt_strdup("Lazy");
448 xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string,
449 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
452 "The model to use for the workstation. Possible values: ");
454 while (*(++p) != '\0');
455 for (i = 0; surf_workstation_model_description[i].name; i++)
456 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
457 surf_workstation_model_description[i].name);
459 ".\n (use 'help' as a value to see the long description of each model)");
460 default_value = xbt_strdup("default");
461 xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string,
462 &default_value, 1, 1,
463 &_surf_cfg_cb__workstation_model, NULL);
465 xbt_free(description);
467 xbt_cfg_register(&_surf_cfg_set, "network/TCP_gamma",
468 "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)",
469 xbt_cfgelm_double, NULL, 1, 1,
470 _surf_cfg_cb__tcp_gamma, NULL);
471 xbt_cfg_setdefault_double(_surf_cfg_set, "network/TCP_gamma", 20000.0);
473 xbt_cfg_register(&_surf_cfg_set, "maxmin/precision",
474 "Numerical precision used when updating simulation models (epsilon in double comparisons)",
475 xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__maxmin_precision, NULL);
476 xbt_cfg_setdefault_double(_surf_cfg_set, "maxmin/precision", 0.00001); // FIXME use setdefault everywhere here!
478 /* The parameters of network models */
480 double_default_value = 0.0;
481 xbt_cfg_register(&_surf_cfg_set, "network/sender_gap",
482 "Minimum gap between two overlapping sends",
483 xbt_cfgelm_double, &double_default_value, 1, 1,
484 _surf_cfg_cb__sender_gap, NULL);
486 double_default_value = 1.0;
487 xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
488 "Correction factor to apply to the provided latency (default value set by network model)",
489 xbt_cfgelm_double, &double_default_value, 1, 1,
490 _surf_cfg_cb__latency_factor, NULL);
491 double_default_value = 1.0;
492 xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
493 "Correction factor to apply to the provided bandwidth (default value set by network model)",
494 xbt_cfgelm_double, &double_default_value, 1, 1,
495 _surf_cfg_cb__bandwidth_factor, NULL);
496 double_default_value = 0.0;
497 xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
498 "Correction factor to apply to the weight of competing streams(default value set by network model)",
499 xbt_cfgelm_double, &double_default_value, 1, 1,
500 _surf_cfg_cb__weight_S, NULL);
503 xbt_cfg_register(&_surf_cfg_set, "path",
504 "Lookup path for inclusions in platform and deployment XML files",
505 xbt_cfgelm_string, NULL, 0, 0,
506 _surf_cfg_cb__surf_path, NULL);
508 default_value_int = 0;
509 xbt_cfg_register(&_surf_cfg_set, "cpu/maxmin_selective_update",
510 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
511 xbt_cfgelm_int, &default_value_int, 0, 1,
513 default_value_int = 0;
514 xbt_cfg_register(&_surf_cfg_set, "network/maxmin_selective_update",
515 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
516 xbt_cfgelm_int, &default_value_int, 0, 1,
520 default_value_int = 0;
521 xbt_cfg_register(&_surf_cfg_set, "model-check",
522 "Activate the model-checking of the \"simulated\" system (EXPERIMENTAL -- msg only for now)",
523 xbt_cfgelm_int, &default_value_int, 0, 1,
524 _surf_cfg_cb_model_check, NULL);
527 FIXME: this function is not setting model-check to it's default value because
528 internally it calls to variable->cb_set that in this case is the function
529 _surf_cfg_cb_model_check which sets it's value to 1 (instead of the default value 0)
530 xbt_cfg_set_int(_surf_cfg_set, "model-check", default_value_int); */
532 /* do verbose-exit */
533 default_value_int = 1;
534 xbt_cfg_register(&_surf_cfg_set, "verbose-exit",
535 "Activate the \"do nothing\" mode in Ctrl-C",
536 xbt_cfgelm_int, &default_value_int, 0, 1,
537 _surf_cfg_cb_verbose_exit, NULL);
540 /* context factory */
541 default_value = xbt_strdup("ucontext");
542 xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
543 "Context factory to use in SIMIX (ucontext, thread or raw)",
544 xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);
546 /* stack size of contexts in Ko */
547 default_value_int = 128;
548 xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
549 "Stack size of contexts in Kib (ucontext or raw only)",
550 xbt_cfgelm_int, &default_value_int, 1, 1,
551 _surf_cfg_cb_context_stack_size, NULL);
553 /* number of parallel threads for user processes */
554 default_value_int = 1;
555 xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
556 "Number of parallel threads used to execute user contexts",
557 xbt_cfgelm_int, &default_value_int, 1, 1,
558 _surf_cfg_cb_contexts_nthreads, NULL);
560 /* minimal number of user contexts to be run in parallel */
561 default_value_int = 2;
562 xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
563 "Minimal number of user contexts to be run in parallel (raw contexts only)",
564 xbt_cfgelm_int, &default_value_int, 1, 1,
565 _surf_cfg_cb_contexts_parallel_threshold, NULL);
567 /* synchronization mode for parallel user contexts */
569 default_value = xbt_strdup("futex");
570 #else //No futex on mac and posix is unimplememted yet
571 default_value = xbt_strdup("busy_wait");
573 xbt_cfg_register(&_surf_cfg_set, "contexts/synchro",
574 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
575 xbt_cfgelm_string, &default_value, 1, 1,
576 _surf_cfg_cb_contexts_parallel_mode, NULL);
578 /* number of parallel threads for Surf */
579 default_value_int = surf_get_nthreads();
580 xbt_cfg_register(&_surf_cfg_set, "surf/nthreads",
581 "Number of parallel threads used to update Surf models",
582 xbt_cfgelm_int, &default_value_int, 1, 1,
583 _surf_cfg_cb_surf_nthreads, NULL);
585 default_value = xbt_strdup("no");
586 xbt_cfg_register(&_surf_cfg_set, "network/coordinates",
587 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
588 xbt_cfgelm_string, &default_value, 1, 1,
589 _surf_cfg_cb__surf_network_coordinates, NULL);
590 xbt_cfg_setdefault_string(_surf_cfg_set, "network/coordinates", default_value);
592 default_value_int = 0;
593 xbt_cfg_register(&_surf_cfg_set, "network/crosstraffic",
594 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
595 xbt_cfgelm_int, &default_value_int, 0, 1,
596 _surf_cfg_cb__surf_network_crosstraffic, NULL);
597 xbt_cfg_setdefault_int(_surf_cfg_set, "network/crosstraffic", default_value_int);
600 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter",
601 "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
602 xbt_cfgelm_double, NULL, 1, 1,
603 _surf_cfg_cb__gtnets_jitter, NULL);
604 xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets/jitter", 0.0);
606 default_value_int = 10;
607 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter_seed",
608 "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
609 xbt_cfgelm_int, &default_value_int, 0, 1,
610 _surf_cfg_cb__gtnets_jitter_seed, NULL);
613 xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
614 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
615 xbt_cfgelm_string, NULL, 1, 1,
617 xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
621 double default_reference_speed = 20000.0;
622 xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
623 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
624 xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
627 int default_display_timing = 0;
628 xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
629 "Boolean indicating whether we should display the timing after simulation.",
630 xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
633 double default_threshold = 1e-6;
634 xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
635 "Minimal computation time (in seconds) not discarded.",
636 xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
639 //For smpi/bw_factor and smpi/lat_factor
640 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
641 //test is if( size >= thresholdN ) return valueN;
642 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
643 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
644 xbt_cfg_register(&_surf_cfg_set, "smpi/bw_factor",
645 "Bandwidth factors for smpi.",
646 xbt_cfgelm_string, NULL, 1, 1, NULL,
648 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");
650 xbt_cfg_register(&_surf_cfg_set, "smpi/lat_factor",
651 "Latency factors for smpi.",
652 xbt_cfgelm_string, NULL, 1, 1, NULL,
654 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");
659 /* retrieves the current directory of the current process */
660 const char *initial_path = __surf_get_initial_path();
661 xbt_assert((initial_path),
662 "__surf_get_initial_path() failed! Can't resolves current Windows directory");
664 surf_path = xbt_dynar_new(sizeof(char *), NULL);
665 xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
669 surf_config_cmd_line(argc, argv);
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();