Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Last version before merging with master
authorJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Tue, 27 Nov 2012 13:49:34 +0000 (07:49 -0600)
committerJonathan Rouzaud-Cornabas <jonathan.rouzaud-cornabas@ens-lyon.fr>
Tue, 27 Nov 2012 13:49:34 +0000 (07:49 -0600)
src/surf/surf_action.c
src/xbt/heap.c

index 90d1878..273f36e 100644 (file)
@@ -374,8 +374,7 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
   while ((xbt_heap_size(model->model_private->action_heap) > 0)
          && (double_equals(xbt_heap_maxkey(model->model_private->action_heap), now))) {
     action = xbt_heap_pop(model->model_private->action_heap);
   while ((xbt_heap_size(model->model_private->action_heap) > 0)
          && (double_equals(xbt_heap_maxkey(model->model_private->action_heap), now))) {
     action = xbt_heap_pop(model->model_private->action_heap);
-    XBT_DEBUG("Action %p: finish", action);
-    action->generic_action.finish = surf_get_clock();
+    XBT_DEBUG("Something happened to action %p", action);
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
       if(model == surf_cpu_model){
 #ifdef HAVE_TRACING
     if (TRACE_is_enabled()) {
       if(model == surf_cpu_model){
@@ -411,6 +410,9 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
 #endif
 
     if(model == surf_cpu_model){
 #endif
 
     if(model == surf_cpu_model){
+      action->generic_action.finish = surf_get_clock();
+      XBT_DEBUG("Action %p finished", action);
+
       /* set the remains to 0 due to precision problems when updating the remaining amount */
       action->generic_action.remains = 0;
       surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
       /* set the remains to 0 due to precision problems when updating the remaining amount */
       action->generic_action.remains = 0;
       surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
@@ -419,6 +421,7 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
     else{
       // if I am wearing a latency hat
       if (action->hat == LATENCY) {
     else{
       // if I am wearing a latency hat
       if (action->hat == LATENCY) {
+        XBT_DEBUG("Latency paid for action %p. Activating", action);
         lmm_update_variable_weight(model->model_private->maxmin_system, action->variable,
             ((surf_action_network_CM02_t)(action))->weight);
         surf_action_lmm_heap_remove(model->model_private->action_heap,action);
         lmm_update_variable_weight(model->model_private->maxmin_system, action->variable,
             ((surf_action_network_CM02_t)(action))->weight);
         surf_action_lmm_heap_remove(model->model_private->action_heap,action);
@@ -429,7 +432,9 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo
           action->hat == NORMAL) {
         // no need to communicate anymore
         // assume that flows that reached max_duration have remaining of 0
           action->hat == NORMAL) {
         // no need to communicate anymore
         // assume that flows that reached max_duration have remaining of 0
-        action->generic_action.remains = 0;
+       action->generic_action.finish = surf_get_clock();
+       XBT_DEBUG("Action %p finished", action);
+       action->generic_action.remains = 0;
         ((surf_action_t)action)->finish = surf_get_clock();
         model->action_state_set((surf_action_t) action,
                                              SURF_ACTION_DONE);
         ((surf_action_t)action)->finish = surf_get_clock();
         model->action_state_set((surf_action_t) action,
                                              SURF_ACTION_DONE);
index d26166b..f024b08 100644 (file)
@@ -11,6 +11,7 @@
 #include "heap_private.h"
 
 #include <stdio.h>
 #include "heap_private.h"
 
 #include <stdio.h>
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_heap, xbt, "Heap");
 
 static void xbt_heap_max_heapify(xbt_heap_t H);
 static void xbt_heap_increase_key(xbt_heap_t H, int i);
 
 static void xbt_heap_max_heapify(xbt_heap_t H);
 static void xbt_heap_increase_key(xbt_heap_t H, int i);
@@ -103,6 +104,7 @@ void xbt_heap_push(xbt_heap_t H, void *content, double key)
   item->key = key;
   item->content = content;
   xbt_heap_increase_key(H, count - 1);
   item->key = key;
   item->content = content;
   xbt_heap_increase_key(H, count - 1);
+  XBT_DEBUG("Heap has now %d elements and max elem is %g",xbt_heap_size(H),xbt_heap_maxkey(H));
   return;
 }
 
   return;
 }
 
@@ -121,6 +123,8 @@ void *xbt_heap_pop(xbt_heap_t H)
   int size = H->size;
   void *max;
 
   int size = H->size;
   void *max;
 
+  XBT_DEBUG("Heap has %d elements before extraction and max elem was %g",xbt_heap_size(H),xbt_heap_maxkey(H));
+
   if (H->count == 0)
     return NULL;
 
   if (H->count == 0)
     return NULL;
 
@@ -152,6 +156,8 @@ void *xbt_heap_pop(xbt_heap_t H)
  */
 void *xbt_heap_remove(xbt_heap_t H, int i)
 {
  */
 void *xbt_heap_remove(xbt_heap_t H, int i)
 {
+  XBT_DEBUG("Heap has %d elements: extracting element %d",xbt_heap_size(H),i);
+
   if ((i < 0) || (i > H->count - 1))
     return NULL;
   /* put element i at head */
   if ((i < 0) || (i > H->count - 1))
     return NULL;
   /* put element i at head */