From: Jean-Baptiste Hervé Date: Thu, 26 Jul 2012 12:57:31 +0000 (+0200) Subject: Platform generation : modify some interface X-Git-Tag: v3_8~260 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/db8fd6b61aba2af810b61d8523a673c9678a608e Platform generation : modify some interface --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 476e44d3c1..834000080e 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -275,6 +275,7 @@ set(MSG_SRC set(PLATFGEN_SRC include/simgrid/platf_generator.h src/surf/platf_generator.c + src/surf/platf_generator_private.h ) set(SIMDAG_SRC diff --git a/include/simgrid/platf_generator.h b/include/simgrid/platf_generator.h index 4c40f51fe7..c36dcdf6d4 100644 --- a/include/simgrid/platf_generator.h +++ b/include/simgrid/platf_generator.h @@ -9,19 +9,16 @@ #ifndef SG_PLATF_GEN_H #define SG_PLATF_GEN_H +#include + typedef enum { ROUTER, HOST, CLUSTER } e_platf_node_kind; -typedef enum { - UNIFORM, - HEAVY_TAILED -} e_platf_placement; - -void platf_random_seed(unsigned long seed[6]); +XBT_PUBLIC(void) platf_random_seed(unsigned long seed[6]); -void platf_graph_init(int node_count, e_platf_placement placement); +XBT_PUBLIC(void) platf_graph_uniform(int node_count); -#endif +#endif /* SG_PLATF_GEN_H */ diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index 3c09809791..0acd807a1a 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -1,23 +1,17 @@ #include +#include "platf_generator_private.h" #include #include #include - -typedef struct { - double x, y; - int degree; - e_platf_node_kind kind; -} s_context_node_t, *context_node_t; - static xbt_graph_t platform_graph = NULL; static RngStream rng_stream = NULL; void platf_random_seed(unsigned long seed[6]) { - + if(rng_stream == NULL) { //stream not created yet, we do it now rng_stream = RngStream_CreateStream(NULL); @@ -27,27 +21,34 @@ void platf_random_seed(unsigned long seed[6]) { } } -void platf_graph_init(int node_count, e_platf_placement placement) { +void platf_graph_init(int node_count) { int i; platform_graph = xbt_graph_new_graph(TRUE, NULL); if(rng_stream == NULL) { rng_stream = RngStream_CreateStream(NULL); } - + for(i=0 ; ix = RngStream_RandU01(rng_stream); - node_data->y = RngStream_RandU01(rng_stream); - break; - case HEAVY_TAILED: - //Not implemented... - THROW_UNIMPLEMENTED; - } + 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); } } + +void platf_graph_uniform(int node_count) { + xbt_dynar_t dynar_nodes = NULL; + xbt_node_t graph_node = NULL; + context_node_t node_data = NULL; + unsigned int i; + platf_graph_init(node_count); + dynar_nodes = xbt_graph_get_nodes(platform_graph); + xbt_dynar_foreach(dynar_nodes, i, graph_node) { + node_data = (context_node_t) xbt_graph_node_get_data(graph_node); + node_data->x = RngStream_RandU01(rng_stream); + node_data->y = RngStream_RandU01(rng_stream); + } +} diff --git a/src/surf/platf_generator_private.h b/src/surf/platf_generator_private.h new file mode 100644 index 0000000000..db486a99a3 --- /dev/null +++ b/src/surf/platf_generator_private.h @@ -0,0 +1,12 @@ +#ifndef SG_PLATF_GEN_PRIVATE_H +#define SG_PLATF_GEN_PRIVATE_H + +typedef struct { + double x, y; + int degree; + e_platf_node_kind kind; +} s_context_node_t, *context_node_t; + +void platf_graph_init(int node_count); + +#endif /* SG_PLATF_GEN_PRIVATE_H */