Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'smpi' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid into...
[simgrid.git] / src / surf / network.c
index 7a75d8b..6e6e794 100644 (file)
@@ -103,40 +103,54 @@ static double constant_bandwidth_constraint(double rate, double bound,
   return rate;
 }
 
-/**********************/
-/*   SMPI callbacks   */
-/**********************/
-static double smpi_latency_factor(double size)
-{
-  /* 1 B <= size <= 1 KiB */
-  if (size <= 1024.0) {
-    return 1.0056;
-  }
+/**--------- <copy/paste C code snippet in surf/network.c> -------------
+  * produced by:
+  * ./regression2.py ./pingpong-in.dat 0.15 100 2 2.4e-5 1.25e8
+  * outliers: 65
+  * gnuplot: 
+    plot "./pingpong-in.dat" using 1:2 with lines title "data", \
+        (x >= 65472) ? 0.00850436*x+558.894 : \
+        (x >= 15424) ? 0.0114635*x+167.446 : \
+        (x >= 9376) ? 0.0136219*x+124.464 : \
+        (x >= 5776) ? 0.00735707*x+105.022 : \
+        (x >= 3484) ? 0.0103235*x+90.2886 : \
+        (x >= 1426) ? 0.0131384*x+77.3159 : \
+        (x >= 732) ? 0.0233927*x+93.6146 : \
+        (x >= 257) ? 0.0236608*x+93.7637 : \
+        (x >= 0) ? 0.00985119*x+96.704 : \
+        1.0 with lines title "piecewise function"
+  *-------------------------------------------------------------------*/
 
-  /* 2 KiB <= size <= 32 KiB */
-  if (size <= 32768.0) {
-    return 1.8805;
-  }
+static double smpi_bandwidth_factor(double size)
+{
 
-  /* 64 KiB <= size <= 4 MiB */
-  return 22.7111;
+    if (size >= 65472) return 0.940694;
+    if (size >= 15424) return 0.697866;
+    if (size >= 9376) return 0.58729;
+    if (size >= 5776) return 1.08739;
+    if (size >= 3484) return 0.77493;
+    if (size >= 1426) return 0.608902;
+    if (size >= 732) return 0.341987;
+    if (size >= 257) return 0.338112;
+    if (size >= 0) return 0.812084;
+    return 1.0;
 }
 
-static double smpi_bandwidth_factor(double size)
+static double smpi_latency_factor(double size)
 {
-  /* 1 B <= size <= 1 KiB */
-  if (size <= 1024.0) {
-    return 0.2758;
-  }
-
-  /* 2 KiB <= size <= 32 KiB */
-  if (size <= 32768.0) {
-    return 0.5477;
-  }
 
-  /* 64 KiB <= size <= 4 MiB */
-  return 0.9359;
+    if (size >= 65472) return 11.6436;
+    if (size >= 15424) return 3.48845;
+    if (size >= 9376) return 2.59299;
+    if (size >= 5776) return 2.18796;
+    if (size >= 3484) return 1.88101;
+    if (size >= 1426) return 1.61075;
+    if (size >= 732) return 1.9503;
+    if (size >= 257) return 1.95341;
+    if (size >= 0) return 2.01467;
+    return 1.0;
 }
+/**--------- <copy/paste C code snippet in surf/network.c> -----------*/
 
 static double smpi_bandwidth_constraint(double rate, double bound,
                                         double size)
@@ -173,8 +187,7 @@ static link_CM02_t net_link_new(char *name,
                             state_initial, state_trace,
                             bw_initial, bw_trace);
 
-  xbt_assert1(!xbt_dict_get_or_null
-              (surf_network_model->resource_set, name),
+  xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
               "Link '%s' declared several times in the platform file.",
               name);
 
@@ -186,8 +199,7 @@ static link_CM02_t net_link_new(char *name,
   if (policy == SURF_LINK_FATPIPE)
     lmm_constraint_shared(nw_link->lmm_resource.constraint);
 
-  xbt_dict_set(surf_network_model->resource_set, name, nw_link,
-               surf_resource_free);
+  xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
 
   return nw_link;
 }
@@ -209,7 +221,7 @@ static void net_parse_link_init(void)
   surf_parse_get_double(&lat_initial, A_surfxml_link_latency);
   lat_trace = tmgr_trace_new(A_surfxml_link_latency_file);
 
-  xbt_assert0((A_surfxml_link_state == A_surfxml_link_state_ON)
+  xbt_assert((A_surfxml_link_state == A_surfxml_link_state_ON)
               || (A_surfxml_link_state ==
                   A_surfxml_link_state_OFF), "Invalid state");
   if (A_surfxml_link_state == A_surfxml_link_state_ON)
@@ -277,11 +289,11 @@ static void net_add_traces(void)
   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
     link_CM02_t link =
-        xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+        xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
 
-    xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
+    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
-    xbt_assert2(trace,
+    xbt_assert(trace,
                 "Cannot connect trace %s to link %s: trace undefined",
                 trace_name, elm);
 
@@ -292,11 +304,11 @@ static void net_add_traces(void)
   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
     link_CM02_t link =
-        xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+               xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
 
-    xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
+    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
-    xbt_assert2(trace,
+    xbt_assert(trace,
                 "Cannot connect trace %s to link %s: trace undefined",
                 trace_name, elm);
 
@@ -307,11 +319,11 @@ static void net_add_traces(void)
   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
     link_CM02_t link =
-        xbt_dict_get_or_null(surf_network_model->resource_set, elm);
+               xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL);
 
-    xbt_assert2(link, "Cannot connect trace %s to link %s: link undefined",
+    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
                 trace_name, elm);
-    xbt_assert2(trace,
+    xbt_assert(trace,
                 "Cannot connect trace %s to link %s: trace undefined",
                 trace_name, elm);
 
@@ -439,17 +451,19 @@ static void net_update_actions_state(double now, double delta)
                                    action->weight);
     }
 #ifdef HAVE_TRACING
-    xbt_dynar_t route =
-        global_routing->get_route(action->src_name, action->dst_name);
-    link_CM02_t link;
-    unsigned int i;
-    xbt_dynar_foreach(route, i, link) {
-      TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
-                                      action->generic_action.data,
-                                      (surf_action_t) action,
-                                      lmm_variable_getvalue
-                                      (action->variable), now - delta,
-                                      delta);
+    if (TRACE_is_enabled()) {
+      xbt_dynar_t route = global_routing->get_route(action->src_name,
+                                                    action->dst_name);
+      link_CM02_t link;
+      unsigned int i;
+      xbt_dynar_foreach(route, i, link) {
+        TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
+                                        action->generic_action.data,
+                                        (surf_action_t) action,
+                                        lmm_variable_getvalue
+                                        (action->variable), now - delta,
+                                        delta);
+      }
     }
 #endif
     if(!lmm_get_number_of_cnst_from_var(network_maxmin_system, action->variable)) {
@@ -610,9 +624,9 @@ static surf_action_t net_communicate(const char *src_name,
 
   xbt_dynar_t back_route = NULL;
   int constraints_per_variable = 0;
-  // I will need this route for some time so let's call get_route_no_cleanup
-  xbt_dynar_t route = global_routing->get_route_no_cleanup(src_name, dst_name);
-
+  xbt_dynar_t route;
+  // I will need this route for some time so require for no cleanup
+  global_routing->get_route_latency(src_name, dst_name, &route, &latency, 0);
 
   if (sg_network_fullduplex == 1) {
     back_route = global_routing->get_route(dst_name, src_name);
@@ -624,8 +638,7 @@ static surf_action_t net_communicate(const char *src_name,
   XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
   /* LARGE PLATFORMS HACK:
      assert on total_route_size */
-  latency = global_routing->get_latency(src_name,dst_name);
-  xbt_assert2(xbt_dynar_length(route) || latency,
+  xbt_assert(xbt_dynar_length(route) || latency,
               "You're trying to send data from %s to %s but there is no connection at all between these two hosts.",
               src_name, dst_name);
 
@@ -733,11 +746,12 @@ static surf_action_t net_communicate(const char *src_name,
   /* LARGE PLATFORMS HACK:
      expand also with src->link and dst->link */
 #ifdef HAVE_TRACING
-  action->src_name = xbt_new(char, strlen(src_name) + 1);
-  strncpy(action->src_name, src_name, strlen(src_name) + 1);
-
-  action->dst_name = xbt_new(char, strlen(dst_name) + 1);
-  strncpy(action->dst_name, dst_name, strlen(dst_name) + 1);
+  if (TRACE_is_enabled()) {
+    action->src_name = xbt_strdup(src_name);
+    action->dst_name = xbt_strdup(dst_name);
+  } else {
+    action->src_name = action->dst_name = NULL;
+  }
 #endif
 
   xbt_dynar_free(&route);