Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Major bug fix in SURF.
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 4 Feb 2005 05:39:50 +0000 (05:39 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 4 Feb 2005 05:39:50 +0000 (05:39 +0000)
In MSG, tasks that were transfered multiple times or whose state was changed did leave some variables in the linear system. Those variables were removed only when the corresponding tasks was destroyed. So sometimes, the result was correct (as in the comparison with masterslave3 of the old MSG).

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@847 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/surf/cpu.c
src/surf/network.c
src/surf/workstation.c
src/surf/workstation_KCCFLN05.c

index 490ac65..31307f6 100644 (file)
@@ -106,10 +106,9 @@ static int resource_used(void *resource_id)
 
 static void action_free(surf_action_t action)
 {
 
 static void action_free(surf_action_t action)
 {
-  surf_action_cpu_t Action = (surf_action_cpu_t) action;
-
   xbt_swag_remove(action, action->state_set);
   xbt_swag_remove(action, action->state_set);
-  lmm_variable_free(maxmin_system, Action->variable);
+  if(((surf_action_cpu_t)action)->variable)
+    lmm_variable_free(maxmin_system, ((surf_action_cpu_t)action)->variable);
   xbt_free(action);
 
   return;
   xbt_free(action);
 
   return;
@@ -128,6 +127,12 @@ static void action_recycle(surf_action_t action)
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
+  if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED))
+    if(((surf_action_cpu_t)action)->variable) {
+      lmm_variable_free(maxmin_system, ((surf_action_cpu_t)action)->variable);
+      ((surf_action_cpu_t)action)->variable = NULL;
+    }
+
   surf_action_change_state(action, state);
   return;
 }
   surf_action_change_state(action, state);
   return;
 }
index 9a59eaf..0590f9a 100644 (file)
@@ -210,10 +210,9 @@ static int resource_used(void *resource_id)
 
 static void action_free(surf_action_t action)
 {
 
 static void action_free(surf_action_t action)
 {
-  surf_action_network_t Action = (surf_action_network_t) action;
-
   xbt_swag_remove(action, action->state_set);
   xbt_swag_remove(action, action->state_set);
-  lmm_variable_free(maxmin_system, Action->variable);
+  if(((surf_action_network_t)action)->variable)
+    lmm_variable_free(maxmin_system, ((surf_action_network_t)action)->variable);
   xbt_free(action);
 
   return;
   xbt_free(action);
 
   return;
@@ -232,6 +231,12 @@ static void action_recycle(surf_action_t action)
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
+  if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED))
+    if(((surf_action_network_t)action)->variable) {
+      lmm_variable_free(maxmin_system, ((surf_action_network_t)action)->variable);
+      ((surf_action_network_t)action)->variable = NULL;
+    }
+
   surf_action_change_state(action, state);
   return;
 }
   surf_action_change_state(action, state);
   return;
 }
@@ -404,7 +409,7 @@ static surf_action_t communicate(void *src, void *dst, double size, double rate)
                              min(action->rate,SG_TCP_CTE_GAMMA / action->lat_current));
 
   if(route_size == 0) {
                              min(action->rate,SG_TCP_CTE_GAMMA / action->lat_current));
 
   if(route_size == 0) {
-    surf_action_change_state((surf_action_t) action, SURF_ACTION_DONE);
+    action_change_state((surf_action_t) action, SURF_ACTION_DONE);
   }
 
   for (i = 0; i < route_size; i++)
   }
 
   for (i = 0; i < route_size; i++)
index 0bfebdb..b0c219c 100644 (file)
@@ -75,6 +75,11 @@ static int resource_used(void *resource_id)
 
 static void action_free(surf_action_t action)
 {
 
 static void action_free(surf_action_t action)
 {
+  if(action->resource_type==(surf_resource_t)surf_network_resource) 
+    surf_network_resource->common_public->action_free(action);
+  else if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
+    surf_cpu_resource->common_public->action_free(action);
+  else DIE_IMPOSSIBLE;
   return;
 }
 
   return;
 }
 
@@ -91,7 +96,11 @@ static void action_recycle(surf_action_t action)
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
-  surf_action_change_state(action, state);
+  if(action->resource_type==(surf_resource_t)surf_network_resource) 
+    surf_network_resource->common_public->action_change_state(action,state);
+  else if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
+    surf_cpu_resource->common_public->action_change_state(action,state);
+  else DIE_IMPOSSIBLE;
   return;
 }
 
   return;
 }
 
index 51fda8f..8c13426 100644 (file)
@@ -394,6 +394,11 @@ static double share_network_KCCFLN05_resources(double now)
 static void action_network_KCCFLN05_change_state(surf_action_t action,
                                                 e_surf_action_state_t state)
 {
 static void action_network_KCCFLN05_change_state(surf_action_t action,
                                                 e_surf_action_state_t state)
 {
+  if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED))
+    if(((surf_action_network_KCCFLN05_t)action)->variable) {
+      lmm_variable_free(maxmin_system, ((surf_action_network_KCCFLN05_t)action)->variable);
+      ((surf_action_network_KCCFLN05_t)action)->variable = NULL;
+    }
   surf_action_change_state(action, state);
   return;
 }
   surf_action_change_state(action, state);
   return;
 }
@@ -505,6 +510,19 @@ static void action_cpu_KCCFLN05_free(surf_action_t action)
   xbt_free(action);
 }
 
   xbt_free(action);
 }
 
+static void action_cpu_KCCFLN05_change_state(surf_action_t action,
+                               e_surf_action_state_t state)
+{
+  if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED))
+    if(((surf_action_cpu_KCCFLN05_t)action)->variable) {
+      lmm_variable_free(maxmin_system, ((surf_action_cpu_KCCFLN05_t)action)->variable);
+      ((surf_action_cpu_KCCFLN05_t)action)->variable = NULL;
+    }
+
+  surf_action_change_state(action, state);
+  return;
+}
+
 /* #define WARNING(format, ...) (fprintf(stderr, "[%s , %s : %d] ", __FILE__, __FUNCTION__, __LINE__),\ */
 /*                               fprintf(stderr, format, ## __VA_ARGS__), \ */
 /*                               fprintf(stderr, "\n")) */
 /* #define WARNING(format, ...) (fprintf(stderr, "[%s , %s : %d] ", __FILE__, __FUNCTION__, __LINE__),\ */
 /*                               fprintf(stderr, format, ## __VA_ARGS__), \ */
 /*                               fprintf(stderr, "\n")) */
@@ -594,11 +612,11 @@ static void update_actions_cpu_KCCFLN05_state(double now, double delta)
     if ((action->generic_action.remains <= 0) && 
        (lmm_get_variable_weight(action->variable)>0)) {
       action->generic_action.finish = surf_get_clock();
     if ((action->generic_action.remains <= 0) && 
        (lmm_get_variable_weight(action->variable)>0)) {
       action->generic_action.finish = surf_get_clock();
-      surf_action_change_state((surf_action_t) action, SURF_ACTION_DONE);
+      action_cpu_KCCFLN05_change_state((surf_action_t) action, SURF_ACTION_DONE);
     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
               (action->generic_action.max_duration <= 0)) {
       action->generic_action.finish = surf_get_clock();
     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
               (action->generic_action.max_duration <= 0)) {
       action->generic_action.finish = surf_get_clock();
-      surf_action_change_state((surf_action_t) action, SURF_ACTION_DONE);
+      action_cpu_KCCFLN05_change_state((surf_action_t) action, SURF_ACTION_DONE);
     } else {                   /* Need to check that none of the resource has failed */
       lmm_constraint_t cnst = NULL;
       int i = 0;
     } else {                   /* Need to check that none of the resource has failed */
       lmm_constraint_t cnst = NULL;
       int i = 0;
@@ -610,7 +628,7 @@ static void update_actions_cpu_KCCFLN05_state(double now, double delta)
        cpu = lmm_constraint_id(cnst);
        if (cpu->state_current == SURF_CPU_OFF) {
          action->generic_action.finish = surf_get_clock();
        cpu = lmm_constraint_id(cnst);
        if (cpu->state_current == SURF_CPU_OFF) {
          action->generic_action.finish = surf_get_clock();
-         surf_action_change_state((surf_action_t) action, SURF_ACTION_FAILED);
+         action_cpu_KCCFLN05_change_state((surf_action_t) action, SURF_ACTION_FAILED);
          break;
        }
       }
          break;
        }
       }
@@ -675,8 +693,11 @@ static int cpu_KCCFLN05_action_is_suspended(surf_action_t action)
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
 static void action_change_state(surf_action_t action,
                                e_surf_action_state_t state)
 {
-  xbt_assert0(0, "Workstation is a virtual resource. I should not be there!");
-  surf_action_change_state(action, state);
+  if(action->resource_type==(surf_resource_t)surf_network_resource) 
+    surf_network_resource->common_public->action_change_state(action,state);
+  else if(action->resource_type==(surf_resource_t)surf_cpu_resource) 
+    surf_cpu_resource->common_public->action_change_state(action,state);
+  else DIE_IMPOSSIBLE;
   return;
 }
 
   return;
 }
 
@@ -796,7 +817,7 @@ static void cpu_KCCFLN05_resource_init_internal(void)
   surf_cpu_resource->common_public->action_free = action_cpu_KCCFLN05_free;
   surf_cpu_resource->common_public->action_cancel = NULL;
   surf_cpu_resource->common_public->action_recycle = NULL;
   surf_cpu_resource->common_public->action_free = action_cpu_KCCFLN05_free;
   surf_cpu_resource->common_public->action_cancel = NULL;
   surf_cpu_resource->common_public->action_recycle = NULL;
-  surf_cpu_resource->common_public->action_change_state = surf_action_change_state;
+  surf_cpu_resource->common_public->action_change_state = action_cpu_KCCFLN05_change_state;
   surf_cpu_resource->common_public->action_set_data = surf_action_set_data;
   surf_cpu_resource->common_public->name = "CPU KCCFLN05";
 
   surf_cpu_resource->common_public->action_set_data = surf_action_set_data;
   surf_cpu_resource->common_public->name = "CPU KCCFLN05";