Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make the rest of trace:connect private to the XML parsing
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 8 Feb 2016 10:43:32 +0000 (11:43 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 8 Feb 2016 10:43:32 +0000 (11:43 +0100)
src/surf/cpu_interface.hpp
src/surf/host_ptask_L07.cpp
src/surf/network_cm02.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/surf_interface.hpp
src/surf/surfxml_parseplatf.cpp

index d565730..6e8e71a 100644 (file)
@@ -163,8 +163,8 @@ public:
   void **p_constraintCoreId=NULL;
 
 public:
   void **p_constraintCoreId=NULL;
 
 public:
-  virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF) */
-  virtual void set_speed_trace(tmgr_trace_t trace); /*< setup the trace file with availability events (peak speed changes due to external load) */
+  virtual void set_state_trace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain boolean values (0 or 1). */
+  virtual void set_speed_trace(tmgr_trace_t trace); /*< setup the trace file with availability events (peak speed changes due to external load). Trace must contain relative values (ratio between 0 and 1) */
 
   tmgr_trace_iterator_t p_stateEvent = nullptr;
   s_surf_metric_t p_speed = {1.0, 0, nullptr};
 
   tmgr_trace_iterator_t p_stateEvent = nullptr;
   s_surf_metric_t p_speed = {1.0, 0, nullptr};
index bc73ae6..c062c50 100644 (file)
@@ -36,9 +36,6 @@ void surf_host_model_init_ptask_L07(void)
 
   // Define the callbacks to parse the XML
   simgrid::surf::on_link.connect(ptask_netlink_parse_init);
 
   // Define the callbacks to parse the XML
   simgrid::surf::on_link.connect(ptask_netlink_parse_init);
-  simgrid::surf::on_postparse.connect([](){
-      surf_host_model->addTraces();
-  });
 
   surf_host_model = new simgrid::surf::HostL07Model();
   xbt_dynar_push(all_existing_models, &surf_host_model);
 
   surf_host_model = new simgrid::surf::HostL07Model();
   xbt_dynar_push(all_existing_models, &surf_host_model);
@@ -334,42 +331,7 @@ Link* NetworkL07Model::createLink(const char *name,
 
 void HostL07Model::addTraces()
 {
 
 void HostL07Model::addTraces()
 {
-  xbt_dict_cursor_t cursor = NULL;
-  char *trace_name, *elm;
-
-  if (!trace_connect_list_link_avail)
-    return;
-
-  /* Connect traces relative to network */
-  xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
-
-    xbt_assert(link, "Link %s undefined", elm);
-    xbt_assert(trace, "Trace %s undefined", trace_name);
-
-    link->m_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
-  }
-
-  xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
-
-    xbt_assert(link, "Link %s undefined", elm);
-    xbt_assert(trace, "Trace %s undefined", trace_name);
-
-    link->m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, link);
-  }
-
-  xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    LinkL07 *link = static_cast<LinkL07*>(Link::byName(elm));
-
-    xbt_assert(link, "Link %s undefined", elm);
-    xbt_assert(trace, "Trace %s undefined", trace_name);
-
-    link->m_latency.event = future_evt_set->add_trace(trace, 0.0, link);
-  }
+  THROW_DEADCODE;
 }
 
 /************
 }
 
 /************
index c19dbfd..9322e1b 100644 (file)
@@ -29,9 +29,6 @@ void net_define_callbacks(void)
 {
   /* Figuring out the network links */
   simgrid::surf::on_link.connect(netlink_parse_init);
 {
   /* Figuring out the network links */
   simgrid::surf::on_link.connect(netlink_parse_init);
-  simgrid::surf::on_postparse.connect([]() {
-    surf_network_model->addTraces();
-  });
 }
 
 /*********
 }
 
 /*********
@@ -458,53 +455,7 @@ Action *NetworkCm02Model::communicate(NetCard *src, NetCard *dst,
 }
 
 void NetworkCm02Model::addTraces(){
 }
 
 void NetworkCm02Model::addTraces(){
-  xbt_dict_cursor_t cursor = NULL;
-  char *trace_name, *elm;
-
-  static int called = 0;
-  if (called)
-    return;
-  called = 1;
-
-  /* connect all traces relative to network */
-  xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    NetworkCm02Link *link = static_cast<NetworkCm02Link*>( Link::byName(elm) );
-
-    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
-               trace_name, elm);
-    xbt_assert(trace,
-               "Cannot connect trace %s to link %s: trace undefined",
-               trace_name, elm);
-
-    link->m_stateEvent = future_evt_set->add_trace(trace, 0.0, link);
-  }
-
-  xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    NetworkCm02Link *link = static_cast<NetworkCm02Link*>( Link::byName(elm) );
-
-    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
-               trace_name, elm);
-    xbt_assert(trace,
-               "Cannot connect trace %s to link %s: trace undefined",
-               trace_name, elm);
-
-    link->m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, link);
-  }
-
-  xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
-    tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
-    NetworkCm02Link *link = static_cast<NetworkCm02Link*>(Link::byName(elm));;
-
-    xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
-               trace_name, elm);
-    xbt_assert(trace,
-               "Cannot connect trace %s to link %s: trace undefined",
-               trace_name, elm);
-
-    link->m_latency.event = future_evt_set->add_trace(trace, 0.0, link);
-  }
+THROW_DEADCODE;
 }
 
 /************
 }
 
 /************
index 4489f8a..547145b 100644 (file)
@@ -266,6 +266,25 @@ void Link::turnOff(){
     onStateChange(this);
   }
 }
     onStateChange(this);
   }
 }
+void Link::set_state_trace(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)
+{
+  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)
+{
+  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);
+}
+
 
 /**********
  * Action *
 
 /**********
  * Action *
index 2b94aaf..ca9f7e1 100644 (file)
@@ -235,6 +235,10 @@ public:
   void turnOn() override;
   void turnOff() override;
 
   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 */
+
   tmgr_trace_iterator_t m_stateEvent = NULL;
   s_surf_metric_t m_latency = {1.0,0,NULL};
   s_surf_metric_t m_bandwidth = {1.0,0,NULL};
   tmgr_trace_iterator_t m_stateEvent = NULL;
   s_surf_metric_t m_latency = {1.0,0,NULL};
   s_surf_metric_t m_bandwidth = {1.0,0,NULL};
index ebbf7a8..1635966 100644 (file)
@@ -71,9 +71,6 @@ enum heap_action_type{
  *********/
 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
  *********/
 /* For the trace and trace:connect tag (store their content till the end of the parsing) */
 XBT_PUBLIC_DATA(xbt_dict_t) traces_set_list;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_avail;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_bw;
-XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_link_lat;
 
 /**********
  * Action *
 
 /**********
  * Action *
index 51ce41a..ead4804 100644 (file)
@@ -10,7 +10,7 @@
 #include "xbt/dict.h"
 #include "simgrid/platf.h"
 #include "src/surf/cpu_interface.hpp"
 #include "xbt/dict.h"
 #include "simgrid/platf.h"
 #include "src/surf/cpu_interface.hpp"
-#include "src/surf/surf_private.h"
+#include "src/surf/network_interface.hpp"
 #include "src/surf/surfxml_private.h"
 
 #ifdef HAVE_LUA
 #include "src/surf/surfxml_private.h"
 
 #ifdef HAVE_LUA
@@ -64,11 +64,11 @@ void surfxml_bufferstack_pop(int new_one)
  */
 
 xbt_dict_t traces_set_list = NULL;
  */
 
 xbt_dict_t traces_set_list = NULL;
-xbt_dict_t trace_connect_list_host_avail = NULL;
-xbt_dict_t trace_connect_list_host_speed = NULL;
-xbt_dict_t trace_connect_list_link_avail = NULL;
-xbt_dict_t trace_connect_list_link_bw = NULL;
-xbt_dict_t trace_connect_list_link_lat = NULL;
+XBT_PRIVATE xbt_dict_t trace_connect_list_host_avail = NULL;
+XBT_PRIVATE xbt_dict_t trace_connect_list_host_speed = NULL;
+XBT_PRIVATE xbt_dict_t trace_connect_list_link_avail = NULL;
+XBT_PRIVATE xbt_dict_t trace_connect_list_link_bw = NULL;
+XBT_PRIVATE xbt_dict_t trace_connect_list_link_lat = NULL;
 
 void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect)
 {
 
 void sg_platf_trace_connect(sg_platf_trace_connect_cbarg_t trace_connect)
 {
@@ -201,7 +201,29 @@ void parse_platform_file(const char *file)
 
       cpu->set_speed_trace(trace);
     }
 
       cpu->set_speed_trace(trace);
     }
+    xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
+      tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+      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);
+    }
+
+    xbt_dict_foreach(trace_connect_list_link_bw, cursor, trace_name, elm) {
+      tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+      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);
+    }
 
 
+    xbt_dict_foreach(trace_connect_list_link_lat, cursor, trace_name, elm) {
+      tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+      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);
+    }
 
     /* Free my data */
     xbt_dict_free(&trace_connect_list_host_avail);
 
     /* Free my data */
     xbt_dict_free(&trace_connect_list_host_avail);