X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fb588fbb8c119a8f04e6d2cb15b663257786ba70..9e821066f7f85d43404ed9ca2f566bf7c718b51a:/src/surf/network_cm02.cpp diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index d7c41bbce0..37fc2717d8 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -138,7 +138,7 @@ void surf_network_model_init_Reno2(void) xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 10.4); xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S_parameter", + xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); } @@ -192,7 +192,8 @@ void NetworkCm02Model::initialize() SURF_LINK_FATPIPE, NULL)); if (p_updateMechanism == UM_LAZY) { - p_actionHeap = new ActionHeap(); + p_actionHeap = xbt_heap_new(8, NULL); + xbt_heap_set_update_callback(p_actionHeap, surf_action_lmm_update_index_heap); p_modifiedSet = new ActionLmmList(); p_maxminSystem->keep_track = p_modifiedSet; } @@ -228,12 +229,10 @@ NetworkLinkPtr NetworkCm02Model::createNetworkLink(const char *name, void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) { NetworkCm02ActionPtr action; - while ((!p_actionHeap->empty()) - && (double_equals(p_actionHeap->topKey(), now, sg_surf_precision))) { - action = (NetworkCm02ActionPtr) p_actionHeap->topValue(); - p_actionHeap->pop(); + while ((xbt_heap_size(p_actionHeap) > 0) + && (double_equals(xbt_heap_maxkey(p_actionHeap), now, sg_surf_precision))) { + action = (NetworkCm02ActionPtr) xbt_heap_pop(p_actionHeap); XBT_DEBUG("Something happened to action %p", action); -#ifdef HAVE_TRACING if (TRACE_is_enabled()) { int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable()); int i; @@ -252,25 +251,24 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) now - action->getLastUpdate()); } } -#endif // if I am wearing a latency hat - if (action->getHeapActionType() == LATENCY) { + if (action->getHat() == LATENCY) { XBT_DEBUG("Latency paid for action %p. Activating", action); lmm_update_variable_weight(p_maxminSystem, action->getVariable(), action->m_weight); - action->heapRemove(); + action->heapRemove(p_actionHeap); action->refreshLastUpdate(); // if I am wearing a max_duration or normal hat - } else if (action->getHeapActionType() == MAX_DURATION || - action->getHeapActionType() == NORMAL) { + } else if (action->getHat() == MAX_DURATION || + action->getHat() == NORMAL) { // no need to communicate anymore // assume that flows that reached max_duration have remaining of 0 XBT_DEBUG("Action %p finished", action); action->setRemains(0); action->finish(); action->setState(SURF_ACTION_DONE); - action->heapRemove(); + action->heapRemove(p_actionHeap); action->gapRemove(); } @@ -278,6 +276,77 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) return; } + +void NetworkCm02Model::updateActionsStateFull(double now, double delta) +{ + NetworkCm02ActionPtr action; + ActionListPtr running_actions = getRunningActionSet(); + + for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) + ; it != itend ; it=itNext) { + ++itNext; + + action = (NetworkCm02ActionPtr) &*it; + XBT_DEBUG("Something happened to action %p", action); + double deltap = delta; + if (action->m_latency > 0) { + if (action->m_latency > deltap) { + double_update(&(action->m_latency), deltap, sg_surf_precision); + deltap = 0.0; + } else { + double_update(&(deltap), action->m_latency, sg_surf_precision); + action->m_latency = 0.0; + } + if (action->m_latency == 0.0 && !(action->isSuspended())) + lmm_update_variable_weight(p_maxminSystem, action->getVariable(), + action->m_weight); + } + if (TRACE_is_enabled()) { + int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable()); + int i; + for (i = 0; i < n; i++){ + lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem, + action->getVariable(), + i); + NetworkCm02LinkPtr link = static_cast(lmm_constraint_id(constraint)); + TRACE_surf_link_set_utilization(link->getName(), + action->getCategory(), + (lmm_variable_getvalue(action->getVariable())* + lmm_get_cnst_weight_from_var(p_maxminSystem, + action->getVariable(), + i)), + action->getLastUpdate(), + now - action->getLastUpdate()); + } + } + if (!lmm_get_number_of_cnst_from_var + (p_maxminSystem, action->getVariable())) { + /* There is actually no link used, hence an infinite bandwidth. + * This happens often when using models like vivaldi. + * In such case, just make sure that the action completes immediately. + */ + action->updateRemains(action->getRemains()); + } + action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta); + + if (action->getMaxDuration() != NO_MAX_DURATION) + action->updateMaxDuration(delta); + + if ((action->getRemains() <= 0) && + (lmm_get_variable_weight(action->getVariable()) > 0)) { + action->finish(); + action->setState(SURF_ACTION_DONE); + action->gapRemove(); + } else if (((action->getMaxDuration() != NO_MAX_DURATION) + && (action->getMaxDuration() <= 0))) { + action->finish(); + action->setState(SURF_ACTION_DONE); + action->gapRemove(); + } + } + return; +} + ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate) { @@ -327,6 +396,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, action->m_rate = rate; if (p_updateMechanism == UM_LAZY) { + action->m_indexHeap = -1; action->m_lastUpdate = surf_get_clock(); } @@ -369,8 +439,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, // add to the heap the event when the latency is payed XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->m_latency + action->m_lastUpdate); - - action->heapInsert(action->m_latency + action->m_lastUpdate, xbt_dynar_is_empty(route) ? NORMAL : LATENCY); + action->heapInsert(p_actionHeap, action->m_latency + action->m_lastUpdate, xbt_dynar_is_empty(route) ? NORMAL : LATENCY); } } else action->p_variable = lmm_variable_new(p_maxminSystem, action, 1.0, -1.0, constraints_per_variable); @@ -541,6 +610,9 @@ void NetworkCm02Link::updateBandwidth(double value, double date){ (p_power.peak * p_power.scale); lmm_variable_t var = NULL; lmm_element_t elem = NULL; + lmm_element_t nextelem = NULL; + int numelem = 0; + NetworkCm02ActionPtr action = NULL; p_power.peak = value; @@ -548,11 +620,9 @@ void NetworkCm02Link::updateBandwidth(double value, double date){ getConstraint(), sg_bandwidth_factor * (p_power.peak * p_power.scale)); -#ifdef HAVE_TRACING TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_power.peak * p_power.scale); -#endif if (sg_weight_S_parameter > 0) { - while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { + while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) { action = (NetworkCm02ActionPtr) lmm_variable_id(var); action->m_weight += delta; if (!action->isSuspended()) @@ -565,10 +635,12 @@ void NetworkCm02Link::updateLatency(double value, double date){ double delta = value - m_latCurrent; lmm_variable_t var = NULL; lmm_element_t elem = NULL; + lmm_element_t nextelem = NULL; + int numelem = 0; NetworkCm02ActionPtr action = NULL; m_latCurrent = value; - while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { + while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) { action = (NetworkCm02ActionPtr) lmm_variable_id(var); action->m_latCurrent += delta; action->m_weight += delta; @@ -617,12 +689,12 @@ void NetworkCm02Action::updateRemainingLazy(double now) finish(); setState(SURF_ACTION_DONE); - heapRemove(); + heapRemove(getModel()->getActionHeap()); } else if (((m_maxDuration != NO_MAX_DURATION) && (m_maxDuration <= 0))) { finish(); setState(SURF_ACTION_DONE); - heapRemove(); + heapRemove(getModel()->getActionHeap()); } m_lastUpdate = now;