From: mquinson Date: Thu, 2 Jul 2009 08:00:10 +0000 (+0000) Subject: Add a command-line option to choose the routing schema to use X-Git-Tag: SVN~1201 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b84bad24cc0d403e9773384376ecff7d360f8379 Add a command-line option to choose the routing schema to use git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6440 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/ChangeLog b/ChangeLog index 898566b0d8..3a73949bcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ SimGrid (3.3.2-svn) unstable; urgency=low => kill now useless network_card concept - Use dynar to represent routes (instead of void** + int*) - kill link_set (use surf_network_model->resource_set instead) + - Add a command-line option to choose the routing schema to use * Simplify model declaration (less redirections, less function to write when defining a model) diff --git a/src/surf/network.c b/src/surf/network.c index 6a6984bebc..c5b61f6a68 100644 --- a/src/surf/network.c +++ b/src/surf/network.c @@ -514,7 +514,7 @@ static void surf_network_model_init_internal(void) if (!network_maxmin_system) network_maxmin_system = lmm_system_new(); - routing_model_full_create(sizeof(link_CM02_t), + routing_model_create(sizeof(link_CM02_t), link_new(xbt_strdup("__loopback__"), 498000000, NULL, 0.000015, NULL, SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL)); diff --git a/src/surf/surf_config.c b/src/surf/surf_config.c index 096bd61dc3..7533ba294f 100644 --- a/src/surf/surf_config.c +++ b/src/surf/surf_config.c @@ -122,18 +122,6 @@ void surf_config_init(int *argc, char **argv) char *description = xbt_malloc(1024), *p = description; char *default_value; int i; - sprintf(description, - "The model to use for the workstation. Possible values: "); - while (*(++p) != '\0'); - for (i = 0; surf_workstation_model_description[i].name; i++) - p += - sprintf(p, "%s%s", (i == 0 ? "" : ", "), - surf_workstation_model_description[i].name); - default_value = xbt_strdup("CLM03"); - xbt_cfg_register(&_surf_cfg_set, - "workstation_model", description, xbt_cfgelm_string, - &default_value, 1, 1, &_surf_cfg_cb__workstation_model, - NULL); sprintf(description, "The model to use for the CPU. Possible values: "); p = description; @@ -160,8 +148,29 @@ void surf_config_init(int *argc, char **argv) "network_model", description, xbt_cfgelm_string, &default_value, 1, 1, &_surf_cfg_cb__network_model, NULL); + + sprintf(description, + "The model to use for the workstation. Possible values: "); + p = description; + while (*(++p) != '\0'); + for (i = 0; surf_workstation_model_description[i].name; i++) + p += + sprintf(p, "%s%s", (i == 0 ? "" : ", "), + surf_workstation_model_description[i].name); + default_value = xbt_strdup("CLM03"); + xbt_cfg_register(&_surf_cfg_set, + "workstation_model", description, xbt_cfgelm_string, + &default_value, 1, 1, &_surf_cfg_cb__workstation_model, + NULL); + xbt_free(description); + default_value = xbt_strdup("Full"); + xbt_cfg_register(&_surf_cfg_set, "routing", + "Model to use to store the routing information", + xbt_cfgelm_string, &default_value, 0, 0, NULL, + NULL); + xbt_cfg_register(&_surf_cfg_set, "TCP_gamma", "Size of the biggest TCP window", xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__tcp_gamma, NULL); @@ -181,6 +190,7 @@ void surf_config_init(int *argc, char **argv) xbt_cfg_set_string(_surf_cfg_set, "path", initial_path); } + surf_config_cmd_line(argc, argv); } } diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 95b0cf37d1..bd935818eb 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -96,6 +96,6 @@ struct s_routing { void (*finalize)(void); int host_count; }; -XBT_PUBLIC(routing_t) routing_model_full_create(size_t size_of_link,void *loopback); +XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback); #endif /* _SURF_SURF_PRIVATE_H */ diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index c46d31213c..1ed0b66a5d 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -6,19 +6,51 @@ #include "surf_private.h" #include "xbt/dynar.h" #include "xbt/str.h" +#include "xbt/config.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route,surf,"Routing part of surf");// FIXME: connect this under windows +routing_t used_routing = NULL; + +/* Prototypes of each model */ +static void routing_model_full_create(size_t size_of_link,void *loopback); + +/* Definition of each model */ +struct model_type { + const char *name; + const char *desc; + void (*fun)(size_t,void*); +}; +struct model_type models[] = +{ {"Full", "Full routing data (fast, large memory requirements, fully expressive)", routing_model_full_create }, + {NULL,NULL}}; + + +void routing_model_create(size_t size_of_links, void* loopback) { + + char * wanted=xbt_cfg_get_string(_surf_cfg_set,"routing"); + int cpt; + for (cpt=0;models[cpt].name;cpt++) { + if (!strcmp(wanted,models[cpt].name)) { + (*(models[cpt].fun))(size_of_links,loopback); + return; + } + } + fprintf(stderr,"Routing model %s not found. Existing models:\n",wanted); + for (cpt=0;models[cpt].name;cpt++) + if (!strcmp(wanted,models[cpt].name)) + fprintf(stderr," %s: %s\n",models[cpt].name,models[cpt].desc); + exit(1); +} + +/* ************************************************************************** */ +/* *************************** FULL ROUTING ********************************* */ typedef struct { s_routing_t generic_routing; xbt_dynar_t *routing_table; void *loopback; size_t size_of_link; -}s_routing_full_t,*routing_full_t; - -routing_t used_routing = NULL; -/* ************************************************************************** */ -/* *************************** FULL ROUTING ********************************* */ +} s_routing_full_t,*routing_full_t; #define ROUTE_FULL(i,j) ((routing_full_t)used_routing)->routing_table[(i)+(j)*(used_routing)->host_count] @@ -124,26 +156,24 @@ static void routing_full_finalize(void) { } } -routing_t routing_model_full_create(size_t size_of_link,void *loopback) { +static void routing_model_full_create(size_t size_of_link,void *loopback) { /* initialize our structure */ - routing_full_t res = xbt_new0(s_routing_full_t,1); - res->generic_routing.name = "Full"; - res->generic_routing.host_count = 0; - res->generic_routing.get_route = routing_full_get_route; - res->generic_routing.finalize = routing_full_finalize; - res->size_of_link = size_of_link; - res->loopback = loopback; + routing_full_t routing = xbt_new0(s_routing_full_t,1); + routing->generic_routing.name = "Full"; + routing->generic_routing.host_count = 0; + routing->generic_routing.get_route = routing_full_get_route; + routing->generic_routing.finalize = routing_full_finalize; + routing->size_of_link = size_of_link; + routing->loopback = loopback; /* Set it in position */ - used_routing = (routing_t) res; + used_routing = (routing_t) routing; /* Setup the parsing callbacks we need */ - used_routing->host_id = xbt_dict_new(); + routing->generic_routing.host_id = xbt_dict_new(); surfxml_add_callback(STag_surfxml_host_cb_list, &routing_full_parse_Shost); surfxml_add_callback(ETag_surfxml_platform_cb_list, &routing_full_parse_end); surfxml_add_callback(STag_surfxml_route_cb_list, - &routing_full_parse_Sroute_set_endpoints); + &routing_full_parse_Sroute_set_endpoints); surfxml_add_callback(ETag_surfxml_route_cb_list, &routing_full_parse_Eroute); - - return used_routing; } diff --git a/src/surf/workstation_ptask_L07.c b/src/surf/workstation_ptask_L07.c index 1256da696d..a1b38faa6a 100644 --- a/src/surf/workstation_ptask_L07.c +++ b/src/surf/workstation_ptask_L07.c @@ -845,8 +845,8 @@ static void model_init_internal(void) if (!ptask_maxmin_system) ptask_maxmin_system = lmm_system_new(); - routing_model_full_create(sizeof(link_L07_t), - link_new(xbt_strdup("__MSG_loopback__"), + routing_model_create(sizeof(link_L07_t), + link_new(xbt_strdup("__loopback__"), 498000000, NULL, 0.000015, NULL, SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));