Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Remove sg_ callbacks for AS
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 1 Dec 2015 14:13:53 +0000 (15:13 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 1 Dec 2015 15:42:10 +0000 (16:42 +0100)
src/include/simgrid/platf_interface.h
src/include/surf/surf.h
src/surf/instr_routing.cpp
src/surf/network_ns3.cpp
src/surf/sg_platf.cpp
src/surf/surf_private.h
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp

index 5f1ee7a..4d1939a 100644 (file)
@@ -54,8 +54,6 @@ XBT_PUBLIC(void) sg_platf_peer_add_cb(sg_platf_peer_cb_t fct);
 XBT_PUBLIC(void) sg_platf_cluster_add_cb(sg_platf_cluster_cb_t fct);
 XBT_PUBLIC(void) sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct);
 XBT_PUBLIC(void) sg_platf_postparse_add_cb(void_f_void_t fct);
-XBT_PUBLIC(void) sg_platf_AS_begin_add_cb(sg_platf_AS_cb_t fct);
-XBT_PUBLIC(void) sg_platf_AS_end_add_cb(sg_platf_AS_cb_t fct);
 XBT_PUBLIC(void) sg_platf_prop_add_cb(sg_platf_prop_cb_t fct);
 
 XBT_PUBLIC(void) sg_platf_route_add_cb(sg_platf_route_cb_t);
index 4f9979b..a6bb939 100644 (file)
@@ -1164,11 +1164,9 @@ int instr_platform_traced (void);
 xbt_graph_t instr_routing_platform_graph (void);
 void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
 
-XBT_PRIVATE void sg_instr_new_router(sg_platf_router_cbarg_t router);
-
 /********** Routing **********/
 void routing_AS_begin(sg_platf_AS_cbarg_t AS);
-void routing_AS_end(sg_platf_AS_cbarg_t AS);
+void routing_AS_end(void);
 RoutingEdge *routing_add_host(As* as, sg_platf_host_cbarg_t host);
 void routing_cluster_add_backbone(void* bb);
 As* routing_get_current();
index b737e87..05a4706 100644 (file)
@@ -165,7 +165,7 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
 /*
  * Callbacks
  */
-static void instr_routing_parse_start_AS (sg_platf_AS_cbarg_t AS)
+void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS)
 {
   const char*id = AS->id;
 
@@ -200,7 +200,7 @@ static void instr_routing_parse_start_AS (sg_platf_AS_cbarg_t AS)
   }
 }
 
-static void instr_routing_parse_end_AS (sg_platf_AS_cbarg_t)
+void sg_instr_AS_end()
 {
   if (TRACE_needs_platform()){
     xbt_dynar_pop_ptr (currentContainer);
@@ -342,8 +342,6 @@ void instr_routing_define_callbacks ()
   if (!TRACE_is_enabled()) return;
   //always need the call backs to ASes (we need only the root AS),
   //to create the rootContainer and the rootType properly
-  sg_platf_AS_begin_add_cb(instr_routing_parse_start_AS);
-  sg_platf_AS_end_add_cb(instr_routing_parse_end_AS);
   if (!TRACE_needs_platform()) return;
   sg_platf_link_add_cb(instr_routing_parse_start_link);
   sg_platf_host_add_cb(instr_routing_parse_start_host);
index 2ef3c94..56361f7 100644 (file)
@@ -79,14 +79,11 @@ static void simgrid_ns3_add_router(RoutingEdge* router)
     );
 }
 
-static void parse_ns3_add_AS(sg_platf_AS_cbarg_t AS)
+static void parse_ns3_add_AS(As* as)
 {
-  XBT_DEBUG("NS3_ADD_AS '%s'",AS->id);
-  xbt_lib_set(as_router_lib,
-              AS->id,
-              NS3_ASR_LEVEL,
-              ns3_add_AS(AS->id)
-    );
+  const char* as_id = as->p_name;
+  XBT_DEBUG("NS3_ADD_AS '%s'", as_id);
+  xbt_lib_set(as_router_lib, as_id, NS3_ASR_LEVEL, ns3_add_AS(as_id) );
 }
 
 static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster)
@@ -247,7 +244,9 @@ static void define_callbacks_ns3(void)
   routingEdgeCreatedCallbacks.connect(simgrid_ns3_add_router);
   sg_platf_link_add_cb (&parse_ns3_add_link);
   sg_platf_cluster_add_cb (&parse_ns3_add_cluster);
-  sg_platf_AS_begin_add_cb (&parse_ns3_add_AS);
+
+  asCreatedCallbacks.connect(parse_ns3_add_AS);
+
   sg_platf_postparse_add_cb(&create_ns3_topology); //get_one_link_routes
   sg_platf_postparse_add_cb(&parse_ns3_end_platform); //InitializeRoutes
 }
index d2af7bb..460886a 100644 (file)
@@ -11,6 +11,7 @@
 #include "xbt/RngStream.h"
 #include "simgrid/platf_interface.h"
 #include "surf/surf_routing.h"
+#include "surf/surf.h"
 
 #include "src/simix/smx_private.h"
 
@@ -24,8 +25,6 @@ xbt_dynar_t sg_platf_link_cb_list = NULL;   // of sg_platf_link_cb_t
 xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t
 xbt_dynar_t sg_platf_cluster_cb_list = NULL; // of sg_platf_cluster_cb_t
 xbt_dynar_t sg_platf_cabinet_cb_list = NULL; // of sg_platf_cluster_cb_t
-xbt_dynar_t sg_platf_AS_begin_cb_list = NULL; //of sg_platf_AS_begin_cb_t
-xbt_dynar_t sg_platf_AS_end_cb_list = NULL; //of void_f_void_t
 xbt_dynar_t sg_platf_postparse_cb_list = NULL; // of void_f_void_t
 xbt_dynar_t sg_platf_prop_cb_list = NULL; // of sg_platf_prop_cb_t
 
@@ -63,8 +62,6 @@ void sg_platf_init(void) {
   sg_platf_cluster_cb_list = xbt_dynar_new(sizeof(sg_platf_cluster_cb_t), NULL);
   sg_platf_cabinet_cb_list = xbt_dynar_new(sizeof(sg_platf_cabinet_cb_t), NULL);
   sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t),NULL);
-  sg_platf_AS_begin_cb_list = xbt_dynar_new(sizeof(sg_platf_AS_cb_t),NULL);
-  sg_platf_AS_end_cb_list = xbt_dynar_new(sizeof(sg_platf_AS_cb_t),NULL);
   sg_platf_prop_cb_list = xbt_dynar_new(sizeof(sg_platf_prop_cb_t),NULL);
 
   sg_platf_route_cb_list = xbt_dynar_new(sizeof(sg_platf_route_cb_t), NULL);
@@ -90,8 +87,6 @@ void sg_platf_exit(void) {
   xbt_dynar_free(&sg_platf_peer_cb_list);
   xbt_dynar_free(&sg_platf_cluster_cb_list);
   xbt_dynar_free(&sg_platf_cabinet_cb_list);
-  xbt_dynar_free(&sg_platf_AS_begin_cb_list);
-  xbt_dynar_free(&sg_platf_AS_end_cb_list);
   xbt_dynar_free(&sg_platf_prop_cb_list);
 
   xbt_dynar_free(&sg_platf_trace_cb_list);
@@ -506,11 +501,9 @@ void sg_platf_end() {
   }
 }
 
-void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS) {
-  unsigned int iterator;
-  sg_platf_AS_cb_t fun;
-
-  if (!surf_parse_models_setup_already_called && !xbt_dynar_is_empty(sg_platf_AS_begin_cb_list)) {
+void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS)
+{
+  if (!surf_parse_models_setup_already_called) {
     /* Initialize the surf models. That must be done after we got all config, and before we need the models.
      * That is, after the last <config> tag, if any, and before the first of cluster|peer|AS|trace|trace_connect
      *
@@ -518,26 +511,30 @@ void sg_platf_new_AS_begin(sg_platf_AS_cbarg_t AS) {
      * (FIXME: check it out by creating a file beginning with one of these tags)
      * but cluster and peer create ASes internally, so putting the code in there is ok.
      *
-     * We are also guarding against xbt_dynar_length(sg_platf_AS_begin_cb_list) because we don't
-     * want to initialize the models if we are parsing the file to get the deployment. That could happen if
-     * the same file would be used for platf and deploy: it'd contain AS tags even during the deploy parsing.
-     * Removing that guard would result of the models to get re-inited when parsing for deploy.
+     * TODO, There used to be a guard protecting here against
+     * xbt_dynar_length(sg_platf_AS_begin_cb_list) because we don't want to
+     * initialize the models if we are parsing the file to get the deployment.
+     * That could happen if the same file would be used for platf and deploy:
+     * it'd contain AS tags even during the deploy parsing. Removing that guard
+     * would result of the models to get re-inited when parsing for deploy.
+     * Currently using the same file for platform and deployment is broken
+     * however. This guard will have to ba adapted in order to make this feature
+     * work again.
      */
     surf_parse_models_setup_already_called = 1;
     surf_config_models_setup();
   }
 
-  xbt_dynar_foreach(sg_platf_AS_begin_cb_list, iterator, fun) {
-    fun(AS);
-  }
+  routing_AS_begin(AS);
+  if (TRACE_is_enabled())
+    sg_instr_AS_begin(AS);
 }
 
-void sg_platf_new_AS_end() {
-  unsigned int iterator;
-  void_f_void_t fun;
-  xbt_dynar_foreach(sg_platf_AS_end_cb_list, iterator, fun) {
-    fun();
-  }
+void sg_platf_new_AS_end()
+{
+  routing_AS_end();
+  if (TRACE_is_enabled())
+    sg_instr_AS_end();
 }
 
 /* ***************************************** */
@@ -579,12 +576,6 @@ void sg_platf_cabinet_add_cb(sg_platf_cabinet_cb_t fct) {
 void sg_platf_postparse_add_cb(void_f_void_t fct) {
   xbt_dynar_push(sg_platf_postparse_cb_list, &fct);
 }
-void sg_platf_AS_begin_add_cb(sg_platf_AS_cb_t fct) {
-  xbt_dynar_push(sg_platf_AS_begin_cb_list, &fct);
-}
-void sg_platf_AS_end_add_cb(sg_platf_AS_cb_t fct) {
-  xbt_dynar_push(sg_platf_AS_end_cb_list, &fct);
-}
 void sg_platf_route_add_cb(sg_platf_route_cb_t fct) {
   xbt_dynar_push(sg_platf_route_cb_list, &fct);
 }
index ad73b45..a985c26 100644 (file)
@@ -97,6 +97,12 @@ XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
 void TRACE_surf_host_set_power(double date, const char *resource, double power);
 void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth);
 
+/********** Instr. **********/
+
+XBT_PRIVATE void sg_instr_AS_begin(sg_platf_AS_cbarg_t AS);
+XBT_PRIVATE void sg_instr_new_router(sg_platf_router_cbarg_t router);
+XBT_PRIVATE void sg_instr_AS_end(void);
+
 SG_END_DECL()
 
 #endif                          /* _SURF_SURF_PRIVATE_H */
index bea4474..3e2f45f 100644 (file)
@@ -21,6 +21,7 @@
  *************/
 
 surf_callback(void, RoutingEdge*) routingEdgeCreatedCallbacks;
+surf_callback(void, As*) asCreatedCallbacks;
 
 /**
  * @ingroup SURF_build_api
@@ -375,11 +376,12 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
               (void *) info);
   XBT_DEBUG("Having set name '%s' id '%d'", new_as->p_name, info->getId());
 
-  routingEdgeCreatedCallbacks(info);
-
   /* set the new current component of the tree */
   current_routing = new_as;
   current_routing->p_netElem = info;
+
+  routingEdgeCreatedCallbacks(info);
+  asCreatedCallbacks(new_as);
 }
 
 /**
@@ -393,7 +395,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
  * even if you add stuff to a closed AS
  *
  */
-void routing_AS_end(sg_platf_AS_cbarg_t /*AS*/)
+void routing_AS_end()
 {
 
   if (current_routing == NULL) {
@@ -1262,10 +1264,6 @@ void routing_register_callbacks()
   sg_platf_postparse_add_cb(routing_parse_postparse);
   sg_platf_postparse_add_cb(check_disk_attachment);
 
-  /* we care about the ASes while parsing the platf. Incredible, isnt it? */
-  sg_platf_AS_end_add_cb(routing_AS_end);
-  sg_platf_AS_begin_add_cb(routing_AS_begin);
-
   sg_platf_trace_add_cb(routing_parse_trace);
   sg_platf_trace_connect_add_cb(routing_parse_trace_connect);
 
index b698f4c..0a4fe65 100644 (file)
@@ -162,5 +162,6 @@ public:
  *************/
 
 XBT_PUBLIC_DATA(surf_callback(void, RoutingEdge*)) routingEdgeCreatedCallbacks;
+XBT_PUBLIC_DATA(surf_callback(void, As*)) asCreatedCallbacks;
 
 #endif /* NETWORK_ROUTING_HPP_ */