Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
initialize field As::p_linkUpDownList at declaration (+ cosmetics)
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 11 Feb 2016 23:25:09 +0000 (00:25 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 11 Feb 2016 23:25:09 +0000 (00:25 +0100)
src/surf/sg_platf.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_vivaldi.cpp

index 8156a97..5d47172 100644 (file)
@@ -176,9 +176,6 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
   s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
 
   unsigned int iter;
   s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
 
   unsigned int iter;
-  int start, end, i;
-  xbt_dynar_t radical_elements;
-  xbt_dynar_t radical_ends;
 
   if ((cluster->availability_trace && strcmp(cluster->availability_trace, ""))
       || (cluster->state_trace && strcmp(cluster->state_trace, ""))) {
 
   if ((cluster->availability_trace && strcmp(cluster->availability_trace, ""))
       || (cluster->state_trace && strcmp(cluster->state_trace, ""))) {
@@ -221,14 +218,13 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
   }
 
 
   }
 
 
-  current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
-
   //Make all hosts
   //Make all hosts
-  radical_elements = xbt_str_split(cluster->radical, ",");
+  xbt_dynar_t radical_elements = xbt_str_split(cluster->radical, ",");
   xbt_dynar_foreach(radical_elements, iter, groups) {
 
   xbt_dynar_foreach(radical_elements, iter, groups) {
 
-    radical_ends = xbt_str_split(groups, "-");
-    start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+    xbt_dynar_t radical_ends = xbt_str_split(groups, "-");
+    int start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+    int end;
 
     switch (xbt_dynar_length(radical_ends)) {
     case 1:
 
     switch (xbt_dynar_length(radical_ends)) {
     case 1:
@@ -241,7 +237,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
       surf_parse_error("Malformed radical");
       break;
     }
       surf_parse_error("Malformed radical");
       break;
     }
-    for (i = start; i <= end; i++) {
+    for (int 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);
 
       host_id = bprintf("%s%d%s", cluster->prefix, i, cluster->suffix);
       link_id = bprintf("%s_link_%d", cluster->id, i);
 
index 126f532..119b9ab 100644 (file)
@@ -125,9 +125,6 @@ void sg_platf_new_netcard(sg_platf_host_link_cbarg_t netcard)
   xbt_assert(link_up_down.link_up, "Link '%s' not found!",netcard->link_up);
   xbt_assert(link_up_down.link_down, "Link '%s' not found!",netcard->link_down);
 
   xbt_assert(link_up_down.link_up, "Link '%s' not found!",netcard->link_up);
   xbt_assert(link_up_down.link_down, "Link '%s' not found!",netcard->link_down);
 
-  if(!current_routing->p_linkUpDownList)
-    current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
-
   // If dynar is is greater than netcard id and if the host_link is already defined
   if((int)xbt_dynar_length(current_routing->p_linkUpDownList) > info->getId() &&
       xbt_dynar_get_as(current_routing->p_linkUpDownList, info->getId(), void*))
   // If dynar is is greater than netcard id and if the host_link is already defined
   if((int)xbt_dynar_length(current_routing->p_linkUpDownList) > info->getId() &&
       xbt_dynar_get_as(current_routing->p_linkUpDownList, info->getId(), void*))
@@ -197,13 +194,13 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
   new_as->p_hierarchy = SURF_ROUTING_NULL;
   new_as->p_name = xbt_strdup(AS->id);
 
   new_as->p_hierarchy = SURF_ROUTING_NULL;
   new_as->p_name = xbt_strdup(AS->id);
 
-  simgrid::surf::NetCard *info = new simgrid::surf::NetCardImpl(new_as->p_name, SURF_NETWORK_ELEMENT_AS, current_routing);
+  simgrid::surf::NetCard *netcard = new simgrid::surf::NetCardImpl(new_as->p_name, SURF_NETWORK_ELEMENT_AS, current_routing);
   if (current_routing == NULL && routing_platf->p_root == NULL) {
 
     /* it is the first one */
     new_as->p_routingFather = NULL;
     routing_platf->p_root = new_as;
   if (current_routing == NULL && routing_platf->p_root == NULL) {
 
     /* it is the first one */
     new_as->p_routingFather = NULL;
     routing_platf->p_root = new_as;
-    info->setId(-1);
+    netcard->setId(-1);
   } else if (current_routing != NULL && routing_platf->p_root != NULL) {
 
     xbt_assert(!xbt_dict_get_or_null
   } else if (current_routing != NULL && routing_platf->p_root != NULL) {
 
     xbt_assert(!xbt_dict_get_or_null
@@ -218,20 +215,20 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
     xbt_dict_set(current_routing->p_routingSons, AS->id,
                  (void *) new_as, NULL);
     /* add to the father element list */
     xbt_dict_set(current_routing->p_routingSons, AS->id,
                  (void *) new_as, NULL);
     /* add to the father element list */
-    info->setId(current_routing->parseAS(info));
+    netcard->setId(current_routing->parseAS(netcard));
   } else {
     THROWF(arg_error, 0, "All defined components must belong to a AS");
   }
 
   } else {
     THROWF(arg_error, 0, "All defined components must belong to a AS");
   }
 
-  xbt_lib_set(as_router_lib, info->getName(), ROUTING_ASR_LEVEL,
-              (void *) info);
-  XBT_DEBUG("Having set name '%s' id '%d'", new_as->p_name, info->getId());
+  xbt_lib_set(as_router_lib, netcard->getName(), ROUTING_ASR_LEVEL,
+              (void *) netcard);
+  XBT_DEBUG("Having set name '%s' id '%d'", new_as->p_name, netcard->getId());
 
   /* set the new current component of the tree */
   current_routing = new_as;
 
   /* set the new current component of the tree */
   current_routing = new_as;
-  current_routing->p_netcard = info;
+  current_routing->p_netcard = netcard;
 
 
-  simgrid::surf::netcardCreatedCallbacks(info);
+  simgrid::surf::netcardCreatedCallbacks(netcard);
   simgrid::surf::asCreatedCallbacks(new_as);
 }
 
   simgrid::surf::asCreatedCallbacks(new_as);
 }
 
@@ -589,8 +586,6 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
   AS.routing               = A_surfxml_AS_routing_Cluster;
   sg_platf_new_AS_begin(&AS);
 
   AS.routing               = A_surfxml_AS_routing_Cluster;
   sg_platf_new_AS_begin(&AS);
 
-  current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
-
   XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->speed);
   s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
   memset(&host, 0, sizeof(host));
   XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->speed);
   s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
   memset(&host, 0, sizeof(host));
index 7b3ed8b..e6ef6b7 100644 (file)
@@ -56,7 +56,7 @@ public:
   As *p_routingFather = nullptr;
   xbt_dict_t p_routingSons = xbt_dict_new_homogeneous(NULL);
   NetCard *p_netcard;
   As *p_routingFather = nullptr;
   xbt_dict_t p_routingSons = xbt_dict_new_homogeneous(NULL);
   NetCard *p_netcard;
-  xbt_dynar_t p_linkUpDownList = NULL;
+  xbt_dynar_t p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
 
   As(){};
   /* Close that AS: no more content can be added to it */
 
   As(){};
   /* Close that AS: no more content can be added to it */
index 6e9d4bc..d6a5f90 100644 (file)
@@ -53,7 +53,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
   if(src->getRcType() == SURF_NETWORK_ELEMENT_HOST){
     tmp_src_name = HOST_PEER(src->getName());
 
   if(src->getRcType() == SURF_NETWORK_ELEMENT_HOST){
     tmp_src_name = HOST_PEER(src->getName());
 
-    if(p_linkUpDownList){
+    if ((int)xbt_dynar_length(p_linkUpDownList)>src->getId()) {
       info = xbt_dynar_get_as(p_linkUpDownList, src->getId(), s_surf_parsing_link_up_down_t);
       if(info.link_up) { // link up
         xbt_dynar_push_as(route->link_list, void*, info.link_up);
       info = xbt_dynar_get_as(p_linkUpDownList, src->getId(), s_surf_parsing_link_up_down_t);
       if(info.link_up) { // link up
         xbt_dynar_push_as(route->link_list, void*, info.link_up);
@@ -76,7 +76,7 @@ void AsVivaldi::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb
   if(dst->getRcType() == SURF_NETWORK_ELEMENT_HOST){
     tmp_dst_name = HOST_PEER(dst->getName());
 
   if(dst->getRcType() == SURF_NETWORK_ELEMENT_HOST){
     tmp_dst_name = HOST_PEER(dst->getName());
 
-    if(p_linkUpDownList){
+    if ((int)xbt_dynar_length(p_linkUpDownList)>dst->getId()) {
       info = xbt_dynar_get_as(p_linkUpDownList, dst->getId(), s_surf_parsing_link_up_down_t);
       if(info.link_down) { // link down
         xbt_dynar_push_as(route->link_list,void*,info.link_down);
       info = xbt_dynar_get_as(p_linkUpDownList, dst->getId(), s_surf_parsing_link_up_down_t);
       if(info.link_down) { // link down
         xbt_dynar_push_as(route->link_list,void*,info.link_down);