From: Arnaud Legrand Date: Thu, 3 Apr 2014 15:47:11 +0000 (+0200) Subject: Use more explicit variable names and add a bit of debug. X-Git-Tag: v3_11~172 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/71460434911c9b4398bd6df2c9c6d31f9c011005?ds=sidebyside Use more explicit variable names and add a bit of debug. There is still something "wrong" with this code, which is that it aborts whenever an action gets a share of 0 (in which case I am not able to assign it a completion date and insert it into the calendar). This could happen but is more likely to be a bug in lmm or in surf, which is why I leave it as such for the moment. --- diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 56454da3db..5c7050115d 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -520,7 +520,7 @@ double Model::shareResourcesLazy(double now) { ActionPtr action = NULL; double min = -1; - double value; + double share, time_to_completion; XBT_DEBUG ("Before share resources, the size of modified actions set is %zd", @@ -533,29 +533,30 @@ double Model::shareResourcesLazy(double now) p_modifiedSet->size()); while(!p_modifiedSet->empty()) { - action = &(p_modifiedSet->front()); - p_modifiedSet->pop_front(); + action = &(p_modifiedSet->front()); + p_modifiedSet->pop_front(); int max_dur_flag = 0; if (action->getStateSet() != p_runningActionSet) continue; /* bogus priority, skip it */ - if (action->getPriority() <= 0) + if (action->getPriority() <= 0 || action->getHat()==LATENCY) continue; action->updateRemainingLazy(now); min = -1; - value = lmm_variable_getvalue(action->getVariable()); - if (value > 0) { + time_to_completion = -1; + share = lmm_variable_getvalue(action->getVariable()); + + if (share > 0) { if (action->getRemains() > 0) { - value = action->getRemainsNoUpdate() / value; - min = now + value; + time_to_completion = action->getRemainsNoUpdate() / share; } else { - value = 0.0; - min = now; + time_to_completion = 0.0; } + min = now + time_to_completion; // when the task will complete if nothing changes } if ((action->getMaxDuration() != NO_MAX_DURATION) @@ -563,12 +564,15 @@ double Model::shareResourcesLazy(double now) || action->getStartTime() + action->getMaxDuration() < min)) { min = action->getStartTime() + - action->getMaxDuration(); + action->getMaxDuration(); // when the task will complete anyway because of the deadline if any max_dur_flag = 1; } - XBT_DEBUG("Action(%p) Start %f Finish %f Max_duration %f", action, - action->getStartTime(), now + value, + + XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->id_int); + + XBT_DEBUG("Action(%p) Start %f. May finish at %f (got a share of %f). Max_duration %f", action, + action->getStartTime(), min, share, action->getMaxDuration()); if (min != -1) {