From: Martin Quinson Date: Tue, 8 Mar 2016 21:11:15 +0000 (+0100) Subject: remove bw and lat traces from the Link constructor X-Git-Tag: v3_13~467 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c4c51bdbf0da9491133f9d42f16b11da211b664b remove bw and lat traces from the Link constructor --- diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index a9e78eeec5..1ea74f3de5 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -161,9 +161,7 @@ NetworkCm02Model::NetworkCm02Model() if (!p_maxminSystem) p_maxminSystem = lmm_system_new(m_selectiveUpdate); - routing_model_create(createLink("__loopback__", - 498000000, NULL, 0.000015, NULL, - SURF_LINK_FATPIPE, NULL)); + routing_model_create(createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, NULL)); if (p_updateMechanism == UM_LAZY) { p_actionHeap = xbt_heap_new(8, NULL); @@ -173,17 +171,11 @@ NetworkCm02Model::NetworkCm02Model() } } -Link* NetworkCm02Model::createLink(const char *name, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, - e_surf_link_sharing_policy_t policy, xbt_dict_t properties) +Link* NetworkCm02Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) { - xbt_assert(NULL == Link::byName(name), - "Link '%s' declared several times in the platform", - name); + xbt_assert(NULL == Link::byName(name), "Link '%s' declared several times in the platform", name); - Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, - bw_initial, bw_trace, lat_initial, lat_trace, policy); + Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bandwidth, bandwidth, latency, policy); Link::onCreation(link); return link; } @@ -408,22 +400,15 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst, double size, d NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props, lmm_system_t system, double constraint_value, - double bw_peak, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, + double bw_peak, double lat_initial, e_surf_link_sharing_policy_t policy) : Link(model, name, props, lmm_constraint_new(system, this, constraint_value)) { 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 - m_bandwidth.event = NULL; m_latency.scale = 1.0; m_latency.peak = lat_initial; - if (lat_trace) - m_latency.event = future_evt_set->add_trace(lat_trace, 0.0, this); if (policy == SURF_LINK_FATPIPE) lmm_constraint_shared(getConstraint()); diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index d28defd275..098563e4da 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -40,10 +40,7 @@ namespace simgrid { public: NetworkCm02Model(); ~NetworkCm02Model() { } - Link* createLink(const char *name, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, - e_surf_link_sharing_policy_t policy, + Link* createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override; void updateActionsStateLazy(double now, double delta) override; void updateActionsStateFull(double now, double delta) override; @@ -62,9 +59,7 @@ namespace simgrid { public: NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props, lmm_system_t system, - double constraint_value, - double bw_peak, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, + double constraint_value, double bw_peak, double lat_initial, e_surf_link_sharing_policy_t policy); void apply_event(tmgr_trace_iterator_t event, double value) override; diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index c3c23f013b..9848e7ae8b 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -34,12 +34,8 @@ namespace simgrid { bool next_occuring_event_isIdempotent() override {return true;} void updateActionsState(double now, double delta) override; - Link* - createLink(const char *name, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, - e_surf_link_sharing_policy_t policy, - xbt_dict_t properties) override { DIE_IMPOSSIBLE; } + Link* createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override + { DIE_IMPOSSIBLE; } }; /********** diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index ed0dd2188d..3c2bb7e818 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -109,33 +109,33 @@ void netlink_parse_init(sg_platf_link_cbarg_t link){ if (link->policy == SURF_LINK_FULLDUPLEX) { char *link_id; link_id = bprintf("%s_UP", link->id); - Link *l = surf_network_model->createLink(link_id, - link->bandwidth, - link->bandwidth_trace, - link->latency, - link->latency_trace, + Link *l = surf_network_model->createLink(link_id, link->bandwidth, link->latency, link->policy, link->properties); + if (link->latency_trace) + l->setLatencyTrace(link->latency_trace); + if (link->bandwidth_trace) + l->setBandwidthTrace(link->bandwidth_trace); if (link->state_trace) l->setStateTrace(link->state_trace); xbt_free(link_id); link_id = bprintf("%s_DOWN", link->id); - l = surf_network_model->createLink(link_id, - link->bandwidth, - link->bandwidth_trace, - link->latency, - link->latency_trace, + l = surf_network_model->createLink(link_id, link->bandwidth, link->latency, link->policy, link->properties); + if (link->latency_trace) + l->setLatencyTrace(link->latency_trace); + if (link->bandwidth_trace) + l->setBandwidthTrace(link->bandwidth_trace); if (link->state_trace) l->setStateTrace(link->state_trace); xbt_free(link_id); } else { - Link *l=surf_network_model->createLink(link->id, - link->bandwidth, - link->bandwidth_trace, - link->latency, - link->latency_trace, + Link *l=surf_network_model->createLink(link->id, link->bandwidth, link->latency, link->policy, link->properties); + if (link->latency_trace) + l->setLatencyTrace(link->latency_trace); + if (link->bandwidth_trace) + l->setBandwidthTrace(link->bandwidth_trace); if (link->state_trace) l->setStateTrace(link->state_trace); } @@ -209,11 +209,6 @@ namespace simgrid { XBT_DEBUG("Create link '%s'",name); } - void Link::setStateTrace(tmgr_trace_t trace) { - if (m_stateEvent != nullptr) - XBT_INFO("Changing the state trace is not well tested. You're on your own."); - m_stateEvent = future_evt_set->add_trace(trace, 0.0, this); - } /** @brief use destroy() instead of this destructor */ Link::~Link() { @@ -264,22 +259,18 @@ namespace simgrid { onStateChange(this); } } - void Link::set_state_trace(tmgr_trace_t trace) - { + void Link::setStateTrace(tmgr_trace_t trace) { xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName()); - m_stateEvent = future_evt_set->add_trace(trace, 0.0, this); } - void Link::set_bandwidth_trace(tmgr_trace_t trace) + void Link::setBandwidthTrace(tmgr_trace_t trace) { xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName()); - m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this); } - void Link::set_latency_trace(tmgr_trace_t trace) + void Link::setLatencyTrace(tmgr_trace_t trace) { xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName()); - m_latency.event = future_evt_set->add_trace(trace, 0.0, this); } diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 7bacd5ac06..cb59af1720 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -80,21 +80,14 @@ namespace simgrid { * @brief Create a Link * * @param name The name of the Link - * @param bw_initial The initial bandwidth of the Link in bytes per second - * @param bw_trace The trace associated to the Link bandwidth - * @param lat_initial The initial latency of the Link in seconds - * @param lat_trace The trace associated to the Link latency + * @param bandwidth The initial bandwidth of the Link in bytes per second + * @param latency The initial latency of the Link in seconds * @param policy The sharing policy of the Link * @param properties Dictionary of properties associated to this Resource * @return The created Link */ - virtual Link* createLink(const char *name, - double bw_initial, - tmgr_trace_t bw_trace, - double lat_initial, - tmgr_trace_t lat_trace, - e_surf_link_sharing_policy_t policy, - xbt_dict_t properties)=0; + virtual Link* createLink(const char *name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy, xbt_dict_t properties)=0; /** * @brief Create a communication between two hosts. @@ -184,9 +177,6 @@ namespace simgrid { */ Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint); - /** @brief State traces are used to model the on/off state of the link */ - void setStateTrace(tmgr_trace_t trace); - /* Link destruction logic */ /**************************/ protected: @@ -231,9 +221,9 @@ namespace simgrid { void turnOn() override; void turnOff() override; - virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */ - virtual void set_bandwidth_trace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */ - virtual void set_latency_trace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */ + virtual void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values. */ + virtual void setBandwidthTrace(tmgr_trace_t trace); /*< setup the trace file with bandwidth events (peak speed changes due to external load). Trace must contain percentages (value between 0 and 1). */ + virtual void setLatencyTrace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to external load). Trace must contain absolute values */ tmgr_trace_iterator_t m_stateEvent = NULL; s_surf_metric_t m_latency = {1.0,0,NULL}; diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 20729223ce..7a64e73225 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -40,14 +40,15 @@ static void parse_ns3_add_link(sg_platf_link_cbarg_t link) if(!IPV4addr) IPV4addr = xbt_dynar_new(sizeof(char*),free); - Link *l = surf_network_model->createLink(link->id, - link->bandwidth, link->bandwidth_trace, - link->latency, link->latency_trace, + Link *l = surf_network_model->createLink(link->id, link->bandwidth, link->latency, link->policy, link->properties); + if (link->bandwidth_trace) + l->setBandwidthTrace(link->latency_trace); + if (link->latency_trace) + l->setLatencyTrace(link->latency_trace); if (link->state_trace) l->setStateTrace(link->state_trace); } - static void simgrid_ns3_add_router(simgrid::surf::NetCard* router) { const char* router_id = router->name(); @@ -260,17 +261,10 @@ NetworkNS3Model::~NetworkNS3Model() { xbt_dict_free(&dict_socket); } -Link* NetworkNS3Model::createLink(const char *name, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, - e_surf_link_sharing_policy_t policy, +Link* NetworkNS3Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, xbt_dict_t properties){ - if (bw_trace) - XBT_INFO("The NS3 network model doesn't support bandwidth state traces"); - if (lat_trace) - XBT_INFO("The NS3 network model doesn't support latency state traces"); - Link* link = new NetworkNS3Link(this, name, properties, bw_initial, lat_initial); + Link* link = new NetworkNS3Link(this, name, properties, bandwidth, latency); Link::onCreation(link); return link; } @@ -390,6 +384,12 @@ void NetworkNS3Link::apply_event(tmgr_trace_iterator_t event, double value) { THROW_UNIMPLEMENTED; } +void NetworkNS3Link::setBandwidthTrace(tmgr_trace_t trace) { + xbt_die("The NS3 network model doesn't support latency state traces"); +} +void NetworkNS3Link::setLatencyTrace(tmgr_trace_t trace) { + xbt_die("The NS3 network model doesn't support latency state traces"); +} /********** * Action * diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 96b091e10d..adfca7c629 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -41,13 +41,9 @@ namespace surf { class NetworkNS3Model : public NetworkModel { public: NetworkNS3Model(); - ~NetworkNS3Model(); - Link* createLink(const char *name, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, - e_surf_link_sharing_policy_t policy, - xbt_dict_t properties) override; + Link* createLink(const char *name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override; Action *communicate(NetCard *src, NetCard *dst, double size, double rate); double next_occuring_event(double now) override; bool next_occuring_event_isIdempotent() {return false;} @@ -59,13 +55,14 @@ public: ************/ class NetworkNS3Link : public Link { public: - NetworkNS3Link(NetworkNS3Model *model, const char *name, xbt_dict_t props, - double bw_initial, double lat_initial); + NetworkNS3Link(NetworkNS3Model *model, const char *name, xbt_dict_t props, double bandwidth, double latency); ~NetworkNS3Link(); void apply_event(tmgr_trace_iterator_t event, double value) override; void updateBandwidth(double value) override {THROW_UNIMPLEMENTED;} void updateLatency(double value) override {THROW_UNIMPLEMENTED;} + void setBandwidthTrace(tmgr_trace_t trace) override; + void setLatencyTrace(tmgr_trace_t trace) override; //private: int m_created; diff --git a/src/surf/network_smpi.hpp b/src/surf/network_smpi.hpp index c369fdb109..ce6105dd6a 100644 --- a/src/surf/network_smpi.hpp +++ b/src/surf/network_smpi.hpp @@ -24,16 +24,5 @@ namespace simgrid { double bandwidthConstraint(double rate, double bound, double size); void communicateCallBack() {}; }; - - - /************ - * Resource * - ************/ - - - /********** - * Action * - **********/ - } } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 2179b1790c..1b5534d57b 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -49,10 +49,7 @@ HostL07Model::HostL07Model() : HostModel() { surf_network_model = new NetworkL07Model(this,p_maxminSystem); surf_cpu_model_pm = new CpuL07Model(this,p_maxminSystem); - routing_model_create(surf_network_model->createLink("__loopback__", - 498000000, NULL, - 0.000015, NULL, - SURF_LINK_FATPIPE, NULL)); + routing_model_create(surf_network_model->createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, NULL)); } HostL07Model::~HostL07Model() { @@ -292,15 +289,13 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t powerPeakList return cpu; } -Link* NetworkL07Model::createLink(const char *name, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, +Link* NetworkL07Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) { xbt_assert(!Link::byName(name), "Link '%s' declared several times in the platform.", name); - Link* link = new LinkL07(this, name, properties, bw_initial, bw_trace, lat_initial, lat_trace, policy); + Link* link = new LinkL07(this, name, properties, bandwidth, latency, policy); Link::onCreation(link); return link; } @@ -328,19 +323,12 @@ CpuL07::~CpuL07() { } -LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, +LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) - : Link(model, name, props, lmm_constraint_new(model->getMaxminSystem(), this, bw_initial)) + : Link(model, name, props, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth)) { - m_bandwidth.peak = bw_initial; - if (bw_trace) - m_bandwidth.event = future_evt_set->add_trace(bw_trace, 0.0, this); - - m_latency.peak = lat_initial; - if (lat_trace) - m_latency.event = future_evt_set->add_trace(lat_trace, 0.0, this); + m_bandwidth.peak = bandwidth; + m_latency.peak = latency; if (policy == SURF_LINK_FATPIPE) lmm_constraint_shared(getConstraint()); diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index c9faa7538d..9315cd1f95 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -64,11 +64,7 @@ class NetworkL07Model : public NetworkModel { public: NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys); ~NetworkL07Model(); - Link* createLink(const char *name, - double bw_initial, - tmgr_trace_t bw_trace, - double lat_initial, - tmgr_trace_t lat_trace, + Link* createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override; @@ -98,9 +94,7 @@ protected: class LinkL07 : public Link { public: LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, - double bw_initial, tmgr_trace_t bw_trace, - double lat_initial, tmgr_trace_t lat_trace, - e_surf_link_sharing_policy_t policy); + double bandwidth, double latency, e_surf_link_sharing_policy_t policy); ~LinkL07(){ }; bool isUsed() override; void apply_event(tmgr_trace_iterator_t event, double value) override; diff --git a/src/surf/xml/surfxml_parseplatf.cpp b/src/surf/xml/surfxml_parseplatf.cpp index 02f8ccdeda..d87f73c1f3 100644 --- a/src/surf/xml/surfxml_parseplatf.cpp +++ b/src/surf/xml/surfxml_parseplatf.cpp @@ -207,7 +207,7 @@ void parse_platform_file(const char *file) xbt_assert(trace, "Trace %s undefined", trace_name); Link *link = Link::byName(elm); xbt_assert(link, "Link %s undefined", elm); - link->set_state_trace(trace); + link->setStateTrace(trace); } xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) { @@ -215,7 +215,7 @@ void parse_platform_file(const char *file) xbt_assert(trace, "Trace %s undefined", trace_name); Link *link = Link::byName(elm); xbt_assert(link, "Link %s undefined", elm); - link->set_bandwidth_trace(trace); + link->setBandwidthTrace(trace); } xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) { @@ -223,7 +223,7 @@ void parse_platform_file(const char *file) xbt_assert(trace, "Trace %s undefined", trace_name); Link *link = Link::byName(elm); xbt_assert(link, "Link %s undefined", elm); - link->set_latency_trace(trace); + link->setLatencyTrace(trace); } /* Free my data */