From 6da2ee58d9d2b8f4910b82e87d0be4488f31b911 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Baptiste=20Herv=C3=A9?= Date: Fri, 27 Jul 2012 11:53:34 +0200 Subject: [PATCH 1/1] Platform generation : Add 2 topology setup functions Add the "heavy tailed" positionning for the nodes, and the "line" connection between them --- include/simgrid/platf_generator.h | 4 ++- src/surf/platf_generator.c | 54 +++++++++++++++++++++++++++--- src/surf/platf_generator_private.h | 4 ++- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/include/simgrid/platf_generator.h b/include/simgrid/platf_generator.h index a1012c5f3e..3b89513ce1 100644 --- a/include/simgrid/platf_generator.h +++ b/include/simgrid/platf_generator.h @@ -20,9 +20,11 @@ typedef enum { XBT_PUBLIC(void) platf_random_seed(unsigned long seed[6]); -XBT_PUBLIC(void) platf_graph_uniform(int node_count); +XBT_PUBLIC(void) platf_graph_uniform(unsigned long node_count); +XBT_PUBLIC(void) platf_graph_heavytailed(unsigned long node_count); XBT_PUBLIC(void) platf_graph_interconnect_star(void); +XBT_PUBLIC(void) platf_graph_interconnect_line(void); // WARNING : Only for debbugging ; should be removed when platform // generation works correctly diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index 3a2e44b589..693e169576 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -1,9 +1,10 @@ -#include +#include "simgrid/platf_generator.h" #include "platf_generator_private.h" -#include -#include +#include "xbt.h" +#include "xbt/RngStream.h" +#include static xbt_graph_t platform_graph = NULL; @@ -78,8 +79,22 @@ void platf_graph_uniform(unsigned long node_count) { } } -void platf_graph_interconnect_star(void) { +void platf_graph_heavytailed(unsigned long 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 = random_pareto(0, 1, 1.0/*K*/, 10e9/*P*/, 1.0/*alpha*/); + node_data->y = random_pareto(0, 1, 1.0/*K*/, 10e9/*P*/, 1.0/*alpha*/); + } +} +void platf_graph_interconnect_star(void) { + /* All the nodes are connected to the first one */ xbt_dynar_t dynar_nodes = NULL; xbt_node_t graph_node = NULL; xbt_node_t first_node = NULL; @@ -96,3 +111,34 @@ void platf_graph_interconnect_star(void) { } } } + +void platf_graph_interconnect_line(void) { + /* Node are connected to the previous and the next node, in a line */ + xbt_dynar_t dynar_nodes = NULL; + xbt_node_t graph_node = NULL; + xbt_node_t old_node = NULL; + unsigned int i; + + dynar_nodes = xbt_graph_get_nodes(platform_graph); + xbt_dynar_foreach(dynar_nodes, i, graph_node) { + if(old_node != NULL) { + platf_node_connect(graph_node, old_node); + } + old_node = graph_node; + } +} + + + +/* Functions used to generate interesting random values */ + +double random_pareto(double min, double max, double K, double P, double ALPHA) { + double x = RngStream_RandU01(rng_stream); + double den = pow(1.0 - x + x*pow(K/P, ALPHA), 1.0/ALPHA); + double res = (1/den); + res += min - 1; // pareto is on [1, infinity) by default + if (res>max) { + return max; + } + return res; +} diff --git a/src/surf/platf_generator_private.h b/src/surf/platf_generator_private.h index 77bba79d72..a1a430f47c 100644 --- a/src/surf/platf_generator_private.h +++ b/src/surf/platf_generator_private.h @@ -10,8 +10,10 @@ typedef struct { e_platf_node_kind kind; } s_context_node_t, *context_node_t; -void platf_graph_init(int node_count); +void platf_graph_init(unsigned long node_count); void platf_node_connect(xbt_node_t node1, xbt_node_t node2); +double random_pareto(double min, double max, double K, double P, double ALPHA); + #endif /* SG_PLATF_GEN_PRIVATE_H */ -- 2.20.1