X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5c883f36294946e34ab8349ea4be2dedbd31bb3c..738a6645ea58a89cf957c360faf26e01eae7f7b4:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index ac7f043c52..d33eb6446f 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -428,7 +428,7 @@ static route_extended_t _get_route(const char* src,const char* dst) { xbt_assert0(src&&dst,"bad parameters for \"_get_route\" method"); - route_extended_t e_route, e_route_cnt, e_route_src, e_route_dst; + route_extended_t e_route, e_route_cnt, e_route_src=NULL, e_route_dst=NULL; xbt_dynar_t elem_father_list = elements_father(src,dst); @@ -581,6 +581,16 @@ static void finalize(void) { xbt_free(global_routing); } +static void get_onelink_routes(void) +{ + xbt_die("get_onelink_routes function not implemented yet!!!"); +} + +static int is_router(const char *name) +{ + xbt_die("is_router function not implemented yet!!!"); +} + /** * \brief Generic method: create the global routing schema * @@ -819,7 +829,7 @@ static route_extended_t floyd_get_route(routing_component_t rc, const char* src, int first = 1; int pred = *dst_id; int prev_pred = 0; - char *gw_src,*gw_dst, *prev_gw_src,*prev_gw_dst, *first_gw; + char *gw_src=NULL,*gw_dst=NULL, *prev_gw_src,*prev_gw_dst, *first_gw=NULL; unsigned int cpt; void* link; xbt_dynar_t links; @@ -1269,7 +1279,7 @@ static route_extended_t dijkstra_get_route(routing_component_t rc, const char* s } /* compose route path with links */ - char *gw_src,*gw_dst, *prev_gw_src,*prev_gw_dst, *first_gw; + char *gw_src=NULL,*gw_dst=NULL, *prev_gw_src,*prev_gw_dst, *first_gw=NULL; for(v = dst_node_id; v != src_node_id; v = pred_arr[v]) { xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t); @@ -1596,7 +1606,7 @@ static char* remplace(char* value, const char** src_list, int src_size, const ch /* Business methods */ static route_extended_t rulebased_get_route(routing_component_t rc, const char* src,const char* dst) { xbt_assert1(rc&&src&&dst, "Invalid params for \"get_route\" function at AS \"%s\"",rc->name); - + /* set utils vars */ routing_component_rulebased_t routing = (routing_component_rulebased_t) rc; @@ -1611,7 +1621,8 @@ static route_extended_t rulebased_get_route(routing_component_t rc, const char* } else xbt_assert2(NULL, "Ask for route \"from\"(%s) or \"to\"(%s) no found in the local table",src,dst); - int rc_src,rc_dst; + int rc_src = -1; + int rc_dst = -1; int src_length = (int)strlen(src); int dst_length = (int)strlen(dst); @@ -1649,8 +1660,14 @@ static route_extended_t rulebased_get_route(routing_component_t rc, const char* if(rc_src >= 0 && rc_dst >= 0) { new_e_route = xbt_new0(s_route_extended_t,1); new_e_route->generic_route.link_list = links_list; + } else if( !strcmp(src,dst) && are_processing_units ) { + new_e_route = xbt_new0(s_route_extended_t,1); + xbt_dynar_push(links_list,&(global_routing->loopback)); + new_e_route->generic_route.link_list = links_list; + } else { + xbt_dynar_free(&link_list); } - + if(!are_processing_units && new_e_route) { rule_route_extended_t ruleroute_extended = (rule_route_extended_t)ruleroute; @@ -2187,6 +2204,7 @@ static void generic_src_dst_check(routing_component_t rc, const char* src, const static void routing_full_parse_Scluster(void) { + static int AX_ptr = 0; char *cluster_id = A_surfxml_cluster_id; char *cluster_prefix = A_surfxml_cluster_prefix; @@ -2203,16 +2221,13 @@ static void routing_full_parse_Scluster(void) int start, end, i; xbt_dynar_t radical_elements; xbt_dynar_t radical_ends; - static int AX_ptr = 0; - static int surfxml_bufferstack_size = 2048; - /* allocating memory for the buffer, I think 2kB should be enough */ - surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); + static unsigned int surfxml_buffer_stack_stack_ptr = 1; + static unsigned int surfxml_buffer_stack_stack[1024]; + + surfxml_buffer_stack_stack[0]= 0; -// DEBUG4("id='%s' prefix='%s' suffix='%s' radical='%s'", -// cluster_id,cluster_prefix,cluster_suffix,cluster_radical); -// DEBUG5("power='%s' bw='%s' lat='%s' bb_bw='%s' bb_lat='%s'", -// cluster_power,cluster_bw,cluster_lat,cluster_bb_bw,cluster_bb_lat); + surfxml_bufferstack_push(1); DEBUG1("",cluster_id); SURFXML_BUFFER_SET(AS_id, cluster_id); @@ -2231,7 +2246,6 @@ static void routing_full_parse_Scluster(void) link_id = bprintf("%s_link_%d", cluster_id, start); DEBUG2("",host_id,cluster_power); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(host_id, host_id); SURFXML_BUFFER_SET(host_power, cluster_power); SURFXML_BUFFER_SET(host_availability, "1.0"); @@ -2246,7 +2260,6 @@ static void routing_full_parse_Scluster(void) SURFXML_END_TAG(host); DEBUG3("",link_id,cluster_bw,cluster_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_id); SURFXML_BUFFER_SET(link_bandwidth, cluster_bw); SURFXML_BUFFER_SET(link_latency, cluster_lat); @@ -2264,13 +2277,13 @@ static void routing_full_parse_Scluster(void) surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *)); surf_parse_get_int(&end, xbt_dynar_get_as(radical_ends, 1, char *)); + DEBUG2("Create hosts and links from %d to %d",start,end); for (i = start; i <= end; i++) { host_id = bprintf("%s%d%s", cluster_prefix, i, cluster_suffix); link_id = bprintf("%s_link_%d", cluster_id, i); DEBUG2("",host_id,cluster_power); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(host_id, host_id); SURFXML_BUFFER_SET(host_power, cluster_power); SURFXML_BUFFER_SET(host_availability, "1.0"); @@ -2285,7 +2298,6 @@ static void routing_full_parse_Scluster(void) SURFXML_END_TAG(host); DEBUG3("",link_id,cluster_bw,cluster_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_id); SURFXML_BUFFER_SET(link_bandwidth, cluster_bw); SURFXML_BUFFER_SET(link_latency, cluster_lat); @@ -2312,13 +2324,11 @@ static void routing_full_parse_Scluster(void) link_backbone = bprintf("%s_backbone",cluster_id); DEBUG1("",router_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(router_id, router_id);; SURFXML_START_TAG(router); SURFXML_END_TAG(router); DEBUG3("",link_router,cluster_bw,cluster_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_router); SURFXML_BUFFER_SET(link_bandwidth, cluster_bw); SURFXML_BUFFER_SET(link_latency, cluster_lat); @@ -2331,7 +2341,6 @@ static void routing_full_parse_Scluster(void) SURFXML_END_TAG(link); DEBUG3("",link_backbone,cluster_bb_bw,cluster_bb_lat); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_id, link_backbone); SURFXML_BUFFER_SET(link_bandwidth, cluster_bb_bw); SURFXML_BUFFER_SET(link_latency, cluster_bb_lat); @@ -2358,25 +2367,21 @@ static void routing_full_parse_Scluster(void) DEBUG0(" "); DEBUG2("",route_src_dst,route_src_dst); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(route_src, route_src_dst); SURFXML_BUFFER_SET(route_dst, route_src_dst); SURFXML_START_TAG(route); DEBUG1("",cluster_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_c_ctn_id, bprintf("%s_link_$1src",cluster_id)); SURFXML_START_TAG(link_c_ctn); SURFXML_END_TAG(link_c_ctn); DEBUG1("",cluster_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_c_ctn_id, bprintf("%s_backbone",cluster_id)); SURFXML_START_TAG(link_c_ctn); SURFXML_END_TAG(link_c_ctn); DEBUG1("",cluster_id); - SURFXML_BUFFER_RESET(); SURFXML_BUFFER_SET(link_c_ctn_id, bprintf("%s_link_$1dst",cluster_id)); SURFXML_START_TAG(link_c_ctn); SURFXML_END_TAG(link_c_ctn); @@ -2388,4 +2393,5 @@ static void routing_full_parse_Scluster(void) SURFXML_END_TAG(AS); DEBUG0(" "); + surfxml_bufferstack_pop(1); }