From: Martin Quinson Date: Sat, 5 Nov 2011 14:27:26 +0000 (+0100) Subject: Add a new module allowing to interact with the platform directly X-Git-Tag: exp_20120216~480 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5bcfbaff5a82e40d9a5d1861f073fc0befbd7f1b Add a new module allowing to interact with the platform directly * 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 --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 4245520eb2..ef743ce0d5 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -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 index 0000000000..c6ec0f6c17 --- /dev/null +++ b/include/simgrid/platf.h @@ -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 /* 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 */ diff --git a/src/bindings/lua/lua_console.c b/src/bindings/lua/lua_console.c index 1e8880fff1..a3263f1b0f 100644 --- a/src/bindings/lua/lua_console.c +++ b/src/bindings/lua/lua_console.c @@ -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 #include @@ -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() } /* */ // Finalize AS - routing_AS_end(p_as->id); + sg_platf_new_AS_close(); } // add traces surf_wsL07_add_traces(); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 7f48885836..cde8899573 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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 diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 007a2cc8ba..6acb74e1de 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -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 /* 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), diff --git a/src/surf/surfxml_parseplatf.c b/src/surf/surfxml_parseplatf.c index 72d1ed48c8..9cfd8ea2c0 100644 --- a/src/surf/surfxml_parseplatf.c +++ b/src/surf/surfxml_parseplatf.c @@ -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 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(); }