From b0369916c688e5342762f7914dbf5868fac309c6 Mon Sep 17 00:00:00 2001 From: mquinson Date: Thu, 16 Jul 2009 19:12:58 +0000 Subject: [PATCH] Allow to instanciate the constant network model. It uses a newly created routing schema 'none' doing nothing, and every communication takes exactly 1s git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6522 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/network_constant.c | 25 ++++++++++++++----------- src/surf/surf_routing.c | 28 +++++++++++++++++++++++++++- src/surf/workstation.c | 3 +-- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/surf/network_constant.c b/src/surf/network_constant.c index 4bc123c58b..264fceb4a6 100644 --- a/src/surf/network_constant.c +++ b/src/surf/network_constant.c @@ -125,8 +125,9 @@ static surf_action_t communicate(const char *src_name,const char *dst_name,int s action->suspended = 0; - action->latency = random_generate(random_latency); + action->latency = 1;//random_generate(random_latency); action->lat_init = action->latency; + INFO1("Latency: %f",action->latency); if (action->latency <= 0.0) { action->generic_action.state_set = @@ -187,11 +188,17 @@ static void finalize(void) surf_network_model = NULL; } -static void surf_network_model_init_internal(void) + + +void surf_network_model_init_Constant(const char *filename) { + xbt_assert(surf_network_model == NULL); + if (surf_network_model) + return; surf_network_model = surf_model_init(); - surf_network_model->name = "network constant"; + INFO0("Blah"); + surf_network_model->name = "constant time network"; surf_network_model->action_unref = action_unref; surf_network_model->action_cancel = action_cancel; surf_network_model->action_recycle = action_recycle; @@ -217,17 +224,13 @@ static void surf_network_model_init_internal(void) if (!random_latency) random_latency = random_new(RAND, 100, 0.0, 1.0, .125, .034); -} - -void surf_network_model_init_Constant(const char *filename) -{ - - if (surf_network_model) - return; - surf_network_model_init_internal(); define_callbacks(filename); xbt_dynar_push(model_list, &surf_network_model); update_model_description(surf_network_model_description, "Constant", surf_network_model); + + xbt_cfg_set_string(_surf_cfg_set,"routing","none"); + routing_model_create(sizeof(double),NULL); } + diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 742ccd50c6..2a68363675 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -20,6 +20,7 @@ static void routing_model_full_create(size_t size_of_link,void *loopback); static void routing_model_floyd_create(size_t size_of_link, void*loopback); static void routing_model_dijkstra_create(size_t size_of_link, void*loopback); static void routing_model_dijkstracache_create(size_t size_of_link, void*loopback); +static void routing_model_none_create(size_t size_of_link, void*loopback); /* Definition of each model */ struct model_type { @@ -32,6 +33,7 @@ struct model_type models[] = {"Floyd", "Floyd routing data (slow initialization, fast lookup, lesser memory requirements, shortest path routing only)", routing_model_floyd_create }, {"Dijkstra", "Dijkstra routing data (fast initialization, slow lookup, small memory requirements, shortest path routing only)", routing_model_dijkstra_create }, {"DijkstraCache", "Dijkstra routing data (fast initialization, fast lookup, small memory requirements, shortest path routing only)", routing_model_dijkstracache_create }, + {"none", "No routing (usable with Constant network only)", routing_model_none_create }, {NULL,NULL,NULL}}; @@ -340,6 +342,7 @@ static void routing_model_floyd_create(size_t size_of_link,void *loopback) { routing_floyd_t routing = xbt_new0(s_routing_floyd_t,1); routing->generic_routing.name = "Floyd"; routing->generic_routing.host_count = 0; + routing->generic_routing.host_id = xbt_dict_new(); routing->generic_routing.get_route = routing_floyd_get_route; routing->generic_routing.finalize = routing_floyd_finalize; routing->generic_routing.finalize_route = routing_floyd_finalize_route; @@ -350,7 +353,6 @@ static void routing_model_floyd_create(size_t size_of_link,void *loopback) { used_routing = (routing_t) routing; /* Setup the parsing callbacks we need */ - 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_floyd_parse_end); surfxml_add_callback(STag_surfxml_route_cb_list, @@ -738,3 +740,27 @@ static void routing_model_dijkstra_create(size_t size_of_link,void *loopback) { static void routing_model_dijkstracache_create(size_t size_of_link,void *loopback) { routing_model_dijkstraboth_create(size_of_link, loopback, 1); } + +/* ************************************************** */ +/* ********** NO ROUTING **************************** */ + +static void routing_none_finalize(void) { + if (used_routing) { + xbt_dict_free(&used_routing->host_id); + free(used_routing); + used_routing=NULL; + } +} + +static void routing_model_none_create(size_t size_of_link,void *loopback) { + routing_t routing = xbt_new0(s_routing_t,1); + INFO0("Null routing"); + routing->name = "none"; + routing->host_count = 0; + routing->host_id = xbt_dict_new(); + routing->get_route = NULL; + routing->finalize = routing_none_finalize; + + /* Set it in position */ + used_routing = (routing_t) routing; +} diff --git a/src/surf/workstation.c b/src/surf/workstation.c index ef35309ce7..7a56c2723a 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -45,9 +45,8 @@ void create_workstations(void) xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, name, cpu) { int *id = xbt_dict_get_or_null(used_routing->host_id,name); - xbt_assert1(id, "No host %s found in the platform file", name); - workstation_new(name, cpu, *id); + workstation_new(name, cpu, id?*id:0); } } -- 2.20.1