X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/bc5903068a99bfc50a9f7a479cc3305326f774e9..a279c221114b93985c6aa249e71cc4141082b310:/src/surf/network_cm02.cpp diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index e34e829965..66e588370d 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -1,3 +1,9 @@ +/* Copyright (c) 2013-2014. 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. */ + #include "network_cm02.hpp" #include "maxmin_private.hpp" #include "simgrid/sg_config.h" @@ -372,12 +378,12 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL); - XBT_IN("(%s,%s,%g,%g)", src->p_name, dst->p_name, size, rate); + XBT_IN("(%s,%s,%g,%g)", src->getName(), dst->getName(), size, rate); routing_platf->getRouteAndLatency(src, dst, &route, &latency); xbt_assert(!xbt_dynar_is_empty(route) || latency, "You're trying to send data from %s to %s but there is no connection at all between these two hosts.", - src->p_name, dst->p_name); + src->getName(), dst->getName()); xbt_dynar_foreach(route, i, _link) { link = static_cast(_link); @@ -434,7 +440,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, link = *static_cast(xbt_dynar_get_ptr(route, 0)); gapAppend(size, link, action); XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)", - action, src->p_name, dst->p_name, action->m_senderGap, + action, src->getName(), dst->getName(), action->m_senderGap, action->m_latency); } @@ -476,6 +482,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_free(&route); XBT_OUT(); + surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate); return action; } @@ -524,59 +531,11 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, /* value, event_type); */ if (event_type == p_power.event) { - double delta = - sg_weight_S_parameter / value - sg_weight_S_parameter / - (p_power.peak * p_power.scale); - lmm_variable_t var = NULL; - lmm_element_t elem = NULL; - NetworkCm02ActionPtr action = NULL; - - p_power.peak = value; - lmm_update_constraint_bound(getModel()->getMaxminSystem(), - 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))) { - action = (NetworkCm02ActionPtr) lmm_variable_id(var); - action->m_weight += delta; - if (!action->isSuspended()) - lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); - } - } + updateBandwidth(value, date); if (tmgr_trace_event_free(event_type)) p_power.event = NULL; } else if (event_type == p_latEvent) { - double delta = value - m_latCurrent; - lmm_variable_t var = NULL; - lmm_element_t elem = NULL; - NetworkCm02ActionPtr action = NULL; - - m_latCurrent = value; - while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { - action = (NetworkCm02ActionPtr) lmm_variable_id(var); - action->m_latCurrent += delta; - action->m_weight += delta; - if (action->m_rate < 0) - lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent)); - else { - lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), - min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent))); - - if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) { - XBT_INFO("Flow is limited BYBANDWIDTH"); - } else { - XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", - action->m_latCurrent); - } - } - if (!action->isSuspended()) - lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); - - } + updateLatency(value, date); if (tmgr_trace_event_free(event_type)) p_latEvent = NULL; } else if (event_type == p_stateEvent) { @@ -611,6 +570,60 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, return; } +void NetworkCm02Link::updateBandwidth(double value, double date){ + double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / + (p_power.peak * p_power.scale); + lmm_variable_t var = NULL; + lmm_element_t elem = NULL; + NetworkCm02ActionPtr action = NULL; + + p_power.peak = value; + lmm_update_constraint_bound(getModel()->getMaxminSystem(), + 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))) { + action = (NetworkCm02ActionPtr) lmm_variable_id(var); + action->m_weight += delta; + if (!action->isSuspended()) + lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); + } + } +} + +void NetworkCm02Link::updateLatency(double value, double date){ + double delta = value - m_latCurrent; + lmm_variable_t var = NULL; + lmm_element_t elem = NULL; + NetworkCm02ActionPtr action = NULL; + + m_latCurrent = value; + while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { + action = (NetworkCm02ActionPtr) lmm_variable_id(var); + action->m_latCurrent += delta; + action->m_weight += delta; + if (action->m_rate < 0) + lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent)); + else { + lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), + min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent))); + + if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) { + XBT_INFO("Flow is limited BYBANDWIDTH"); + } else { + XBT_INFO("Flow is limited BYLATENCY, latency of flow is %f", + action->m_latCurrent); + } + } + if (!action->isSuspended()) + lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); + } +} + /********** * Action * **********/ @@ -624,10 +637,10 @@ void NetworkCm02Action::updateRemainingLazy(double now) delta = now - m_lastUpdate; if (m_remains > 0) { - XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", this, m_remains, m_lastUpdate); + XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate); double_update(&(m_remains), m_lastValue * delta); - XBT_DEBUG("Updating action(%p): remains is now %lf", this, m_remains); + XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains); } if (m_maxDuration != NO_MAX_DURATION)