X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6aac8bb90869cf0dccc9caf03be425af62ee2813..a2c25e0bae01a59891fac21447f3210ba26302c5:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index e32d928ac0..e34912999f 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -818,6 +818,7 @@ static xbt_dynar_t get_route_or_null(const char *src, const char *dst) TRY { get_route_latency(src, dst, &route, NULL, 1); }CATCH(exception) { + xbt_ex_free(exception); return NULL; } return route; @@ -1510,21 +1511,16 @@ void routing_parse_Scluster(void) 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_core = A_surfxml_cluster_core; - char *cluster_bw = A_surfxml_cluster_bw; - char *cluster_lat = A_surfxml_cluster_lat; - char *temp_cluster_bw = NULL; - char *temp_cluster_lat = NULL; - char *temp_cluster_power = NULL; char *cluster_bb_bw = A_surfxml_cluster_bb_bw; char *cluster_bb_lat = A_surfxml_cluster_bb_lat; - char *cluster_availability_file = A_surfxml_cluster_availability_file; - char *cluster_state_file = A_surfxml_cluster_state_file; + char *cluster_power = xbt_strdup(A_surfxml_cluster_power); + char *cluster_bw = xbt_strdup(A_surfxml_cluster_bw); + char *cluster_lat = xbt_strdup(A_surfxml_cluster_lat); char *host_id, *groups, *link_id = NULL; char *router_id = xbt_strdup(A_surfxml_cluster_router_id); - char *availability_file = xbt_strdup(cluster_availability_file); - char *state_file = xbt_strdup(cluster_state_file); + char *availability_file = xbt_strdup(A_surfxml_cluster_availability_file); + char *state_file = xbt_strdup(A_surfxml_cluster_state_file); if(xbt_dict_size(patterns)==0) patterns = xbt_dict_new(); @@ -1533,6 +1529,10 @@ void routing_parse_Scluster(void) xbt_dict_set(patterns,"prefix",cluster_prefix,NULL); xbt_dict_set(patterns,"suffix",cluster_suffix,NULL); + cluster_power = replace_random_parameter(cluster_power); + cluster_bw = replace_random_parameter(cluster_bw); + cluster_lat = replace_random_parameter(cluster_lat); + char *route_src_dst; unsigned int iter; int start, end, i; @@ -1558,57 +1558,66 @@ void routing_parse_Scluster(void) 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 *)); + 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); - xbt_dict_set(patterns, "radical", bprintf("%d", start), xbt_free); - temp_cluster_power = xbt_strdup(cluster_power); - temp_cluster_power = replace_random_parameter(temp_cluster_power); - XBT_DEBUG("", host_id, temp_cluster_power); A_surfxml_host_state = A_surfxml_host_state_ON; + + XBT_DEBUG("", host_id, cluster_power); SURFXML_BUFFER_SET(host_id, host_id); - SURFXML_BUFFER_SET(host_power, temp_cluster_power); + SURFXML_BUFFER_SET(host_power, cluster_power); + + if(!strcmp(A_surfxml_cluster_availability_file,"")){ + char* tmp_availability_file = xbt_strdup(availability_file); + xbt_str_varsubst(tmp_availability_file,patterns); + XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file); + SURFXML_BUFFER_SET(host_availability_file, tmp_availability_file); + xbt_free(tmp_availability_file); + } + else + { + XBT_DEBUG("\tavailability_file=\"\""); + SURFXML_BUFFER_SET(host_availability_file, ""); + } + if(!strcmp(A_surfxml_cluster_state_file,"")){ + char *tmp_state_file = xbt_strdup(state_file); + xbt_str_varsubst(tmp_state_file,patterns); + XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file); + SURFXML_BUFFER_SET(host_state_file, tmp_state_file); + xbt_free(tmp_state_file); + } + else + { + XBT_DEBUG("\tstate_file=\"\""); + SURFXML_BUFFER_SET(host_state_file, ""); + } + SURFXML_BUFFER_SET(host_core, cluster_core); SURFXML_BUFFER_SET(host_availability, "1.0"); SURFXML_BUFFER_SET(host_coordinates, ""); - xbt_free(availability_file); - availability_file = xbt_strdup(cluster_availability_file); - xbt_free(state_file); - state_file = xbt_strdup(cluster_state_file); - XBT_DEBUG("\tavailability_file=\"%s\"",xbt_str_varsubst(availability_file,patterns)); - XBT_DEBUG("\tstate_file=\"%s\"",xbt_str_varsubst(state_file,patterns)); - SURFXML_BUFFER_SET(host_availability_file, xbt_str_varsubst(availability_file,patterns)); - SURFXML_BUFFER_SET(host_state_file, xbt_str_varsubst(state_file,patterns)); - XBT_DEBUG(""); SURFXML_START_TAG(host); SURFXML_END_TAG(host); + XBT_DEBUG(""); - - temp_cluster_bw = xbt_strdup(cluster_bw); - temp_cluster_bw = replace_random_parameter(temp_cluster_bw); - temp_cluster_lat = xbt_strdup(cluster_lat); - temp_cluster_lat = replace_random_parameter(temp_cluster_lat); - XBT_DEBUG("", link_id,temp_cluster_bw, cluster_lat); A_surfxml_link_state = A_surfxml_link_state_ON; A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FULLDUPLEX) {A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FULLDUPLEX;} if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FATPIPE) {A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FATPIPE;} + + XBT_DEBUG("", link_id,cluster_bw, cluster_lat); + SURFXML_BUFFER_SET(link_id, link_id); - SURFXML_BUFFER_SET(link_bandwidth, temp_cluster_bw); - SURFXML_BUFFER_SET(link_latency, temp_cluster_lat); + 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, ""); SURFXML_BUFFER_SET(link_state_file, ""); SURFXML_START_TAG(link); SURFXML_END_TAG(link); - xbt_free(temp_cluster_bw); - xbt_free(temp_cluster_lat); - xbt_free(temp_cluster_power); free(link_id); free(host_id); break; @@ -1619,62 +1628,73 @@ void routing_parse_Scluster(void) 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); - - xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free); - temp_cluster_power = xbt_strdup(cluster_power); - temp_cluster_power = replace_random_parameter(temp_cluster_power); - XBT_DEBUG("", host_id, temp_cluster_power); - A_surfxml_host_state = A_surfxml_host_state_ON; - SURFXML_BUFFER_SET(host_id, host_id); - SURFXML_BUFFER_SET(host_power, temp_cluster_power); - SURFXML_BUFFER_SET(host_core, cluster_core); - SURFXML_BUFFER_SET(host_availability, "1.0"); - SURFXML_BUFFER_SET(host_coordinates, ""); - xbt_free(availability_file); - availability_file = xbt_strdup(cluster_availability_file); - xbt_free(state_file); - state_file = xbt_strdup(cluster_state_file); - XBT_DEBUG("\tavailability_file=\"%s\"",xbt_str_varsubst(availability_file,patterns)); - XBT_DEBUG("\tstate_file=\"%s\"",xbt_str_varsubst(state_file,patterns)); - SURFXML_BUFFER_SET(host_availability_file, xbt_str_varsubst(availability_file,patterns)); - SURFXML_BUFFER_SET(host_state_file, xbt_str_varsubst(state_file,patterns)); - XBT_DEBUG(""); - SURFXML_START_TAG(host); - SURFXML_END_TAG(host); - - xbt_free(temp_cluster_power); - - temp_cluster_bw = xbt_strdup(cluster_bw); - temp_cluster_bw = replace_random_parameter(temp_cluster_bw); - temp_cluster_lat = xbt_strdup(cluster_lat); - temp_cluster_lat = replace_random_parameter(temp_cluster_lat); - XBT_DEBUG("", link_id,temp_cluster_bw, cluster_lat); - A_surfxml_link_state = A_surfxml_link_state_ON; - A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; - if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FULLDUPLEX) - {A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FULLDUPLEX;} - if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FATPIPE) - {A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FATPIPE;} - SURFXML_BUFFER_SET(link_id, link_id); - SURFXML_BUFFER_SET(link_bandwidth, temp_cluster_bw); - SURFXML_BUFFER_SET(link_latency, temp_cluster_lat); - SURFXML_BUFFER_SET(link_bandwidth_file, ""); - SURFXML_BUFFER_SET(link_latency_file, ""); - SURFXML_BUFFER_SET(link_state_file, ""); - SURFXML_START_TAG(link); - SURFXML_END_TAG(link); - - xbt_free(temp_cluster_bw); - xbt_free(temp_cluster_lat); - free(link_id); - free(host_id); + host_id = bprintf("%s%d%s", cluster_prefix, i, cluster_suffix); + link_id = bprintf("%s_link_%d", cluster_id, i); + xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free); + A_surfxml_host_state = A_surfxml_host_state_ON; + + XBT_DEBUG("", host_id, cluster_power); + SURFXML_BUFFER_SET(host_id, host_id); + SURFXML_BUFFER_SET(host_power, cluster_power); + + if(!strcmp(A_surfxml_cluster_availability_file,"")){ + char* tmp_availability_file = xbt_strdup(availability_file); + xbt_str_varsubst(tmp_availability_file,patterns); + XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file); + SURFXML_BUFFER_SET(host_availability_file, tmp_availability_file); + xbt_free(tmp_availability_file); + } + else + { + XBT_DEBUG("\tavailability_file=\"\""); + SURFXML_BUFFER_SET(host_availability_file, ""); + } + if(!strcmp(A_surfxml_cluster_state_file,"")){ + char *tmp_state_file = xbt_strdup(state_file); + xbt_str_varsubst(tmp_state_file,patterns); + XBT_DEBUG("\tstate_file=\"%s\"",tmp_state_file); + SURFXML_BUFFER_SET(host_state_file, tmp_state_file); + xbt_free(tmp_state_file); + } + else + { + XBT_DEBUG("\tstate_file=\"\""); + SURFXML_BUFFER_SET(host_state_file, ""); + } + + SURFXML_BUFFER_SET(host_core, cluster_core); + SURFXML_BUFFER_SET(host_availability, "1.0"); + SURFXML_BUFFER_SET(host_coordinates, ""); + SURFXML_START_TAG(host); + SURFXML_END_TAG(host); + XBT_DEBUG(""); + + A_surfxml_link_state = A_surfxml_link_state_ON; + A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; + if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FULLDUPLEX) + {A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FULLDUPLEX;} + if(cluster_sharing_policy == A_surfxml_cluster_sharing_policy_FATPIPE) + {A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_FATPIPE;} + + XBT_DEBUG("", link_id,cluster_bw, cluster_lat); + + 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, ""); + SURFXML_BUFFER_SET(link_state_file, ""); + SURFXML_START_TAG(link); + SURFXML_END_TAG(link); + + free(link_id); + free(host_id); } break; default: XBT_DEBUG("Malformed radical"); + break; } xbt_dynar_free(&radical_ends); @@ -1723,7 +1743,7 @@ void routing_parse_Scluster(void) } route_src_dst = bprintf("%s(.*)%s", cluster_prefix, new_suffix); xbt_dynar_free(&radical_elements); - free(new_suffix); + xbt_free(new_suffix); char *pcre_link_src = bprintf("%s_link_$1src", cluster_id); char *pcre_link_backbone = bprintf("%s_backbone", cluster_id); @@ -1842,10 +1862,14 @@ void routing_parse_Scluster(void) free(pcre_link_src); free(route_src_dst); - free(router_id); + xbt_free(cluster_bw); + xbt_free(cluster_lat); + xbt_free(cluster_power); + xbt_free(availability_file); + xbt_free(state_file); + + xbt_free(router_id); xbt_dict_free(&patterns); - free(availability_file); - free(state_file); XBT_DEBUG(""); SURFXML_END_TAG(AS); @@ -1930,6 +1954,7 @@ static void routing_parse_Speer(void) SURFXML_BUFFER_SET(host_availability_file, peer_availability_file); SURFXML_BUFFER_SET(host_state_file, peer_state_file); SURFXML_BUFFER_SET(host_coordinates, ""); + SURFXML_BUFFER_SET(host_core, "1.0"); SURFXML_START_TAG(host); SURFXML_END_TAG(host); @@ -2106,6 +2131,7 @@ static void routing_parse_Srandom(void) break; default: XBT_INFO("Malformed radical"); + break; } res = random_generate(random); rd_name = bprintf("%s_router",random_id);