Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
empty the link factories
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 19 Mar 2016 21:58:16 +0000 (22:58 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 20 Mar 2016 00:01:28 +0000 (01:01 +0100)
src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_interface.cpp
src/surf/network_ns3.cpp
src/surf/ptask_L07.cpp

index a9df4e7..0c5fc8c 100644 (file)
@@ -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)
 {
 
 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*/)
 }
 
 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,
 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;
     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.scale = 1.0;
-  m_latency.peak = lat_initial;
+  m_latency.peak = latency;
 
   if (policy == SURF_LINK_FATPIPE)
     lmm_constraint_shared(getConstraint());
 
   if (policy == SURF_LINK_FATPIPE)
     lmm_constraint_shared(getConstraint());
+
+  Link::onCreation(this);
 }
 
 
 }
 
 
index 098563e..9afea8f 100644 (file)
@@ -59,7 +59,7 @@ namespace simgrid {
     public:
       NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props,
           lmm_system_t system,
     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;
           e_surf_link_sharing_policy_t policy);
 
       void apply_event(tmgr_trace_iterator_t event, double value) override;
index 6034eae..9c14062 100644 (file)
@@ -185,6 +185,9 @@ namespace simgrid {
     : Resource(model, name, constraint),
       PropertyHolder(props)
     {
     : 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;
 
       m_latency.scale = 1;
       m_bandwidth.scale = 1;
 
index 3064e7d..59a28ea 100644 (file)
@@ -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* 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);
 {
   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;
 {
   m_bandwidth.peak = bandwidth;
   m_latency.peak = latency;
+
+  Link::onCreation(this);
 }
 
 LinkNS3::~LinkNS3()
 }
 
 LinkNS3::~LinkNS3()
index 9c70b31..0f34db8 100644 (file)
@@ -258,8 +258,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t*host_list,
   xbt_free(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);
 {
   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)
 {
 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());
 
   if (policy == SURF_LINK_FATPIPE)
     lmm_constraint_shared(getConstraint());
+
+  Link::onCreation(this);
 }
 
 Action *CpuL07::execution_start(double size)
 }
 
 Action *CpuL07::execution_start(double size)