From 87ce37a26d39bad9a2533f6a54ea11f526ab4046 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 19 Mar 2016 22:58:16 +0100 Subject: [PATCH] empty the link factories --- src/surf/network_cm02.cpp | 14 ++++++-------- src/surf/network_cm02.hpp | 2 +- src/surf/network_interface.cpp | 3 +++ src/surf/network_ns3.cpp | 9 ++++----- src/surf/ptask_L07.cpp | 11 ++++------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index a9df4e7d9f..0c5fc8cbc7 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -173,11 +173,7 @@ NetworkCm02Model::NetworkCm02Model() 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); - - Link* link = new NetworkCm02Link(this, name, properties, maxminSystem_, sg_bandwidth_factor * bandwidth, bandwidth, latency, policy); - Link::onCreation(link); - return link; + return new NetworkCm02Link(this, name, properties, maxminSystem_, sg_bandwidth_factor * bandwidth, bandwidth, latency, policy); } void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) @@ -400,18 +396,20 @@ 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, double lat_initial, + double bandwidth, double latency, 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; + m_bandwidth.peak = bandwidth; m_latency.scale = 1.0; - m_latency.peak = lat_initial; + m_latency.peak = latency; if (policy == SURF_LINK_FATPIPE) lmm_constraint_shared(getConstraint()); + + Link::onCreation(this); } diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 098563e4da..9afea8fa98 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -59,7 +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, double lat_initial, + double constraint_value, double bandwidth, double latency, e_surf_link_sharing_policy_t policy); void apply_event(tmgr_trace_iterator_t event, double value) override; diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 6034eaeea1..9c14062a5e 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -185,6 +185,9 @@ namespace simgrid { : Resource(model, name, constraint), PropertyHolder(props) { + if (strcmp(name,"__loopback__")) + xbt_assert(!Link::byName(name), "Link '%s' declared several times in the platform.", name); + m_latency.scale = 1; m_bandwidth.scale = 1; diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 3064e7dc78..59a28ea24b 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -260,13 +260,10 @@ NetworkNS3Model::~NetworkNS3Model() { Link* NetworkNS3Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, xbt_dict_t properties){ - Link* link = new LinkNS3(this, name, properties, bandwidth, latency); - Link::onCreation(link); - return link; + return new LinkNS3(this, name, properties, bandwidth, latency); } -Action *NetworkNS3Model::communicate(NetCard *src, NetCard *dst, - double size, double rate) +Action *NetworkNS3Model::communicate(NetCard *src, NetCard *dst, double size, double rate) { XBT_DEBUG("Communicate from %s to %s", src->name(), dst->name()); NetworkNS3Action *action = new NetworkNS3Action(this, size, 0); @@ -369,6 +366,8 @@ LinkNS3::LinkNS3(NetworkNS3Model *model, const char *name, xbt_dict_t props, dou { m_bandwidth.peak = bandwidth; m_latency.peak = latency; + + Link::onCreation(this); } LinkNS3::~LinkNS3() diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 9c70b312e4..0f34db8807 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -258,8 +258,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t*host_list, xbt_free(host_list); } -Action *NetworkL07Model::communicate(NetCard *src, NetCard *dst, - double size, double rate) +Action *NetworkL07Model::communicate(NetCard *src, NetCard *dst, double size, double rate) { sg_host_t*host_list = xbt_new0(sg_host_t, 2); double *flops_amount = xbt_new0(double, 2); @@ -280,11 +279,7 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, xbt_dynar_t speedsList, i 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, bandwidth, latency, policy); - Link::onCreation(link); - return link; + return new LinkL07(this, name, properties, bandwidth, latency, policy); } /************ @@ -310,6 +305,8 @@ LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, dou if (policy == SURF_LINK_FATPIPE) lmm_constraint_shared(getConstraint()); + + Link::onCreation(this); } Action *CpuL07::execution_start(double size) -- 2.20.1