From f34ca502a5eb4e4c15cfa6cd36d4ee4da88bc5e1 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 27 Nov 2015 14:04:32 +0100 Subject: [PATCH] [surf] Change routing_parse_init() into routing_add_host() Do not depend on the parsing state in this function. --- include/surf/surf_routing.h | 7 ------- src/include/surf/surf.h | 7 +++++++ src/surf/sg_platf.cpp | 4 +++- src/surf/surf_routing.cpp | 13 ++++++++----- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/include/surf/surf_routing.h b/include/surf/surf_routing.h index e4ddcd9bc4..655b2b4da1 100644 --- a/include/surf/surf_routing.h +++ b/include/surf/surf_routing.h @@ -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 -/* 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 */ diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index a605c4c8db..38cebedd91 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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); +/********** 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 */ diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 3a35fccc9e..df1622759d 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -137,7 +137,9 @@ void sg_platf_exit(void) { 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, diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index a80a7f6627..971df4c27c 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -56,13 +56,19 @@ RoutingEdge *sg_routing_edge_by_name_or_null(const char *name) { /* 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"); +/** 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 */ @@ -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 */ -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), -- 2.20.1