+/* 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"
{
NetworkCm02ActionPtr action;
while ((xbt_heap_size(p_actionHeap) > 0)
- && (double_equals(xbt_heap_maxkey(p_actionHeap), now))) {
+ && (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
xbt_dynar_free(&route);
XBT_OUT();
+ surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate);
return action;
}
/* 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) {
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 *
**********/
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);
- double_update(&(m_remains), m_lastValue * delta);
+ XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, m_remains, m_lastUpdate);
+ double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision);
- 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)
- double_update(&m_maxDuration, delta);
+ double_update(&m_maxDuration, delta, sg_surf_precision);
if (m_remains <= 0 &&
(lmm_get_variable_weight(getVariable()) > 0)) {