Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I comment all the calls to used_routing, in order to use global routing.
[simgrid.git] / src / surf / network_gtnets.c
index 26b05d2..6580578 100644 (file)
@@ -13,7 +13,9 @@ static double time_to_next_flow_completion = -1;
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets, surf,
                                 "Logging specific to the SURF network GTNetS module");
 
-extern routing_t used_routing;
+//extern routing_t used_routing; // COMMENTED BY DAVID
+extern routing_global_t global_routing; // ADDED BY DAVID
+
 double sg_gtnets_jitter=0.0;
 int sg_gtnets_jitter_seed=10;
 
@@ -21,62 +23,47 @@ static void link_new(char *name, double bw, double lat, xbt_dict_t props)
 {
   static int link_count = -1;
   network_link_GTNETS_t gtnets_link;
+  network_link_GTNETS_t gtnets_link_friend;
   int tmp_idsrc=-1;
   int tmp_iddst=-1;
   char *name_friend;
-  char *name_normal;
 
   if (xbt_dict_get_or_null(surf_network_model->resource_set, name)) {
     return;
   }
 
+#ifdef HAVE_TRACING
+  TRACE_surf_link_declaration (name, bw, lat);
+#endif
+
   DEBUG1("Scanning link name %s", name);
   sscanf(name, "%d_%d", &tmp_idsrc, &tmp_iddst);
   DEBUG2("Link name split into %d and %d", tmp_idsrc, tmp_iddst);
 
   xbt_assert0( (tmp_idsrc!=-1)&&(tmp_idsrc!=-1), "You need to respect fullduplex convention x_y for xml link id.");
 
-  name_normal = (char *)calloc(strlen(name), sizeof(char));
   name_friend = (char *)calloc(strlen(name), sizeof(char));
+  sprintf(name_friend, "%d_%d", tmp_iddst, tmp_idsrc);
 
-  if(tmp_idsrc < tmp_iddst){
-         sprintf(name_normal, "%d_%d", tmp_idsrc, tmp_iddst);
-         sprintf(name_friend, "%d_%d", tmp_iddst, tmp_idsrc);
-  }else{
-         sprintf(name_normal, "%d_%d", tmp_iddst, tmp_idsrc);
-         sprintf(name_friend, "%d_%d", tmp_idsrc, tmp_iddst);
-  }
-
-  gtnets_link = xbt_dict_get_or_null(surf_network_model->resource_set, name_normal);
-
-  if (gtnets_link) {
-    DEBUG3("Link already added as friend normal=%s friend=%s (#%d)", name_normal, name_friend, ((network_link_GTNETS_t)gtnets_link)->id );
-    return;
-  }
-
-  link_count++;
-
-  DEBUG4("Adding new link, linkid %d, name %s, latency %g, bandwidth %g", link_count, name, lat, bw);
-
-  if (gtnets_add_link(link_count, bw, lat)) {
-    xbt_assert0(0, "Cannot create GTNetS link");
-  }
-
-  /* KF: Insert entry in the dictionary */
   gtnets_link = xbt_new0(s_network_link_GTNETS_t, 1);
   gtnets_link->generic_resource.name = name;
   gtnets_link->generic_resource.properties = props;
   gtnets_link->bw_current = bw;
   gtnets_link->lat_current = lat;
-  gtnets_link->id = link_count;
-#ifdef HAVE_TRACING
-  TRACE_surf_link_declaration (name, bw, lat);
-#endif
-  xbt_dict_set(surf_network_model->resource_set, name_normal, gtnets_link,
-               surf_resource_free);
 
-  xbt_dict_set(surf_network_model->resource_set, name_friend, gtnets_link,
-               surf_resource_free);
+  if((gtnets_link_friend=xbt_dict_get_or_null(surf_network_model->resource_set, name_friend))) {
+    gtnets_link->id = gtnets_link_friend->id;
+  } else {
+    link_count++;
+
+    DEBUG4("Adding new link, linkid %d, name %s, latency %g, bandwidth %g", link_count, name, lat, bw);
+    if (gtnets_add_link(link_count, bw, lat)) {
+      xbt_assert0(0, "Cannot create GTNetS link");
+    }
+    gtnets_link->id = link_count;
+  }
+  xbt_dict_set(surf_network_model->resource_set, name, gtnets_link,
+      surf_resource_free);
 }
 
 static void route_new(int src_id, int dst_id, xbt_dynar_t links,int nb_link)
@@ -148,29 +135,31 @@ static void create_gtnets_topology()
   xbt_dict_cursor_t cursor = NULL;
   char *key, *data;
 
-  xbt_dict_t onelink_routes = used_routing->get_onelink_routes();
-  xbt_assert0(onelink_routes, "Error onelink_routes was not initialized");
-
-  DEBUG0("Starting topology generation");
-
-  xbt_dict_foreach(onelink_routes, cursor, key, data){
-       s_onelink_t link = (s_onelink_t) data;
+// COMMENTED BY DAVID
+//   xbt_dict_t onelink_routes = used_routing->get_onelink_routes();
+//   xbt_assert0(onelink_routes, "Error onelink_routes was not initialized");
+// 
+//   DEBUG0("Starting topology generation");
+// 
+//   xbt_dict_foreach(onelink_routes, cursor, key, data){
+//     s_onelink_t link = (s_onelink_t) data;
+// 
+//     DEBUG3("Link (#%d), src (#%d), dst (#%d)", ((network_link_GTNETS_t)(link->link_ptr))->id , link->src_id, link->dst_id);
+//     DEBUG0("Calling one link route");
+//     if(used_routing->is_router(link->src_id)){
+//             gtnets_add_router(link->src_id);
+//     }
+//     if(used_routing->is_router(link->dst_id)){
+//             gtnets_add_router(link->dst_id);
+//     }
+//     route_onehop_new(link->src_id, link->dst_id, (network_link_GTNETS_t)(link->link_ptr));
+//   }
+// 
+//   xbt_dict_free(&route_table);
+//   if (XBT_LOG_ISENABLED(surf_network_gtnets, xbt_log_priority_debug)) {
+//       gtnets_print_topology();
+//   }
 
-       DEBUG3("Link (#%d), src (#%d), dst (#%d)", ((network_link_GTNETS_t)(link->link_ptr))->id , link->src_id, link->dst_id);
-    DEBUG0("Calling one link route");
-    if(used_routing->is_router(link->src_id)){
-       gtnets_add_router(link->src_id);
-    }
-    if(used_routing->is_router(link->dst_id)){
-       gtnets_add_router(link->dst_id);
-    }
-    route_onehop_new(link->src_id, link->dst_id, (network_link_GTNETS_t)(link->link_ptr));
-  }
-
-  xbt_dict_free(&route_table);
-  if (XBT_LOG_ISENABLED(surf_network_gtnets, xbt_log_priority_debug)) {
-         gtnets_print_topology();
-  }
 }
 
 /* Main XML parsing */
@@ -270,7 +259,13 @@ static void update_actions_state(double now, double delta)
       double sent = gtnets_get_flow_rx(action);
 
 #ifdef HAVE_TRACING
+      double trace_sent = sent;
+      if (trace_sent == 0){
+        //if sent is equals to 0, means that gtnets sent all the bytes
+        trace_sent = action->generic_action.cost;
+      }
       // tracing resource utilization
+<<<<<<< HEAD
       int src = TRACE_surf_gtnets_get_src (action);
       int dst = TRACE_surf_gtnets_get_dst (action);
       if (src != -1 && dst != -1){
@@ -278,11 +273,26 @@ static void update_actions_state(double now, double delta)
         network_link_GTNETS_t link;
         unsigned int i;
         xbt_dynar_foreach(route, i, link) {
-
                TRACE_surf_link_set_utilization (link->generic_resource.name,
-            action->generic_action.data, (action->generic_action.remains-remain)/delta, now-delta, delta);
+            action->generic_action.data, trace_sent/delta, now-delta, delta);
         }
       }
+=======
+      
+// COMMENTED BY DAVID
+//       int src = TRACE_surf_gtnets_get_src (action);
+//       int dst = TRACE_surf_gtnets_get_dst (action);
+//       if (src != -1 && dst != -1){
+//         xbt_dynar_t route = used_routing->get_route(src, dst);
+//         network_link_GTNETS_t link;
+//         unsigned int i;
+//         xbt_dynar_foreach(route, i, link) {
+// 
+//             TRACE_surf_link_set_utilization (link->generic_resource.name,
+//             action->generic_action.data, (action->generic_action.remains-remain)/delta, now-delta, delta);
+//         }
+//       }
+>>>>>>> I comment all the calls to used_routing, in order to use global routing.
 #endif
 
       DEBUG1("Sent value returned by GTNetS : %f", sent);
@@ -334,7 +344,8 @@ static surf_action_t communicate(const char *src_name, const char *dst_name,
 
   DEBUG4("Setting flow src %d \"%s\", dst %d \"%s\"", src, src_name, dst, dst_name);
 
-  xbt_dynar_t links = used_routing->get_route(src, dst);
+  //xbt_dynar_t links = used_routing->get_route(src, dst); // COMMENTED BY DAVID
+  xbt_dynar_t links = global_routing->get_route(src_name, dst_name); // ADDED BY DAVID
   route_new(src, dst, links, xbt_dynar_length(links));
 
   action =  surf_action_new(sizeof(s_surf_action_network_GTNETS_t), size, surf_network_model, 0);