X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/63d18c86bbffb905a9d31dc2384596cead30529a..95f6003dd91bcac6493664491e831de740ebffd3:/src/surf/network_cm02.cpp diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index c5c242be8c..f0fce7bc86 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -4,6 +4,8 @@ /* 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 + #include "network_cm02.hpp" #include "maxmin_private.hpp" #include "simgrid/sg_config.h" @@ -52,9 +54,9 @@ void surf_network_model_init_LegrandVelho(void) if (surf_network_model) return; - surf_network_model = new NetworkCm02Model(); + surf_network_model = new simgrid::surf::NetworkCm02Model(); net_define_callbacks(); - Model *model = surf_network_model; + simgrid::surf::Model *model = surf_network_model; xbt_dynar_push(all_existing_models, &model); xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", @@ -81,14 +83,12 @@ void surf_network_model_init_CM02(void) if (surf_network_model) return; - surf_network_model = new NetworkCm02Model(); + surf_network_model = new simgrid::surf::NetworkCm02Model(); + xbt_dynar_push(all_existing_models, &surf_network_model); net_define_callbacks(); - Model *model = surf_network_model; - xbt_dynar_push(all_existing_models, &model); xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0); - xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", - 1.0); + xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 1.0); xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 0.0); } @@ -107,17 +107,14 @@ void surf_network_model_init_Reno(void) if (surf_network_model) return; - surf_network_model = new NetworkCm02Model(); + surf_network_model = new simgrid::surf::NetworkCm02Model(); + xbt_dynar_push(all_existing_models, &surf_network_model); net_define_callbacks(); - Model *model = surf_network_model; - xbt_dynar_push(all_existing_models, &model); - lmm_set_default_protocol_function(func_reno_f, func_reno_fp, - func_reno_fpi); + lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi); surf_network_model->f_networkSolve = lagrange_solve; 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/bandwidth_factor", 0.92); xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); } @@ -127,19 +124,15 @@ void surf_network_model_init_Reno2(void) if (surf_network_model) return; - surf_network_model = new NetworkCm02Model(); + surf_network_model = new simgrid::surf::NetworkCm02Model(); + xbt_dynar_push(all_existing_models, &surf_network_model); net_define_callbacks(); - Model *model = surf_network_model; - xbt_dynar_push(all_existing_models, &model); - lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, - func_reno2_fpi); + lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi); surf_network_model->f_networkSolve = lagrange_solve; 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", - 8775); + xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor", 0.92); + xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); } void surf_network_model_init_Vegas(void) @@ -147,20 +140,20 @@ void surf_network_model_init_Vegas(void) if (surf_network_model) return; - surf_network_model = new NetworkCm02Model(); + surf_network_model = new simgrid::surf::NetworkCm02Model(); + xbt_dynar_push(all_existing_models, &surf_network_model); net_define_callbacks(); - Model *model = surf_network_model; - xbt_dynar_push(all_existing_models, &model); - lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, - func_vegas_fpi); + lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi); surf_network_model->f_networkSolve = lagrange_solve; 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/bandwidth_factor", 0.92); xbt_cfg_setdefault_double(_sg_cfg_set, "network/weight_S", 8775); } +namespace simgrid { +namespace surf { + NetworkCm02Model::NetworkCm02Model() :NetworkModel() { @@ -197,8 +190,6 @@ NetworkCm02Model::NetworkCm02Model() p_modifiedSet = new ActionLmmList(); p_maxminSystem->keep_track = p_modifiedSet; } - - m_haveGap = false; } Link* NetworkCm02Model::createLink(const char *name, @@ -215,8 +206,10 @@ Link* NetworkCm02Model::createLink(const char *name, "Link '%s' declared several times in the platform", name); - return new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, history, + Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, history, state_initial, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy); + Link::onCreation(link); + return link; } void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) @@ -340,7 +333,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) return; } -Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, +Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, double rate) { unsigned int i; @@ -353,13 +346,13 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, xbt_dynar_t back_route = NULL; int constraints_per_variable = 0; - xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdge*), NULL); + xbt_dynar_t route = xbt_dynar_new(sizeof(NetCard*), NULL); 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.", + "You're trying to send data from %s to %s but there is no connecting path between these two hosts.", src->getName(), dst->getName()); xbt_dynar_foreach(route, i, _link) { @@ -402,9 +395,9 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, } xbt_dynar_foreach(route, i, _link) { link = static_cast(_link); - double bb = bandwidthFactor(size) * link->getBandwidth(); //(link->p_power.peak * link->p_power.scale); + double bb = bandwidthFactor(size) * link->getBandwidth(); bandwidth_bound = - (bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb); + (bandwidth_bound < 0.0) ? bb : std::min(bandwidth_bound, bb); } action->m_latCurrent = action->m_latency; @@ -440,7 +433,7 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, if (action->m_rate < 0) { lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0); } else { - lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate); + lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? std::min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate); } xbt_dynar_foreach(route, i, _link) { @@ -459,7 +452,7 @@ Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, xbt_dynar_free(&route); XBT_OUT(); - surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate); + networkCommunicateCallbacks(action, src, dst, size, rate); return action; } @@ -496,7 +489,7 @@ void NetworkCm02Model::addTraces(){ "Cannot connect trace %s to link %s: trace undefined", trace_name, elm); - link->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, link); + link->p_speed.event = tmgr_history_add_trace(history, trace, 0.0, 0, link); } xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) { @@ -531,12 +524,12 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_ { setState(state_init); - p_power.scale = 1.0; - p_power.peak = metric_peak; + p_speed.scale = 1.0; + p_speed.peak = metric_peak; if (metric_trace) - p_power.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, this); + p_speed.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, this); else - p_power.event = NULL; + p_speed.event = NULL; m_latCurrent = lat_initial; if (lat_trace) @@ -555,10 +548,10 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, /* "%g" " for event %p\n", surf_get_clock(), nw_link->name, */ /* value, event_type); */ - if (event_type == p_power.event) { + if (event_type == p_speed.event) { updateBandwidth(value, date); if (tmgr_trace_event_free(event_type)) - p_power.event = NULL; + p_speed.event = NULL; } else if (event_type == p_latEvent) { updateLatency(value, date); if (tmgr_trace_event_free(event_type)) @@ -597,7 +590,7 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, void NetworkCm02Link::updateBandwidth(double value, double date){ double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / - (p_power.peak * p_power.scale); + (p_speed.peak * p_speed.scale); lmm_variable_t var = NULL; lmm_element_t elem = NULL; lmm_element_t nextelem = NULL; @@ -605,12 +598,12 @@ void NetworkCm02Link::updateBandwidth(double value, double date){ NetworkCm02Action *action = NULL; - p_power.peak = value; + p_speed.peak = value; lmm_update_constraint_bound(getModel()->getMaxminSystem(), getConstraint(), sg_bandwidth_factor * - (p_power.peak * p_power.scale)); - TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_power.peak * p_power.scale); + (p_speed.peak * p_speed.scale)); + TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_speed.peak * p_speed.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); @@ -638,7 +631,7 @@ void NetworkCm02Link::updateLatency(double value, double date){ 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))); + std::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"); @@ -691,3 +684,5 @@ void NetworkCm02Action::updateRemainingLazy(double now) m_lastValue = lmm_variable_getvalue(getVariable()); } +} +}