From 17023af1f7484d0592aa37f08bcd35e7dda3efe3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 12 Feb 2016 01:48:12 +0100 Subject: [PATCH] and now, blow up the routing_models table \o/ --- include/simgrid/platf.h | 5 --- src/surf/surf_routing.cpp | 49 +++++++++------------- src/surf/surf_routing_cluster.cpp | 5 --- src/surf/surf_routing_cluster_fat_tree.cpp | 5 --- src/surf/surf_routing_cluster_torus.cpp | 5 --- src/surf/surf_routing_dijkstra.cpp | 8 ---- src/surf/surf_routing_floyd.cpp | 5 --- src/surf/surf_routing_full.cpp | 5 --- src/surf/surf_routing_none.cpp | 5 --- src/surf/surf_routing_private.hpp | 27 ++---------- src/surf/surf_routing_vivaldi.cpp | 5 --- 11 files changed, 23 insertions(+), 101 deletions(-) diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 75b26ff3f9..a691131bfb 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -31,11 +31,6 @@ typedef enum { SURF_CLUSTER_TORUS = 0 } e_surf_cluster_topology_t; - -typedef struct s_model_type { - AS_t (*create) (); -} s_routing_model_description_t, *routing_model_description_t; - /* ***************************************** */ /* * Platform creation functions. Instead of passing 123 arguments to the creation functions diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index acb39d7db5..e36b003d61 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -13,6 +13,12 @@ #include "storage_interface.hpp" #include "src/surf/platform.hpp" #include "surf/surfxml_parse_values.h" + +#include "src/surf/surf_routing_cluster_torus.hpp" +#include "src/surf/surf_routing_cluster_fat_tree.hpp" +#include "src/surf/surf_routing_dijkstra.hpp" +#include "src/surf/surf_routing_floyd.hpp" +#include "src/surf/surf_routing_full.hpp" #include "src/surf/surf_routing_vivaldi.hpp" /************* @@ -85,19 +91,6 @@ typedef enum { SURF_MODEL_FAT_TREE_CLUSTER, } e_routing_types; -struct s_model_type routing_models[] = { - {model_full_create}, - {model_floyd_create}, - {model_dijkstra_create}, - {model_dijkstracache_create}, - {model_none_create}, - {model_vivaldi_create}, - {model_cluster_create}, - {model_torus_cluster_create}, - {model_fat_tree_cluster_create}, - {NULL} -}; - /** @brief Add a link connecting an host to the rest of its AS (which must be cluster or vivaldi) */ void sg_platf_new_hostlink(sg_platf_host_link_cbarg_t netcard_arg) { @@ -152,32 +145,30 @@ void sg_platf_new_trace(sg_platf_trace_cbarg_t trace) void routing_AS_begin(sg_platf_AS_cbarg_t AS) { XBT_DEBUG("routing_AS_begin"); - routing_model_description_t model = NULL; xbt_assert(NULL == xbt_lib_get_or_null(as_router_lib, AS->id, ROUTING_ASR_LEVEL), "Refusing to create a second AS called \"%s\".", AS->id); - _sg_cfg_init_status = 2; /* horrible hack: direct access to the global - * controlling the level of configuration to prevent - * any further config */ + _sg_cfg_init_status = 2; /* HACK: direct access to the global controlling the level of configuration to prevent + * any further config now that we created some real content */ + + simgrid::surf::As *new_as = NULL; /* search the routing model */ switch(AS->routing){ - case A_surfxml_AS_routing_Cluster: model = &routing_models[SURF_MODEL_CLUSTER];break; - case A_surfxml_AS_routing_ClusterTorus: model = &routing_models[SURF_MODEL_TORUS_CLUSTER];break; - case A_surfxml_AS_routing_ClusterFatTree: model = &routing_models[SURF_MODEL_FAT_TREE_CLUSTER];break; - case A_surfxml_AS_routing_Dijkstra: model = &routing_models[SURF_MODEL_DIJKSTRA];break; - case A_surfxml_AS_routing_DijkstraCache: model = &routing_models[SURF_MODEL_DIJKSTRACACHE];break; - case A_surfxml_AS_routing_Floyd: model = &routing_models[SURF_MODEL_FLOYD];break; - case A_surfxml_AS_routing_Full: model = &routing_models[SURF_MODEL_FULL];break; - case A_surfxml_AS_routing_None: model = &routing_models[SURF_MODEL_NONE];break; - case A_surfxml_AS_routing_Vivaldi: model = &routing_models[SURF_MODEL_VIVALDI];break; - default: xbt_die("Not a valid model!!!"); - break; + case A_surfxml_AS_routing_Cluster: new_as = new simgrid::surf::AsCluster(); break; + case A_surfxml_AS_routing_ClusterTorus: new_as = new simgrid::surf::AsClusterTorus(); break; + case A_surfxml_AS_routing_ClusterFatTree: new_as = new simgrid::surf::AsClusterFatTree(); break; + case A_surfxml_AS_routing_Dijkstra: new_as = new simgrid::surf::AsDijkstra(0); break; + case A_surfxml_AS_routing_DijkstraCache: new_as = new simgrid::surf::AsDijkstra(1); break; + case A_surfxml_AS_routing_Floyd: new_as = new simgrid::surf::AsFloyd(); break; + case A_surfxml_AS_routing_Full: new_as = new simgrid::surf::AsFull(); break; + case A_surfxml_AS_routing_None: new_as = new simgrid::surf::AsNone(); break; + case A_surfxml_AS_routing_Vivaldi: new_as = new simgrid::surf::AsVivaldi(); break; + default: xbt_die("Not a valid model!"); break; } /* make a new routing component */ - simgrid::surf::As *new_as = model->create(); new_as->p_hierarchy = SURF_ROUTING_NULL; new_as->p_name = xbt_strdup(AS->id); diff --git a/src/surf/surf_routing_cluster.cpp b/src/surf/surf_routing_cluster.cpp index 6c284fc59e..ebb2a58ebd 100644 --- a/src/surf/surf_routing_cluster.cpp +++ b/src/surf/surf_routing_cluster.cpp @@ -13,11 +13,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf" * Note that a router is created, easing the interconnexion with the rest of the world. */ -AS_t model_cluster_create(void) -{ - return new simgrid::surf::AsCluster(); -} - namespace simgrid { namespace surf { diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index 9ecbb8ad1f..5d9bc0c961 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -18,11 +18,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_fat_tree, surf, "Routing for fat trees"); -AS_t model_fat_tree_cluster_create(void) -{ - return new simgrid::surf::AsClusterFatTree(); -} - namespace simgrid { namespace surf { diff --git a/src/surf/surf_routing_cluster_torus.cpp b/src/surf/surf_routing_cluster_torus.cpp index 03bedd5c47..1288cf8da5 100644 --- a/src/surf/surf_routing_cluster_torus.cpp +++ b/src/surf/surf_routing_cluster_torus.cpp @@ -25,11 +25,6 @@ inline unsigned int *rankId_to_coords(int rankId, xbt_dynar_t dimensions) } -AS_t model_torus_cluster_create(void) -{ - return new simgrid::surf::AsClusterTorus(); -} - namespace simgrid { namespace surf { AsClusterTorus::AsClusterTorus():AsCluster() { diff --git a/src/surf/surf_routing_dijkstra.cpp b/src/surf/surf_routing_dijkstra.cpp index ccdeaadbcd..c5cf6a33a9 100644 --- a/src/surf/surf_routing_dijkstra.cpp +++ b/src/surf/surf_routing_dijkstra.cpp @@ -36,14 +36,6 @@ static void graph_edge_data_free(void *e) // FIXME: useless code duplication } } -AS_t model_dijkstra_create(void){ - return new simgrid::surf::AsDijkstra(0); -} - -AS_t model_dijkstracache_create(void){ - return new simgrid::surf::AsDijkstra(1); -} - /* Utility functions */ namespace simgrid { diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index ffe8e5a623..bed72895c8 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -14,11 +14,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_floyd, surf, "Routing part of surf"); #define TO_FLOYD_PRED(i,j) (p_predecessorTable)[(i)+(j)*table_size] #define TO_FLOYD_LINK(i,j) (p_linkTable)[(i)+(j)*table_size] -AS_t model_floyd_create(void) -{ - return new simgrid::surf::AsFloyd(); -} - namespace simgrid { namespace surf { diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index f80b2f6440..49e71cc36f 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -12,11 +12,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); #define TO_ROUTE_FULL(i,j) p_routingTable[(i)+(j)*table_size] -AS_t model_full_create(void) -{ - return new simgrid::surf::AsFull(); -} - namespace simgrid { namespace surf { void AsFull::Seal() { diff --git a/src/surf/surf_routing_none.cpp b/src/surf/surf_routing_none.cpp index a4e5059ed2..86d41d47bf 100644 --- a/src/surf/surf_routing_none.cpp +++ b/src/surf/surf_routing_none.cpp @@ -9,11 +9,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_none, surf, "Routing part of surf"); -AS_t model_none_create(void) -{ - return new simgrid::surf::AsNone(); -} - namespace simgrid { namespace surf { diff --git a/src/surf/surf_routing_private.hpp b/src/surf/surf_routing_private.hpp index 36c6f731b8..5904dc9fc5 100644 --- a/src/surf/surf_routing_private.hpp +++ b/src/surf/surf_routing_private.hpp @@ -50,42 +50,21 @@ XBT_PRIVATE sg_platf_route_cbarg_t generic_get_bypassroute(AS_t rc, * produced route */ XBT_PRIVATE sg_platf_route_cbarg_t generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t data, int preserve_order); -XBT_PRIVATE AS_t -generic_autonomous_system_exist(AS_t rc, char *element); -XBT_PRIVATE AS_t -generic_processing_units_exist(AS_t rc, char *element); -void generic_src_dst_check(AS_t rc, sg_netcard_t src, - sg_netcard_t dst); +XBT_PRIVATE AS_t generic_autonomous_system_exist(AS_t rc, char *element); +XBT_PRIVATE AS_t generic_processing_units_exist(AS_t rc, char *element); +void generic_src_dst_check(AS_t rc, sg_netcard_t src, sg_netcard_t dst); /* ************************************************************************** */ /* *************************** FLOYD ROUTING ******************************** */ -XBT_PRIVATE AS_t model_floyd_create(void); /* create structures for floyd routing model */ XBT_PRIVATE void model_floyd_parse_route(AS_t rc, sg_platf_route_cbarg_t route); -/* ************************************************** */ -/* ************** Cluster ROUTING **************** */ - -XBT_PRIVATE surf_As *model_cluster_create(void); /* create structures for cluster routing model */ -XBT_PRIVATE surf_As *model_torus_cluster_create(void); -XBT_PRIVATE surf_As *model_fat_tree_cluster_create(void); - -/* ************************************************** */ -/* ************** Vivaldi ROUTING **************** */ -XBT_PRIVATE AS_t model_vivaldi_create(void); /* create structures for vivaldi routing model */ #define HOST_PEER(peername) bprintf("peer_%s", peername) #define ROUTER_PEER(peername) bprintf("router_%s", peername) #define LINK_PEER(peername) bprintf("link_%s", peername) /* ************************************************************************** */ /* ********** Dijkstra & Dijkstra Cached ROUTING **************************** */ -XBT_PRIVATE AS_t model_dijkstra_both_create(int cached); /* create by calling dijkstra or dijkstracache */ -XBT_PRIVATE AS_t model_dijkstra_create(void); /* create structures for dijkstra routing model */ -XBT_PRIVATE AS_t model_dijkstracache_create(void); /* create structures for dijkstracache routing model */ XBT_PRIVATE void model_dijkstra_both_parse_route (AS_t rc, sg_platf_route_cbarg_t route); - -/* ************************************************************************** */ -/* *************************** FULL ROUTING ********************************* */ -XBT_PRIVATE AS_t model_full_create(void); /* create structures for full routing model */ XBT_PRIVATE void model_full_set_route( /* Set the route and ASroute between src and dst */ AS_t rc, sg_platf_route_cbarg_t route); /* ************************************************************************** */ diff --git a/src/surf/surf_routing_vivaldi.cpp b/src/surf/surf_routing_vivaldi.cpp index d6a5f90da3..69899fc99a 100644 --- a/src/surf/surf_routing_vivaldi.cpp +++ b/src/surf/surf_routing_vivaldi.cpp @@ -22,11 +22,6 @@ static XBT_INLINE double euclidean_dist_comp(int index, xbt_dynar_t src, xbt_dyn return (src_coord-dst_coord)*(src_coord-dst_coord); } -AS_t model_vivaldi_create(void) -{ - return new simgrid::surf::AsVivaldi(); -} - namespace simgrid { namespace surf { -- 2.20.1