From 892c5381a1e84836f326457f4740ae60844f074c Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 13 Nov 2016 11:54:57 +0100 Subject: [PATCH] don't give the properties to the Link constructor either --- src/surf/network_cm02.cpp | 14 +++++++------- src/surf/network_cm02.hpp | 9 ++++----- src/surf/network_constant.cpp | 11 ++++++----- src/surf/network_constant.hpp | 2 +- src/surf/network_interface.cpp | 4 ++-- src/surf/network_interface.hpp | 7 +++---- src/surf/network_ns3.cpp | 12 ++++++------ src/surf/network_ns3.hpp | 5 ++--- src/surf/ptask_L07.cpp | 12 ++++++------ src/surf/ptask_L07.hpp | 8 +++----- src/surf/sg_platf.cpp | 10 +++++++++- 11 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 0824bdb5fa..3a27f59086 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -153,7 +153,7 @@ NetworkCm02Model::NetworkCm02Model() maxminSystem_ = lmm_system_new(selectiveUpdate_); - routing_model_create(createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, nullptr)); + routing_model_create(createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE)); if (updateMechanism_ == UM_LAZY) { actionHeap_ = xbt_heap_new(8, nullptr); @@ -171,10 +171,10 @@ NetworkCm02Model::NetworkCm02Model(void (*specificSolveFun)(lmm_system_t self)) NetworkCm02Model::~NetworkCm02Model() {} -Link* NetworkCm02Model::createLink(const char *name, double bandwidth, double latency, 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) { - return new NetworkCm02Link(this, name, properties, bandwidth, latency, policy, maxminSystem_); + return new NetworkCm02Link(this, name, bandwidth, latency, policy, maxminSystem_); } void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) @@ -395,9 +395,9 @@ void NetworkCm02Model::gapAppend(double size, const Link* link, NetworkAction* a /************ * Resource * ************/ -NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, xbt_dict_t props, double bandwidth, - double latency, e_surf_link_sharing_policy_t policy, lmm_system_t system) - : Link(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth), props) +NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy, lmm_system_t system) + : Link(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth)) { bandwidth_.scale = 1.0; bandwidth_.peak = bandwidth; diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 27e419b37d..e231d3a497 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -41,8 +41,8 @@ namespace simgrid { NetworkCm02Model(); explicit NetworkCm02Model(void (*solve_fun)(lmm_system_t self)); virtual ~NetworkCm02Model(); - Link* createLink(const char *name, double bandwidth, double latency, 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) override; void updateActionsStateLazy(double now, double delta) override; void updateActionsStateFull(double now, double delta) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; @@ -57,9 +57,8 @@ namespace simgrid { class NetworkCm02Link : public Link { public: - NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props, - double bandwidth, double latency, e_surf_link_sharing_policy_t policy, - lmm_system_t system); + NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy, lmm_system_t system); ~NetworkCm02Link() override; void apply_event(tmgr_trace_iterator_t event, double value) override; void setBandwidth(double value) override; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 4581f26aec..f349fbdf18 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -22,12 +22,13 @@ void surf_network_model_init_Constant() namespace simgrid { namespace surf { - Link* NetworkConstantModel::createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy, - xbt_dict_t properties) { + Link* NetworkConstantModel::createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy) + { - xbt_die("Refusing to create the link %s: there is no link in the Constant network model. " - "Please remove any link from your platform (and switch to routing='None')", name); - return nullptr; + xbt_die("Refusing to create the link %s: there is no link in the Constant network model. " + "Please remove any link from your platform (and switch to routing='None')", + name); + return nullptr; } double NetworkConstantModel::nextOccuringEvent(double /*now*/) diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index 58e8ce97a6..ffb165990a 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -30,7 +30,7 @@ namespace simgrid { double nextOccuringEvent(double now) override; void updateActionsState(double now, double delta) override; - Link* createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override; + Link* createLink(const char* name, double bw, double lat, e_surf_link_sharing_policy_t policy) override; }; /********** diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 493b71bb2b..89819e142c 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -147,8 +147,8 @@ namespace simgrid { * Resource * ************/ - Link::Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint, xbt_dict_t props) - : Resource(model, name, constraint), PropertyHolder(props) + Link::Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint) + : Resource(model, name, constraint), PropertyHolder(nullptr) { if (strcmp(name,"__loopback__")) xbt_assert(!Link::byName(name), "Link '%s' declared several times in the platform.", name); diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 1354e73acc..afeadcb6c3 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -60,10 +60,9 @@ namespace simgrid { * @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 props Dictionary of properties associated to this Link */ - virtual Link* createLink(const char *name, double bandwidth, double latency, - 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) = 0; /** * @brief Create a communication between two hosts. @@ -135,7 +134,7 @@ namespace simgrid { public: /** @brief Constructor of LMM links */ - Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint, xbt_dict_t props); + Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint); /* Link destruction logic */ /**************************/ diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index d4b933be5b..267b726d18 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -193,10 +193,10 @@ NetworkNS3Model::~NetworkNS3Model() { xbt_dict_free(&flowFromSock); } -Link* NetworkNS3Model::createLink(const char *name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy, - xbt_dict_t properties){ - - return new LinkNS3(this, name, properties, bandwidth, latency); +Link* NetworkNS3Model::createLink(const char* name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy) +{ + return new LinkNS3(this, name, bandwidth, latency); } Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) @@ -283,8 +283,8 @@ void NetworkNS3Model::updateActionsState(double now, double delta) * Resource * ************/ -LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, xbt_dict_t props, double bandwidth, double latency) - : Link(model, name, nullptr, props) +LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency) + : Link(model, name, nullptr) { bandwidth_.peak = bandwidth; latency_.peak = latency; diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 75e414e589..b1162b3c1d 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -19,8 +19,7 @@ class NetworkNS3Model : public NetworkModel { public: NetworkNS3Model(); ~NetworkNS3Model(); - Link* createLink(const char *name, double bandwidth, double latency, - 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) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; double nextOccuringEvent(double now) override; bool nextOccuringEventIsIdempotent() {return false;} @@ -32,7 +31,7 @@ public: ************/ class LinkNS3 : public Link { public: - LinkNS3(NetworkNS3Model *model, const char *name, xbt_dict_t props, double bandwidth, double latency); + explicit LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency); ~LinkNS3(); void apply_event(tmgr_trace_iterator_t event, double value) override; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 33f500d6ed..caee551396 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -41,7 +41,7 @@ HostL07Model::HostL07Model() : HostModel() { surf_network_model = new NetworkL07Model(this,maxminSystem_); surf_cpu_model_pm = new CpuL07Model(this,maxminSystem_); - routing_model_create(surf_network_model->createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE, nullptr)); + routing_model_create(surf_network_model->createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE)); } HostL07Model::~HostL07Model() = default; @@ -249,10 +249,10 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host, std::vector *spee return new CpuL07(this, host, speedPerPstate, core); } -Link* NetworkL07Model::createLink(const char *name, double bandwidth, double latency, - e_surf_link_sharing_policy_t policy, xbt_dict_t properties) +Link* NetworkL07Model::createLink(const char* name, double bandwidth, double latency, + e_surf_link_sharing_policy_t policy) { - return new LinkL07(this, name, properties, bandwidth, latency, policy); + return new LinkL07(this, name, bandwidth, latency, policy); } /************ @@ -267,9 +267,9 @@ CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector CpuL07::~CpuL07()=default; -LinkL07::LinkL07(NetworkL07Model* model, const char* name, xbt_dict_t props, double bandwidth, double latency, +LinkL07::LinkL07(NetworkL07Model* model, const char* name, double bandwidth, double latency, e_surf_link_sharing_policy_t policy) - : Link(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth), props) + : Link(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth)) { bandwidth_.peak = bandwidth; latency_.peak = latency; diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 78127ce28b..1b04286973 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -58,9 +58,7 @@ class NetworkL07Model : public NetworkModel { public: NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys); ~NetworkL07Model(); - Link* createLink(const char *name, double bandwidth, double latency, - 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) override; Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; @@ -85,8 +83,8 @@ protected: class LinkL07 : public Link { public: - LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, - double bandwidth, double latency, e_surf_link_sharing_policy_t policy); + LinkL07(NetworkL07Model* model, const char* name, 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/sg_platf.cpp b/src/surf/sg_platf.cpp index 82dde2f05d..cb5a0d4b41 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -158,7 +158,15 @@ void sg_platf_new_link(sg_platf_link_cbarg_t link){ names.push_back(xbt_strdup(link->id)); } for (auto link_name : names) { - Link *l = surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy, link->properties); + Link* l = surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy); + + if (link->properties) { + xbt_dict_cursor_t cursor = nullptr; + char *key, *data; + xbt_dict_foreach (link->properties, cursor, key, data) + l->setProperty(key, data); + xbt_dict_free(&link->properties); + } if (link->latency_trace) l->setLatencyTrace(link->latency_trace); -- 2.20.1