Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] Change routing_parse_init() into routing_add_host()
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 27 Nov 2015 13:04:32 +0000 (14:04 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 27 Nov 2015 13:04:32 +0000 (14:04 +0100)
Do not depend on the parsing state in this function.

include/surf/surf_routing.h
src/include/surf/surf.h
src/surf/sg_platf.cpp
src/surf/surf_routing.cpp

index e4ddcd9..655b2b4 100644 (file)
@@ -33,13 +33,6 @@ XBT_PUBLIC_DATA(xbt_lib_t) file_lib;
 XBT_PUBLIC_DATA(xbt_lib_t) storage_type_lib;
 XBT_PUBLIC_DATA(int) ROUTING_STORAGE_TYPE_LEVEL;   //Routing storage_type level
 
 XBT_PUBLIC_DATA(xbt_lib_t) storage_type_lib;
 XBT_PUBLIC_DATA(int) ROUTING_STORAGE_TYPE_LEVEL;   //Routing storage_type level
 
-/* The callbacks to register for the routing to work */
-void routing_AS_begin(sg_platf_AS_cbarg_t AS);
-void routing_AS_end(sg_platf_AS_cbarg_t AS);
-
-void routing_parse_init(sg_platf_host_cbarg_t host);
-void routing_cluster_add_backbone(void* bb);
-
 SG_END_DECL()
 
 #endif                          /* _SURF_SURF_H */
 SG_END_DECL()
 
 #endif                          /* _SURF_SURF_H */
index a605c4c..38cebed 100644 (file)
@@ -1164,5 +1164,12 @@ 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_graph_t instr_routing_platform_graph (void);
 void instr_routing_platform_graph_export_graphviz (xbt_graph_t g, const char *filename);
 
+/********** Routing **********/
+void routing_AS_begin(sg_platf_AS_cbarg_t AS);
+void routing_AS_end(sg_platf_AS_cbarg_t AS);
+void routing_add_host(As* as, sg_platf_host_cbarg_t host);
+void routing_cluster_add_backbone(void* bb);
+As* routing_get_current();
+
 SG_END_DECL()
 #endif                          /* _SURF_SURF_H */
 SG_END_DECL()
 #endif                          /* _SURF_SURF_H */
index 3a35fcc..df16227 100644 (file)
@@ -137,7 +137,9 @@ void sg_platf_exit(void) {
 
 void sg_platf_new_host(sg_platf_host_cbarg_t host)
 {
 
 void sg_platf_new_host(sg_platf_host_cbarg_t host)
 {
-  routing_parse_init(host);
+  As* current_routing = routing_get_current();
+  if (current_routing)
+    routing_add_host(current_routing, host);
   surf_cpu_model_pm->createCpu(
         host->id,
         host->power_peak,
   surf_cpu_model_pm->createCpu(
         host->id,
         host->power_peak,
index a80a7f6..971df4c 100644 (file)
@@ -56,13 +56,19 @@ RoutingEdge *sg_routing_edge_by_name_or_null(const char *name) {
 
 /* Global vars */
 RoutingPlatf *routing_platf = NULL;
 
 /* Global vars */
 RoutingPlatf *routing_platf = NULL;
-As *current_routing = NULL;
 
 /* global parse functions */
 extern xbt_dynar_t mount_list;
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
 
 
 /* global parse functions */
 extern xbt_dynar_t mount_list;
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
 
+/** The current AS in the parsing */
+static As *current_routing = NULL;
+As* routing_get_current()
+{
+  return current_routing;
+}
+
 static void routing_parse_peer(sg_platf_peer_cbarg_t peer);     /* peer bypass */
 // static void routing_parse_Srandom(void);        /* random bypass */
 
 static void routing_parse_peer(sg_platf_peer_cbarg_t peer);     /* peer bypass */
 // static void routing_parse_Srandom(void);        /* random bypass */
 
@@ -140,11 +146,8 @@ static void parse_S_host(sg_platf_host_link_cbarg_t host)
 /**
  * \brief Add a "host" to the network element list
  */
 /**
  * \brief Add a "host" to the network element list
  */
-void routing_parse_init(sg_platf_host_cbarg_t host)
+void routing_add_host(As* current_routing, sg_platf_host_cbarg_t host)
 {
 {
-  if (! current_routing)
-    return;
-
   if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
     current_routing->p_hierarchy = SURF_ROUTING_BASE;
   xbt_assert(!sg_host_by_name(host->id),
   if (current_routing->p_hierarchy == SURF_ROUTING_NULL)
     current_routing->p_hierarchy = SURF_ROUTING_BASE;
   xbt_assert(!sg_host_by_name(host->id),