Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First step to implement a platform generator in Simgrid
authorJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Thu, 26 Jul 2012 08:14:57 +0000 (10:14 +0200)
committerJean-Baptiste Hervé <jean-baptiste.herve@esial.net>
Thu, 26 Jul 2012 08:14:57 +0000 (10:14 +0200)
This tool may replace Simulacrum when it is finished.
I don't know exactly where to implement that in Simgrid, so if you have any suggestion, feel free to comment :)

buildtools/Cmake/DefinePackages.cmake
include/simgrid/platf_generator.h [new file with mode: 0644]
src/surf/platf_generator.c [new file with mode: 0644]

index 6e6c711..476e44d 100644 (file)
@@ -272,6 +272,11 @@ set(MSG_SRC
   src/msg/msg_vm.c
   )
 
   src/msg/msg_vm.c
   )
 
+set(PLATFGEN_SRC
+  include/simgrid/platf_generator.h
+  src/surf/platf_generator.c
+  )
+
 set(SIMDAG_SRC
   src/simdag/sd_daxloader.c
   src/simdag/sd_global.c
 set(SIMDAG_SRC
   src/simdag/sd_daxloader.c
   src/simdag/sd_global.c
@@ -401,6 +406,7 @@ set(headers_to_install
   include/simdag/simdag.h
   include/simgrid/modelchecker.h
   include/simgrid/platf.h
   include/simdag/simdag.h
   include/simgrid/modelchecker.h
   include/simgrid/platf.h
+  include/simgrid/platf_generator.h
   include/simgrid/simix.h
   include/smpi/mpi.h
   include/smpi/mpif.h
   include/simgrid/simix.h
   include/smpi/mpi.h
   include/smpi/mpif.h
@@ -509,6 +515,7 @@ set(simgrid_sources
   ${SIMDAG_SRC}
   ${SIMIX_SRC}
   ${SURF_SRC}
   ${SIMDAG_SRC}
   ${SIMIX_SRC}
   ${SURF_SRC}
+  ${PLATFGEN_SRC}
   ${TRACING_SRC}
   ${XBT_SRC}
   )
   ${TRACING_SRC}
   ${XBT_SRC}
   )
diff --git a/include/simgrid/platf_generator.h b/include/simgrid/platf_generator.h
new file mode 100644 (file)
index 0000000..4c40f51
--- /dev/null
@@ -0,0 +1,27 @@
+
+/* platf_generator.h - Public interface to the SimGrid platforms generator  */
+
+/* Copyright (c) 2004-2012. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef SG_PLATF_GEN_H
+#define SG_PLATF_GEN_H
+
+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]);
+
+void platf_graph_init(int node_count, e_platf_placement placement);
+
+#endif
diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c
new file mode 100644 (file)
index 0000000..3c09809
--- /dev/null
@@ -0,0 +1,53 @@
+
+
+#include <simgrid/platf_generator.h>
+#include <xbt.h>
+#include <xbt/graph.h>
+#include <xbt/RngStream.h>
+
+
+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);
+  }
+  if(seed != NULL) {
+    RngStream_SetSeed(rng_stream, seed);
+  }
+}
+
+void platf_graph_init(int node_count, e_platf_placement placement) {
+  int i;
+  platform_graph = xbt_graph_new_graph(TRUE, NULL);
+  if(rng_stream == NULL) {
+    rng_stream = RngStream_CreateStream(NULL);
+  }
+  
+  for(i=0 ; i<node_count ; i++) {
+    context_node_t node_data = NULL;
+    node_data = xbt_new(s_context_node_t, 1);
+    switch(placement) {
+      case UNIFORM:
+        node_data->x = RngStream_RandU01(rng_stream);
+        node_data->y = RngStream_RandU01(rng_stream);
+        break;
+      case HEAVY_TAILED:
+        //Not implemented...
+        THROW_UNIMPLEMENTED;
+    }
+    node_data->degree = 0;
+    node_data->kind = ROUTER;
+    xbt_graph_new_node(platform_graph, (void*) node_data);
+  }
+}