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 (j = i = 1; i < *argc; i++) {
74 if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
75 opt = strchr(argv[i], '=');
78 xbt_cfg_set_parse(_surf_cfg_set, opt);
79 XBT_DEBUG("Did apply '%s' as config setting", opt);
80 } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) {
82 ("Description of the configuration accepted by this simulator:\n");
83 xbt_cfg_help(_surf_cfg_set);
86 "You can also use --help-models to see the details of all models known by this simulator.\n"
89 "You can also use --help-tracing to see the details of all tracing options known by this simulator.\n"
92 "You can also use --help-logs to see the details of logging output.\n"
96 } else if (!strcmp(argv[i], "--help-models")) {
97 model_help("workstation", surf_workstation_model_description);
99 model_help("CPU", surf_cpu_model_description);
101 model_help("network", surf_network_model_description);
102 printf("\nLong description of all optimization levels accepted by the models of this simulator:\n");
103 for (i = 0; surf_optimization_mode_description[i].name; i++)
104 printf(" %s: %s\n", surf_optimization_mode_description[i].name, surf_optimization_mode_description[i].description);
105 printf("Both network and CPU models have 'Lazy' as default optimization level\n");
107 } else if (!strcmp(argv[i], "--help-logs")) {
111 } else if (!strcmp(argv[i], "--help-tracing")) {
126 int _surf_init_status = 0; /* 0: beginning of time;
127 1: pre-inited (cfg_set created);
128 2: inited (running) */
130 /* callback of the workstation/model variable */
131 static void _surf_cfg_cb__workstation_model(const char *name, int pos)
135 xbt_assert(_surf_init_status < 2,
136 "Cannot change the model after the initialization");
138 val = xbt_cfg_get_string(_surf_cfg_set, name);
140 if (!strcmp(val, "help")) {
141 model_help("workstation", surf_workstation_model_description);
145 /* Make sure that the model exists */
146 find_model_description(surf_workstation_model_description, val);
149 /* callback of the cpu/model variable */
150 static void _surf_cfg_cb__cpu_model(const char *name, int pos)
154 xbt_assert(_surf_init_status < 2,
155 "Cannot change the model after the initialization");
157 val = xbt_cfg_get_string(_surf_cfg_set, name);
159 if (!strcmp(val, "help")) {
160 model_help("CPU", surf_cpu_model_description);
164 /* New Module missing */
165 find_model_description(surf_cpu_model_description, val);
168 /* callback of the cpu/model variable */
169 static void _surf_cfg_cb__optimization_mode(const char *name, int pos)
173 xbt_assert(_surf_init_status < 2,
174 "Cannot change the model after the initialization");
176 val = xbt_cfg_get_string(_surf_cfg_set, name);
178 if (!strcmp(val, "help")) {
179 model_help("optimization", surf_optimization_mode_description);
183 /* New Module missing */
184 find_model_description(surf_optimization_mode_description, val);
187 /* callback of the cpu/model variable */
188 static void _surf_cfg_cb__storage_mode(const char *name, int pos)
192 xbt_assert(_surf_init_status < 2,
193 "Cannot change the model after the initialization");
195 val = xbt_cfg_get_string(_surf_cfg_set, name);
197 if (!strcmp(val, "help")) {
198 model_help("storage", surf_storage_model_description);
202 /* New Module missing */
203 find_model_description(surf_storage_model_description, val);
206 /* callback of the workstation_model variable */
207 static void _surf_cfg_cb__network_model(const char *name, int pos)
211 xbt_assert(_surf_init_status < 2,
212 "Cannot change the model after the initialization");
214 val = xbt_cfg_get_string(_surf_cfg_set, name);
216 if (!strcmp(val, "help")) {
217 model_help("network", surf_network_model_description);
221 /* New Module missing */
222 find_model_description(surf_network_model_description, val);
226 /* callbacks of the network models values */
227 static void _surf_cfg_cb__tcp_gamma(const char *name, int pos)
229 sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
232 static void _surf_cfg_cb__maxmin_precision(const char* name, int pos)
234 sg_maxmin_precision = xbt_cfg_get_double(_surf_cfg_set, name);
237 static void _surf_cfg_cb__sender_gap(const char* name, int pos)
239 sg_sender_gap = xbt_cfg_get_double(_surf_cfg_set, name);
242 static void _surf_cfg_cb__latency_factor(const char *name, int pos)
244 sg_latency_factor = xbt_cfg_get_double(_surf_cfg_set, name);
247 static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos)
249 sg_bandwidth_factor = xbt_cfg_get_double(_surf_cfg_set, name);
252 static void _surf_cfg_cb__weight_S(const char *name, int pos)
254 sg_weight_S_parameter = xbt_cfg_get_double(_surf_cfg_set, name);
257 /* callback of the inclusion path */
258 static void _surf_cfg_cb__surf_path(const char *name, int pos)
260 char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
261 xbt_dynar_push(surf_path, &path);
264 /* callback to decide if we want to use the model-checking */
265 #include "xbt_modinter.h"
266 extern int _surf_do_model_check; /* this variable lives in xbt_main until I find a right location for it */
268 static void _surf_cfg_cb_model_check(const char *name, int pos)
270 _surf_do_model_check = xbt_cfg_get_int(_surf_cfg_set, name);
272 if (_surf_do_model_check) {
273 /* Tell modules using mallocators that they shouldn't. MC don't like them */
279 extern int _surf_do_verbose_exit;
281 static void _surf_cfg_cb_verbose_exit(const char *name, int pos)
283 _surf_do_verbose_exit = xbt_cfg_get_int(_surf_cfg_set, name);
287 static void _surf_cfg_cb_context_factory(const char *name, int pos)
289 smx_context_factory_name = xbt_cfg_get_string(_surf_cfg_set, name);
292 static void _surf_cfg_cb_context_stack_size(const char *name, int pos)
294 smx_context_stack_size = xbt_cfg_get_int(_surf_cfg_set, name) * 1024;
297 static void _surf_cfg_cb_contexts_nthreads(const char *name, int pos)
299 SIMIX_context_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
302 static void _surf_cfg_cb_contexts_parallel_threshold(const char *name, int pos)
304 SIMIX_context_set_parallel_threshold(xbt_cfg_get_int(_surf_cfg_set, name));
307 static void _surf_cfg_cb_contexts_parallel_mode(const char *name, int pos)
309 const char* mode_name = xbt_cfg_get_string(_surf_cfg_set, name);
310 if (!strcmp(mode_name, "posix")) {
311 SIMIX_context_set_parallel_mode(XBT_PARMAP_POSIX);
313 else if (!strcmp(mode_name, "futex")) {
314 SIMIX_context_set_parallel_mode(XBT_PARMAP_FUTEX);
316 else if (!strcmp(mode_name, "busy_wait")) {
317 SIMIX_context_set_parallel_mode(XBT_PARMAP_BUSY_WAIT);
320 xbt_die("Command line setting of the parallel synchronization mode should "
321 "be one of \"posix\", \"futex\" or \"busy_wait\"");
325 static void _surf_cfg_cb_surf_nthreads(const char *name, int pos)
327 surf_set_nthreads(xbt_cfg_get_int(_surf_cfg_set, name));
330 static void _surf_cfg_cb__surf_network_coordinates(const char *name,
333 char *val = xbt_cfg_get_string(_surf_cfg_set, name);
334 if (!strcmp(val, "yes")) {
335 if (!COORD_HOST_LEVEL) {
336 COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
337 COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
339 } else if (!strcmp(val, "no")) {
340 if (COORD_HOST_LEVEL)
341 xbt_die("Setting of whether to use coordinate cannot be disabled once set.");
343 xbt_die("Command line setting of whether to use coordinates must be either \"yes\" or \"no\"");
347 static void _surf_cfg_cb__surf_network_crosstraffic(const char *name,
350 sg_network_crosstraffic = xbt_cfg_get_int(_surf_cfg_set, name);
354 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos)
356 sg_gtnets_jitter = xbt_cfg_get_double(_surf_cfg_set, name);
359 static void _surf_cfg_cb__gtnets_jitter_seed(const char *name, int pos)
361 sg_gtnets_jitter_seed = xbt_cfg_get_int(_surf_cfg_set, name);
365 /* create the config set, register what should be and parse the command line*/
366 void surf_config_init(int *argc, char **argv)
368 char *description = xbt_malloc(1024), *p = description;
370 double double_default_value;
371 int default_value_int;
374 /* Create the configuration support */
375 if (_surf_init_status == 0) { /* Only create stuff if not already inited */
376 _surf_init_status = 1;
379 "The model to use for the CPU. Possible values: ");
381 while (*(++p) != '\0');
382 for (i = 0; surf_cpu_model_description[i].name; i++)
383 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
384 surf_cpu_model_description[i].name);
386 ".\n (use 'help' as a value to see the long description of each model)");
387 default_value = xbt_strdup("Cas01");
388 xbt_cfg_register(&_surf_cfg_set, "cpu/model", description, xbt_cfgelm_string,
389 &default_value, 1, 1, &_surf_cfg_cb__cpu_model, NULL);
392 "The optimization modes to use for the CPU. Possible values: ");
394 while (*(++p) != '\0');
395 for (i = 0; surf_optimization_mode_description[i].name; i++)
396 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
397 surf_optimization_mode_description[i].name);
399 ".\n (use 'help' as a value to see the long description of each optimization mode)");
400 default_value = xbt_strdup("Lazy");
401 xbt_cfg_register(&_surf_cfg_set, "cpu/optim", description, xbt_cfgelm_string,
402 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
405 "The model to use for the storage. Possible values: ");
407 while (*(++p) != '\0');
408 for (i = 0; surf_storage_model_description[i].name; i++)
409 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
410 surf_storage_model_description[i].name);
412 ".\n (use 'help' as a value to see the long description of each model)");
413 default_value = xbt_strdup("default");
414 xbt_cfg_register(&_surf_cfg_set, "storage/model", description, xbt_cfgelm_string,
415 &default_value, 1, 1, &_surf_cfg_cb__storage_mode,
419 "The model to use for the network. Possible values: ");
421 while (*(++p) != '\0');
422 for (i = 0; surf_network_model_description[i].name; i++)
423 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
424 surf_network_model_description[i].name);
426 ".\n (use 'help' as a value to see the long description of each model)");
427 default_value = xbt_strdup("LV08");
428 xbt_cfg_register(&_surf_cfg_set, "network/model", description, xbt_cfgelm_string,
429 &default_value, 1, 1, &_surf_cfg_cb__network_model,
433 "The optimization modes to use for the network. Possible values: ");
435 while (*(++p) != '\0');
436 for (i = 0; surf_optimization_mode_description[i].name; i++)
437 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
438 surf_optimization_mode_description[i].name);
440 ".\n (use 'help' as a value to see the long description of each optimization mode)");
441 default_value = xbt_strdup("Lazy");
442 xbt_cfg_register(&_surf_cfg_set, "network/optim", description, xbt_cfgelm_string,
443 &default_value, 1, 1, &_surf_cfg_cb__optimization_mode, NULL);
446 "The model to use for the workstation. Possible values: ");
448 while (*(++p) != '\0');
449 for (i = 0; surf_workstation_model_description[i].name; i++)
450 p += sprintf(p, "%s%s", (i == 0 ? "" : ", "),
451 surf_workstation_model_description[i].name);
453 ".\n (use 'help' as a value to see the long description of each model)");
454 default_value = xbt_strdup("default");
455 xbt_cfg_register(&_surf_cfg_set, "workstation/model", description, xbt_cfgelm_string,
456 &default_value, 1, 1,
457 &_surf_cfg_cb__workstation_model, NULL);
459 xbt_free(description);
461 xbt_cfg_register(&_surf_cfg_set, "network/TCP_gamma",
462 "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)",
463 xbt_cfgelm_double, NULL, 1, 1,
464 _surf_cfg_cb__tcp_gamma, NULL);
465 xbt_cfg_setdefault_double(_surf_cfg_set, "network/TCP_gamma", 20000.0);
467 xbt_cfg_register(&_surf_cfg_set, "maxmin/precision",
468 "Numerical precision used when updating simulation models (epsilon in double comparisons)",
469 xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__maxmin_precision, NULL);
470 xbt_cfg_setdefault_double(_surf_cfg_set, "maxmin/precision", 0.00001); // FIXME use setdefault everywhere here!
472 /* The parameters of network models */
474 double_default_value = 0.0;
475 xbt_cfg_register(&_surf_cfg_set, "network/sender_gap",
476 "Minimum gap between two overlapping sends",
477 xbt_cfgelm_double, &double_default_value, 1, 1,
478 _surf_cfg_cb__sender_gap, NULL);
480 double_default_value = 1.0;
481 xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
482 "Correction factor to apply to the provided latency (default value set by network model)",
483 xbt_cfgelm_double, &double_default_value, 1, 1,
484 _surf_cfg_cb__latency_factor, NULL);
485 double_default_value = 1.0;
486 xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
487 "Correction factor to apply to the provided bandwidth (default value set by network model)",
488 xbt_cfgelm_double, &double_default_value, 1, 1,
489 _surf_cfg_cb__bandwidth_factor, NULL);
490 double_default_value = 0.0;
491 xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
492 "Correction factor to apply to the weight of competing streams(default value set by network model)",
493 xbt_cfgelm_double, &double_default_value, 1, 1,
494 _surf_cfg_cb__weight_S, NULL);
497 xbt_cfg_register(&_surf_cfg_set, "path",
498 "Lookup path for inclusions in platform and deployment XML files",
499 xbt_cfgelm_string, NULL, 0, 0,
500 _surf_cfg_cb__surf_path, NULL);
502 default_value_int = 0;
503 xbt_cfg_register(&_surf_cfg_set, "cpu/maxmin_selective_update",
504 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
505 xbt_cfgelm_int, &default_value_int, 0, 1,
507 default_value_int = 0;
508 xbt_cfg_register(&_surf_cfg_set, "network/maxmin_selective_update",
509 "Update the constraint set propagating recursively to others constraints (1 by default when optim is set to lazy)",
510 xbt_cfgelm_int, &default_value_int, 0, 1,
514 default_value_int = 0;
515 xbt_cfg_register(&_surf_cfg_set, "model-check",
516 "Activate the model-checking of the \"simulated\" system (EXPERIMENTAL -- msg only for now)",
517 xbt_cfgelm_int, &default_value_int, 0, 1,
518 _surf_cfg_cb_model_check, NULL);
521 FIXME: this function is not setting model-check to it's default value because
522 internally it calls to variable->cb_set that in this case is the function
523 _surf_cfg_cb_model_check which sets it's value to 1 (instead of the default value 0)
524 xbt_cfg_set_int(_surf_cfg_set, "model-check", default_value_int); */
526 /* do verbose-exit */
527 default_value_int = 1;
528 xbt_cfg_register(&_surf_cfg_set, "verbose-exit",
529 "Activate the \"do nothing\" mode in Ctrl-C",
530 xbt_cfgelm_int, &default_value_int, 0, 1,
531 _surf_cfg_cb_verbose_exit, NULL);
534 /* context factory */
535 default_value = xbt_strdup("ucontext");
536 xbt_cfg_register(&_surf_cfg_set, "contexts/factory",
537 "Context factory to use in SIMIX (ucontext, thread or raw)",
538 xbt_cfgelm_string, &default_value, 1, 1, _surf_cfg_cb_context_factory, NULL);
540 /* stack size of contexts in Ko */
541 default_value_int = 128;
542 xbt_cfg_register(&_surf_cfg_set, "contexts/stack_size",
543 "Stack size of contexts in Kib (ucontext or raw only)",
544 xbt_cfgelm_int, &default_value_int, 1, 1,
545 _surf_cfg_cb_context_stack_size, NULL);
547 /* number of parallel threads for user processes */
548 default_value_int = 1;
549 xbt_cfg_register(&_surf_cfg_set, "contexts/nthreads",
550 "Number of parallel threads used to execute user contexts",
551 xbt_cfgelm_int, &default_value_int, 1, 1,
552 _surf_cfg_cb_contexts_nthreads, NULL);
554 /* minimal number of user contexts to be run in parallel */
555 default_value_int = 2;
556 xbt_cfg_register(&_surf_cfg_set, "contexts/parallel_threshold",
557 "Minimal number of user contexts to be run in parallel (raw contexts only)",
558 xbt_cfgelm_int, &default_value_int, 1, 1,
559 _surf_cfg_cb_contexts_parallel_threshold, NULL);
561 /* synchronization mode for parallel user contexts */
563 default_value = xbt_strdup("futex");
564 #else //No futex on mac and posix is unimplememted yet
565 default_value = xbt_strdup("busy_wait");
567 xbt_cfg_register(&_surf_cfg_set, "contexts/synchro",
568 "Synchronization mode to use when running contexts in parallel (either futex, posix or busy_wait)",
569 xbt_cfgelm_string, &default_value, 1, 1,
570 _surf_cfg_cb_contexts_parallel_mode, NULL);
572 /* number of parallel threads for Surf */
573 default_value_int = surf_get_nthreads();
574 xbt_cfg_register(&_surf_cfg_set, "surf/nthreads",
575 "Number of parallel threads used to update Surf models",
576 xbt_cfgelm_int, &default_value_int, 1, 1,
577 _surf_cfg_cb_surf_nthreads, NULL);
579 default_value = xbt_strdup("no");
580 xbt_cfg_register(&_surf_cfg_set, "network/coordinates",
581 "\"yes\" or \"no\", specifying whether we use a coordinate-based routing (as Vivaldi)",
582 xbt_cfgelm_string, &default_value, 1, 1,
583 _surf_cfg_cb__surf_network_coordinates, NULL);
584 xbt_cfg_setdefault_string(_surf_cfg_set, "network/coordinates", default_value);
586 default_value_int = 0;
587 xbt_cfg_register(&_surf_cfg_set, "network/crosstraffic",
588 "Activate the interferences between uploads and downloads for fluid max-min models (LV08, CM02)",
589 xbt_cfgelm_int, &default_value_int, 0, 1,
590 _surf_cfg_cb__surf_network_crosstraffic, NULL);
591 xbt_cfg_setdefault_int(_surf_cfg_set, "network/crosstraffic", default_value_int);
594 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter",
595 "Double value to oscillate the link latency, uniformly in random interval [-latency*gtnets_jitter,latency*gtnets_jitter)",
596 xbt_cfgelm_double, NULL, 1, 1,
597 _surf_cfg_cb__gtnets_jitter, NULL);
598 xbt_cfg_setdefault_double(_surf_cfg_set, "gtnets/jitter", 0.0);
600 default_value_int = 10;
601 xbt_cfg_register(&_surf_cfg_set, "gtnets/jitter_seed",
602 "Use a positive seed to reproduce jitted results, value must be in [1,1e8], default is 10",
603 xbt_cfgelm_int, &default_value_int, 0, 1,
604 _surf_cfg_cb__gtnets_jitter_seed, NULL);
607 xbt_cfg_register(&_surf_cfg_set, "ns3/TcpModel",
608 "The ns3 tcp model can be : NewReno or Reno or Tahoe",
609 xbt_cfgelm_string, NULL, 1, 1,
611 xbt_cfg_setdefault_string(_surf_cfg_set, "ns3/TcpModel", "default");
615 double default_reference_speed = 20000.0;
616 xbt_cfg_register(&_surf_cfg_set, "smpi/running_power",
617 "Power of the host running the simulation (in flop/s). Used to bench the operations.",
618 xbt_cfgelm_double, &default_reference_speed, 1, 1, NULL,
621 int default_display_timing = 0;
622 xbt_cfg_register(&_surf_cfg_set, "smpi/display_timing",
623 "Boolean indicating whether we should display the timing after simulation.",
624 xbt_cfgelm_int, &default_display_timing, 1, 1, NULL,
627 double default_threshold = 1e-6;
628 xbt_cfg_register(&_surf_cfg_set, "smpi/cpu_threshold",
629 "Minimal computation time (in seconds) not discarded.",
630 xbt_cfgelm_double, &default_threshold, 1, 1, NULL,
633 //For smpi/bw_factor and smpi/lat_factor
634 //Default value have to be "threshold0:value0;threshold1:value1;...;thresholdN:valueN"
635 //test is if( size >= thresholdN ) return valueN;
636 //Values can be modified with command line --cfg=smpi/bw_factor:"threshold0:value0;threshold1:value1;...;thresholdN:valueN"
637 // or with tag config put line <prop id="smpi/bw_factor" value="threshold0:value0;threshold1:value1;...;thresholdN:valueN"></prop>
638 xbt_cfg_register(&_surf_cfg_set, "smpi/bw_factor",
639 "Bandwidth factors for smpi.",
640 xbt_cfgelm_string, NULL, 1, 1, NULL,
642 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");
644 xbt_cfg_register(&_surf_cfg_set, "smpi/lat_factor",
645 "Latency factors for smpi.",
646 xbt_cfgelm_string, NULL, 1, 1, NULL,
648 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");
653 /* retrieves the current directory of the current process */
654 const char *initial_path = __surf_get_initial_path();
655 xbt_assert((initial_path),
656 "__surf_get_initial_path() failed! Can't resolves current Windows directory");
658 surf_path = xbt_dynar_new(sizeof(char *), NULL);
659 xbt_cfg_setdefault_string(_surf_cfg_set, "path", initial_path);
663 surf_config_cmd_line(argc, argv);
665 XBT_WARN("Call to surf_config_init() after initialization ignored");
669 void surf_config_finalize(void)
671 if (!_surf_init_status)
672 return; /* Not initialized yet. Nothing to do */
674 xbt_cfg_free(&_surf_cfg_set);
675 _surf_init_status = 0;
678 /* Pick the right models for CPU, net and workstation, and call their model_init_preparse */
679 void surf_config_models_setup()
681 char *workstation_model_name;
682 int workstation_id = -1;
683 char *network_model_name = NULL;
684 char *cpu_model_name = NULL;
686 char *storage_model_name = NULL;
688 workstation_model_name =
689 xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
690 network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
691 cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
692 storage_model_name = xbt_cfg_get_string(_surf_cfg_set, "storage/model");
694 /* Check whether we use a net/cpu model differing from the default ones, in which case
695 * we should switch to the "compound" workstation model to correctly dispatch stuff to
696 * the right net/cpu models.
699 if((!xbt_cfg_is_default_value(_surf_cfg_set, "network/model") ||
700 !xbt_cfg_is_default_value(_surf_cfg_set, "cpu/model")) &&
701 xbt_cfg_is_default_value(_surf_cfg_set, "workstation/model"))
703 const char *val = "compound";
705 ("Switching workstation model to compound since you changed the network and/or cpu model(s)");
706 xbt_cfg_set_string(_surf_cfg_set, "workstation/model", val);
707 workstation_model_name = (char *) "compound";
710 XBT_DEBUG("Workstation model: %s", workstation_model_name);
712 find_model_description(surf_workstation_model_description,
713 workstation_model_name);
714 if (!strcmp(workstation_model_name, "compound")) {
718 xbt_assert(cpu_model_name,
719 "Set a cpu model to use with the 'compound' workstation model");
721 xbt_assert(network_model_name,
722 "Set a network model to use with the 'compound' workstation model");
725 find_model_description(surf_network_model_description,
728 find_model_description(surf_cpu_model_description, cpu_model_name);
730 surf_cpu_model_description[cpu_id].model_init_preparse();
731 surf_network_model_description[network_id].model_init_preparse();
734 XBT_DEBUG("Call workstation_model_init");
735 surf_workstation_model_description[workstation_id].model_init_preparse();
737 XBT_DEBUG("Call storage_model_init");
738 storage_id = find_model_description(surf_storage_model_description, storage_model_name);
739 surf_storage_model_description[storage_id].model_init_preparse();