Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Complete rewrite of the sharing function for the ptask_L07 model.
[simgrid.git] / src / surf / network_gtnets.c
index 778c3f3..df514d6 100644 (file)
@@ -9,6 +9,9 @@
 #include "gtnets/gtnets_interface.h"
 #include "xbt/str.h"
 
+
+static   double time_to_next_flow_completion=-1;
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets, surf,
                                "Logging specific to the SURF network module");
 
@@ -346,7 +349,11 @@ static double share_resources(double now)
   if (!xbt_swag_size(running_actions))
     return -1.0;
 
-  return gtnets_get_time_to_next_flow_completion();
+  xbt_assert0(time_to_next_flow_completion, "Time to next flow completion not initialized!\n");
+  
+  time_to_next_flow_completion = gtnets_get_time_to_next_flow_completion();
+
+  return time_to_next_flow_completion;
 }
 
 /* delta: by how many time units the simulation must advance */
@@ -363,9 +370,6 @@ static void update_actions_state(double now, double delta)
   xbt_swag_t running_actions =
       surf_network_model->common_public->states.running_action_set;
 
-  double time_to_next_flow_completion =
-      gtnets_get_time_to_next_flow_completion();
-
   /* If there are no renning flows, just return */
   if (time_to_next_flow_completion < 0.0) {
     return;
@@ -387,18 +391,17 @@ static void update_actions_state(double now, double delta)
                  "GTNetS simulation couldn't find a flow that would complete");
     }
 
-
-
     xbt_swag_foreach(action, running_actions) {
-      DEBUG1("]]]]]]]]] Action remains old value: %f", action->generic_action.remains);
+      DEBUG2("Action (%p) remains old value: %f", action, action->generic_action.remains);
       double remain = gtnets_get_flow_rx(action);
+      DEBUG1("Remain value returned by GTNetS : %f", remain);
       //need to trust this remain value
       if(remain == 0){
        action->generic_action.remains=0;
       }else {
-       action->generic_action.remains-=remain;
+       action->generic_action.remains=action->generic_action.cost-remain;
       }
-      DEBUG1("[[[[[[[[[ Action remains new value: %f", action->generic_action.remains);
+      DEBUG2("Action (%p) remains new value: %f", action, action->generic_action.remains);
     }
 
     for (i = 0; i < num_flows; i++) {
@@ -406,12 +409,7 @@ static void update_actions_state(double now, double delta)
       
       action->generic_action.finish = now + time_to_next_flow_completion;
       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
-      /* TODO: Anything else here? */
-
-      //need to map this action to the gtnets engine
-      DEBUG1("]]]]]]]]] Action remains old value: %f", action->generic_action.remains);
-      action->generic_action.remains -= gtnets_get_flow_rx(metadata[i]);
-      DEBUG1("[[[[[[[[[ Action remains new value: %f", action->generic_action.remains);
+      DEBUG1("----> Action (%p) just terminated",action);
     }