namespace surf {
NetworkCm02Model::NetworkCm02Model()
- :NetworkModel()
+ :NetworkModel()
{
char *optim = xbt_cfg_get_string(_sg_cfg_set, "network/optim");
int select =
} else if (!strcmp(optim, "Lazy")) {
p_updateMechanism = UM_LAZY;
m_selectiveUpdate = 1;
- xbt_assert((select == 1)
- ||
- (xbt_cfg_is_default_value
- (_sg_cfg_set, "network/maxmin_selective_update")),
+ xbt_assert((select == 1) || (xbt_cfg_is_default_value(_sg_cfg_set, "network/maxmin_selective_update")),
"Disabling selective update while using the lazy update mechanism is dumb!");
} else {
xbt_die("Unsupported optimization (%s) for this model", optim);
}
if (!p_maxminSystem)
- p_maxminSystem = lmm_system_new(m_selectiveUpdate);
+ p_maxminSystem = lmm_system_new(m_selectiveUpdate);
routing_model_create(createLink("__loopback__",
- 498000000, NULL, 0.000015, NULL,
- 1 /*SURF_RESOURCE_ON*/, NULL,
- SURF_LINK_FATPIPE, NULL));
+ 498000000, NULL, 0.000015, NULL,
+ 1 /*SURF_RESOURCE_ON*/, NULL,
+ SURF_LINK_FATPIPE, NULL));
if (p_updateMechanism == UM_LAZY) {
- 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;
+ 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;
}
}
"Link '%s' declared several times in the platform",
name);
- Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, future_evt_set,
- initiallyOn, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
+ Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial,
+ initiallyOn, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
Link::onCreation(link);
return link;
}
for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
; it != itend ; it=itNext) {
- ++itNext;
+ ++itNext;
action = static_cast<NetworkCm02Action*> (&*it);
XBT_DEBUG("Something happened to action %p", action);
src->getName(), dst->getName());
xbt_dynar_foreach(route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
+ link = static_cast<NetworkCm02Link*>(_link);
if (link->isOff()) {
failed = 1;
break;
}
}
if (sg_network_crosstraffic == 1) {
- routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
+ routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
xbt_dynar_foreach(back_route, i, _link) {
link = static_cast<NetworkCm02Link*>(_link);
if (link->isOff()) {
}
}
xbt_dynar_foreach(route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
+ link = static_cast<NetworkCm02Link*>(_link);
double bb = bandwidthFactor(size) * link->getBandwidth();
bandwidth_bound =
(bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb);
}
xbt_dynar_foreach(route, i, _link) {
- link = static_cast<NetworkCm02Link*>(_link);
+ link = static_cast<NetworkCm02Link*>(_link);
lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), 1.0);
}
"Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
- link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
+ link->m_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
}
xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
"Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
- link->p_speed.event = future_evt_set->add_trace(trace, 0.0, link);
+ link->m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, link);
}
xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
"Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
- link->p_latEvent = future_evt_set->add_trace(trace, 0.0, link);
+ link->m_latency.event = future_evt_set->add_trace(trace, 0.0, link);
}
}
* Resource *
************/
NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props,
- lmm_system_t system,
- double constraint_value,
- sg_future_evt_set_t fes,
- int initiallyOn,
- tmgr_trace_t state_trace,
- double metric_peak,
- tmgr_trace_t metric_trace,
- double lat_initial,
- tmgr_trace_t lat_trace,
- e_surf_link_sharing_policy_t policy)
-: Link(model, name, props, lmm_constraint_new(system, this, constraint_value), fes, state_trace)
+ lmm_system_t system,
+ double constraint_value,
+ int initiallyOn, tmgr_trace_t state_trace,
+ double bw_peak, tmgr_trace_t bw_trace,
+ double lat_initial, tmgr_trace_t lat_trace,
+ e_surf_link_sharing_policy_t policy)
+: Link(model, name, props, lmm_constraint_new(system, this, constraint_value), state_trace)
{
if (initiallyOn)
turnOn();
else
turnOff();
- p_speed.scale = 1.0;
- p_speed.peak = metric_peak;
- if (metric_trace)
- p_speed.event = fes->add_trace(metric_trace, 0.0, this);
+ m_bandwidth.scale = 1.0;
+ m_bandwidth.peak = bw_peak;
+ if (bw_trace)
+ m_bandwidth.event = future_evt_set->add_trace(bw_trace, 0.0, this);
else
- p_speed.event = NULL;
+ m_bandwidth.event = NULL;
- m_latCurrent = lat_initial;
+ m_latency.scale = 1.0;
+ m_latency.peak = lat_initial;
if (lat_trace)
- p_latEvent = fes->add_trace(lat_trace, 0.0, this);
+ m_latency.event = future_evt_set->add_trace(lat_trace, 0.0, this);
if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(getConstraint());
+ lmm_constraint_shared(getConstraint());
}
-void NetworkCm02Link::updateState(tmgr_trace_iterator_t triggered,
- double value, double date)
+void NetworkCm02Link::apply_event(tmgr_trace_iterator_t triggered, double value)
{
/* Find out which of my iterators was triggered, and react accordingly */
- if (triggered == p_speed.event) {
- updateBandwidth(value, date);
- tmgr_trace_event_unref(&p_speed.event);
- } else if (triggered == p_latEvent) {
- updateLatency(value, date);
- tmgr_trace_event_unref(&p_latEvent);
- } else if (triggered == p_stateEvent) {
+ if (triggered == m_bandwidth.event) {
+ updateBandwidth(value);
+ tmgr_trace_event_unref(&m_bandwidth.event);
+ } else if (triggered == m_latency.event) {
+ updateLatency(value);
+ tmgr_trace_event_unref(&m_latency.event);
+ } else if (triggered == m_stateEvent) {
if (value > 0)
turnOn();
else {
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
+ double now = surf_get_clock();
turnOff();
while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
if (action->getState() == SURF_ACTION_RUNNING ||
action->getState() == SURF_ACTION_READY) {
- action->setFinishTime(date);
+ action->setFinishTime(now);
action->setState(SURF_ACTION_FAILED);
}
}
}
- tmgr_trace_event_unref(&p_stateEvent);
+ tmgr_trace_event_unref(&m_stateEvent);
} else {
xbt_die("Unknown event!\n");
}
getConstraint());
}
-void NetworkCm02Link::updateBandwidth(double value, double date){
+void NetworkCm02Link::updateBandwidth(double value) {
double delta = sg_weight_S_parameter / value - sg_weight_S_parameter /
- (p_speed.peak * p_speed.scale);
+ (m_bandwidth.peak * m_bandwidth.scale);
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
lmm_element_t nextelem = NULL;
NetworkCm02Action *action = NULL;
- p_speed.peak = value;
+ m_bandwidth.peak = value;
lmm_update_constraint_bound(getModel()->getMaxminSystem(),
getConstraint(),
sg_bandwidth_factor *
- (p_speed.peak * p_speed.scale));
- TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_speed.peak * p_speed.scale);
+ (m_bandwidth.peak * m_bandwidth.scale));
+ TRACE_surf_link_set_bandwidth(surf_get_clock(), getName(), sg_bandwidth_factor * m_bandwidth.peak * m_bandwidth.scale);
if (sg_weight_S_parameter > 0) {
while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) {
action = (NetworkCm02Action*) lmm_variable_id(var);
}
}
-void NetworkCm02Link::updateLatency(double value, double date){
- double delta = value - m_latCurrent;
+void NetworkCm02Link::updateLatency(double value){
+ double delta = value - m_latency.peak;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
lmm_element_t nextelem = NULL;
int numelem = 0;
NetworkCm02Action *action = NULL;
- m_latCurrent = value;
+ m_latency.peak = value;
while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) {
action = (NetworkCm02Action*) lmm_variable_id(var);
action->m_latCurrent += delta;