X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3e28ddc195798007e79ad79e87003f1993b46b7e..6f4f913bfa515c8a880730da0b430521530bba2f:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 285a61c6fa..62c1c006ad 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -48,6 +48,8 @@ static void model_none_load(void); /* none routing model */ static void model_none_unload(void); /* none routing model */ static void model_none_end(void); /* none routing model */ +static void routing_full_parse_Scluster(void);/*cluster bypass*/ + /* this lines are olny for replace use like index in the model table */ #define SURF_MODEL_FULL 0 #define SURF_MODEL_FLOYD 1 @@ -615,9 +617,9 @@ void routing_model_create(size_t size_of_links, void* loopback) { surfxml_add_callback(STag_surfxml_AS_cb_list, &parse_S_AS); surfxml_add_callback(ETag_surfxml_AS_cb_list, &parse_E_AS); - -// /* DEBUG ONLY */ -// surfxml_add_callback(ETag_surfxml_platform_cb_list, &DEBUG_exit); + + surfxml_add_callback(STag_surfxml_cluster_cb_list, &routing_full_parse_Scluster); + } /* ************************************************************************** */ @@ -1594,7 +1596,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; @@ -1609,7 +1611,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); @@ -1647,8 +1650,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; @@ -1873,6 +1882,7 @@ static void generic_set_route(routing_component_t rc, const char* src, const cha static void generic_set_ASroute(routing_component_t rc, const char* src, const char* dst, route_extended_t e_route) { DEBUG4("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",src,e_route->src_gateway,dst,e_route->dst_gateway); + printf("Load ASroute from \"%s(%s)\" to \"%s(%s)\"\n",src,e_route->src_gateway,dst,e_route->dst_gateway); model_type_t modeltype = rc->routing; xbt_dict_t _parse_routes; xbt_dict_t _to_index; @@ -2182,3 +2192,210 @@ static void generic_src_dst_check(routing_component_t rc, const char* src, const xbt_assert2(rc == dst_as, "The routing component of src and dst is not the same as the network elements belong (%s==%s)",rc->name,dst_as->name); } + +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; + char *cluster_suffix = A_surfxml_cluster_suffix; + char *cluster_radical = A_surfxml_cluster_radical; + char *cluster_power = A_surfxml_cluster_power; + char *cluster_bw = A_surfxml_cluster_bw; + char *cluster_lat = A_surfxml_cluster_lat; + char *cluster_bb_bw = A_surfxml_cluster_bb_bw; + char *cluster_bb_lat = A_surfxml_cluster_bb_lat; + char *host_id, *groups, *link_id; + char *router_id, *link_router, *link_backbone, *route_src_dst; + unsigned int iter; + int start, end, i; + xbt_dynar_t radical_elements; + xbt_dynar_t radical_ends; + + surfxml_bufferstack_push(1); + + /* allocating memory for the buffer, I think 2kB should be enough */ + // surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size); + +// 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); + + DEBUG1("",cluster_id); + SURFXML_BUFFER_SET(AS_id, cluster_id); + SURFXML_BUFFER_SET(AS_routing, "RuleBased"); + SURFXML_START_TAG(AS); + + radical_elements = xbt_str_split(cluster_radical, ","); + xbt_dynar_foreach(radical_elements, iter, groups) + { + radical_ends = xbt_str_split(groups, "-"); + switch (xbt_dynar_length(radical_ends)) + { + case 1: + surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *)); + host_id = bprintf("%s%d%s", cluster_prefix, start, cluster_suffix); + 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"); + SURFXML_BUFFER_SET(host_availability_file, ""); + A_surfxml_host_state = A_surfxml_host_state_ON; + SURFXML_BUFFER_SET(host_state_file, ""); + SURFXML_BUFFER_SET(host_interference_send, "1.0"); + SURFXML_BUFFER_SET(host_interference_recv, "1.0"); + SURFXML_BUFFER_SET(host_interference_send_recv, "1.0"); + SURFXML_BUFFER_SET(host_max_outgoing_rate, "-1.0"); + SURFXML_START_TAG(host); + 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); + SURFXML_BUFFER_SET(link_bandwidth_file, ""); + SURFXML_BUFFER_SET(link_latency_file, ""); + A_surfxml_link_state = A_surfxml_link_state_ON; + SURFXML_BUFFER_SET(link_state_file, ""); + A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; + SURFXML_START_TAG(link); + SURFXML_END_TAG(link); + + break; + + case 2: + + 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 *)); + 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"); + SURFXML_BUFFER_SET(host_availability_file, ""); + A_surfxml_host_state = A_surfxml_host_state_ON; + SURFXML_BUFFER_SET(host_state_file, ""); + SURFXML_BUFFER_SET(host_interference_send, "1.0"); + SURFXML_BUFFER_SET(host_interference_recv, "1.0"); + SURFXML_BUFFER_SET(host_interference_send_recv, "1.0"); + SURFXML_BUFFER_SET(host_max_outgoing_rate, "-1.0"); + SURFXML_START_TAG(host); + 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); + SURFXML_BUFFER_SET(link_bandwidth_file, ""); + SURFXML_BUFFER_SET(link_latency_file, ""); + A_surfxml_link_state = A_surfxml_link_state_ON; + SURFXML_BUFFER_SET(link_state_file, ""); + A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; + SURFXML_START_TAG(link); + SURFXML_END_TAG(link); + } + break; + + default: + DEBUG0("Malformed radical"); + } + + xbt_dynar_free(&radical_ends); + } + + DEBUG0(" "); + router_id = bprintf("%srouter%s",cluster_prefix,cluster_suffix); + link_router = bprintf("%s_link_router",cluster_id); + 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); + SURFXML_BUFFER_SET(link_bandwidth_file, ""); + SURFXML_BUFFER_SET(link_latency_file, ""); + A_surfxml_link_state = A_surfxml_link_state_ON; + SURFXML_BUFFER_SET(link_state_file, ""); + A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; + SURFXML_START_TAG(link); + 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); + SURFXML_BUFFER_SET(link_bandwidth_file, ""); + SURFXML_BUFFER_SET(link_latency_file, ""); + A_surfxml_link_state = A_surfxml_link_state_ON; + SURFXML_BUFFER_SET(link_state_file, ""); + A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; + SURFXML_START_TAG(link); + SURFXML_END_TAG(link); + + char *new_suffix = bprintf("%s",""); + + radical_elements = xbt_str_split(cluster_suffix, "."); + xbt_dynar_foreach(radical_elements, iter, groups) + { + if(strcmp(groups,"")) + { + new_suffix = bprintf("%s\\.%s",new_suffix,groups); + } + } + route_src_dst = bprintf("%s(.*)%s",cluster_prefix,new_suffix); + + 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); + + DEBUG0(""); + SURFXML_END_TAG(route); + + DEBUG0(""); + SURFXML_END_TAG(AS); + DEBUG0(" "); + + surfxml_bufferstack_pop(1); +}