Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sorry ;)
[simgrid.git] / src / surf / network.c
index 5b704ea..af6e1ed 100644 (file)
@@ -60,7 +60,6 @@ static void update_action_remaining(double now);
 
 static xbt_swag_t net_modified_set = NULL;
 static xbt_heap_t net_action_heap = NULL;
-xbt_swag_t keep_track = NULL;
 
 /* added to manage the communication action's heap */
 static void net_action_update_index_heap(void *action, int i)
@@ -81,7 +80,7 @@ static void heap_insert(surf_action_network_CM02_t    action, double key, enum h
 }
 
 static void heap_remove(surf_action_network_CM02_t action){
-  action->hat = NONE;
+  action->hat = NOTSET;
   if(((surf_action_network_CM02_t) action)->index_heap >= 0){
       xbt_heap_remove(net_action_heap,action->index_heap);
   }
@@ -109,40 +108,42 @@ static double constant_bandwidth_constraint(double rate, double bound,
 /**********************/
 /*   SMPI callbacks   */
 /**********************/
-static double smpi_bandwidth_factor(double size)
+static xbt_dynar_t parse_factor(const char *smpi_coef_string)
 {
        char *value = NULL;
-       unsigned int iter;
-       smpi_factor_t fact;
-
-       if(!smpi_bw_factor){
-               xbt_dynar_t radical_elements,radical_elements2;
-
-               char *smpi_coef_string = xbt_cfg_get_string(_surf_cfg_set,"smpi/bw_factor");
-               smpi_bw_factor = xbt_dynar_new(sizeof(s_smpi_factor_t),free);
-               radical_elements = xbt_str_split(smpi_coef_string, ";");
-               xbt_dynar_foreach(radical_elements, iter, value) {
-
-                       radical_elements2 = xbt_str_split(value, ":");
-                       if(xbt_dynar_length(radical_elements2) != 2)
-                               xbt_die("Malformed radical for smpi/bw_factor!");
-                       fact = xbt_new(s_smpi_factor_t,1);
-                       fact->factor = atol(xbt_dynar_get_as(radical_elements2,0,char*));
-                       fact->value = atof(xbt_dynar_get_as(radical_elements2,1,char*));
-                       xbt_dynar_push_as(smpi_bw_factor,smpi_factor_t,fact);
-                       XBT_DEBUG("smpi_bandwidth_factor:\t%ld : %f",fact->factor,fact->value);
-                       xbt_dynar_free(&radical_elements2);
-               }
-               xbt_dynar_free(&radical_elements);
+       unsigned int iter = 0;
+       s_smpi_factor_t fact;
+       xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL;
+
+       smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL);
+       radical_elements = xbt_str_split(smpi_coef_string, ";");
+       xbt_dynar_foreach(radical_elements, iter, value) {
+
+               radical_elements2 = xbt_str_split(value, ":");
+               if(xbt_dynar_length(radical_elements2) != 2)
+                       xbt_die("Malformed radical for smpi factor!");
+               fact.factor = atol(xbt_dynar_get_as(radical_elements2,0,char*));
+               fact.value = atof(xbt_dynar_get_as(radical_elements2,1,char*));
+               xbt_dynar_push_as(smpi_factor,s_smpi_factor_t,fact);
+               XBT_DEBUG("smpi_factor:\t%ld : %f",fact.factor,fact.value);
+               xbt_dynar_free(&radical_elements2);
        }
+       xbt_dynar_free(&radical_elements);
+       return smpi_factor;
+}
+
+static double smpi_bandwidth_factor(double size)
+{
+       if(!smpi_bw_factor)
+               smpi_bw_factor = parse_factor( xbt_cfg_get_string(_surf_cfg_set,"smpi/bw_factor") );
 
+       unsigned int iter = 0;
+       s_smpi_factor_t fact;
        xbt_dynar_foreach(smpi_bw_factor, iter, fact) {
-               if(size >= fact->factor)
-               {
-                       XBT_DEBUG("%lf >= %ld return %f",size,fact->factor,fact->value);
-                       return fact->value;
+               if(size >= fact.factor){
+                       XBT_DEBUG("%lf >= %ld return %f",size,fact.factor,fact.value);
+                       return fact.value;
                }
-
        }
 
     return 1.0;
@@ -150,36 +151,15 @@ static double smpi_bandwidth_factor(double size)
 
 static double smpi_latency_factor(double size)
 {
-       char *value = NULL;
-       unsigned int iter;
-       smpi_factor_t fact;
-
-       if(!smpi_lat_factor){
-               xbt_dynar_t radical_elements,radical_elements2;
-
-               char *smpi_coef_string = xbt_cfg_get_string(_surf_cfg_set,"smpi/lat_factor");
-               smpi_lat_factor = xbt_dynar_new(sizeof(s_smpi_factor_t),free);
-               radical_elements = xbt_str_split(smpi_coef_string, ";");
-               xbt_dynar_foreach(radical_elements, iter, value) {
-
-                       radical_elements2 = xbt_str_split(value, ":");
-                       if(xbt_dynar_length(radical_elements2) != 2)
-                               xbt_die("Malformed radical for smpi/lat_factor!");
-                       fact = xbt_new(s_smpi_factor_t,1);
-                       fact->factor = atol(xbt_dynar_get_as(radical_elements2,0,char*));
-                       fact->value = atof(xbt_dynar_get_as(radical_elements2,1,char*));
-                       xbt_dynar_push_as(smpi_lat_factor,smpi_factor_t,fact);
-                       XBT_DEBUG("smpi_latency_factor:\t%ld : %f",fact->factor,fact->value);
-                       xbt_dynar_free(&radical_elements2);
-               }
-               xbt_dynar_free(&radical_elements);
-       }
+       if(!smpi_lat_factor)
+               smpi_lat_factor = parse_factor( xbt_cfg_get_string(_surf_cfg_set,"smpi/lat_factor") );
 
+       unsigned int iter = 0;
+       s_smpi_factor_t fact;
        xbt_dynar_foreach(smpi_lat_factor, iter, fact) {
-               if(size >= fact->factor)
-               {
-                       XBT_DEBUG("%lf >= %ld return %f",size,fact->factor,fact->value);
-                       return fact->value;
+               if(size >= fact.factor){
+                       XBT_DEBUG("%lf >= %ld return %f",size,fact.factor,fact.value);
+                       return fact.value;
                }
        }
 
@@ -392,7 +372,7 @@ void net_action_recycle(surf_action_t action)
 }
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-static int net_get_link_latency_limited(surf_action_t action)
+int net_get_link_latency_limited(surf_action_t action)
 {
   return action->latency_limited;
 }
@@ -484,9 +464,7 @@ static double net_share_resources_lazy(double now)
   XBT_DEBUG("Before share resources, the size of modified actions set is %d", xbt_swag_size(net_modified_set));
   update_action_remaining(now);
 
-  keep_track = net_modified_set;
   lmm_solve(network_maxmin_system);
-  keep_track = NULL;
 
   XBT_DEBUG("After share resources, The size of modified actions set is %d", xbt_swag_size(net_modified_set));
 
@@ -984,6 +962,11 @@ static void net_finalize(void)
     xbt_heap_free(net_action_heap);
     xbt_swag_free(net_modified_set);
   }
+
+  if(smpi_bw_factor)
+         xbt_dynar_free(&smpi_bw_factor);
+  if(smpi_lat_factor)
+         xbt_dynar_free(&smpi_lat_factor);
 }
 
 static void smpi_gap_append(double size, const link_CM02_t link, surf_action_network_CM02_t action) {
@@ -1094,8 +1077,8 @@ static void surf_network_model_init_internal(void)
   if(network_update_mechanism == UM_LAZY){
     net_action_heap = xbt_heap_new(8,NULL);
     xbt_heap_set_update_callback(net_action_heap, net_action_update_index_heap);
-    net_modified_set =
-        xbt_swag_new(xbt_swag_offset(comm, action_list_hookup));
+    net_modified_set = xbt_swag_new(xbt_swag_offset(comm, action_list_hookup));
+    network_maxmin_system->keep_track = net_modified_set;
   }
 }
 
@@ -1178,9 +1161,9 @@ void surf_network_model_init_LegrandVelho(void)
   xbt_dynar_push(model_list, &surf_network_model);
   network_solve = lmm_solve;
 
-  xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 10.4); // 13.01 when callibration is done without phase effects
-  xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",0.92);// 0.97 when callibration is done without phase effects
-  xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 8775);       // 20537 when callibration is done without phase effects
+  xbt_cfg_setdefault_double(_surf_cfg_set, "network/latency_factor", 13.01);
+  xbt_cfg_setdefault_double(_surf_cfg_set, "network/bandwidth_factor",0.97);
+  xbt_cfg_setdefault_double(_surf_cfg_set, "network/weight_S", 20537);
 }
 
 /***************************************************************************/