From: Martin Quinson Date: Thu, 1 Sep 2016 15:43:15 +0000 (+0200) Subject: redemption of a LMM function used by the energy plugin X-Git-Tag: v3_14~454^2~4 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/73d1f79133c1e0e086ce5e2414aa04d180cba08a?hp=2137ac0e87390b19e5799794777a8a173039afa4 redemption of a LMM function used by the energy plugin --- diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index 6645a0d206..40e186f60d 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -1220,25 +1220,28 @@ static void lmm_remove_all_modified_set(lmm_system_t sys) } /** - * Returns total resource load + * Returns resource load (in flop per second, or byte per second, or similar) * - * \param cnst the lmm_constraint_t associated to the resource + * If the resource is shared (the default case), the load is sum of + * resource usage made by every variables located on this resource. * - * This is dead code, but we may use it later for debug/trace. + * If the resource is not shared (ie in FATPIPE mode), then the the + * load is the max (not the sum) of all resource usages located on this resource. + * . + * \param cnst the lmm_constraint_t associated to the resource */ double lmm_constraint_get_usage(lmm_constraint_t cnst) { double usage = 0.0; xbt_swag_t elem_list = &(cnst->enabled_element_set); void *_elem; - lmm_element_t elem = nullptr; xbt_swag_foreach(_elem, elem_list) { - elem = (lmm_element_t)_elem; - if ((elem->value > 0)) { + lmm_element_t elem = (lmm_element_t)_elem; + if (elem->value > 0) { if (cnst->sharing_policy) usage += elem->value * elem->variable->value; else if (usage < elem->value * elem->variable->value) - usage = elem->value * elem->variable->value; + usage = max(usage, elem->value * elem->variable->value); } } return usage;