From bed55a06c0de08698519ba251e4c4298cc2ff4b6 Mon Sep 17 00:00:00 2001 From: Jonathan Rouzaud-Cornabas Date: Tue, 27 Nov 2012 07:49:34 -0600 Subject: [PATCH] Last version before merging with master --- src/surf/surf_action.c | 11 ++++++++--- src/xbt/heap.c | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/surf/surf_action.c b/src/surf/surf_action.c index 90d1878604..273f36e1a6 100644 --- a/src/surf/surf_action.c +++ b/src/surf/surf_action.c @@ -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); - 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){ @@ -411,6 +410,9 @@ void generic_update_actions_state_lazy(double now, double delta, surf_model_t mo #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); @@ -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) { + 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); @@ -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->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); diff --git a/src/xbt/heap.c b/src/xbt/heap.c index d26166b5fa..f024b08e98 100644 --- a/src/xbt/heap.c +++ b/src/xbt/heap.c @@ -11,6 +11,7 @@ #include "heap_private.h" #include +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); @@ -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); + XBT_DEBUG("Heap has now %d elements and max elem is %g",xbt_heap_size(H),xbt_heap_maxkey(H)); return; } @@ -121,6 +123,8 @@ void *xbt_heap_pop(xbt_heap_t H) 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; @@ -152,6 +156,8 @@ void *xbt_heap_pop(xbt_heap_t H) */ 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 */ -- 2.20.1