From 35cac2ff2faac99a3b8311f774ecbe86cfde1374 Mon Sep 17 00:00:00 2001 From: donassbr Date: Thu, 27 Aug 2009 11:25:12 +0000 Subject: [PATCH] Remove unnecessary changes at maxmin.c. Error when updating max_duration of action. Make indent. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6643 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/include/surf/maxmin.h | 2 - src/surf/cpu_im.c | 94 ++++++++++++++++----------------------- src/surf/maxmin.c | 21 +-------- src/surf/maxmin_private.h | 3 -- 4 files changed, 41 insertions(+), 79 deletions(-) diff --git a/src/include/surf/maxmin.h b/src/include/surf/maxmin.h index fe7f3c5178..c8580a0325 100644 --- a/src/include/surf/maxmin.h +++ b/src/include/surf/maxmin.h @@ -86,8 +86,6 @@ XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys, XBT_PUBLIC(void) lmm_solve(lmm_system_t sys); -XBT_PUBLIC(void *) lmm_extract_modified_variable(lmm_system_t sys); - XBT_PUBLIC(void) lagrange_solve(lmm_system_t sys); XBT_PUBLIC(void) bottleneck_solve(lmm_system_t sys); diff --git a/src/surf/cpu_im.c b/src/surf/cpu_im.c index 730d969618..0a65e33600 100644 --- a/src/surf/cpu_im.c +++ b/src/surf/cpu_im.c @@ -221,46 +221,47 @@ static double share_resources(double now) double value; cpu_Cas01_im_t cpu, cpu_next; - xbt_swag_foreach_safe(cpu, cpu_next, modified_cpu) { + xbt_swag_foreach(cpu, modified_cpu) cpu_update_remains(cpu, now); - xbt_swag_remove(cpu, modified_cpu); - } lmm_solve(cpu_im_maxmin_system); - while ((action = lmm_extract_modified_variable(cpu_im_maxmin_system))) { - min = -1; - value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable); - if (value > 0) { - if (GENERIC_ACTION(action).remains > 0) - value = GENERIC_ACTION(action).remains / value; - else - value = 0.0; - } - if (value > 0) - min = now + value; - - if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) - && (min == -1 - || GENERIC_ACTION(action).start + - GENERIC_ACTION(action).max_duration < min)) - min = - GENERIC_ACTION(action).start + GENERIC_ACTION(action).max_duration; - - DEBUG4("Action(%p) Start %lf Finish %lf Max_duration %lf", action, - GENERIC_ACTION(action).start, now + value, - GENERIC_ACTION(action).max_duration); - - if (action->index_heap >= 0) { - surf_action_cpu_Cas01_im_t heap_act = - xbt_heap_remove(action_heap, action->index_heap); - if (heap_act != action) - DIE_IMPOSSIBLE; - } - if (min != -1) { - xbt_heap_push(action_heap, action, min); - DEBUG2("Insert at heap action(%p) min %lf", action, min); + xbt_swag_foreach_safe(cpu, cpu_next, modified_cpu) { + xbt_swag_foreach(action, cpu->action_set) { + min = -1; + value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable); + if (value > 0) { + if (GENERIC_ACTION(action).remains > 0) + value = GENERIC_ACTION(action).remains / value; + else + value = 0.0; + } + if (value > 0) + min = now + value; + + if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) + && (min == -1 + || GENERIC_ACTION(action).start + + GENERIC_ACTION(action).max_duration < min)) + min = + GENERIC_ACTION(action).start + GENERIC_ACTION(action).max_duration; + + DEBUG4("Action(%p) Start %lf Finish %lf Max_duration %lf", action, + GENERIC_ACTION(action).start, now + value, + GENERIC_ACTION(action).max_duration); + + if (action->index_heap >= 0) { + surf_action_cpu_Cas01_im_t heap_act = + xbt_heap_remove(action_heap, action->index_heap); + if (heap_act != action) + DIE_IMPOSSIBLE; + } + if (min != -1) { + xbt_heap_push(action_heap, action, min); + DEBUG2("Insert at heap action(%p) min %lf", action, min); + } } + xbt_swag_remove(cpu, modified_cpu); } return xbt_heap_size(action_heap) > 0 ? xbt_heap_maxkey(action_heap) - now : -1; @@ -412,29 +413,11 @@ static int action_is_suspended(surf_action_t action) static void action_set_max_duration(surf_action_t action, double duration) { - surf_action_cpu_Cas01_im_t ACT = (surf_action_cpu_Cas01_im_t) action; - double min_finish; - XBT_IN2("(%p,%g)", action, duration); action->max_duration = duration; - - if (duration >= 0) - min_finish = - (action->start + action->max_duration) < - action->finish ? (action->start + - action->max_duration) : action->finish; - else - min_finish = action->finish; - - /* add in action heap */ - if (ACT->index_heap >= 0) { - surf_action_cpu_Cas01_im_t heap_act = - xbt_heap_remove(action_heap, ACT->index_heap); - if (heap_act != ACT) - DIE_IMPOSSIBLE; - } - xbt_heap_push(action_heap, ACT, min_finish); + /* insert cpu in modified_cpu set to notice the max duration change */ + xbt_swag_insert(ACTION_GET_CPU(action), modified_cpu); XBT_OUT; } @@ -453,6 +436,7 @@ static void action_set_priority(surf_action_t action, double priority) static double action_get_remains(surf_action_t action) { XBT_IN1("(%p)", action); + /* update remains before return it */ cpu_update_remains(ACTION_GET_CPU(action), surf_get_clock()); return action->remains; XBT_OUT; diff --git a/src/surf/maxmin.c b/src/surf/maxmin.c index 37d53c716c..8b63e08a42 100644 --- a/src/surf/maxmin.c +++ b/src/surf/maxmin.c @@ -53,9 +53,6 @@ lmm_system_t lmm_system_new(void) xbt_swag_init(&(l->saturated_constraint_set), xbt_swag_offset(cnst, saturated_constraint_set_hookup)); - xbt_swag_init(&(l->modified_variable_set), - xbt_swag_offset(var, modified_variable_set_hookup)); - l->variable_mallocator = xbt_mallocator_new(64, lmm_variable_mallocator_new_f, lmm_variable_mallocator_free_f, @@ -494,11 +491,8 @@ void lmm_solve(lmm_system_t sys) //DEBUG1("Variable set : %d", xbt_swag_size(elem_list)); xbt_swag_foreach(elem, elem_list) { var = elem->variable; - xbt_swag_insert(var, &(sys->modified_variable_set)); - /* FIXME: modified this test because we need all actions in cpu_im */ if (var->weight <= 0.0) - //break; - continue; + break; var->value = 0.0; } } @@ -572,7 +566,6 @@ void lmm_solve(lmm_system_t sys) while ((var = xbt_swag_getFirst(var_list))) { int i; - xbt_swag_insert(var, &(sys->modified_variable_set)); if (min_bound < 0) { var->value = min_usage / var->weight; @@ -619,8 +612,7 @@ void lmm_solve(lmm_system_t sys) /* Find out which variables reach the maximum */ cnst_list = - sys->selective_update_active ? &(sys-> - modified_constraint_set) : + sys->selective_update_active ? &(sys->modified_constraint_set) : &(sys->active_constraint_set); min_usage = -1; min_bound = -1; @@ -801,12 +793,3 @@ static void lmm_remove_all_modified_set(lmm_system_t sys) xbt_swag_remove(elem, elem_list); } } - -void *lmm_extract_modified_variable(lmm_system_t sys) -{ - lmm_variable_t var; - var = xbt_swag_extract(&(sys->modified_variable_set)); - if (var) - return var->id; - return NULL; -} diff --git a/src/surf/maxmin_private.h b/src/surf/maxmin_private.h index e492e6eae8..07428e1494 100644 --- a/src/surf/maxmin_private.h +++ b/src/surf/maxmin_private.h @@ -47,7 +47,6 @@ typedef struct lmm_variable { /* hookup to system */ s_xbt_swag_hookup_t variable_set_hookup; s_xbt_swag_hookup_t saturated_variable_set_hookup; - s_xbt_swag_hookup_t modified_variable_set_hookup; s_lmm_element_t *cnsts; int cnsts_size; @@ -79,8 +78,6 @@ typedef struct lmm_system { s_xbt_swag_t saturated_variable_set; /* a list of lmm_variable_t */ s_xbt_swag_t saturated_constraint_set; /* a list of lmm_constraint_t_t */ - s_xbt_swag_t modified_variable_set; /* list of modified variables used in new model CpuIM */ - xbt_mallocator_t variable_mallocator; } s_lmm_system_t; -- 2.20.1