Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Platform generation : Add some debug
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 27 Jul 2012 08:27:33 +0000 (10:27 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Fri, 27 Jul 2012 08:27:33 +0000 (10:27 +0200)
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
src/surf/platf_generator.c
src/surf/platf_generator_private.h

index 5f3d506..a1012c5 100644 (file)
@@ -10,6 +10,7 @@
 #define SG_PLATF_GEN_H
 
 #include <xbt.h>
 #define SG_PLATF_GEN_H
 
 #include <xbt.h>
+#include <xbt/graph.h> //Only for platf_graph_get()
 
 typedef enum {
   ROUTER,
 
 typedef enum {
   ROUTER,
@@ -23,4 +24,8 @@ XBT_PUBLIC(void) platf_graph_uniform(int node_count);
 
 XBT_PUBLIC(void) platf_graph_interconnect_star(void);
 
 
 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 */
 #endif              /* SG_PLATF_GEN_H */
index c8f4937..3a2e44b 100644 (file)
@@ -9,6 +9,14 @@ static xbt_graph_t platform_graph = NULL;
 
 static RngStream rng_stream = 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) {
 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);
   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 ; i<node_count ; i++) {
     context_node_t node_data = NULL;
     node_data = xbt_new(s_context_node_t, 1);
   for(i=0 ; i<node_count ; i++) {
     context_node_t node_data = NULL;
     node_data = xbt_new(s_context_node_t, 1);
+    node_data->id = 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);
   }
     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) {
 }
 
 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++;
   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;
   xbt_dynar_t dynar_nodes = NULL;
   xbt_node_t graph_node = NULL;
   context_node_t node_data = NULL;
index 153c1bf..77bba79 100644 (file)
@@ -4,6 +4,7 @@
 #include <xbt/graph.h>
 
 typedef struct {
 #include <xbt/graph.h>
 
 typedef struct {
+  unsigned long id;
   double x, y;
   int degree;
   e_platf_node_kind kind;
   double x, y;
   int degree;
   e_platf_node_kind kind;