From: Jean-Baptiste Hervé Date: Thu, 2 Aug 2012 16:00:51 +0000 (+0200) Subject: Platform generation: add the function to put into Surf the generated platform X-Git-Tag: v3_8~219 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/59b71b5ec45e206c1ea787b3982563817742f113 Platform generation: add the function to put into Surf the generated platform It is partially implemented, for the moment... --- diff --git a/include/simgrid/platf_generator.h b/include/simgrid/platf_generator.h index 0aa682339d..38476fc0d7 100644 --- a/include/simgrid/platf_generator.h +++ b/include/simgrid/platf_generator.h @@ -66,6 +66,8 @@ XBT_PUBLIC(void) platf_graph_labeler(platf_labeler_cb_t labeler_callback); XBT_PUBLIC(void) platf_do_promote(void); XBT_PUBLIC(void) platf_do_label(void); +XBT_PUBLIC(void) platf_generate(void); + // WARNING : Only for debbugging ; should be removed when platform // generation works correctly XBT_PUBLIC(xbt_graph_t) platf_graph_get(void); diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index 23f33efcca..895e9f8dc2 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -4,6 +4,8 @@ #include "platf_generator_private.h" #include "xbt.h" #include "xbt/RngStream.h" +#include "surf/simgrid_dtd.h" +#include "surf_private.h" #include static xbt_graph_t platform_graph = NULL; @@ -362,6 +364,59 @@ void platf_do_label(void) { } } +void platf_generate(void) { + + xbt_dynar_t nodes = NULL; + xbt_node_t graph_node = NULL; + context_node_t node_data = NULL; + unsigned int i; + + unsigned int last_host = 0; + unsigned int last_router = 0; + //unsigned int last_cluster = 0; + + sg_platf_host_cbarg_t host_parameters; + s_sg_platf_router_cbarg_t router_parameters; /* This one is not a pointer! */ + sg_platf_cluster_cbarg_t cluster_parameters; + + router_parameters.coord = NULL; + + nodes = xbt_graph_get_nodes(platform_graph); + + sg_platf_init(); + sg_platf_begin(); + surf_parse_init_callbacks(); + routing_register_callbacks(); + + + sg_platf_new_AS_begin("random platform", A_surfxml_AS_routing_Floyd); + + xbt_dynar_foreach(nodes, i, graph_node) { + node_data = xbt_graph_node_get_data(graph_node); + switch(node_data->kind) { + case HOST: + host_parameters = &node_data->host_parameters; + if(host_parameters->id == NULL) { + host_parameters->id = bprintf("host-%d", ++last_host); + } + sg_platf_new_host(host_parameters); + break; + case CLUSTER: + cluster_parameters = &node_data->cluster_parameters; + //TODO: handle NULL IDs for clusters + sg_platf_new_cluster(cluster_parameters); + break; + case ROUTER: + router_parameters.id = bprintf("router-%d", ++last_router); + sg_platf_new_router(&router_parameters); + } + } + + + sg_platf_new_AS_end(); + sg_platf_end(); +} + /* Functions used to generate interesting random values */ double random_pareto(double min, double max, double K, double P, double ALPHA) {