Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove the state trace from the Link constructor
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Mar 2016 20:30:50 +0000 (21:30 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Mar 2016 20:30:56 +0000 (21:30 +0100)
use setStateTrace() after creation.

src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_constant.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp
src/surf/network_ns3.hpp
src/surf/ptask_L07.cpp
src/surf/ptask_L07.hpp

index 35dae59..a9e78ee 100644 (file)
@@ -163,7 +163,6 @@ NetworkCm02Model::NetworkCm02Model()
 
   routing_model_create(createLink("__loopback__",
                                 498000000, NULL, 0.000015, NULL,
-                                NULL,
                                 SURF_LINK_FATPIPE, NULL));
 
   if (p_updateMechanism == UM_LAZY) {
@@ -177,7 +176,6 @@ NetworkCm02Model::NetworkCm02Model()
 Link* NetworkCm02Model::createLink(const char *name,
     double bw_initial, tmgr_trace_t bw_trace,
     double lat_initial, tmgr_trace_t lat_trace,
-    tmgr_trace_t state_trace,
     e_surf_link_sharing_policy_t policy, xbt_dict_t properties)
 {
   xbt_assert(NULL == Link::byName(name),
@@ -185,7 +183,7 @@ Link* NetworkCm02Model::createLink(const char *name,
              name);
 
   Link* link = new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial,
-                     state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
+      bw_initial, bw_trace, lat_initial, lat_trace, policy);
   Link::onCreation(link);
   return link;
 }
@@ -410,11 +408,10 @@ 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,
-    tmgr_trace_t state_trace,
     double bw_peak, tmgr_trace_t bw_trace,
     double lat_initial, tmgr_trace_t lat_trace,
     e_surf_link_sharing_policy_t policy)
-: Link(model, name, props, lmm_constraint_new(system, this, constraint_value), state_trace)
+: Link(model, name, props, lmm_constraint_new(system, this, constraint_value))
 {
   m_bandwidth.scale = 1.0;
   m_bandwidth.peak = bw_peak;
index 6698295..d28defd 100644 (file)
@@ -43,7 +43,6 @@ namespace simgrid {
       Link* createLink(const char *name,
           double bw_initial, tmgr_trace_t bw_trace,
           double lat_initial, tmgr_trace_t lat_trace,
-          tmgr_trace_t state_trace,
           e_surf_link_sharing_policy_t policy,
           xbt_dict_t properties) override;
       void updateActionsStateLazy(double now, double delta) override;
@@ -64,7 +63,6 @@ namespace simgrid {
       NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props,
           lmm_system_t system,
           double constraint_value,
-          tmgr_trace_t state_trace,
           double bw_peak, tmgr_trace_t bw_trace,
           double lat_initial, tmgr_trace_t lat_trace,
           e_surf_link_sharing_policy_t policy);
index 60f166e..c3c23f0 100644 (file)
@@ -38,7 +38,6 @@ namespace simgrid {
       createLink(const char *name,
           double bw_initial, tmgr_trace_t bw_trace,
           double lat_initial, tmgr_trace_t lat_trace,
-          tmgr_trace_t state_trace,
           e_surf_link_sharing_policy_t policy,
           xbt_dict_t properties)          override { DIE_IMPOSSIBLE; }
     };
index d3ce07e..ed0dd21 100644 (file)
@@ -109,28 +109,35 @@ 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);
-    surf_network_model->createLink(link_id,
+    Link *l = surf_network_model->createLink(link_id,
         link->bandwidth,
         link->bandwidth_trace,
         link->latency,
         link->latency_trace,
-        link->state_trace, link->policy, link->properties);
+        link->policy, link->properties);
+    if (link->state_trace)
+      l->setStateTrace(link->state_trace);
+
     xbt_free(link_id);
     link_id = bprintf("%s_DOWN", link->id);
-    surf_network_model->createLink(link_id,
+    l = surf_network_model->createLink(link_id,
         link->bandwidth,
         link->bandwidth_trace,
         link->latency,
         link->latency_trace,
-        link->state_trace, link->policy, link->properties);
+        link->policy, link->properties);
+    if (link->state_trace)
+      l->setStateTrace(link->state_trace);
     xbt_free(link_id);
   } else {
-    surf_network_model->createLink(link->id,
+    Link *l=surf_network_model->createLink(link->id,
         link->bandwidth,
         link->bandwidth_trace,
         link->latency,
         link->latency_trace,
-        link->state_trace, link->policy, link->properties);
+        link->policy, link->properties);
+    if (link->state_trace)
+      l->setStateTrace(link->state_trace);
   }
 }
 
@@ -191,21 +198,22 @@ namespace simgrid {
       XBT_DEBUG("Create link '%s'",name);
     }
 
-    Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
-        lmm_constraint_t constraint,
-        tmgr_trace_t state_trace)
+    Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint)
     : Resource(model, name, constraint),
       PropertyHolder(props)
     {
       m_latency.scale = 1;
       m_bandwidth.scale = 1;
-      if (state_trace)
-        m_stateEvent = future_evt_set->add_trace(state_trace, 0.0, this);
 
       links->insert({name, this});
       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() {
index 0bda751..7bacd5a 100644 (file)
@@ -84,7 +84,6 @@ namespace simgrid {
        * @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 state_trace The trace associated to the Link (state)[e_surf_resource_state_t]
        * @param policy The sharing policy of the Link
        * @param properties Dictionary of properties associated to this Resource
        * @return The created Link
@@ -94,7 +93,6 @@ namespace simgrid {
           tmgr_trace_t bw_trace,
           double lat_initial,
           tmgr_trace_t lat_trace,
-          tmgr_trace_t state_trace,
           e_surf_link_sharing_policy_t policy,
           xbt_dict_t properties)=0;
 
@@ -183,11 +181,11 @@ namespace simgrid {
        * @param name The name of the Link
        * @param props Dictionary of properties associated to this Link
        * @param constraint The lmm constraint associated to this Cpu if it is part of a LMM component
-       * @param state_trace [TODO]
        */
-      Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props,
-          lmm_constraint_t constraint,
-          tmgr_trace_t state_trace);
+      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 */
       /**************************/
index f86ef2c..2072922 100644 (file)
@@ -40,10 +40,12 @@ static void parse_ns3_add_link(sg_platf_link_cbarg_t link)
   if(!IPV4addr)
     IPV4addr = xbt_dynar_new(sizeof(char*),free);
 
-  surf_network_model->createLink(link->id,
+  Link *l = surf_network_model->createLink(link->id,
       link->bandwidth, link->bandwidth_trace,
       link->latency, link->latency_trace,
-      link->state_trace, link->policy, link->properties);
+      link->policy, link->properties);
+  if (link->state_trace)
+    l->setStateTrace(link->state_trace);
 }
 
 static void simgrid_ns3_add_router(simgrid::surf::NetCard* router)
@@ -261,15 +263,13 @@ NetworkNS3Model::~NetworkNS3Model() {
 Link* NetworkNS3Model::createLink(const char *name,
     double bw_initial, tmgr_trace_t bw_trace,
     double lat_initial, tmgr_trace_t lat_trace,
-    tmgr_trace_t state_trace,
     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");
-  if (state_trace)
-    XBT_INFO("The NS3 network model doesn't support link state traces");
+
   Link* link = new NetworkNS3Link(this, name, properties, bw_initial, lat_initial);
   Link::onCreation(link);
   return link;
index 3807ebe..96b091e 100644 (file)
@@ -46,7 +46,6 @@ public:
   Link* createLink(const char *name,
       double bw_initial, tmgr_trace_t bw_trace,
       double lat_initial, tmgr_trace_t lat_trace,
-      tmgr_trace_t state_trace,
       e_surf_link_sharing_policy_t policy,
       xbt_dict_t properties) override;
   Action *communicate(NetCard *src, NetCard *dst, double size, double rate);
index d7cf81c..2179b17 100644 (file)
@@ -52,7 +52,6 @@ HostL07Model::HostL07Model() : HostModel() {
   routing_model_create(surf_network_model->createLink("__loopback__",
                                                     498000000, NULL,
                                                     0.000015, NULL,
-                                                    NULL,
                                                     SURF_LINK_FATPIPE, NULL));
 }
 
@@ -294,22 +293,14 @@ Cpu *CpuL07Model::createCpu(simgrid::s4u::Host *host,  xbt_dynar_t powerPeakList
 }
 
 Link* NetworkL07Model::createLink(const char *name,
-                                 double bw_initial,
-                                 tmgr_trace_t bw_trace,
-                                 double lat_initial,
-                                 tmgr_trace_t lat_trace,
-                                 tmgr_trace_t state_trace,
-                                 e_surf_link_sharing_policy_t policy,
-                                 xbt_dict_t properties)
+    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)
 {
   xbt_assert(!Link::byName(name),
-           "Link '%s' declared several times in the platform file.", 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,
-      state_trace,
-      policy);
+  Link* link = new LinkL07(this, name, properties, bw_initial, bw_trace, lat_initial, lat_trace, policy);
   Link::onCreation(link);
   return link;
 }
@@ -340,9 +331,8 @@ 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,
-             tmgr_trace_t state_trace,
              e_surf_link_sharing_policy_t policy)
- : Link(model, name, props, lmm_constraint_new(model->getMaxminSystem(), this, bw_initial), state_trace)
+ : Link(model, name, props, lmm_constraint_new(model->getMaxminSystem(), this, bw_initial))
 {
   m_bandwidth.peak = bw_initial;
   if (bw_trace)
index 74209df..c9faa75 100644 (file)
@@ -69,7 +69,6 @@ public:
       tmgr_trace_t bw_trace,
       double lat_initial,
       tmgr_trace_t lat_trace,
-      tmgr_trace_t state_trace,
       e_surf_link_sharing_policy_t policy,
       xbt_dict_t properties) override;
 
@@ -99,12 +98,9 @@ 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,
-          tmgr_trace_t state_trace,
-          e_surf_link_sharing_policy_t policy);
+      double bw_initial, tmgr_trace_t bw_trace,
+      double lat_initial, tmgr_trace_t lat_trace,
+      e_surf_link_sharing_policy_t policy);
   ~LinkL07(){ };
   bool isUsed() override;
   void apply_event(tmgr_trace_iterator_t event, double value) override;