From d70aa4f0453eeef031df1154d0236ae7a28208e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Baptiste=20Herv=C3=A9?= Date: Fri, 27 Jul 2012 10:27:33 +0200 Subject: [PATCH] Platform generation : Add some debug Add a function to get the graph. This is only for debugging purpose, because it is a bad idea to access it directly. Also add an ID for nodes and edges. --- include/simgrid/platf_generator.h | 5 +++++ src/surf/platf_generator.c | 24 ++++++++++++++++++++---- src/surf/platf_generator_private.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/simgrid/platf_generator.h b/include/simgrid/platf_generator.h index 5f3d5069a8..a1012c5f3e 100644 --- a/include/simgrid/platf_generator.h +++ b/include/simgrid/platf_generator.h @@ -10,6 +10,7 @@ #define SG_PLATF_GEN_H #include +#include //Only for platf_graph_get() typedef enum { ROUTER, @@ -23,4 +24,8 @@ XBT_PUBLIC(void) platf_graph_uniform(int node_count); XBT_PUBLIC(void) platf_graph_interconnect_star(void); +// WARNING : Only for debbugging ; should be removed when platform +// generation works correctly +XBT_PUBLIC(xbt_graph_t) platf_graph_get(void); + #endif /* SG_PLATF_GEN_H */ diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index c8f49372c9..3a2e44b589 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -9,6 +9,14 @@ static xbt_graph_t platform_graph = NULL; static RngStream rng_stream = NULL; +static unsigned long last_link_id = 0; + +xbt_graph_t platf_graph_get(void) { + // We need some debug, so let's add this function + // WARNING : shold be removed when it becomes useless + return platform_graph; +} + void platf_random_seed(unsigned long seed[6]) { if(rng_stream == NULL) { @@ -20,8 +28,8 @@ void platf_random_seed(unsigned long seed[6]) { } } -void platf_graph_init(int node_count) { - int i; +void platf_graph_init(unsigned long node_count) { + unsigned long i; platform_graph = xbt_graph_new_graph(FALSE, NULL); if(rng_stream == NULL) { rng_stream = RngStream_CreateStream(NULL); @@ -30,12 +38,16 @@ void platf_graph_init(int node_count) { for(i=0 ; iid = i+1; node_data->x = 0; node_data->y = 0; node_data->degree = 0; node_data->kind = ROUTER; xbt_graph_new_node(platform_graph, (void*) node_data); } + + last_link_id = 0; + } void platf_node_connect(xbt_node_t node1, xbt_node_t node2) { @@ -45,10 +57,14 @@ void platf_node_connect(xbt_node_t node1, xbt_node_t node2) { node2_data = (context_node_t) xbt_graph_node_get_data(node2); node1_data->degree++; node2_data->degree++; - xbt_graph_new_edge(platform_graph, node1, node2, NULL); + + unsigned long *link_id = xbt_new(unsigned long, 1); + *link_id = ++last_link_id; + + xbt_graph_new_edge(platform_graph, node1, node2, (void*)link_id); } -void platf_graph_uniform(int node_count) { +void platf_graph_uniform(unsigned long node_count) { xbt_dynar_t dynar_nodes = NULL; xbt_node_t graph_node = NULL; context_node_t node_data = NULL; diff --git a/src/surf/platf_generator_private.h b/src/surf/platf_generator_private.h index 153c1bfaa9..77bba79d72 100644 --- a/src/surf/platf_generator_private.h +++ b/src/surf/platf_generator_private.h @@ -4,6 +4,7 @@ #include typedef struct { + unsigned long id; double x, y; int degree; e_platf_node_kind kind; -- 2.20.1