Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to set latency_factor, bandwidth_factor and weight_S parameters of the network...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 30 Mar 2010 13:19:44 +0000 (13:19 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 30 Mar 2010 13:19:44 +0000 (13:19 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7395 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
src/surf/network.c
src/surf/surf_config.c
src/surf/surf_private.h

index 0765590..a9df8d7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,10 @@ SimGrid (3.3.5-svn) unstable; urgency=low
     o cpu_model -> cpu/model
     o network_model -> network/model
     o workstation_model -> workstation/model
     o cpu_model -> cpu/model
     o network_model -> network/model
     o workstation_model -> workstation/model
+  * New configuration variables:
+    o network/bandwidth_factor: correction to bandwith
+    o network/latency_factor: correction to latency
+    o netwotk/weight_S: correction to the weight of competing streams
  SMPI:
   * Implement MPI_Get_count, MPI_MAXLOC, MPI_MINLOC
  XBT:
  SMPI:
   * Implement MPI_Get_count, MPI_MAXLOC, MPI_MINLOC
  XBT:
index ecd6d4e..2ebad7f 100644 (file)
@@ -16,9 +16,9 @@ surf_model_t surf_network_model = NULL;
 static lmm_system_t network_maxmin_system = NULL;
 static void (*network_solve) (lmm_system_t) = NULL;
 
 static lmm_system_t network_maxmin_system = NULL;
 static void (*network_solve) (lmm_system_t) = NULL;
 
-double latency_factor = 1.0;    /* default value */
-double bandwidth_factor = 1.0;  /* default value */
-double weight_S_parameter = 0.0;        /* default value */
+double sg_latency_factor = 1.0;    /* default value; can be set by model or from command line */
+double sg_bandwidth_factor = 1.0;  /* default value; can be set by model or from command line */
+double sg_weight_S_parameter = 0.0;/* default value; can be set by model or from command line */
 
 double sg_tcp_gamma = 0.0;
 
 
 double sg_tcp_gamma = 0.0;
 
@@ -38,7 +38,7 @@ static link_CM02_t net_link_new(char *name,
     surf_resource_lmm_new(sizeof(s_link_CM02_t),
                           surf_network_model, name, properties,
                           network_maxmin_system,
     surf_resource_lmm_new(sizeof(s_link_CM02_t),
                           surf_network_model, name, properties,
                           network_maxmin_system,
-                          bandwidth_factor * bw_initial,
+                          sg_bandwidth_factor * bw_initial,
                           history,
                           state_initial, state_trace,
                           bw_initial, bw_trace);
                           history,
                           state_initial, state_trace,
                           bw_initial, bw_trace);
@@ -279,7 +279,7 @@ static void net_update_resource_state(void *id,
 
   if (event_type == nw_link->lmm_resource.power.event) {
     double delta =
 
   if (event_type == nw_link->lmm_resource.power.event) {
     double delta =
-      weight_S_parameter / value - weight_S_parameter /
+      sg_weight_S_parameter / value - sg_weight_S_parameter /
       (nw_link->lmm_resource.power.peak * nw_link->lmm_resource.power.scale);
     lmm_variable_t var = NULL;
     lmm_element_t elem = NULL;
       (nw_link->lmm_resource.power.peak * nw_link->lmm_resource.power.scale);
     lmm_variable_t var = NULL;
     lmm_element_t elem = NULL;
@@ -288,10 +288,10 @@ static void net_update_resource_state(void *id,
     nw_link->lmm_resource.power.peak = value;
     lmm_update_constraint_bound(network_maxmin_system,
                                 nw_link->lmm_resource.constraint,
     nw_link->lmm_resource.power.peak = value;
     lmm_update_constraint_bound(network_maxmin_system,
                                 nw_link->lmm_resource.constraint,
-                                bandwidth_factor *
+                                sg_bandwidth_factor *
                                 (nw_link->lmm_resource.power.peak *
                                  nw_link->lmm_resource.power.scale));
                                 (nw_link->lmm_resource.power.peak *
                                  nw_link->lmm_resource.power.scale));
-    if (weight_S_parameter > 0) {
+    if (sg_weight_S_parameter > 0) {
       while ((var = lmm_get_var_from_cnst
               (network_maxmin_system, nw_link->lmm_resource.constraint,
                &elem))) {
       while ((var = lmm_get_var_from_cnst
               (network_maxmin_system, nw_link->lmm_resource.constraint,
                &elem))) {
@@ -402,13 +402,13 @@ static surf_action_t net_communicate(const char *src_name, const char *dst_name,
     action->latency += link->lat_current;
     action->weight +=
       link->lat_current +
     action->latency += link->lat_current;
     action->weight +=
       link->lat_current +
-      weight_S_parameter /
+      sg_weight_S_parameter /
       (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
   }
   /* LARGE PLATFORMS HACK:
      Add src->link and dst->link latencies */
   action->lat_current = action->latency;
       (link->lmm_resource.power.peak * link->lmm_resource.power.scale);
   }
   /* LARGE PLATFORMS HACK:
      Add src->link and dst->link latencies */
   action->lat_current = action->latency;
-  action->latency *= latency_factor;
+  action->latency *= sg_latency_factor;
 
   /* LARGE PLATFORMS HACK:
      lmm_variable_new(..., total_route_size) */
 
   /* LARGE PLATFORMS HACK:
      lmm_variable_new(..., total_route_size) */
@@ -558,9 +558,9 @@ void surf_network_model_init_LegrandVelho(const char *filename)
   xbt_dynar_push(model_list, &surf_network_model);
   network_solve = lmm_solve;
 
   xbt_dynar_push(model_list, &surf_network_model);
   network_solve = lmm_solve;
 
-  latency_factor = 10.4;
-  bandwidth_factor = 0.92;
-  weight_S_parameter = 8775;
+  xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor",10.4);
+  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,
                            "LV08", surf_network_model);
 
   update_model_description(surf_network_model_description,
                            "LV08", surf_network_model);
@@ -602,9 +602,9 @@ void surf_network_model_init_Reno(const char *filename)
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
   network_solve = lagrange_solve;
 
   lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
   network_solve = lagrange_solve;
 
-  latency_factor = 10.4;
-  bandwidth_factor = 0.92;
-  weight_S_parameter = 8775;
+  xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor", 10.4);
+  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);
 
   update_model_description(surf_network_model_description,
                            "Reno", surf_network_model);
@@ -623,9 +623,9 @@ void surf_network_model_init_Reno2(const char *filename)
                                     func_reno2_fpi);
   network_solve = lagrange_solve;
 
                                     func_reno2_fpi);
   network_solve = lagrange_solve;
 
-  latency_factor = 10.4;
-  bandwidth_factor = 0.92;
-  weight_S_parameter = 8775;
+  xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor", 10.4);
+  xbt_cfg_setdefault_double(_surf_cfg_set,"network/bandwidth_factor", 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);
 
   update_model_description(surf_network_model_description,
                            "Reno2", surf_network_model);
@@ -643,9 +643,9 @@ void surf_network_model_init_Vegas(const char *filename)
                                     func_vegas_fpi);
   network_solve = lagrange_solve;
 
                                     func_vegas_fpi);
   network_solve = lagrange_solve;
 
-  latency_factor = 10.4;
-  bandwidth_factor = 0.92;
-  weight_S_parameter = 8775;
+  xbt_cfg_setdefault_double(_surf_cfg_set,"network/latency_factor", 10.4);
+  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);
 
   update_model_description(surf_network_model_description,
                            "Vegas", surf_network_model);
index e5b64aa..3b28a51 100644 (file)
@@ -1,6 +1,4 @@
-/*     $Id$     */
-
-/* Copyright (c) 2009 The SimGrid team. All rights reserved.                */
+/* Copyright (c) 2009-2010 The SimGrid team. All rights reserved.           */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -97,22 +95,30 @@ static void _surf_cfg_cb__network_model(const char *name, int pos)
   find_model_description(surf_network_model_description, val);
 }
 
   find_model_description(surf_network_model_description, val);
 }
 
-/* callback of the tcp gamma variable */
-static void _surf_cfg_cb__tcp_gamma(const char *name, int pos)
-{
+
+/* callbacks of the network models values */
+static void _surf_cfg_cb__tcp_gamma(const char *name, int pos) {
   sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
 }
   sg_tcp_gamma = xbt_cfg_get_double(_surf_cfg_set, name);
 }
+static void _surf_cfg_cb__latency_factor(const char *name, int pos) {
+  sg_latency_factor = xbt_cfg_get_double(_surf_cfg_set, name);
+}
+static void _surf_cfg_cb__bandwidth_factor(const char *name, int pos) {
+  sg_bandwidth_factor = xbt_cfg_get_double(_surf_cfg_set, name);
+}
+static void _surf_cfg_cb__weight_S(const char *name, int pos) {
+  sg_weight_S_parameter = xbt_cfg_get_double(_surf_cfg_set, name);
+}
+static void _surf_cfg_cb__surf_maxmin_selective_update(const char *name, int pos) {
+       sg_maxmin_selective_update = xbt_cfg_get_int(_surf_cfg_set, name);
+}
 
 
-static void _surf_cfg_cb__surf_path(const char *name, int pos)
-{
+/* callback of the inclusion path */
+static void _surf_cfg_cb__surf_path(const char *name, int pos) {
   char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
   xbt_dynar_push(surf_path, &path);
 }
 
   char *path = xbt_cfg_get_string_at(_surf_cfg_set, name, pos);
   xbt_dynar_push(surf_path, &path);
 }
 
-static void _surf_cfg_cb__surf_maxmin_selective_update(const char *name, int pos)
-{
-       sg_maxmin_selective_update = xbt_cfg_get_int(_surf_cfg_set, name);
-}
 
 #ifdef HAVE_GTNETS
 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos){
 
 #ifdef HAVE_GTNETS
 static void _surf_cfg_cb__gtnets_jitter(const char *name, int pos){
@@ -133,6 +139,7 @@ void surf_config_init(int *argc, char **argv)
 
     char *description = xbt_malloc(1024), *p = description;
     char *default_value;
 
     char *description = xbt_malloc(1024), *p = description;
     char *default_value;
+    double double_default_value;
        int default_value_int;
     int i;
 
        int default_value_int;
     int i;
 
@@ -181,14 +188,28 @@ void surf_config_init(int *argc, char **argv)
     default_value = xbt_strdup("Full");
     xbt_cfg_register(&_surf_cfg_set, "routing",
                      "Model to use to store the routing information",
     default_value = xbt_strdup("Full");
     xbt_cfg_register(&_surf_cfg_set, "routing",
                      "Model to use to store the routing information",
-                     xbt_cfgelm_string, &default_value, 1, 1, NULL,
-                     NULL);
+                     xbt_cfgelm_string, &default_value, 1, 1, NULL, NULL);
 
     xbt_cfg_register(&_surf_cfg_set, "TCP_gamma",
 
     xbt_cfg_register(&_surf_cfg_set, "TCP_gamma",
-                     "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; middle value=default value => you probably want default send value)", xbt_cfgelm_double,
-                     NULL, 1, 1, _surf_cfg_cb__tcp_gamma, NULL);
+                     "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; middle value=default value => you probably want default send value)",
+                     xbt_cfgelm_double, NULL, 1, 1, _surf_cfg_cb__tcp_gamma, NULL);
     xbt_cfg_set_double(_surf_cfg_set, "TCP_gamma", 20000.0);
 
     xbt_cfg_set_double(_surf_cfg_set, "TCP_gamma", 20000.0);
 
+    /* The parameters of network models */
+    double_default_value = 1.0;
+    xbt_cfg_register(&_surf_cfg_set, "network/latency_factor",
+                     "Correction factor to apply to the provided latency (default value set by network model)",
+                     xbt_cfgelm_double, &double_default_value, 1, 1, _surf_cfg_cb__latency_factor, NULL);
+    double_default_value = 1.0;
+    xbt_cfg_register(&_surf_cfg_set, "network/bandwidth_factor",
+                     "Correction factor to apply to the provided bandwidth (default value set by network model)",
+                     xbt_cfgelm_double, &double_default_value, 1, 1, _surf_cfg_cb__bandwidth_factor, NULL);
+    double_default_value = 0.0;
+    xbt_cfg_register(&_surf_cfg_set, "network/weight_S",
+                     "Correction factor to apply to the weight of competing streams(default value set by network model)",
+                     xbt_cfgelm_double, &double_default_value, 1, 1, _surf_cfg_cb__weight_S, NULL);
+
+    /* Inclusion path */
     xbt_cfg_register(&_surf_cfg_set, "path",
                      "Lookup path for inclusions in platform and deployment XML files",
                      xbt_cfgelm_string, NULL, 0, 0, _surf_cfg_cb__surf_path,
     xbt_cfg_register(&_surf_cfg_set, "path",
                      "Lookup path for inclusions in platform and deployment XML files",
                      xbt_cfgelm_string, NULL, 0, 0, _surf_cfg_cb__surf_path,
index 9bad336..1c1ad35 100644 (file)
 #include "surf/random_mgr.h"
 
 #define NO_MAX_DURATION -1.0
 #include "surf/random_mgr.h"
 
 #define NO_MAX_DURATION -1.0
+
+/* user-visible parameters */
 extern double sg_tcp_gamma;
 extern double sg_tcp_gamma;
+extern double sg_latency_factor;
+extern double sg_bandwidth_factor;
+extern double sg_weight_S_parameter;
 extern int sg_maxmin_selective_update;
 #ifdef HAVE_GTNETS
   extern double sg_gtnets_jitter;
   extern int sg_gtnets_jitter_seed;
 #endif
 
 extern int sg_maxmin_selective_update;
 #ifdef HAVE_GTNETS
   extern double sg_gtnets_jitter;
   extern int sg_gtnets_jitter_seed;
 #endif
 
+
 extern const char *surf_action_state_names[6];
 
 typedef enum {
 extern const char *surf_action_state_names[6];
 
 typedef enum {