X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/86a08ab9c895a99c7efb4ee38db24c3541deb6bd..9a042f95a062f5fdf726c3ab83c91df4527db8e9:/src/surf/surf_config.c diff --git a/src/surf/surf_config.c b/src/surf/surf_config.c index 5c32d96fcb..fb2a7e114a 100644 --- a/src/surf/surf_config.c +++ b/src/surf/surf_config.c @@ -15,6 +15,42 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config,surf,"About the configuration of sur xbt_cfg_t _surf_cfg_set = NULL; + +/* Parse the command line, looking for options */ +static void surf_config_cmd_line(int *argc,char **argv) +{ + int i, j; + char *opt; + + for (i = 1; i < *argc; i++) { + int remove_it = 0; + if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) { + opt = strchr(argv[i], '='); + opt++; + + xbt_cfg_set_parse(_surf_cfg_set,opt); + DEBUG1("Did apply '%s' as config setting", opt); + remove_it = 1; + } else if (!strncmp(argv[i], "--cfg-help", strlen("--cfg-help")+1) || + !strncmp(argv[i], "--help", strlen("--help")+1)) { + printf("Description of the configuration accepted by this simulator:\n"); + xbt_cfg_help(_surf_cfg_set); + remove_it=1; + exit(0); + } + if (remove_it) { /*remove this from argv */ + for (j = i + 1; j < *argc; j++) { + argv[j - 1] = argv[j]; + } + + argv[j - 1] = NULL; + (*argc)--; + i--; /* compensate effect of next loop incrementation */ + } + } +} + + int _surf_init_status = 0; /* 0: beginning of time; 1: pre-inited (cfg_set created); 2: inited (running) */ @@ -59,31 +95,17 @@ static void _surf_cfg_cb__network_model(const char *name, int pos) find_model_description(surf_network_model_description, val); } -/* Parse the command line, looking for options */ -static void surf_config_cmd_line(int *argc,char **argv) -{ - int i, j; - char *opt; - - for (i = 1; i < *argc; i++) { - if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) { - opt = strchr(argv[i], '='); - opt++; +/* callback of the tcp gamma variable */ +static void _surf_cfg_cb__tcp_gamma(const char *name, int pos) { + sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name); +} - xbt_cfg_set_parse(_surf_cfg_set,opt); - DEBUG1("Did apply '%s' as config setting", opt); - /*remove this from argv */ +static void _surf_cfg_cb__surf_path(const char *name, int pos) { + char *path = xbt_cfg_get_string_at(_surf_cfg_set, name,pos); + xbt_dynar_push(surf_path, &path); +} - for (j = i + 1; j < *argc; j++) { - argv[j - 1] = argv[j]; - } - argv[j - 1] = NULL; - (*argc)--; - i--; /* compensate effect of next loop incrementation */ - } - } -} /* create the config set, register what should be and parse the command line*/ void surf_config_init(int *argc, char **argv) { @@ -101,7 +123,7 @@ void surf_config_init(int *argc, char **argv) { p+=sprintf(p,"%s%s",(i==0?"":", "),surf_workstation_model_description[i].name); xbt_cfg_register(_surf_cfg_set, - "workstation_model", description, xbt_cfgelm_string, 1, 1, + "workstation_model", xbt_strdup(description), xbt_cfgelm_string, 1, 1, &_surf_cfg_cb__workstation_model, NULL); sprintf(description,"The model to use for the CPU. Possible values: "); @@ -110,7 +132,7 @@ void surf_config_init(int *argc, char **argv) { for (i=0;surf_cpu_model_description[i].name;i++) p+=sprintf(p,"%s%s",(i==0?"":", "),surf_cpu_model_description[i].name); xbt_cfg_register(_surf_cfg_set, - "cpu_model", description, xbt_cfgelm_string, 1, 1, + "cpu_model", xbt_strdup(description), xbt_cfgelm_string, 1, 1, &_surf_cfg_cb__cpu_model, NULL); sprintf(description,"The model to use for the network. Possible values: "); @@ -123,6 +145,24 @@ void surf_config_init(int *argc, char **argv) { &_surf_cfg_cb__network_model, NULL); xbt_cfg_set_string(_surf_cfg_set, "workstation_model", "CLM03"); + xbt_cfg_set_string(_surf_cfg_set, "cpu_model", "Cas01"); + xbt_cfg_set_string(_surf_cfg_set, "network_model", "CM02"); + + xbt_cfg_register(_surf_cfg_set,"TCP_gamma","Size of the biggest TCP window",1,1, + xbt_cfgelm_double,_surf_cfg_cb__tcp_gamma,NULL); + xbt_cfg_set_double(_surf_cfg_set, "TCP_gamma", 20000.0); + + xbt_cfg_register(_surf_cfg_set,"path","Lookup path for inclusions in platform and deployment XML files", + xbt_cfgelm_string, 0,0,_surf_cfg_cb__surf_path,NULL); + if (!surf_path) { + /* retrieves the current directory of the current process */ + const char *initial_path = __surf_get_initial_path(); + xbt_assert0((initial_path), + "__surf_get_initial_path() failed! Can't resolves current Windows directory"); + + surf_path = xbt_dynar_new(sizeof(char *), NULL); + xbt_cfg_set_string(_surf_cfg_set,"path", initial_path); + } surf_config_cmd_line(argc,argv); }