X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6badbbf58554a35b03f58509b0b18cf606c38f5e..41fc8c54b8e9e4c610a8e54791d8efa8c5e6129e:/src/surf/network_cm02.cpp diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index c83cd4a71a..2e503cc550 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -9,6 +9,7 @@ #include "network_cm02.hpp" #include "maxmin_private.hpp" #include "simgrid/sg_config.h" +#include "src/surf/platform.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network); @@ -27,8 +28,10 @@ int sg_network_crosstraffic = 0; void net_define_callbacks(void) { /* Figuring out the network links */ - sg_platf_link_add_cb(netlink_parse_init); - sg_platf_postparse_add_cb(net_add_traces); + simgrid::surf::on_link.connect(netlink_parse_init); + simgrid::surf::on_postparse.connect([]() { + surf_network_model->addTraces(); + }); } /********* @@ -155,7 +158,7 @@ namespace simgrid { namespace surf { NetworkCm02Model::NetworkCm02Model() - :NetworkModel() + :NetworkModel() { char *optim = xbt_cfg_get_string(_sg_cfg_set, "network/optim"); int select = @@ -177,18 +180,18 @@ NetworkCm02Model::NetworkCm02Model() } 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; } } @@ -206,8 +209,8 @@ Link* NetworkCm02Model::createLink(const char *name, "Link '%s' declared several times in the platform", name); - Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, history, - 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, future_evt_set, + initiallyOn, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy); Link::onCreation(link); return link; } @@ -270,7 +273,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) ; it != itend ; it=itNext) { - ++itNext; + ++itNext; action = static_cast (&*it); XBT_DEBUG("Something happened to action %p", action); @@ -356,14 +359,14 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, src->getName(), dst->getName()); xbt_dynar_foreach(route, i, _link) { - link = static_cast(_link); + link = static_cast(_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(_link); if (link->isOff()) { @@ -394,7 +397,7 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, } } xbt_dynar_foreach(route, i, _link) { - link = static_cast(_link); + link = static_cast(_link); double bb = bandwidthFactor(size) * link->getBandwidth(); bandwidth_bound = (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb); @@ -437,7 +440,7 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, } xbt_dynar_foreach(route, i, _link) { - link = static_cast(_link); + link = static_cast(_link); lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), 1.0); } @@ -447,6 +450,7 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, link = static_cast(_link); lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), .05); } + lmm_variable_concurrency_share_set(action->getVariable(),2); } xbt_dynar_free(&route); @@ -476,10 +480,10 @@ void NetworkCm02Model::addTraces(){ "Cannot connect trace %s to link %s: trace undefined", trace_name, elm); - link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link); + link->p_stateEvent = future_evt_set->add_trace(trace, 0.0, link); } - xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) { + xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); NetworkCm02Link *link = static_cast( Link::byName(elm) ); @@ -489,10 +493,10 @@ void NetworkCm02Model::addTraces(){ "Cannot connect trace %s to link %s: trace undefined", trace_name, elm); - link->p_speed.event = tmgr_history_add_trace(history, trace, 0.0, 0, link); + link->p_speed.event = future_evt_set->add_trace(trace, 0.0, link); } - xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) { + xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) { tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name); NetworkCm02Link *link = static_cast(Link::byName(elm));; @@ -502,7 +506,7 @@ void NetworkCm02Model::addTraces(){ "Cannot connect trace %s to link %s: trace undefined", trace_name, elm); - link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link); + link->p_latEvent = future_evt_set->add_trace(trace, 0.0, link); } } @@ -510,17 +514,14 @@ void NetworkCm02Model::addTraces(){ * Resource * ************/ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props, - lmm_system_t system, - double constraint_value, - tmgr_history_t history, - 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), history, state_trace) + lmm_system_t system, + double constraint_value, + sg_future_evt_set_t fes, + 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), fes, state_trace) { if (initiallyOn) turnOn(); @@ -528,47 +529,42 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_ turnOff(); p_speed.scale = 1.0; - p_speed.peak = metric_peak; - if (metric_trace) - p_speed.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, this); + p_speed.peak = bw_peak; + if (bw_trace) + p_speed.event = fes->add_trace(bw_trace, 0.0, this); else p_speed.event = NULL; m_latCurrent = lat_initial; if (lat_trace) - p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, this); + p_latEvent = fes->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_event_t event_type, +void NetworkCm02Link::updateState(tmgr_trace_iterator_t triggered, double value, double date) { - /* printf("[" "%g" "] Asking to update network card \"%s\" with value " */ - /* "%g" " for event %p\n", surf_get_clock(), nw_link->name, */ - /* value, event_type); */ - if (event_type == p_speed.event) { + /* Find out which of my iterators was triggered, and react accordingly */ + if (triggered == p_speed.event) { updateBandwidth(value, date); - if (tmgr_trace_event_free(event_type)) - p_speed.event = NULL; - } else if (event_type == p_latEvent) { + tmgr_trace_event_unref(&p_speed.event); + } else if (triggered == p_latEvent) { updateLatency(value, date); - if (tmgr_trace_event_free(event_type)) - p_latEvent = NULL; - } else if (event_type == p_stateEvent) { + tmgr_trace_event_unref(&p_latEvent); + } else if (triggered == p_stateEvent) { if (value > 0) turnOn(); else { - lmm_constraint_t cnst = getConstraint(); lmm_variable_t var = NULL; lmm_element_t elem = NULL; turnOff(); - while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) { + while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) { Action *action = static_cast( lmm_variable_id(var) ); if (action->getState() == SURF_ACTION_RUNNING || @@ -578,17 +574,14 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, } } } - if (tmgr_trace_event_free(event_type)) - p_stateEvent = NULL; + tmgr_trace_event_unref(&p_stateEvent); } else { - XBT_CRITICAL("Unknown event ! \n"); - xbt_abort(); + xbt_die("Unknown event!\n"); } XBT_DEBUG - ("There were a resource state event, need to update actions related to the constraint (%p)", + ("There was a resource state event, need to update actions related to the constraint (%p)", getConstraint()); - return; } void NetworkCm02Link::updateBandwidth(double value, double date){