Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move a function to the right (xml) file
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Mar 2016 20:56:07 +0000 (21:56 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Mar 2016 20:56:07 +0000 (21:56 +0100)
src/surf/sg_platf.cpp
src/surf/surf_routing.cpp

index 55010c7..3adc2e1 100644 (file)
@@ -425,6 +425,75 @@ void routing_cluster_add_backbone(simgrid::surf::Link* bb) {
   XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name());
 }
 
+void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
+{
+  int start, end, i;
+  char *groups , *host_id , *link_id = NULL;
+  unsigned int iter;
+  xbt_dynar_t radical_elements;
+  xbt_dynar_t radical_ends;
+
+  //Make all hosts
+  radical_elements = xbt_str_split(cabinet->radical, ",");
+  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 *));
+
+    switch (xbt_dynar_length(radical_ends)) {
+    case 1:
+      end = start;
+      break;
+    case 2:
+      end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
+      break;
+    default:
+      surf_parse_error("Malformed radical");
+      break;
+    }
+    s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+    memset(&host, 0, sizeof(host));
+    host.pstate        = 0;
+    host.core_amount   = 1;
+
+    s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+    memset(&link, 0, sizeof(link));
+    link.policy    = SURF_LINK_FULLDUPLEX;
+    link.latency   = cabinet->lat;
+    link.bandwidth = cabinet->bw;
+
+    s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+    memset(&host_link, 0, sizeof(host_link));
+
+    for (i = start; i <= end; i++) {
+      host_id                      = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
+      link_id                      = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
+      host.id                      = host_id;
+      link.id                      = link_id;
+      host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
+      xbt_dynar_push(host.speed_peak,&cabinet->speed);
+      sg_platf_new_host(&host);
+      xbt_dynar_free(&host.speed_peak);
+      sg_platf_new_link(&link);
+
+      char* link_up       = bprintf("%s_UP",link_id);
+      char* link_down     = bprintf("%s_DOWN",link_id);
+      host_link.id        = host_id;
+      host_link.link_up   = link_up;
+      host_link.link_down = link_down;
+      sg_platf_new_hostlink(&host_link);
+
+      free(host_id);
+      free(link_id);
+      free(link_up);
+      free(link_down);
+    }
+
+    xbt_dynar_free(&radical_ends);
+  }
+  xbt_dynar_free(&radical_elements);
+}
+
 void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
 {
   xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
@@ -667,15 +736,13 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
   link.latency = peer->lat;
 
   char* link_up = bprintf("%s_UP",link_id);
-  XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_up,
-            peer->bw_out, peer->lat);
+  XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_up, peer->bw_out, peer->lat);
   link.id = link_up;
   link.bandwidth = peer->bw_out;
   sg_platf_new_link(&link);
 
   char* link_down = bprintf("%s_DOWN",link_id);
-  XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_down,
-            peer->bw_in, peer->lat);
+  XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_down, peer->bw_in, peer->lat);
   link.id = link_down;
   link.bandwidth = peer->bw_in;
   sg_platf_new_link(&link);
index 4dba6f1..69ab7ea 100644 (file)
@@ -136,75 +136,6 @@ void routing_model_create(Link *loopback)
 /* ************************************************************************** */
 /* ************************* GENERIC PARSE FUNCTIONS ************************ */
 
-void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
-{
-  int start, end, i;
-  char *groups , *host_id , *link_id = NULL;
-  unsigned int iter;
-  xbt_dynar_t radical_elements;
-  xbt_dynar_t radical_ends;
-
-  //Make all hosts
-  radical_elements = xbt_str_split(cabinet->radical, ",");
-  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 *));
-
-    switch (xbt_dynar_length(radical_ends)) {
-    case 1:
-      end = start;
-      break;
-    case 2:
-      end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
-      break;
-    default:
-      surf_parse_error("Malformed radical");
-      break;
-    }
-    s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
-    memset(&host, 0, sizeof(host));
-    host.pstate        = 0;
-    host.core_amount   = 1;
-
-    s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
-    memset(&link, 0, sizeof(link));
-    link.policy    = SURF_LINK_FULLDUPLEX;
-    link.latency   = cabinet->lat;
-    link.bandwidth = cabinet->bw;
-
-    s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
-    memset(&host_link, 0, sizeof(host_link));
-
-    for (i = start; i <= end; i++) {
-      host_id                      = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
-      link_id                      = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
-      host.id                      = host_id;
-      link.id                      = link_id;
-      host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
-      xbt_dynar_push(host.speed_peak,&cabinet->speed);
-      sg_platf_new_host(&host);
-      xbt_dynar_free(&host.speed_peak);
-      sg_platf_new_link(&link);
-
-      char* link_up       = bprintf("%s_UP",link_id);
-      char* link_down     = bprintf("%s_DOWN",link_id);
-      host_link.id        = host_id;
-      host_link.link_up   = link_up;
-      host_link.link_down = link_down;
-      sg_platf_new_hostlink(&host_link);
-
-      free(host_id);
-      free(link_id);
-      free(link_up);
-      free(link_down);
-    }
-
-    xbt_dynar_free(&radical_ends);
-  }
-  xbt_dynar_free(&radical_elements);
-}
-
 static void check_disk_attachment()
 {
   xbt_lib_cursor_t cursor;