Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
what is that pimple, for god's sake??
[simgrid.git] / src / surf / network.c
index 2d4158c..e3bd03a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2004-2011. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -9,6 +9,9 @@
 #include "xbt/str.h"
 
 #include "surf/surfxml_parse_values.h"
+#include "surf/surf_resource.h"
+#include "surf/surf_resource_lmm.h"
+
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
                                 "Logging specific to the SURF network module");
@@ -192,26 +195,46 @@ static void* net_create_resource(const char *name,
   return nw_link;
 }
 
-static void net_parse_link_init(void)
+static void net_parse_link_init(sg_platf_link_cbarg_t link)
 {
   XBT_DEBUG("link_CM02");
 
-  if(struct_lnk->V_policy_initial_link == SURF_LINK_FULLDUPLEX)
-  {
-    net_create_resource(bprintf("%s_UP",struct_lnk->V_link_id), struct_lnk->V_link_bandwidth, struct_lnk->V_link_bandwidth_file,
-                      struct_lnk->V_link_latency, struct_lnk->V_link_latency_file, struct_lnk->V_link_state, struct_lnk->V_link_state_file,
-                      struct_lnk->V_policy_initial_link, xbt_dict_new());
-    net_create_resource(bprintf("%s_DOWN",struct_lnk->V_link_id), struct_lnk->V_link_bandwidth, struct_lnk->V_link_bandwidth_file,
-            struct_lnk->V_link_latency, struct_lnk->V_link_latency_file, struct_lnk->V_link_state, struct_lnk->V_link_state_file,
-                      struct_lnk->V_policy_initial_link, xbt_dict_new());
-  }
-  else
-  {
-    net_create_resource(xbt_strdup(struct_lnk->V_link_id), struct_lnk->V_link_bandwidth, struct_lnk->V_link_bandwidth_file,
-               struct_lnk->V_link_latency, struct_lnk->V_link_latency_file, struct_lnk->V_link_state, struct_lnk->V_link_state_file,
-                      struct_lnk->V_policy_initial_link, xbt_dict_new());
+  if (link->policy == SURF_LINK_FULLDUPLEX) {
+    char *link_id;
+    link_id = bprintf("%s_UP", link->id);
+    net_create_resource(link_id,
+                        link->bandwidth,
+                        link->bandwidth_trace,
+                        link->latency,
+                        link->latency_trace,
+                        link->state,
+                        link->state_trace,
+                        link->policy,
+                        link->properties);
+    xbt_free(link_id);
+    link_id = bprintf("%s_DOWN", link->id);
+    net_create_resource(link_id,
+                        link->bandwidth,
+                        link->bandwidth_trace,
+                        link->latency,
+                        link->latency_trace,
+                        link->state,
+                        link->state_trace,
+                        link->policy,
+                        NULL); /* FIXME: We need to deep copy the properties or
+                                * we won't be able to free it */
+    xbt_free(link_id);
+  } else {
+    net_create_resource(link->id,
+                        link->bandwidth,
+                        link->bandwidth_trace,
+                        link->latency,
+                        link->latency_trace,
+                        link->state,
+                        link->state_trace,
+                        link->policy,
+                        link->properties);
   }
-
 }
 
 static void net_add_traces(void)
@@ -273,8 +296,8 @@ static void net_add_traces(void)
 static void net_define_callbacks(void)
 {
   /* Figuring out the network links */
-  surfxml_add_callback(STag_surfxml_link_cb_list, &net_parse_link_init);
-  surfxml_add_callback(ETag_surfxml_platform_cb_list, &net_add_traces);
+  sg_platf_link_add_cb(net_parse_link_init);
+  sg_platf_postparse_add_cb(net_add_traces);
 }
 
 static int net_resource_used(void *resource_id)
@@ -295,8 +318,7 @@ static int net_action_unref(surf_action_t action)
 #ifdef HAVE_TRACING
     xbt_free(((surf_action_network_CM02_t) action)->src_name);
     xbt_free(((surf_action_network_CM02_t) action)->dst_name);
-    if (action->category)
-      xbt_free(action->category);
+    xbt_free(action->category);
 #endif
     surf_action_free(&action);
     return 1;
@@ -813,11 +835,11 @@ static void surf_network_model_init_internal(void)
     network_maxmin_system = lmm_system_new();
 
   routing_model_create(sizeof(link_CM02_t),
-      net_create_resource(xbt_strdup("__loopback__"),
-          498000000, NULL, 0.000015, NULL,
-            SURF_RESOURCE_ON, NULL,
-            SURF_LINK_FATPIPE, NULL),
-            net_get_link_latency);
+                       net_create_resource("__loopback__",
+                                           498000000, NULL,
+                                           0.000015, NULL,
+                                           SURF_RESOURCE_ON, NULL,
+                                           SURF_LINK_FATPIPE, NULL));
 }
 
 
@@ -841,8 +863,6 @@ void surf_network_model_init_SMPI(void)
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/sender_gap", 10e-6);
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
 
-  update_model_description(surf_network_model_description,
-                           "SMPI", surf_network_model);
 }
 
 /************************************************************************/
@@ -863,8 +883,6 @@ void surf_network_model_init_LegrandVelho(void)
                             0.92);
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
 
-  update_model_description(surf_network_model_description,
-                           "LV08_fullupdate", surf_network_model);
 }
 
 /***************************************************************************/
@@ -887,9 +905,6 @@ void surf_network_model_init_CM02(void)
   net_define_callbacks();
   xbt_dynar_push(model_list, &surf_network_model);
   network_solve = lmm_solve;
-
-  update_model_description(surf_network_model_description,
-                           "CM02", surf_network_model);
 }
 
 void surf_network_model_init_Reno(void)
@@ -908,9 +923,6 @@ void surf_network_model_init_Reno(void)
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
                             0.92);
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
-
-  update_model_description(surf_network_model_description,
-                           "Reno", surf_network_model);
 }
 
 
@@ -931,9 +943,6 @@ void surf_network_model_init_Reno2(void)
                             0.92);
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S_parameter",
                             8775);
-
-  update_model_description(surf_network_model_description,
-                           "Reno2", surf_network_model);
 }
 
 void surf_network_model_init_Vegas(void)
@@ -952,7 +961,4 @@ void surf_network_model_init_Vegas(void)
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",
                             0.92);
   xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);
-
-  update_model_description(surf_network_model_description,
-                           "Vegas", surf_network_model);
 }