Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Warn when there is some remaining actions in the system we're freeing because it...
[simgrid.git] / src / surf / maxmin.c
index 5a0fe5a..e0d093b 100644 (file)
@@ -21,7 +21,7 @@ static void lmm_variable_mallocator_free_f(void *var);
 static void lmm_variable_mallocator_reset_f(void *var);
 static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst);
 static void lmm_remove_all_modified_set(lmm_system_t sys);
-int sg_maxmin_selective_update = 0;
+int sg_maxmin_selective_update = 1;
 static int Global_debug_id = 1;
 static int Global_const_debug_id = 1;
 lmm_system_t lmm_system_new(void)
@@ -66,8 +66,11 @@ void lmm_system_free(lmm_system_t sys)
   lmm_variable_t var = NULL;
   lmm_constraint_t cnst = NULL;
 
-  while ((var = extract_variable(sys)))
+  while ((var = extract_variable(sys))) {
+    WARN2("Variable %p (%d) still in LMM system when freing it: this may be a bug",
+        var,var->id_int);
     lmm_var_free(sys, var);
+  }
 
   while ((cnst = extract_constraint(sys)))
     lmm_cnst_free(sys, cnst);
@@ -76,7 +79,7 @@ void lmm_system_free(lmm_system_t sys)
   free(sys);
 }
 
-void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var)
+XBT_INLINE void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var)
 {
   int i;
   lmm_element_t elem = NULL;
@@ -327,7 +330,7 @@ XBT_INLINE void *lmm_variable_id(lmm_variable_t var)
   return var->id;
 }
 
-static void saturated_constraint_set_update(lmm_system_t sys,
+static XBT_INLINE void saturated_constraint_set_update(lmm_system_t sys,
                                             lmm_constraint_t cnst,
                                             double *min_usage)
 {
@@ -358,7 +361,7 @@ static void saturated_constraint_set_update(lmm_system_t sys,
   XBT_OUT;
 }
 
-static void saturated_variable_set_update(lmm_system_t sys)
+static XBT_INLINE void saturated_variable_set_update(lmm_system_t sys)
 {
   lmm_constraint_t cnst = NULL;
   xbt_swag_t cnst_list = NULL;
@@ -501,6 +504,8 @@ void lmm_solve(lmm_system_t sys)
   xbt_swag_foreach(cnst, cnst_list) {
     /* INIT */
     cnst->remaining = cnst->bound;
+    if (cnst->remaining == 0)
+      continue;
     cnst->usage = 0;
     elem_list = &(cnst->element_set);
     xbt_swag_foreach(elem, elem_list) {
@@ -576,14 +581,14 @@ void lmm_solve(lmm_system_t sys)
         } else {                /* FIXME one day: We recompute usage.... :( */
           cnst->usage = 0.0;
           make_elem_inactive(elem);
+          elem_list = &(cnst->element_set);
           xbt_swag_foreach(elem, elem_list) {
             if (elem->variable->weight <= 0)
               break;
             if (elem->variable->value > 0)
               break;
             if ((elem->value > 0)) {
-              if (cnst->usage < elem->value / elem->variable->weight)
-                cnst->usage = elem->value / elem->variable->weight;
+              cnst->usage=MAX(cnst->usage,elem->value / elem->variable->weight);
               DEBUG2("Constraint Usage %d : %f", cnst->id_int, cnst->usage);
               make_elem_active(elem);
             }