Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a new module allowing to interact with the platform directly
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 5 Nov 2011 14:27:26 +0000 (15:27 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 5 Nov 2011 14:28:45 +0000 (15:28 +0100)
* For now, it's super sparse, but the ongoing cleanup in the parser aims
  precisely at populating it.
* Also, kill some oneline brain-dead functions in the lua console

buildtools/Cmake/DefinePackages.cmake
include/simgrid/platf.h [new file with mode: 0644]
src/bindings/lua/lua_console.c
src/include/surf/surf.h
src/surf/surf_routing.c
src/surf/surfxml_parseplatf.c

index 4245520..ef743ce 100644 (file)
@@ -406,6 +406,7 @@ set(headers_to_install
        include/xbt/mmalloc.h
        include/xbt/replay_trace_reader.h
        include/xbt/parmap.h
+       include/simgrid/platf.h
        include/mc/modelchecker.h
        include/msg/msg.h
        include/msg/datatypes.h
diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h
new file mode 100644 (file)
index 0000000..c6ec0f6
--- /dev/null
@@ -0,0 +1,17 @@
+/* platf.h - Public interface to the SimGrid platforms                      */
+
+/* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010, 2011. 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_H
+#define SG_PLATF_H
+
+#include <xbt.h>                /* our toolbox */
+
+XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode);
+XBT_PUBLIC(void) sg_platf_new_AS_close(void);
+
+#endif                          /* SG_PLATF_H */
index 1e8880f..a3263f1 100644 (file)
@@ -7,6 +7,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid_lua.h"
+#include "simgrid/platf.h"
 #include <string.h>
 #include <ctype.h>
 
@@ -16,15 +17,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_console, bindings, "Lua Bindings");
 //AS List
 static xbt_dynar_t as_list_d;
 
-/*
- * Initialize platform model routing
- */
-
-static void create_AS(const char *id, const char *mode)
-{
-  routing_AS_init(id, mode);
-}
-
 /**
  * create host resource via CPU model [for MSG]
  */
@@ -707,7 +699,7 @@ static int surf_parse_bypass_platform()
   // Add AS
   xbt_dynar_foreach(as_list_d, i,p_as)
   {
-         create_AS(p_as->id, p_as->mode);
+    sg_platf_new_AS_open(p_as->id,p_as->mode);
          // add associated Hosts
          xbt_dynar_foreach(p_as->host_list_d, j, p_host){
                  create_host(p_host->id, p_host->power_peak, p_host->power_scale,
@@ -732,7 +724,7 @@ static int surf_parse_bypass_platform()
          }
 
          // Finalize AS
-         routing_AS_end(p_as->id);
+         sg_platf_new_AS_close();
   }
 
   // add traces
@@ -760,7 +752,7 @@ static int surf_wsL07_parse_bypass_platform()
   xbt_dynar_foreach(as_list_d, i, p_as)
   {
          // Init AS
-         create_AS(p_as->id, p_as->mode);
+    sg_platf_new_AS_open(p_as->id,p_as->mode);
 
          // add Sub AS
 
@@ -789,7 +781,7 @@ static int surf_wsL07_parse_bypass_platform()
              }
          /* </AS> */
          // Finalize AS
-         routing_AS_end(p_as->id);
+         sg_platf_new_AS_close();
   }
   // add traces
   surf_wsL07_add_traces();
index 7f48885..cde8899 100644 (file)
@@ -791,11 +791,8 @@ XBT_PUBLIC(void) surf_add_link_traces(void);
 XBT_PUBLIC(void) surf_wsL07_add_traces(void);
 
 /*
- * init AS from lua console
- * see surf_routing.c
+ * lua console
  */
-XBT_PUBLIC(void) routing_AS_init(const char *id, const char *mode);
-XBT_PUBLIC(void) routing_AS_end(const char *id);
 // add host to network element list
 XBT_PUBLIC(void) routing_add_host(const char *host_id);
 //Set a new link on the actual list of link for a route or ASroute
index 007a2cc..6acb74e 100644 (file)
@@ -1,10 +1,13 @@
-/* Copyright (c) 2009, 2010. The SimGrid Team. 
+/* Copyright (c) 2009, 2010, 2011. 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. */
 
 #include <pcre.h>               /* regular expression library */
+
+#include "simgrid/platf.h" // platform creation API
+
 #include "surf_routing_private.h"
 #include "surf/surf_routing.h"
 #include "surf/surfxml_parse_values.h"
@@ -419,12 +422,19 @@ static void parse_E_bypassRoute_store_route(void)
 }
 
 /**
- * \brief Make a new routing component
+ * \brief Make a new routing component to the platform
+ *
+ * Add a new autonomous system to the platform. Any elements (such as host,
+ * router or sub-AS) added after this call and before the corresponding call
+ * to sg_platf_new_AS_close() will be added to this AS.
+ *
+ * Once this function was called, the configuration concerning the used
+ * models cannot be changed anymore.
  *
- * make the new structure and
- * set the parsing functions to allows parsing the part of the routing tree
+ * @param AS_id name of this autonomous system. Must be uniq in the platform
+ * @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c
  */
-void routing_AS_init(const char *AS_id, const char *wanted_routing_type)
+void sg_platf_new_AS_open(const char *AS_id, const char *wanted_routing_type)
 {
   routing_component_t new_routing;
   model_type_t model = NULL;
@@ -491,16 +501,20 @@ void routing_AS_init(const char *AS_id, const char *wanted_routing_type)
 }
 
 /**
- * \brief Finish the creation of a new routing component
+ * \brief Specify that the current description of AS is finished
+ *
+ * Once you've declared all the content of your AS, you have to close
+ * it with this call. Your AS is not usable until you call this function.
+ *
+ * @fixme: this call is not as robust as wanted: bad things WILL happen
+ * if you call it twice for the same AS, or if you forget calling it, or
+ * even if you add stuff to a closed AS
  *
- * When you finish to read the routing component, other structures must be created. 
- * the "end" method allow to do that for any routing model type
  */
-void routing_AS_end(const char *AS_id)
-{
+void sg_platf_new_AS_close() {
 
   if (current_routing == NULL) {
-    THROWF(arg_error, 0, "Close AS(%s), that were never opened", AS_id);
+    THROWF(arg_error, 0, "Close an AS, but none was under construction");
   } else {
     network_element_info_t info = NULL;
     xbt_assert(!xbt_lib_get_or_null(as_router_lib,current_routing->name, ROUTING_ASR_LEVEL),
index 72d1ed4..9cfd8ea 100644 (file)
@@ -8,6 +8,7 @@
 #include "xbt/log.h"
 #include "xbt/str.h"
 #include "xbt/dict.h"
+#include "simgrid/platf.h"
 #include "surf/surfxml_parse_private.h"
 #include "surf/surf_private.h"
 
@@ -141,10 +142,10 @@ static void parse_Stag_trace_connect(void)
 
 /* Call the right C function when we see the <AS> tags */
 static void parse_S_AS(void) {
-  routing_AS_init(A_surfxml_AS_id, A_surfxml_AS_routing);
+  sg_platf_new_AS_open(A_surfxml_AS_id, A_surfxml_AS_routing);
 }
 static void parse_E_AS(void) {
-  routing_AS_end(A_surfxml_AS_id);
+  sg_platf_new_AS_close();
 }