Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use the same type name (network_link_GTNETS_t) as in the private header.
[simgrid.git] / src / surf / network_gtnets.c
index d6fe8a9..c8c9557 100644 (file)
@@ -24,7 +24,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets, surf,
 /* Free memory for a network link */
 static void link_free(void *nw_link)
 {
-  free(((link_GTNETS_t) nw_link)->name);
+  free(((network_link_GTNETS_t) nw_link)->name);
   free(nw_link);
 }
 
@@ -35,7 +35,7 @@ static void link_free(void *nw_link)
 static void link_new(char *name, double bw, double lat, xbt_dict_t props)
 {
   static int link_count = -1;
-  link_GTNETS_t gtnets_link;
+  network_link_GTNETS_t gtnets_link;
 
   /* If link already exists, nothing to do (FIXME: check that multiple definition match?) */
   if (xbt_dict_get_or_null(link_set, name)) {
@@ -68,7 +68,7 @@ static void link_new(char *name, double bw, double lat, xbt_dict_t props)
   }
 
   /* KF: Insert entry in the dictionary */
-  gtnets_link = xbt_new0(s_link_GTNETS_t, 1);
+  gtnets_link = xbt_new0(s_network_link_GTNETS_t, 1);
   gtnets_link->name = name;
   gtnets_link->bw_current = bw;
   gtnets_link->lat_current = lat;
@@ -116,12 +116,12 @@ static int network_card_new(const char *name)
 static void route_new(int src_id, int dst_id, char **links, int nb_link)
 {
 #if 0
-  link_GTNETS_t *link_list = NULL;
+  network_link_GTNETS_t *link_list = NULL;
   int i;
 
   ROUTE_SIZE(src_id, dst_id) = nb_link;
   link_list = (ROUTE(src_id, dst_id) =
-              xbt_new0(link_GTNETS_t, nb_link));
+              xbt_new0(network_link_GTNETS_t, nb_link));
   for (i = 0; i < nb_link; i++) {
     link_list[i] = xbt_dict_get_or_null(link_set, links[i]);
     free(links[i]);
@@ -135,7 +135,7 @@ static void route_new(int src_id, int dst_id, char **links, int nb_link)
   gtnets_links = (int *) calloc(nb_link, sizeof(int));
   for (i = 0; i < nb_link; i++) {
     gtnets_links[i] =
-       ((link_GTNETS_t)
+       ((network_link_GTNETS_t)
         (xbt_dict_get(link_set, links[i])))->id;
   }
 
@@ -157,7 +157,7 @@ static void route_onehop_new(int src_id, int dst_id, char **links,
 
   /* KF: Build the list of gtnets link IDs */
   linkid =
-      ((link_GTNETS_t)
+      ((network_link_GTNETS_t)
        (xbt_dict_get(link_set, links[0])))->id;
 
   /* KF: Create the GTNets route */
@@ -223,7 +223,7 @@ static void parse_route_set_endpoints(void)
 /*  nb_link = 0;
   link_name = NULL;
 */
-  route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
+  route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
 /* KF*/
@@ -253,7 +253,7 @@ static void parse_route_set_route(void)
 /*  if (nb_link > 1)
     route_new(src_id, dst_id, link_name, nb_link);
 */
-    name = bprintf("%d##%d",src_id, dst_id);
+    name = bprintf("%x#%x",src_id, dst_id);
     xbt_dict_set(route_table, name, route_link_list, NULL);
     free(name);    
 }
@@ -271,27 +271,39 @@ static void add_route()
   xbt_ex_t e;
   unsigned int cpt = 0;    
   int i = 0;
+  xbt_dict_cursor_t cursor = NULL;
+  char *key,*data, *end;
+  const char *sep = "#";
+  xbt_dynar_t links, keys;
 
-  nb_link = xbt_dynar_length(links);
-  link_name = xbt_realloc(link_name, (nb_link) * sizeof(char *));
+  xbt_dict_foreach(route_table, cursor, key, data) {
+    nb_link = 0;
+    links = (xbt_dynar_t)data;
+    keys = xbt_str_split_str(key, sep);
+
+    nb_link = xbt_dynar_length(links);
+    link_name = xbt_realloc(link_name, (nb_link) * sizeof(char *));
 
-  src_id = atoi(xbt_dynar_get_as(keys, 0, char*));
-  dst_id = atoi(xbt_dynar_get_as(keys, 1, char*));
+    src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16);
+    dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16);
   
-  i = 0;
-  char* link = NULL;
-  xbt_dynar_foreach (links, cpt, link) {
+    i = 0;
+    char* link = NULL;
+    xbt_dynar_foreach (links, cpt, link) {
       TRY {
         link_name[i++] = xbt_dict_get(link_set, link);
       }
       CATCH(e) {
         RETHROW1("Link %s not found (dict raised this exception: %s)", link);
       }     
-  }
-  if (nb_link > 1)
-    route_new(src_id, dst_id, link_name, nb_link);
-  if (nb_link == 1)
-    route_onehop_new(src_id, dst_id, link_name, nb_link);
+    }
+    if (nb_link > 1)
+      route_new(src_id, dst_id, link_name, nb_link);
+    if (nb_link == 1)
+      route_onehop_new(src_id, dst_id, link_name, nb_link);
+   }
+
+   xbt_dict_free(&route_table);
 }
 
 /* Main XML parsing */
@@ -303,8 +315,14 @@ static void define_callbacks(const char *file)
   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
   surfxml_add_callback(ETag_surfxml_route_element_cb_list, &parse_route_elem);
 /* surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_onehop_route);*/
+  surfxml_add_callback(STag_surfxml_platform_cb_list, &init_data);
   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
+  surfxml_add_callback(STag_surfxml_set_cb_list, &parse_sets);
+  surfxml_add_callback(STag_surfxml_route_c_multi_cb_list, &parse_route_multi_set_endpoints);
+  surfxml_add_callback(ETag_surfxml_route_c_multi_cb_list, &parse_route_multi_set_route);
+  surfxml_add_callback(STag_surfxml_foreach_cb_list, &parse_foreach);
+  surfxml_add_callback(STag_surfxml_cluster_cb_list, &parse_cluster);
 }
 
 static void *name_service(const char *name)
@@ -461,7 +479,7 @@ static surf_action_t communicate(void *src, void *dst, double size,
   network_card_GTNETS_t card_dst = dst;
 /*
   int route_size = ROUTE_SIZE(card_src->id, card_dst->id);
-  link_GTNETS_t *route = ROUTE(card_src->id, card_dst->id);
+  network_link_GTNETS_t *route = ROUTE(card_src->id, card_dst->id);
 */
 
 /*