X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/346c06db41ebb088e88351d8381d0c232d2ddbb5..7fdb9c9ac44fba9f76a3b45d032561995bec2e0d:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 53a5d6223e..af94958d67 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -373,7 +373,7 @@ static void routing_parse_E_bypassASroute(void) * @param AS_id name of this autonomous system. Must be unique in the platform * @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c */ -void routing_AS_begin(const char *AS_id, const char *wanted_routing_type) +void routing_AS_begin(const char *AS_id, int wanted_routing_type) { AS_t new_as; routing_model_description_t model = NULL; @@ -384,17 +384,15 @@ void routing_AS_begin(const char *AS_id, const char *wanted_routing_type) "The AS \"%s\" already exists", AS_id); /* search the routing model */ - for (cpt = 0; routing_models[cpt].name; cpt++) - if (!strcmp(wanted_routing_type, routing_models[cpt].name)) - model = &routing_models[cpt]; - /* if its not exist, error */ - if (model == NULL) { - fprintf(stderr, "Routing model %s not found. Existing models:\n", - wanted_routing_type); - for (cpt = 0; routing_models[cpt].name; cpt++) - fprintf(stderr, " %s: %s\n", routing_models[cpt].name, - routing_models[cpt].desc); - xbt_die("dying"); + switch(wanted_routing_type){ + case A_surfxml_AS_routing_Cluster: model = &routing_models[SURF_MODEL_CLUSTER];break; + case A_surfxml_AS_routing_Dijkstra: model = &routing_models[SURF_MODEL_DIJKSTRA];break; + case A_surfxml_AS_routing_DijkstraCache: model = &routing_models[SURF_MODEL_DIJKSTRACACHE];break; + case A_surfxml_AS_routing_Floyd: model = &routing_models[SURF_MODEL_FLOYD];break; + case A_surfxml_AS_routing_Full: model = &routing_models[SURF_MODEL_FULL];break; + case A_surfxml_AS_routing_None: model = &routing_models[SURF_MODEL_NONE];break; + case A_surfxml_AS_routing_RuleBased: model = &routing_models[SURF_MODEL_RULEBASED];break; + case A_surfxml_AS_routing_Vivaldi: model = &routing_models[SURF_MODEL_VIVALDI];break; } /* make a new routing component */ @@ -576,16 +574,14 @@ static void _get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst, /* Common ancestor is kind enough to declare a bypass route from src to dst -- use it and bail out */ if (e_route_bypass) { - xbt_dynar_merge(links,&(e_route_bypass->link_list)); + xbt_dynar_merge(links, &e_route_bypass->link_list); generic_free_route(e_route_bypass); return; } /* If src and dst are in the same AS, life is good */ if (src_father == dst_father) { /* SURF_ROUTING_BASE */ - route.link_list = *links; - common_father->get_route_and_latency(common_father, src, dst, &route,latency); return; } @@ -597,7 +593,9 @@ static void _get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst, sg_routing_edge_t src_father_net_elm = src_father->net_elem; sg_routing_edge_t dst_father_net_elm = dst_father->net_elem; - common_father->get_route_and_latency(common_father, src_father_net_elm, dst_father_net_elm, &route,latency); + common_father->get_route_and_latency(common_father, + src_father_net_elm, dst_father_net_elm, + &route, latency); xbt_assert((route.src_gateway != NULL) && (route.dst_gateway != NULL), "bad gateways for route from \"%s\" to \"%s\"", src->name, dst->name); @@ -609,14 +607,11 @@ static void _get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst, if (src != src_gateway_net_elm) _get_route_and_latency(src, src_gateway_net_elm, links, latency); - xbt_dynar_merge(links,&(route.link_list)); + xbt_dynar_merge(links, &route.link_list); /* If dest gateway is not our destination, we have to recursively find our way from this point */ - // FIXME why can't I factorize it the same way than [src;src_gw] without breaking the examples?? - if (dst_gateway_net_elm != dst) { + if (dst_gateway_net_elm != dst) _get_route_and_latency(dst_gateway_net_elm, dst, links, latency); - } - xbt_dynar_free(&route.link_list); } /** @@ -770,7 +765,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) } XBT_DEBUG("", cluster->id); - sg_platf_new_AS_begin(cluster->id, "Cluster"); + sg_platf_new_AS_begin(cluster->id, A_surfxml_AS_routing_Cluster); current_routing->link_up_down_list = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL); @@ -806,7 +801,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) xbt_dict_set(patterns, "radical", bprintf("%d", i), NULL); char *avail_file = xbt_str_varsubst(cluster->availability_trace, patterns); XBT_DEBUG("\tavailability_file=\"%s\"", avail_file); - host.power_trace = tmgr_trace_new(avail_file); + host.power_trace = tmgr_trace_new_from_file(avail_file); xbt_free(avail_file); } else { XBT_DEBUG("\tavailability_file=\"\""); @@ -815,7 +810,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) if (strcmp(cluster->state_trace, "")) { char *avail_file = xbt_str_varsubst(cluster->state_trace, patterns); XBT_DEBUG("\tstate_file=\"%s\"", avail_file); - host.state_trace = tmgr_trace_new(avail_file); + host.state_trace = tmgr_trace_new_from_file(avail_file); xbt_free(avail_file); } else { XBT_DEBUG("\tstate_file=\"\""); @@ -924,7 +919,7 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) surfxml_bufferstack_push(1); XBT_DEBUG("", peer->id); - sg_platf_new_AS_begin(peer->id, "Full"); + sg_platf_new_AS_begin(peer->id, A_surfxml_AS_routing_Full); XBT_DEBUG(" "); host_id = HOST_PEER(peer->id);