A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Start using optimization mode flag in network.
[simgrid.git]
/
src
/
surf
/
maxmin.c
diff --git
a/src/surf/maxmin.c
b/src/surf/maxmin.c
index
ce9d3ad
..
0a00e66
100644
(file)
--- a/
src/surf/maxmin.c
+++ b/
src/surf/maxmin.c
@@
-1,6
+1,5
@@
-/* $Id$ */
-
-/* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */
+/* Copyright (c) 2004-2011. The SimGrid Team.
+ * All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
@@
-16,14
+15,19
@@
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf,
"Logging specific to SURF (maxmin)");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf,
"Logging specific to SURF (maxmin)");
+double sg_maxmin_precision = 0.00001;
+
static void *lmm_variable_mallocator_new_f(void);
static void lmm_variable_mallocator_free_f(void *var);
static void *lmm_variable_mallocator_new_f(void);
static void lmm_variable_mallocator_free_f(void *var);
-static void lmm_variable_mallocator_reset_f(void *var);
-static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst);
+#define lmm_variable_mallocator_reset_f ((void_f_pvoid_t)NULL)
+static void lmm_update_modified_set(lmm_system_t sys,
+ lmm_constraint_t cnst);
static void lmm_remove_all_modified_set(lmm_system_t sys);
static void lmm_remove_all_modified_set(lmm_system_t sys);
-int sg_maxmin_selective_update =
0
;
+int sg_maxmin_selective_update =
1
;
static int Global_debug_id = 1;
static int Global_const_debug_id = 1;
static int Global_debug_id = 1;
static int Global_const_debug_id = 1;
+extern xbt_swag_t keep_track;
+
lmm_system_t lmm_system_new(void)
{
lmm_system_t l = NULL;
lmm_system_t lmm_system_new(void)
{
lmm_system_t l = NULL;
@@
-35,7
+39,7
@@
lmm_system_t lmm_system_new(void)
l->modified = 0;
l->selective_update_active = sg_maxmin_selective_update;
l->modified = 0;
l->selective_update_active = sg_maxmin_selective_update;
-
DEBUG1
("Setting selective_update_active flag to %d\n",
+
XBT_DEBUG
("Setting selective_update_active flag to %d\n",
l->selective_update_active);
xbt_swag_init(&(l->variable_set),
l->selective_update_active);
xbt_swag_init(&(l->variable_set),
@@
-53,7
+57,7
@@
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->saturated_constraint_set),
xbt_swag_offset(cnst, saturated_constraint_set_hookup));
- l->variable_mallocator = xbt_mallocator_new(6
4
,
+ l->variable_mallocator = xbt_mallocator_new(6
5536
,
lmm_variable_mallocator_new_f,
lmm_variable_mallocator_free_f,
lmm_variable_mallocator_reset_f);
lmm_variable_mallocator_new_f,
lmm_variable_mallocator_free_f,
lmm_variable_mallocator_reset_f);
@@
-66,8
+70,12
@@
void lmm_system_free(lmm_system_t sys)
lmm_variable_t var = NULL;
lmm_constraint_t cnst = NULL;
lmm_variable_t var = NULL;
lmm_constraint_t cnst = NULL;
- while ((var = extract_variable(sys)))
+ while ((var = extract_variable(sys))) {
+ XBT_WARN
+ ("Variable %p (%d) still in LMM system when freing it: this may be a bug",
+ var, var->id_int);
lmm_var_free(sys, var);
lmm_var_free(sys, var);
+ }
while ((cnst = extract_constraint(sys)))
lmm_cnst_free(sys, cnst);
while ((cnst = extract_constraint(sys)))
lmm_cnst_free(sys, cnst);
@@
-76,12
+84,12
@@
void lmm_system_free(lmm_system_t sys)
free(sys);
}
free(sys);
}
-void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var)
+
XBT_INLINE
void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var)
{
int i;
lmm_element_t elem = NULL;
{
int i;
lmm_element_t elem = NULL;
- XBT_IN
2
("(sys=%p, var=%p)", sys, var);
+ XBT_IN("(sys=%p, var=%p)", sys, var);
sys->modified = 1;
for (i = 0; i < var->cnsts_number; i++) {
sys->modified = 1;
for (i = 0; i < var->cnsts_number; i++) {
@@
-94,22
+102,22
@@
void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var)
lmm_update_modified_set(sys, elem->constraint);
}
var->cnsts_number = 0;
lmm_update_modified_set(sys, elem->constraint);
}
var->cnsts_number = 0;
- XBT_OUT;
+ XBT_OUT
()
;
}
static void lmm_var_free(lmm_system_t sys, lmm_variable_t var)
{
lmm_variable_disable(sys, var);
}
static void lmm_var_free(lmm_system_t sys, lmm_variable_t var)
{
lmm_variable_disable(sys, var);
- free(var->cnsts);
xbt_mallocator_release(sys->variable_mallocator, var);
}
xbt_mallocator_release(sys->variable_mallocator, var);
}
-static void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst)
+static XBT_INLINE void lmm_cnst_free(lmm_system_t sys,
+ lmm_constraint_t cnst)
{
{
-/* xbt_assert
0
(xbt_swag_size(&(cnst->element_set)), */
+/* xbt_assert(xbt_swag_size(&(cnst->element_set)), */
/* "This list should be empty!"); */
/* "This list should be empty!"); */
-
remove_active_constraint
(sys, cnst);
+
make_constraint_inactive
(sys, cnst);
free(cnst);
}
free(cnst);
}
@@
-135,17
+143,18
@@
lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id,
return cnst;
}
return cnst;
}
-void lmm_constraint_shared(lmm_constraint_t cnst)
+
XBT_INLINE
void lmm_constraint_shared(lmm_constraint_t cnst)
{
cnst->shared = 0;
}
{
cnst->shared = 0;
}
-int lmm_constraint_is_shared(lmm_constraint_t cnst)
+
XBT_INLINE
int lmm_constraint_is_shared(lmm_constraint_t cnst)
{
return (cnst->shared);
}
{
return (cnst->shared);
}
-void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst)
+XBT_INLINE void lmm_constraint_free(lmm_system_t sys,
+ lmm_constraint_t cnst)
{
remove_constraint(sys, cnst);
lmm_cnst_free(sys, cnst);
{
remove_constraint(sys, cnst);
lmm_cnst_free(sys, cnst);
@@
-153,20
+162,17
@@
void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst)
static void *lmm_variable_mallocator_new_f(void)
{
static void *lmm_variable_mallocator_new_f(void)
{
- return xbt_new(s_lmm_variable_t, 1);
+ lmm_variable_t var = xbt_new(s_lmm_variable_t, 1);
+ var->cnsts = NULL; /* will be created by realloc */
+ return var;
}
static void lmm_variable_mallocator_free_f(void *var)
{
}
static void lmm_variable_mallocator_free_f(void *var)
{
+ xbt_free(((lmm_variable_t) var)->cnsts);
xbt_free(var);
}
xbt_free(var);
}
-static void lmm_variable_mallocator_reset_f(void *var)
-{
- /* memset to zero like calloc */
- memset(var, 0, sizeof(s_lmm_variable_t));
-}
-
lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id,
double weight,
double bound, int number_of_constraints)
lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id,
double weight,
double bound, int number_of_constraints)
@@
-174,16
+180,14
@@
lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id,
lmm_variable_t var = NULL;
int i;
lmm_variable_t var = NULL;
int i;
- XBT_IN
5
("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)",
+ XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)",
sys, id, weight, bound, number_of_constraints);
var = xbt_mallocator_get(sys->variable_mallocator);
var->id = id;
var->id_int = Global_debug_id++;
sys, id, weight, bound, number_of_constraints);
var = xbt_mallocator_get(sys->variable_mallocator);
var->id = id;
var->id_int = Global_debug_id++;
- var->cnsts = xbt_
new0(s_lmm_element_t, number_of_constraints
);
+ var->cnsts = xbt_
realloc(var->cnsts, number_of_constraints * sizeof(s_lmm_element_t)
);
for (i = 0; i < number_of_constraints; i++) {
for (i = 0; i < number_of_constraints; i++) {
- /* Should be useless because of the
- calloc but it seems to help valgrind... */
var->cnsts[i].element_set_hookup.next = NULL;
var->cnsts[i].element_set_hookup.prev = NULL;
var->cnsts[i].active_element_set_hookup.next = NULL;
var->cnsts[i].element_set_hookup.next = NULL;
var->cnsts[i].element_set_hookup.prev = NULL;
var->cnsts[i].active_element_set_hookup.next = NULL;
@@
-193,22
+197,27
@@
lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id,
var->cnsts[i].value = 0.0;
}
var->cnsts_size = number_of_constraints;
var->cnsts[i].value = 0.0;
}
var->cnsts_size = number_of_constraints;
- var->cnsts_number = 0; /* Should be useless because of the
- calloc but it seems to help valgrind... */
+ var->cnsts_number = 0;
var->weight = weight;
var->bound = bound;
var->value = 0.0;
var->weight = weight;
var->bound = bound;
var->value = 0.0;
-
+ var->mu = 0.0;
+ var->new_mu = 0.0;
var->func_f = func_f_def;
var->func_fp = func_fp_def;
var->func_fpi = func_fpi_def;
var->func_f = func_f_def;
var->func_fp = func_fp_def;
var->func_fpi = func_fpi_def;
+ var->variable_set_hookup.next = NULL;
+ var->variable_set_hookup.prev = NULL;
+ var->saturated_variable_set_hookup.next = NULL;
+ var->saturated_variable_set_hookup.prev = NULL;
+
if (weight)
xbt_swag_insert_at_head(var, &(sys->variable_set));
else
xbt_swag_insert_at_tail(var, &(sys->variable_set));
if (weight)
xbt_swag_insert_at_head(var, &(sys->variable_set));
else
xbt_swag_insert_at_tail(var, &(sys->variable_set));
- XBT_OUT;
+ XBT_OUT
()
;
return var;
}
return var;
}
@@
-218,12
+227,12
@@
void lmm_variable_free(lmm_system_t sys, lmm_variable_t var)
lmm_var_free(sys, var);
}
lmm_var_free(sys, var);
}
-double lmm_variable_getvalue(lmm_variable_t var)
+
XBT_INLINE
double lmm_variable_getvalue(lmm_variable_t var)
{
return (var->value);
}
{
return (var->value);
}
-double lmm_variable_getbound(lmm_variable_t var)
+
XBT_INLINE
double lmm_variable_getbound(lmm_variable_t var)
{
return (var->bound);
}
{
return (var->bound);
}
@@
-235,7
+244,7
@@
void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
sys->modified = 1;
sys->modified = 1;
- xbt_assert
0
(var->cnsts_number < var->cnsts_size, "Too much constraints");
+ xbt_assert(var->cnsts_number < var->cnsts_size, "Too much constraints");
elem = &(var->cnsts[var->cnsts_number++]);
elem = &(var->cnsts[var->cnsts_number++]);
@@
-289,8
+298,9
@@
void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
DIE_IMPOSSIBLE;
}
DIE_IMPOSSIBLE;
}
-lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
- lmm_variable_t var, int num)
+XBT_INLINE lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
+ lmm_variable_t var,
+ int num)
{
if (num < var->cnsts_number)
return (var->cnsts[num].constraint);
{
if (num < var->cnsts_number)
return (var->cnsts[num].constraint);
@@
-298,7
+308,8
@@
lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
return NULL;
}
return NULL;
}
-int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var)
+XBT_INLINE int lmm_get_number_of_cnst_from_var(lmm_system_t sys,
+ lmm_variable_t var)
{
return (var->cnsts_number);
}
{
return (var->cnsts_number);
}
@@
-317,34
+328,35
@@
lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
return NULL;
}
return NULL;
}
-void *lmm_constraint_id(lmm_constraint_t cnst)
+
XBT_INLINE
void *lmm_constraint_id(lmm_constraint_t cnst)
{
return cnst->id;
}
{
return cnst->id;
}
-void *lmm_variable_id(lmm_variable_t var)
+
XBT_INLINE
void *lmm_variable_id(lmm_variable_t var)
{
return var->id;
}
{
return var->id;
}
-static void saturated_constraint_set_update(lmm_system_t sys,
- lmm_constraint_t cnst,
- double *min_usage)
+static XBT_INLINE void saturated_constraint_set_update(lmm_system_t sys,
+ lmm_constraint_t
+ cnst,
+ double *min_usage)
{
lmm_constraint_t useless_cnst = NULL;
{
lmm_constraint_t useless_cnst = NULL;
- XBT_IN
3
("sys=%p, cnst=%p, min_usage=%f", sys, cnst, *min_usage);
+ XBT_IN("sys=%p, cnst=%p, min_usage=%f", sys, cnst, *min_usage);
if (cnst->usage <= 0) {
if (cnst->usage <= 0) {
- XBT_OUT;
+ XBT_OUT
()
;
return;
}
if (cnst->remaining <= 0) {
return;
}
if (cnst->remaining <= 0) {
- XBT_OUT;
+ XBT_OUT
()
;
return;
}
if ((*min_usage < 0) || (*min_usage > cnst->remaining / cnst->usage)) {
*min_usage = cnst->remaining / cnst->usage;
return;
}
if ((*min_usage < 0) || (*min_usage > cnst->remaining / cnst->usage)) {
*min_usage = cnst->remaining / cnst->usage;
-
LOG3
(xbt_log_priority_trace,
+
XBT_LOG
(xbt_log_priority_trace,
"min_usage=%f (cnst->remaining=%f, cnst->usage=%f)", *min_usage,
cnst->remaining, cnst->usage);
while ((useless_cnst =
"min_usage=%f (cnst->remaining=%f, cnst->usage=%f)", *min_usage,
cnst->remaining, cnst->usage);
while ((useless_cnst =
@@
-355,10
+367,10
@@
static void saturated_constraint_set_update(lmm_system_t sys,
} else if (*min_usage == cnst->remaining / cnst->usage) {
xbt_swag_insert(cnst, &(sys->saturated_constraint_set));
}
} else if (*min_usage == cnst->remaining / cnst->usage) {
xbt_swag_insert(cnst, &(sys->saturated_constraint_set));
}
- XBT_OUT;
+ XBT_OUT
()
;
}
}
-static void saturated_variable_set_update(lmm_system_t sys)
+static
XBT_INLINE
void saturated_variable_set_update(lmm_system_t sys)
{
lmm_constraint_t cnst = NULL;
xbt_swag_t cnst_list = NULL;
{
lmm_constraint_t cnst = NULL;
xbt_swag_t cnst_list = NULL;
@@
-394,23
+406,22
@@
void lmm_print(lmm_system_t sys)
var_list = &(sys->variable_set);
sprintf(print_buf, "MAX-MIN ( ");
trace_buf =
var_list = &(sys->variable_set);
sprintf(print_buf, "MAX-MIN ( ");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+
xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
xbt_swag_foreach(var, var_list) {
sprintf(print_buf, "'%d'(%f) ", var->id_int, var->weight);
trace_buf =
strcat(trace_buf, print_buf);
xbt_swag_foreach(var, var_list) {
sprintf(print_buf, "'%d'(%f) ", var->id_int, var->weight);
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+
xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
}
sprintf(print_buf, ")");
trace_buf =
strcat(trace_buf, print_buf);
}
sprintf(print_buf, ")");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+
xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
strcat(trace_buf, print_buf);
- fprintf(stderr, "%s", trace_buf);
- //DEBUG1("%20s", trace_buf); FIXME
+ XBT_DEBUG("%20s", trace_buf);
trace_buf[0] = '\000';
trace_buf[0] = '\000';
-
DEBUG0
("Constraints");
+
XBT_DEBUG
("Constraints");
/* Printing Constraints */
cnst_list = &(sys->active_constraint_set);
xbt_swag_foreach(cnst, cnst_list) {
/* Printing Constraints */
cnst_list = &(sys->active_constraint_set);
xbt_swag_foreach(cnst, cnst_list) {
@@
-418,46
+429,55
@@
void lmm_print(lmm_system_t sys)
elem_list = &(cnst->element_set);
sprintf(print_buf, "\t");
trace_buf =
elem_list = &(cnst->element_set);
sprintf(print_buf, "\t");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+
xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
strcat(trace_buf, print_buf);
+ sprintf(print_buf, "%s(",(cnst->shared)?"":"max");
+ trace_buf =
+ xbt_realloc(trace_buf,
+ strlen(trace_buf) + strlen(print_buf) + 1);
+ strcat(trace_buf, print_buf);
xbt_swag_foreach(elem, elem_list) {
xbt_swag_foreach(elem, elem_list) {
- sprintf(print_buf, "%f.'%d'(%f)
+
", elem->value,
- elem->variable->id_int, elem->variable->value);
+ sprintf(print_buf, "%f.'%d'(%f)
%s
", elem->value,
+ elem->variable->id_int, elem->variable->value
,(cnst->shared)?"+":","
);
trace_buf =
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf,
+ strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
strcat(trace_buf, print_buf);
- sum += elem->value * elem->variable->value;
+ if(cnst->shared)
+ sum += elem->value * elem->variable->value;
+ else
+ sum = MAX(sum,elem->value * elem->variable->value);
}
}
- sprintf(print_buf, "0 <= %f ('%d')", cnst->bound, cnst->id_int);
+ sprintf(print_buf, "0
)
<= %f ('%d')", cnst->bound, cnst->id_int);
trace_buf =
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+
xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
if (!cnst->shared) {
sprintf(print_buf, " [MAX-Constraint]");
trace_buf =
strcat(trace_buf, print_buf);
if (!cnst->shared) {
sprintf(print_buf, " [MAX-Constraint]");
trace_buf =
- xbt_realloc(trace_buf, strlen(trace_buf) + strlen(print_buf) + 1);
+ xbt_realloc(trace_buf,
+ strlen(trace_buf) + strlen(print_buf) + 1);
strcat(trace_buf, print_buf);
}
strcat(trace_buf, print_buf);
}
- // DEBUG1("%s", trace_buf);
- fprintf(stderr, "%s", trace_buf);
+ XBT_DEBUG("%s", trace_buf);
trace_buf[0] = '\000';
trace_buf[0] = '\000';
- xbt_assert
3
(!double_positive(sum - cnst->bound),
+ xbt_assert(!double_positive(sum - cnst->bound),
"Incorrect value (%f is not smaller than %f): %g",
sum, cnst->bound, sum - cnst->bound);
}
"Incorrect value (%f is not smaller than %f): %g",
sum, cnst->bound, sum - cnst->bound);
}
-
DEBUG0
("Variables");
+
XBT_DEBUG
("Variables");
/* Printing Result */
xbt_swag_foreach(var, var_list) {
if (var->bound > 0) {
/* Printing Result */
xbt_swag_foreach(var, var_list) {
if (var->bound > 0) {
-
DEBUG4
("'%d'(%f) : %f (<=%f)", var->id_int, var->weight, var->value,
+
XBT_DEBUG
("'%d'(%f) : %f (<=%f)", var->id_int, var->weight, var->value,
var->bound);
var->bound);
- xbt_assert
2
(!double_positive(var->value - var->bound),
+ xbt_assert(!double_positive(var->value - var->bound),
"Incorrect value (%f is not smaller than %f",
var->value, var->bound);
} else {
"Incorrect value (%f is not smaller than %f",
var->value, var->bound);
} else {
-
DEBUG3
("'%d'(%f) : %f", var->id_int, var->weight, var->value);
+
XBT_DEBUG
("'%d'(%f) : %f", var->id_int, var->weight, var->value);
}
}
}
}
@@
-478,17
+498,21
@@
void lmm_solve(lmm_system_t sys)
if (!(sys->modified))
return;
if (!(sys->modified))
return;
+ XBT_IN("(sys=%p)", sys);
+
/*
* Compute Usage and store the variables that reach the maximum.
*/
/*
* Compute Usage and store the variables that reach the maximum.
*/
- cnst_list = sys->selective_update_active ? &(sys->modified_constraint_set) :
- &(sys->active_constraint_set);
+ cnst_list =
+ sys->
+ selective_update_active ? &(sys->modified_constraint_set) :
+ &(sys->active_constraint_set);
-
DEBUG1
("Active constraints : %d", xbt_swag_size(cnst_list));
+
XBT_DEBUG
("Active constraints : %d", xbt_swag_size(cnst_list));
/* Init: Only modified code portions */
xbt_swag_foreach(cnst, cnst_list) {
elem_list = &(cnst->element_set);
/* Init: Only modified code portions */
xbt_swag_foreach(cnst, cnst_list) {
elem_list = &(cnst->element_set);
- //
DEBUG1
("Variable set : %d", xbt_swag_size(elem_list));
+ //
XBT_DEBUG
("Variable set : %d", xbt_swag_size(elem_list));
xbt_swag_foreach(elem, elem_list) {
var = elem->variable;
if (var->weight <= 0.0)
xbt_swag_foreach(elem, elem_list) {
var = elem->variable;
if (var->weight <= 0.0)
@@
-497,10
+521,11
@@
void lmm_solve(lmm_system_t sys)
}
}
}
}
- DEBUG1("Active constraints : %d", xbt_swag_size(cnst_list));
xbt_swag_foreach(cnst, cnst_list) {
/* INIT */
cnst->remaining = cnst->bound;
xbt_swag_foreach(cnst, cnst_list) {
/* INIT */
cnst->remaining = cnst->bound;
+ if (cnst->remaining == 0)
+ continue;
cnst->usage = 0;
elem_list = &(cnst->element_set);
xbt_swag_foreach(elem, elem_list) {
cnst->usage = 0;
elem_list = &(cnst->element_set);
xbt_swag_foreach(elem, elem_list) {
@@
-514,9
+539,12
@@
void lmm_solve(lmm_system_t sys)
cnst->usage = elem->value / elem->variable->weight;
make_elem_active(elem);
cnst->usage = elem->value / elem->variable->weight;
make_elem_active(elem);
+ if(keep_track){
+ xbt_swag_insert((elem->variable)->id, keep_track);
+ }
}
}
}
}
-
DEBUG2("Constraint Usage %d
: %f", cnst->id_int, cnst->usage);
+
XBT_DEBUG("Constraint Usage '%d'
: %f", cnst->id_int, cnst->usage);
/* Saturated constraints update */
saturated_constraint_set_update(sys, cnst, &min_usage);
}
/* Saturated constraints update */
saturated_constraint_set_update(sys, cnst, &min_usage);
}
@@
-533,16
+561,16
@@
void lmm_solve(lmm_system_t sys)
DIE_IMPOSSIBLE;
/* First check if some of these variables have reach their upper
bound and update min_usage accordingly. */
DIE_IMPOSSIBLE;
/* First check if some of these variables have reach their upper
bound and update min_usage accordingly. */
- DEBUG5
- ("var=%d, var->bound=%f, var->weight=%f, min_usage=%f, var->bound*var->weight=%f",
- var->id_int, var->bound, var->weight, min_usage,
- var->bound * var->weight);
+ XBT_DEBUG
+
("var=%d, var->bound=%f, var->weight=%f, min_usage=%f, var->bound*var->weight=%f",
+
var->id_int, var->bound, var->weight, min_usage,
+
var->bound * var->weight);
if ((var->bound > 0) && (var->bound * var->weight < min_usage)) {
if (min_bound < 0)
min_bound = var->bound;
else
min_bound = MIN(min_bound, var->bound);
if ((var->bound > 0) && (var->bound * var->weight < min_usage)) {
if (min_bound < 0)
min_bound = var->bound;
else
min_bound = MIN(min_bound, var->bound);
-
DEBUG1
("Updated min_bound=%f", min_bound);
+
XBT_DEBUG
("Updated min_bound=%f", min_bound);
}
}
}
}
@@
-560,7
+588,7
@@
void lmm_solve(lmm_system_t sys)
continue;
}
}
continue;
}
}
-
DEBUG5
("Min usage: %f, Var(%d)->weight: %f, Var(%d)->value: %f ",
+
XBT_DEBUG
("Min usage: %f, Var(%d)->weight: %f, Var(%d)->value: %f ",
min_usage, var->id_int, var->weight, var->id_int, var->value);
min_usage, var->id_int, var->weight, var->id_int, var->value);
@@
-576,15
+604,17
@@
void lmm_solve(lmm_system_t sys)
} else { /* FIXME one day: We recompute usage.... :( */
cnst->usage = 0.0;
make_elem_inactive(elem);
} else { /* FIXME one day: We recompute usage.... :( */
cnst->usage = 0.0;
make_elem_inactive(elem);
+ elem_list = &(cnst->element_set);
xbt_swag_foreach(elem, elem_list) {
if (elem->variable->weight <= 0)
break;
if (elem->variable->value > 0)
break;
if ((elem->value > 0)) {
xbt_swag_foreach(elem, elem_list) {
if (elem->variable->weight <= 0)
break;
if (elem->variable->value > 0)
break;
if ((elem->value > 0)) {
- if (cnst->usage < elem->value / elem->variable->weight)
- cnst->usage = elem->value / elem->variable->weight;
- DEBUG2("Constraint Usage %d : %f", cnst->id_int, cnst->usage);
+ cnst->usage =
+ MAX(cnst->usage, elem->value / elem->variable->weight);
+ XBT_DEBUG("Constraint Usage %d : %f", cnst->id_int,
+ cnst->usage);
make_elem_active(elem);
}
}
make_elem_active(elem);
}
}
@@
-594,9
+624,6
@@
void lmm_solve(lmm_system_t sys)
}
/* Find out which variables reach the maximum */
}
/* Find out which variables reach the maximum */
- cnst_list =
- sys->selective_update_active ? &(sys->modified_constraint_set) :
- &(sys->active_constraint_set);
min_usage = -1;
min_bound = -1;
xbt_swag_foreach(cnst, cnst_list) {
min_usage = -1;
min_bound = -1;
xbt_swag_foreach(cnst, cnst_list) {
@@
-613,6
+640,7
@@
void lmm_solve(lmm_system_t sys)
if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
lmm_print(sys);
}
if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
lmm_print(sys);
}
+ XBT_OUT();
}
/* Not a O(1) function */
}
/* Not a O(1) function */
@@
-665,7
+693,7
@@
void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
if (weight == var->weight)
return;
if (weight == var->weight)
return;
- XBT_IN
3
("(sys=%p, var=%p, weight=%f)", sys, var, weight);
+ XBT_IN("(sys=%p, var=%p, weight=%f)", sys, var, weight);
sys->modified = 1;
var->weight = weight;
xbt_swag_remove(var, &(sys->variable_set));
sys->modified = 1;
var->weight = weight;
xbt_swag_remove(var, &(sys->variable_set));
@@
-687,38
+715,50
@@
void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
if (!weight)
var->value = 0.0;
if (!weight)
var->value = 0.0;
- XBT_OUT;
+ XBT_OUT
()
;
}
}
-double lmm_get_variable_weight(lmm_variable_t var)
+
XBT_INLINE
double lmm_get_variable_weight(lmm_variable_t var)
{
return var->weight;
}
{
return var->weight;
}
-void lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst,
- double bound)
+XBT_INLINE void lmm_update_constraint_bound(lmm_system_t sys,
+ lmm_constraint_t cnst,
+ double bound)
{
sys->modified = 1;
lmm_update_modified_set(sys, cnst);
cnst->bound = bound;
}
{
sys->modified = 1;
lmm_update_modified_set(sys, cnst);
cnst->bound = bound;
}
-int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst)
+
XBT_INLINE
int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst)
{
return xbt_swag_belongs(cnst, &(sys->active_constraint_set));
}
{
return xbt_swag_belongs(cnst, &(sys->active_constraint_set));
}
-lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys)
+XBT_INLINE lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t
+ sys)
{
return xbt_swag_getFirst(&(sys->active_constraint_set));
}
{
return xbt_swag_getFirst(&(sys->active_constraint_set));
}
-lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys,
- lmm_constraint_t cnst)
+XBT_INLINE lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t
+ sys,
+ lmm_constraint_t
+ cnst)
{
return xbt_swag_getNext(cnst, (sys->active_constraint_set).offset);
}
{
return xbt_swag_getNext(cnst, (sys->active_constraint_set).offset);
}
+#ifdef HAVE_LATENCY_BOUND_TRACKING
+XBT_INLINE int lmm_is_variable_limited_by_latency(lmm_variable_t var)
+{
+ return (double_equals(var->bound, var->value));
+}
+#endif
+
+
/** \brief Update the constraint set propagating recursively to
* other constraints so the system should not be entirely computed.
*
/** \brief Update the constraint set propagating recursively to
* other constraints so the system should not be entirely computed.
*
@@
-729,7
+769,8
@@
lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys,
* constraints that have changed. Each constraint change is propagated
* to the list of constraints for each variable.
*/
* constraints that have changed. Each constraint change is propagated
* to the list of constraints for each variable.
*/
-static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
+static void lmm_update_modified_set(lmm_system_t sys,
+ lmm_constraint_t cnst)
{
lmm_element_t elem = NULL;
lmm_variable_t var = NULL;
{
lmm_element_t elem = NULL;
lmm_variable_t var = NULL;
@@
-740,12
+781,12
@@
static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
if (!sys->selective_update_active)
return;
if (!sys->selective_update_active)
return;
- //
DEBUG1
("Updating modified constraint set with constraint %d", cnst->id_int);
+ //
XBT_DEBUG
("Updating modified constraint set with constraint %d", cnst->id_int);
if (xbt_swag_belongs(cnst, &(sys->modified_constraint_set)))
return;
if (xbt_swag_belongs(cnst, &(sys->modified_constraint_set)))
return;
- //
DEBUG1
("Inserting into modified constraint set %d", cnst->id_int);
+ //
XBT_DEBUG
("Inserting into modified constraint set %d", cnst->id_int);
/* add to modified set */
xbt_swag_insert(cnst, &(sys->modified_constraint_set));
/* add to modified set */
xbt_swag_insert(cnst, &(sys->modified_constraint_set));
@@
-755,7
+796,7
@@
static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
var = elem->variable;
for (i = 0; i < var->cnsts_number; i++)
if (cnst != var->cnsts[i].constraint) {
var = elem->variable;
for (i = 0; i < var->cnsts_number; i++)
if (cnst != var->cnsts[i].constraint) {
- //
DEBUG2
("Updating modified %d calling for %d", cnst->id_int, var->cnsts[i].constraint->id_int);
+ //
XBT_DEBUG
("Updating modified %d calling for %d", cnst->id_int, var->cnsts[i].constraint->id_int);
lmm_update_modified_set(sys, var->cnsts[i].constraint);
}
}
lmm_update_modified_set(sys, var->cnsts[i].constraint);
}
}
@@
-767,12
+808,5
@@
static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
*/
static void lmm_remove_all_modified_set(lmm_system_t sys)
{
*/
static void lmm_remove_all_modified_set(lmm_system_t sys)
{
- lmm_element_t elem = NULL;
- lmm_element_t elem_next = NULL;
- xbt_swag_t elem_list = NULL;
-
- elem_list = &(sys->modified_constraint_set);
- xbt_swag_foreach_safe(elem, elem_next, elem_list) {
- xbt_swag_remove(elem, elem_list);
- }
+ xbt_swag_reset(&sys->modified_constraint_set);
}
}